X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Flists.php;h=5587714afcc3bab30701252100d5518cb788eb53;hb=1dd218522cea6ae08998b0ca107c8fec608ddce8;hp=8479060760926f029c08259ae1c5b9e0d7128812;hpb=353f2d2b11c4e3c6c0bc3553813368b6f42fa9c6;p=platal.git diff --git a/modules/lists.php b/modules/lists.php index 8479060..5587714 100644 --- a/modules/lists.php +++ b/modules/lists.php @@ -1,6 +1,6 @@ $this->make_hook('lists', AUTH_MDP), - 'lists/ajax' => $this->make_hook('ajax', AUTH_MDP, 'user', NO_AUTH), - 'lists/create' => $this->make_hook('create', AUTH_MDP), + 'lists/ajax' => $this->make_hook('ajax', AUTH_MDP, 'user', NO_AUTH), + 'lists/create' => $this->make_hook('create', AUTH_MDP, 'lists'), 'lists/members' => $this->make_hook('members', AUTH_COOKIE), 'lists/csv' => $this->make_hook('csv', AUTH_COOKIE), @@ -43,7 +43,7 @@ class ListsModule extends PLModule 'lists/soptions' => $this->make_hook('soptions', AUTH_MDP), 'lists/check' => $this->make_hook('check', AUTH_MDP), - 'admin/lists' => $this->make_hook('admin_all', AUTH_MDP, 'admin'), + 'admin/lists' => $this->make_hook('admin_all', AUTH_MDP, 'admin'), ); } @@ -64,7 +64,7 @@ class ListsModule extends PLModule { list($subs,$mails) = $this->client->get_pending_ops($list); $res = XDB::query("SELECT mid - FROM ml_moderate + FROM email_list_moderate WHERE ml = {?} AND domain = {?}", $list, $domain); $mids = $res->fetchColumn(); @@ -112,24 +112,25 @@ class ListsModule extends PLModule if ($promo >= 1900 and $promo < 2100) { $this->client->subscribe("promo$promo"); } else { - $page->trigSuccess("promo incorrecte, il faut une promo sur 4 chiffres."); + $page->trigError("promo incorrecte, il faut une promo sur 4 chiffres."); } } - $listes = $this->client->get_lists(); - $owner = array_filter($listes, 'filter_owner'); - $listes = array_diff_key($listes, $owner); - $member = array_filter($listes, 'filter_member'); - $listes = array_diff_key($listes, $member); - foreach ($owner as $key=>$liste) { - list($subs,$mails) = $this->get_pending_ops($domain, $liste['list']); - $owner[$key]['subscriptions'] = $subs; - $owner[$key]['mails'] = $mails; + if (!is_null($listes = $this->client->get_lists())) { + $owner = array_filter($listes, 'filter_owner'); + $listes = array_diff_key($listes, $owner); + $member = array_filter($listes, 'filter_member'); + $listes = array_diff_key($listes, $member); + foreach ($owner as $key => $liste) { + list($subs, $mails) = $this->get_pending_ops($domain, $liste['list']); + $owner[$key]['subscriptions'] = $subs; + $owner[$key]['mails'] = $mails; + } + $page->register_modifier('hdc', 'list_header_decode'); + $page->assign_by_ref('owner', $owner); + $page->assign_by_ref('member', $member); + $page->assign_by_ref('public', $listes); } - $page->register_modifier('hdc', 'list_header_decode'); - $page->assign_by_ref('owner', $owner); - $page->assign_by_ref('member', $member); - $page->assign_by_ref('public', $listes); } function handler_ajax(&$page, $list = null) @@ -168,14 +169,20 @@ class ListsModule extends PLModule $page->changeTpl('lists/create.tpl'); - $user_promo = S::i('promo'); + $user_promo = S::user()->profile()->yearPromo(); $year = date('Y'); $month = date('m'); + // scolar year starts in september + $scolarmonth = ($year - $user_promo) * 12 + ($month - 8); $young_promo = $very_young_promo = 0; - if ((($year > $user_promo) && ($month > 3)) && ($year < $user_promo + 5)) { + // binet are accessible only in april in the first year and until + // march of the 5th year + if ($scolarmonth >= 8 && $scolarmonth < 56) { $young_promo = 1; } - if ((($year > $user_promo) && ($month > 7)) && (($year < $user_promo + 1) && ($month < 8))) { + // PSC aliases are accesible only between september and june of the second + // year of scolarity + if ($scolarmonth >= 12 && $scolarmonth < 22) { $very_young_promo = 1; } $page->assign('young_promo', $young_promo); @@ -258,7 +265,7 @@ class ListsModule extends PLModule if ($asso == "groupex") { $groupex_name = Post::v('groupex_name'); - $res_groupe = XDB::query('SELECT mail_domain FROM #groupex#.asso WHERE nom={?}', $groupex_name); + $res_groupe = XDB::query('SELECT mail_domain FROM groups WHERE nom={?}', $groupex_name); $domain = $res_groupe->fetchOneCell(); if (!$domain) { @@ -294,7 +301,6 @@ class ListsModule extends PLModule if (!$page->nb_errs()) { $page->trigSuccess('Demande de création envoyée !'); $page->assign('created', true); - require_once 'validations.inc.php'; $req = new ListeReq(S::user(), $asso, $liste, $domain, Post::v('desc'), Post::i('advertise'), Post::i('modlevel'), Post::i('inslevel'), @@ -349,13 +355,11 @@ class ListsModule extends PLModule } $this->prepare_client($page); $members = $this->client->get_members($liste); - $list = list_fetch_names(list_extract_members($members[1])); + $list = list_fetch_basic_info(list_extract_members($members[1])); pl_content_headers("text/x-csv"); - echo "email,nom,prenom,promo\n"; - foreach ($list as $member) { - echo @$member['email'] . ',' . @$member['nom'] . ',' . @$member['prenom'] . ',' . @$member['promo'] . "\n"; - } + echo "email,nom,promo\n"; + echo implode("\n", $list); exit; } @@ -395,7 +399,8 @@ class ListsModule extends PLModule if (empty($GLOBALS['IS_XNET_SITE'])) { $view->addMod('minifiche', 'Mini-fiches', false); } - $view->addMod('geoloc', 'Planisphère'); + // TODO: Reactivate when the new map is completed. + // $view->addMod('geoloc', 'Planisphère'); $view->apply("lists/annu/$liste", $page, $action, $subaction); if ($action == 'geoloc' && $subaction) { return; @@ -471,7 +476,7 @@ class ListsModule extends PLModule return false; } Get::kill('mid'); - return XDB::execute("INSERT IGNORE INTO ml_moderate + return XDB::execute("INSERT IGNORE INTO email_list_moderate VALUES ({?}, {?}, {?}, {?}, {?}, NOW(), {?}, NULL)", $liste, $domain, $mid, S::i('uid'), $action, Post::v('reason')); } @@ -507,8 +512,7 @@ class ListsModule extends PLModule $mailer->addTo("$liste-owner@{$domain}"); $mailer->addHeader('Reply-To', "$liste-owner@{$domain}"); $mailer->setSubject("L'inscription de {$sub['name']} a été $info"); - $text = "L'inscription de {$sub['name']} à la liste $liste@{$domain} a été $info par " . S::v('prenom') . ' ' - . S::v('nom') . '(' . S::v('promo') . ")\n"; + $text = "L'inscription de {$sub['name']} à la liste $liste@{$domain} a été $info par " . S::user()->fullName(true) . ".\n"; if (trim(Post::v('reason'))) { $text .= "\nLa raison invoquée est :\n" . Post::v('reason'); } @@ -529,29 +533,15 @@ class ListsModule extends PLModule } } elseif (Env::has('mid')) { if (Get::has('mid') && !Env::has('mok') && !Env::has('mdel')) { - $page->changeTpl('lists/moderate_mail.tpl'); - require_once('banana/moderate.inc.php'); - $params = array('listname' => $liste, 'domain' => $domain, - 'artid' => Get::i('mid'), 'part' => Get::v('part'), 'action' => Get::v('action')); - $params['client'] = $this->client; - run_banana($page, 'ModerationBanana', $params); + require_once 'banana/moderate.inc.php'; - $msg = file_get_contents('/etc/mailman/fr/refuse.txt'); - $msg = str_replace("%(adminaddr)s", "$liste-owner@{$domain}", $msg); - $msg = str_replace("%(request)s", "<< SUJET DU MAIL >>", $msg); - $msg = str_replace("%(reason)s", "<< TON EXPLICATION >>", $msg); - $msg = str_replace("%(listname)s", $liste, $msg); - $page->assign('msg', $msg); - return; - } elseif (Get::has('mid') && Env::has('mok')) { $page->changeTpl('lists/moderate_mail.tpl'); - require_once('banana/moderate.inc.php'); $params = array('listname' => $liste, 'domain' => $domain, 'artid' => Get::i('mid'), 'part' => Get::v('part'), 'action' => Get::v('action')); $params['client'] = $this->client; run_banana($page, 'ModerationBanana', $params); - $msg = file_get_contents('/etc/mailman/fr/accept.txt'); + $msg = file_get_contents('/etc/mailman/fr/refuse.txt'); $msg = str_replace("%(adminaddr)s", "$liste-owner@{$domain}", $msg); $msg = str_replace("%(request)s", "<< SUJET DU MAIL >>", $msg); $msg = str_replace("%(reason)s", "<< TON EXPLICATION >>", $msg); @@ -560,7 +550,7 @@ class ListsModule extends PLModule return; } - $mail = $this->moderate_mail($domain, $liste, Env::i('mid')); + $this->moderate_mail($domain, $liste, Env::i('mid')); } elseif (Env::has('sid')) { if (list($subs,$mails) = $this->get_pending_ops($domain, $liste)) { foreach($subs as $user) { @@ -592,10 +582,9 @@ class ListsModule extends PLModule static public function no_login_callback($login) { - require_once 'user.func.inc.php'; global $list_unregistered, $globals; - $users = get_not_registered_user($login, true); + $users = User::getPendingAccounts($login, true); if ($users && $users->total()) { if (!isset($list_unregistered)) { $list_unregistered = array();