* Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************
- $Id: index.php,v 1.7 2004-10-10 13:51:15 x2000habouzit Exp $
+ $Id: index.php,v 1.8 2004-10-14 22:16:01 x2000habouzit Exp $
***************************************************************************/
require("auto.prepend.inc.php");
new_skinned_page('listes/index.tpl', AUTH_MDP);
include('xml-rpc-client.inc.php');
+include('newsletter.inc.php');
$res = $globals->db->query("SELECT password FROM auth_user_md5 WHERE user_id={$_SESSION['uid']}");
list($pass) = mysql_fetch_row($res);
$client->subscribe('polytechnique.org',"promo$promo");
}
}
-if(!empty($_GET['nl_unsub'])) $client->unsubscribe_nl();
-if(!empty($_GET['nl_sub'])) $client->subscribe_nl();
+if(!empty($_GET['nl_unsub'])) unsubscribe_nl();
+if(!empty($_GET['nl_sub'])) subscribe_nl();
$listes = $client->get_lists('polytechnique.org');
-$nl = $client->get_nl_state();
$page->assign_by_ref('listes',$listes);
-$page->assign('nl',$nl);
+$page->assign('nl',get_nl_state());
$page->run();
?>
* Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************
- $Id: inscription_listes_base.inc.php,v 1.3 2004-10-10 13:51:17 x2000habouzit Exp $
+ $Id: inscription_listes_base.inc.php,v 1.4 2004-10-14 22:16:01 x2000habouzit Exp $
***************************************************************************/
include('xml-rpc-client.inc.php');
+include('newsletter.inc.php');
/** inscrit l'uid donnée à la promo
* @param $uid UID
// récupération de l'id de la liste promo
$client = new xmlrpc_client("http://$uid:$pass@localhost:4949");
$client->subscribe('polytechnique.org',"promo$promo");
- $client->subscribe_nl();
+ subscribe_nl();
}
?>
--- /dev/null
+<?php
+/***************************************************************************
+ * Copyright (C) 2003-2004 Polytechnique.org *
+ * http://opensource.polytechnique.org/ *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software *
+ * Foundation, Inc., *
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
+ ***************************************************************************
+ $Id: newsletter.inc.php,v 1.1 2004-10-14 22:16:01 x2000habouzit Exp $
+ ***************************************************************************/
+
+class NewsLetter {
+ function NewsLetter() { }
+}
+
+function get_nl_state() {
+ global $globals;
+ $res = $globals->db->query("SELECT COUNT(*)>0 FROM newsletter_ins WHERE user_id={$_SESSION['uid']}");
+ list($b) = mysql_fetch_row($res);
+ mysql_free_result($res);
+ return $b;
+}
+
+function unsubscribe_nl() {
+ global $globals;
+ $globals->db->query("DELETE FROM newsletter_ins WHERE user_id={$_SESSION['uid']}");
+}
+
+function subscribe_nl() {
+ global $globals;
+ $globals->db->query("INSERT INTO newsletter_ins (user_id) VALUES ({$_SESSION['uid']})");
+}
+
+?>
#* Foundation, Inc., *
#* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
#***************************************************************************
-# $Id: mailman-rpc.py,v 1.58 2004-10-13 10:05:00 x2000habouzit Exp $
+# $Id: mailman-rpc.py,v 1.59 2004-10-14 22:16:01 x2000habouzit Exp $
#***************************************************************************
import base64, MySQLdb, os, getopt, sys, MySQLdb.converters, sha
names.sort()
result = []
for name in names:
- if not name.startswith(prefix) or name == mm_cfg.MAIN_NEWSLETTER:
+ if not name.startswith(prefix):
continue
try:
mlist = MailList.MailList(name,lock=0)
mlist.Unlock()
return 0
-def subscribe_nl((userdesc,perms)):
- try:
- mlist = MailList.MailList(mm_cfg.MAIN_NEWSLETTER,lock=0)
- except:
- return 0
- try:
- mlist.Lock()
- mlist.ApprovedAddMember(userdesc,0,0)
- mlist.Save()
- mlist.Unlock()
- return 1
- except:
- mlist.Unlock()
- return 0
-
-def unsubscribe_nl((userdesc,perms)):
- try:
- mlist = MailList.MailList(mm_cfg.MAIN_NEWSLETTER,lock=0)
- except:
- return 0
- try:
- mlist.Lock()
- mlist.ApprovedDeleteMember(userdesc.address,0,0)
- mlist.Save()
- mlist.Unlock()
- return 1
- except:
- mlist.Unlock()
- return 0
-
-def get_nl_state((userdesc,perms)):
- try:
- mlist = MailList.MailList(mm_cfg.MAIN_NEWSLETTER,lock=0)
- except:
- return 0
- try:
- return ( userdesc.address in mlist.getRegularMemberKeys() )
- except:
- return 0
-
-
#-------------------------------------------------------------------------------
# users procedures for [ index.php ]
#
server.register_function(get_lists)
server.register_function(subscribe)
server.register_function(unsubscribe)
-server.register_function(subscribe_nl)
-server.register_function(unsubscribe_nl)
-server.register_function(get_nl_state)
# members.php
server.register_function(get_members)
# trombi.php