X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Flists.php;h=e55a6a5b2b5d4743d6ab21d47745d9aa6ca61a2d;hb=2c0315bc77abc3c53b5891d2a8c5d4943fd27143;hp=2f74ea62a1309ef49dc1a95d7492efc0fe28e62c;hpb=7b9d64a8152f719caae96f7088d00834e918d170;p=platal.git diff --git a/modules/lists.php b/modules/lists.php index 2f74ea6..e55a6a5 100644 --- a/modules/lists.php +++ b/modules/lists.php @@ -47,13 +47,11 @@ class ListsModule extends PLModule { require_once 'lists.inc.php'; - $this->client =& lists_xmlrpc(Session::getInt('uid'), Session::get('password')); + $this->client =& lists_xmlrpc(S::v('uid'), S::v('password')); } function handler_lists(&$page) { - global $globals; - $this->prepare_client($page); $page->changeTpl('listes/index.tpl'); @@ -61,15 +59,15 @@ class ListsModule extends PLModule if (Get::has('del')) { - $this->client->unsubscribe(Get::get('del')); - redirect('lists'); + $this->client->unsubscribe(Get::v('del')); + pl_redirect('lists'); } if (Get::has('add')) { - $this->client->subscribe(Get::get('add')); - redirect('lists'); + $this->client->subscribe(Get::v('add')); + pl_redirect('lists'); } if (Post::has('promo_add')) { - $promo = Post::getInt('promo_add'); + $promo = Post::i('promo_add'); if ($promo >= 1900 and $promo < 2100) { $this->client->subscribe("promo$promo"); } else { @@ -82,25 +80,24 @@ class ListsModule extends PLModule function handler_create(&$page) { - global $globals; $page->changeTpl('listes/create.tpl'); - $owners = preg_split("/[\s]+/", Post::get('owners'), -1, PREG_SPLIT_NO_EMPTY); - $members = preg_split("/[\s]+/", Post::get('members'), -1, PREG_SPLIT_NO_EMPTY); + $owners = preg_split("/[\s]+/", Post::v('owners'), -1, PREG_SPLIT_NO_EMPTY); + $members = preg_split("/[\s]+/", Post::v('members'), -1, PREG_SPLIT_NO_EMPTY); // click on validate button 'add_owner_sub' or type if (Post::has('add_owner_sub') && Post::has('add_owner')) { require_once('user.func.inc.php'); // if we want to add an owner and then type , then both // add_owner_sub and add_owner are filled. - if (Post::get('add_owner') != "") { - if (($forlife = get_user_forlife(Post::get('add_owner'))) !== false) { + if (Post::v('add_owner') != "") { + if (($forlife = get_user_forlife(Post::v('add_owner'))) !== false) { $owners [] = $forlife; } // if we want to add a member and then type , then // add_owner_sub is filled, whereas add_owner is empty. } else if (Post::has('add_member')) { - if (($forlife = get_user_forlife(Post::get('add_member'))) !== false) { + if (($forlife = get_user_forlife(Post::v('add_member'))) !== false) { $members[] = $forlife; } } @@ -109,7 +106,7 @@ class ListsModule extends PLModule // click on validate button 'add_member_sub' if (Post::has('add_member_sub') && Post::has('add_member')) { require_once('user.func.inc.php'); - if (($forlife = get_user_forlife(Post::get('add_member'))) !== false) { + if (($forlife = get_user_forlife(Post::v('add_member'))) !== false) { $members[] = $forlife; } } @@ -124,23 +121,23 @@ class ListsModule extends PLModule return; } - $liste = Post::get('liste'); + $liste = Post::v('liste'); if (empty($liste)) { - $page->trig('champs «addresse souhaitée» vide'); + $page->trig('champs «addresse souhaitée» vide'); } if (!preg_match("/^[a-zA-Z0-9\-]*$/", $liste)) { $page->trig('le nom de la liste ne doit contenir que des lettres, chiffres et tirets'); } - $res = $globals->xdb->query("SELECT COUNT(*) FROM aliases WHERE alias={?}", $liste); + $res = XDB::query("SELECT COUNT(*) FROM aliases WHERE alias={?}", $liste); $n = $res->fetchOneCell(); if ($n) { - $page->trig('cet alias est déjà pris'); + $page->trig('cet alias est déjà pris'); } - if (!Post::get(desc)) { + if (!Post::v(desc)) { $page->trig('le sujet est vide'); } @@ -155,9 +152,9 @@ class ListsModule extends PLModule if (!$page->nb_errs()) { $page->assign('created', true); require_once 'validations.inc.php'; - $req = new ListeReq(Session::getInt('uid'), $liste, - Post::get('desc'), Post::getInt('advertise'), - Post::getInt('modlevel'), Post::getInt('inslevel'), + $req = new ListeReq(S::v('uid'), $liste, + Post::v('desc'), Post::i('advertise'), + Post::i('modlevel'), Post::i('inslevel'), $owners, $members); $req->submit(); } @@ -165,8 +162,6 @@ class ListsModule extends PLModule function handler_members(&$page, $liste = null) { - global $globals; - if (is_null($liste)) { return PL_NOT_FOUND; } @@ -177,17 +172,17 @@ class ListsModule extends PLModule if (Get::has('del')) { $this->client->unsubscribe($liste); - redirect($liste); + pl_redirect('lists/members/'.$liste); } if (Get::has('add')) { $this->client->subscribe($liste); - redirect($liste); + pl_redirect('lists/members/'.$liste); } $members = $this->client->get_members($liste); - $tri_promo = !Env::getBool('alpha'); + $tri_promo = !Env::b('alpha'); if (list($det,$mem,$own) = $members) { $membres = list_sort_members($mem, $tri_promo); @@ -198,19 +193,19 @@ class ListsModule extends PLModule $page->assign_by_ref('owners', $moderos); $page->assign('nb_m', count($mem)); } else { - $page->kill("La liste n'existe pas ou tu n'as pas le droit d'en voir les détails"); + $page->kill("La liste n'existe pas ou tu n'as pas le droit d'en voir les détails"); } } function _get_list($offset, $limit) { - global $globals, $platal; + global $platal; list($total, $members) = $this->client->get_members_limit($platal->argv[1], $offset, $limit); $membres = Array(); foreach ($members as $member) { list($m) = explode('@',$member[1]); - $res = $globals->xdb->query("SELECT prenom,if (nom_usage='', nom, nom_usage) AS nom, + $res = XDB::query("SELECT prenom,if (nom_usage='', nom, nom_usage) AS nom, promo, a.alias AS forlife FROM auth_user_md5 AS u INNER JOIN aliases AS a ON u.user_id = a.id @@ -226,8 +221,6 @@ class ListsModule extends PLModule function handler_trombi(&$page, $liste = null) { - global $globals; - if (is_null($liste)) { return PL_NOT_FOUND; } @@ -238,11 +231,11 @@ class ListsModule extends PLModule if (Get::has('del')) { $this->client->unsubscribe($liste); - redirect($liste); + pl_redirect('lists/tromi/'.$liste); } if (Get::has('add')) { $this->client->subscribe($liste); - redirect($liste); + pl_redirect('lists/tromi/'.$liste); } $owners = $this->client->get_owners($liste); @@ -257,7 +250,7 @@ class ListsModule extends PLModule $trombi = new Trombi(array(&$this, '_get_list')); $page->assign('trombi', $trombi); } else { - $page->kill("La liste n'existe pas ou tu n'as pas le droit d'en voir les détails"); + $page->kill("La liste n'existe pas ou tu n'as pas le droit d'en voir les détails"); } } @@ -280,8 +273,8 @@ class ListsModule extends PLModule { $page->kill("La liste n'existe pas ou tu n'as pas le droit de la consulter"); } elseif (Get::has('file')) { - $file = Get::get('file'); - $rep = Get::get('rep'); + $file = Get::v('file'); + $rep = Get::v('rep'); if (strstr('/', $file)!==false || !preg_match(',^\d+/\d+$,', $rep)) { $page->kill("La liste n'existe pas ou tu n'as pas le droit de la consulter"); } else { @@ -307,8 +300,6 @@ class ListsModule extends PLModule function handler_moderate(&$page, $liste = null) { - global $globals; - if (is_null($liste)) { return PL_NOT_FOUND; } @@ -320,45 +311,45 @@ class ListsModule extends PLModule $page->register_modifier('qpd', 'quoted_printable_decode'); if (Env::has('sadd')) { /* 4 = SUBSCRIBE */ - $this->client->handle_request($liste,Env::get('sadd'),4,''); - redirect($liste); + $this->client->handle_request($liste,Env::v('sadd'),4,''); + pl_redirect('lists/moderate/'.$liste); } if (Post::has('sdel')) { /* 2 = REJECT */ - $this->client->handle_request($liste,Post::get('sdel'),2,Post::get('reason')); + $this->client->handle_request($liste,Post::v('sdel'),2,Post::v('reason')); } if (Env::has('mid')) { - $mid = Env::get('mid'); + $mid = Env::v('mid'); $mail = $this->client->get_pending_mail($liste, $mid); $reason = ''; - $prenom = Session::get('prenom'); - $nom = Session::get('nom'); + $prenom = S::v('prenom'); + $nom = S::v('nom'); if (Env::has('mok')) { $action = 1; /** 2 = ACCEPT **/ - $subject = "Message accepté"; - $append .= "a été accepté par $prenom $nom.\n"; + $subject = "Message accepté"; + $append .= "a été accepté par $prenom $nom.\n"; } elseif (Env::has('mno')) { $action = 2; /** 2 = REJECT **/ - $subject = "Message refusé"; - $reason = Post::get('reason'); - $append = "a été refusé par $prenom $nom avec la raison :\n\n" + $subject = "Message refusé"; + $reason = Post::v('reason'); + $append = "a été refusé par $prenom $nom avec la raison :\n\n" . $reason; } elseif (Env::has('mdel')) { $action = 3; /** 3 = DISCARD **/ - $subject = "Message supprimé"; - $append = "a été supprimé par $prenom $nom.\n\n" - . "Rappel: il ne faut utiliser cette opération " + $subject = "Message supprimé"; + $append = "a été supprimé par $prenom $nom.\n\n" + . "Rappel: il ne faut utiliser cette opération " . "que dans le cas de spams ou de virus !\n"; } if (isset($action) && $this->client->handle_request($liste, $mid, $action, $reason)) { $texte = "le message suivant :\n\n" ." Auteur: {$mail['sender']}\n" - ." Sujet : « {$mail['subj']} »\n" - ." Date : ".strftime("le %d %b %Y à %H:%M:%S", (int)$mail['stamp'])."\n\n" + ." Sujet : « {$mail['subj']} »\n" + ." Date : ".strftime("le %d %b %Y à %H:%M:%S", (int)$mail['stamp'])."\n\n" .$append; require_once 'diogenes/diogenes.hermes.inc.php'; $mailer = new HermesMailer(); @@ -381,17 +372,17 @@ class ListsModule extends PLModule $page->changeTpl('listes/moderate_mail.tpl'); $page->assign_by_ref('mail', $mail); - $page->run(); + return; } } elseif (Env::has('sid')) { if (list($subs,$mails) = $this->client->get_pending_ops($liste)) { foreach($subs as $user) { - if ($user['id'] == Env::get('sid')) { + if ($user['id'] == Env::v('sid')) { $page->changeTpl('listes/moderate_sub.tpl'); - $page->assign('del_user',$user); - $page->run(); + $page->assign('del_user', $user); + return; } } } @@ -402,7 +393,7 @@ class ListsModule extends PLModule $page->assign_by_ref('subs', $subs); $page->assign_by_ref('mails', $mails); } else { - $page->kill("La liste n'existe pas ou tu n'as pas le droit de la modérer"); + $page->kill("La liste n'existe pas ou tu n'as pas le droit de la modérer"); } } @@ -421,7 +412,7 @@ class ListsModule extends PLModule if (Env::has('add_member')) { require_once('user.func.inc.php'); - $members = explode(' ', Env::get('add_member')); + $members = explode(' ', Env::v('add_member')); if ($members) foreach ($members as $i => $alias) { if (($login = get_user_forlife($alias)) !== false) {; $members[$i] = $login; @@ -437,19 +428,19 @@ class ListsModule extends PLModule } if (Env::has('del_member')) { - if (strpos(Env::get('del_member'), '@') === false) { + if (strpos(Env::v('del_member'), '@') === false) { $this->client->mass_unsubscribe( - $liste, array(Env::get('del_member').'@'.$globals->mail->domain)); + $liste, array(Env::v('del_member').'@'.$globals->mail->domain)); } else { - $this->client->mass_unsubscribe($liste, array(Env::get('del_member'))); + $this->client->mass_unsubscribe($liste, array(Env::v('del_member'))); } - redirect($liste); + pl_redirect('lists/admin/'.$liste); } if (Env::has('add_owner')) { require_once('user.func.inc.php'); - $owners = explode(' ', Env::get('add_owner')); + $owners = explode(' ', Env::v('add_owner')); if ($owners) foreach ($owners as $alias) { if (($login = get_user_forlife($alias)) === false) {; @@ -457,18 +448,18 @@ class ListsModule extends PLModule } if ($this->client->add_owner($liste, $login)) { - $page->trig($alias." ajouté aux modérateurs."); + $page->trig($alias." ajouté aux modérateurs."); } } } if (Env::has('del_owner')) { - if (strpos(Env::get('del_owner'), '@') === false) { - $this->client->del_owner($liste, Env::get('del_owner').'@'.$globals->mail->domain); + if (strpos(Env::v('del_owner'), '@') === false) { + $this->client->del_owner($liste, Env::v('del_owner').'@'.$globals->mail->domain); } else { - $this->client->del_owner($liste, Env::get('del_owner')); + $this->client->del_owner($liste, Env::v('del_owner')); } - redirect($liste); + pl_redirect('lists/admin/'.$liste); } if (list($det,$mem,$own) = $this->client->get_members($liste)) { @@ -488,8 +479,6 @@ class ListsModule extends PLModule function handler_options(&$page, $liste = null) { - global $globals; - if (is_null($liste)) { return PL_NOT_FOUND; } @@ -523,11 +512,11 @@ class ListsModule extends PLModule $values['subject_prefix'] = trim($values['subject_prefix']).' '; } $this->client->set_owner_options($liste, $values); - } elseif (isvalid_email(Post::get('atn_add'))) { - $this->client->add_to_wl($liste, Post::get('atn_add')); + } elseif (isvalid_email(Post::v('atn_add'))) { + $this->client->add_to_wl($liste, Post::v('atn_add')); } elseif (Get::has('atn_del')) { - $this->client->del_from_wl($liste, Get::get('atn_del')); - redirect("{$_SERVER['PHP_SELF']}?liste=$liste"); + $this->client->del_from_wl($liste, Get::v('atn_del')); + pl_redirect('lists/options/'.$liste); } if (list($details,$options) = $this->client->get_owner_options($liste)) { @@ -541,8 +530,6 @@ class ListsModule extends PLModule function handler_delete(&$page, $liste = null) { - global $globals; - if (is_null($liste)) { return PL_NOT_FOUND; } @@ -551,13 +538,13 @@ class ListsModule extends PLModule $page->changeTpl('listes/delete.tpl'); - if (Post::get('valid') == 'OUI' - && $this->client->delete_list($liste, Post::getBool('del_archive'))) + if (Post::v('valid') == 'OUI' + && $this->client->delete_list($liste, Post::b('del_archive'))) { foreach (array('', '-owner', '-admin', '-bounces') as $app) { - $globals->xdb->execute("DELETE FROM aliases + XDB::execute("DELETE FROM aliases WHERE type='liste' AND alias='{?}'", - $ml.$app); + $liste.$app); } $page->assign('deleted', true); } elseif (list($details,$options) = $this->client->get_owner_options($liste)) { @@ -571,8 +558,6 @@ class ListsModule extends PLModule function handler_soptions(&$page, $liste = null) { - global $globals; - if (is_null($liste)) { return PL_NOT_FOUND; } @@ -599,8 +584,6 @@ class ListsModule extends PLModule function handler_check(&$page, $liste = null) { - global $globals; - if (is_null($liste)) { return PL_NOT_FOUND; }