X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Flists.php;h=7111516b290d71f43b44a0612fd5313d3c668a42;hb=f3da6d81799c3ee012f1ca5f86aac9fc01d5818e;hp=cfd66e18f326f2ed8a52879c2f77d130dd1e0335;hpb=4f355064724a95757bb5ca023f1da9950a04013d;p=platal.git diff --git a/modules/lists.php b/modules/lists.php index cfd66e1..7111516 100644 --- a/modules/lists.php +++ b/modules/lists.php @@ -21,17 +21,17 @@ class ListsModule extends PLModule { - var $client; + protected $client; function handlers() { return array( 'lists' => $this->make_hook('lists', AUTH_MDP), - 'lists/ajax' => $this->make_hook('ajax', AUTH_MDP, '', NO_AUTH), + 'lists/ajax' => $this->make_hook('ajax', AUTH_MDP, 'user', NO_AUTH), 'lists/create' => $this->make_hook('create', AUTH_MDP), 'lists/members' => $this->make_hook('members', AUTH_COOKIE), - 'lists/trombi' => $this->make_hook('trombi', AUTH_COOKIE), + 'lists/annu' => $this->make_hook('annu', AUTH_COOKIE), 'lists/archives' => $this->make_hook('archives', AUTH_COOKIE), 'lists/archives/rss' => $this->make_hook('rss', AUTH_PUBLIC), @@ -42,7 +42,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'), ); } @@ -225,16 +225,6 @@ class ListsModule extends PLModule } } - function changeTpl($tpl) - { - if (!empty($GLOBALS['IS_XNET_SITE'])) { - new_group_open_page($tpl); - } else { - global $page; - $page->changeTpl($tpl); - } - } - function handler_members(&$page, $liste = null) { if (is_null($liste)) { @@ -243,7 +233,7 @@ class ListsModule extends PLModule $this->prepare_client($page); - $this->changeTpl('lists/members.tpl'); + $page->changeTpl('lists/members.tpl'); if (Get::has('del')) { $this->client->unsubscribe($liste); @@ -272,42 +262,7 @@ class ListsModule extends PLModule } } - function compare($a, $b) - { - if ($a['promo'] == $b['promo']) { - if ($a['nom'] == $b['nom']) { - return strcmp($a['prenom'], $b['prenom']); - } - return strcmp($a['nom'], $b['nom']); - } - return $a['promo'] - $b['promo']; - } - - function _get_list($offset, $limit) - { - 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 = 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 - INNER JOIN photo AS p ON p.uid = u.user_id - WHERE a.alias = {?}", $m); - if ($tmp = $res->fetchOneAssoc()) { - $membres[$tmp['nom']] = $tmp; - } else { - $total--; - } - } - uasort($membres, array($this, 'compare')); - return array($total, $membres); - } - - function handler_trombi(&$page, $liste = null) + function handler_annu(&$page, $liste = null, $action = null, $subaction = null) { if (is_null($liste)) { return PL_NOT_FOUND; @@ -315,30 +270,42 @@ class ListsModule extends PLModule $this->prepare_client($page); - $this->changeTpl('lists/trombi.tpl'); - if (Get::has('del')) { $this->client->unsubscribe($liste); - pl_redirect('lists/trombi/'.$liste); + pl_redirect('lists/annu/'.$liste); } if (Get::has('add')) { $this->client->subscribe($liste); - pl_redirect('lists/trombi/'.$liste); + pl_redirect('lists/annu/'.$liste); } $owners = $this->client->get_owners($liste); - - if (is_array($owners)) { - $moderos = list_sort_owners($owners[1]); - - $page->assign_by_ref('details', $owners[0]); - $page->assign_by_ref('owners', $moderos); - - $trombi = new Trombi(array(&$this, '_get_list')); - $page->assign('trombi', $trombi); - } else { + if (!is_array($owners)) { $page->kill("La liste n'existe pas ou tu n'as pas le droit d'en voir les détails"); } + + global $platal; + list(,$members) = $this->client->get_members($liste); + $users = array(); + foreach ($members as $m) { + $users[] = $m[1]; + } + require_once 'userset.inc.php'; + $view = new ArraySet($users); + $view->addMod('trombi', 'Trombinoscope', true, array('with_promo' => true)); + if (empty($GLOBALS['IS_XNET_SITE'])) { + $view->addMod('minifiche', 'Minifiches', false); + } + $view->addMod('geoloc', 'Planisphère'); + $view->apply("lists/annu/$liste", $page, $action, $subaction); + if ($action == 'geoloc' && $subaction) { + return; + } + + $page->changeTpl('lists/annu.tpl'); + $moderos = list_sort_owners($owners[1]); + $page->assign_by_ref('details', $owners[0]); + $page->assign_by_ref('owners', $moderos); } function handler_archives(&$page, $liste = null, $action = null, $artid = null) @@ -351,7 +318,7 @@ class ListsModule extends PLModule $domain = $this->prepare_client($page); - $this->changeTpl('lists/archives.tpl'); + $page->changeTpl('lists/archives.tpl'); if (list($det) = $this->client->get_members($liste)) { if (substr($liste,0,5) != 'promo' && ($det['ins'] || $det['priv']) @@ -392,7 +359,7 @@ class ListsModule extends PLModule exit; } require_once('banana/ml.inc.php'); - $banana = new MLBanana(Array('listname' => $liste, 'domain' => $domain, 'action' => 'rss2')); + $banana = new MLBanana(S::v('forlife'), Array('listname' => $liste, 'domain' => $domain, 'action' => 'rss2')); $banana->run(); } exit; @@ -446,21 +413,43 @@ class ListsModule extends PLModule function handler_moderate(&$page, $liste = null) { if (is_null($liste)) { - return PL_NOT_FOUND; + return PL_NOT_FOUND; } $domain = $this->prepare_client($page); - $this->changeTpl('lists/moderate.tpl'); + $page->changeTpl('lists/moderate.tpl'); $page->register_modifier('hdc', 'list_header_decode'); - if (Env::has('sadd')) { /* 4 = SUBSCRIBE */ - $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::v('sdel'),2,Post::v('reason')); + if (Env::has('sadd') || Env::has('sdel')) { + if (Env::has('sadd')) { /* 4 = SUBSCRIBE */ + $sub = $this->client->get_pending_sub($liste, Env::v('sadd')); + $this->client->handle_request($liste,Env::v('sadd'),4,''); + $info = "validée"; + } + if (Post::has('sdel')) { /* 2 = REJECT */ + $sub = $this->client->get_pending_sub($liste, Env::v('sdel')); + $this->client->handle_request($liste, Post::v('sdel'), 2, Post::v('reason')); + $info = "refusée"; + } + if ($sub) { + $mailer = new PlMailer(); + $mailer->setFrom("$liste-bounces@{$domain}"); + $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"; + if (trim(Post::v('reason'))) { + $text .= "\nLa raison invoquée est :\n" . Post::v('reason'); + } + $mailer->setTxtBody(wordwrap($text, 72)); + $mailer->send(); + } + if (Env::has('sadd')) { + pl_redirect('lists/moderate/'.$liste); + } } if (Post::has('moderate_mails') && Post::has('select_mails')) { @@ -491,7 +480,7 @@ class ListsModule extends PLModule if (list($subs,$mails) = $this->client->get_pending_ops($liste)) { foreach($subs as $user) { if ($user['id'] == Env::v('sid')) { - $this->changeTpl('lists/moderate_sub.tpl'); + $page->changeTpl('lists/moderate_sub.tpl'); $page->assign('del_user', $user); return; } @@ -511,6 +500,22 @@ class ListsModule extends PLModule } } + static public function no_login_callback($login) + { + require_once 'user.func.inc.php'; + global $list_unregistered; + + $users = get_not_registered_user($login, true); + if ($users->total()) { + if (!isset($list_unregistered)) { + $list_unregistered = array(); + } + $list_unregistered[$login] = $users; + } else { + _default_user_callback($login); + } + } + function handler_admin(&$page, $liste = null) { global $globals; @@ -519,13 +524,43 @@ class ListsModule extends PLModule return PL_NOT_FOUND; } - $this->prepare_client($page); + $domain = $this->prepare_client($page); - $this->changeTpl('lists/admin.tpl'); + $page->changeTpl('lists/admin.tpl'); + + if (Env::has('send_mark')) { + $actions = Env::v('mk_action'); + $uids = Env::v('mk_uid'); + $mails = Env::v('mk_email'); + foreach ($actions as $key=>$action) { + switch ($action) { + case 'none': + break; + + case 'marketu': case 'markets': + require_once 'emails.inc.php'; + $mail = valide_email($mails[$key]); + if (isvalid_email_redirection($mail)) { + $from = ($action == 'marketu') ? 'user' : 'staff'; + $market = Marketing::get($uids[$key], $mail); + if (!$market) { + $market = new Marketing($uids[$key], $mail, 'list', "$liste@$domain", $from, S::v('uid')); + $market->add(); + break; + } + } + + default: + XDB::execute('INSERT IGNORE INTO register_subs (uid, type, sub, domain) + VALUES ({?}, \'list\', {?}, {?})', + $uids[$key], $liste, $domain); + } + } + } if (Env::has('add_member')) { require_once('user.func.inc.php'); - $members = get_users_forlife_list(Env::v('add_member')); + $members = get_users_forlife_list(Env::v('add_member'), false, array('ListsModule', 'no_login_callback')); $arr = $this->client->mass_subscribe($liste, $members); if (is_array($arr)) { foreach($arr as $addr) { @@ -546,7 +581,7 @@ class ListsModule extends PLModule if (Env::has('add_owner')) { require_once('user.func.inc.php'); - $owners = get_users_forlife_list(Env::v('add_owner')); + $owners = get_users_forlife_list(Env::v('add_owner'), false, array('ListsModule', 'no_login_callback')); if ($owners) { foreach ($owners as $login) { if ($this->client->add_owner($liste, $login)) { @@ -566,6 +601,10 @@ class ListsModule extends PLModule } if (list($det,$mem,$own) = $this->client->get_members($liste)) { + global $list_unregistered; + if ($list_unregistered) { + $page->assign_by_ref('unregistered', $list_unregistered); + } $membres = list_sort_members($mem, @$tri_promo); $moderos = list_sort_owners($own, @$tri_promo); @@ -589,7 +628,7 @@ class ListsModule extends PLModule $this->prepare_client($page); - $this->changeTpl('lists/options.tpl'); + $page->changeTpl('lists/options.tpl'); if (Post::has('submit')) { $values = $_POST; @@ -651,7 +690,7 @@ class ListsModule extends PLModule $type = 'list'; } - $this->changeTpl('lists/delete.tpl'); + $page->changeTpl('lists/delete.tpl'); if (Post::v('valid') == 'OUI') { if ($this->client->delete_list($liste, Post::b('del_archive'))) { foreach (array('', '-owner', '-admin', '-bounces') as $app) { @@ -682,7 +721,7 @@ class ListsModule extends PLModule $this->prepare_client($page); - $this->changeTpl('lists/soptions.tpl'); + $page->changeTpl('lists/soptions.tpl'); if (Post::has('submit')) { $values = $_POST; @@ -709,7 +748,7 @@ class ListsModule extends PLModule $this->prepare_client($page); - $this->changeTpl('lists/check.tpl'); + $page->changeTpl('lists/check.tpl'); if (Post::has('correct')) { $this->client->check_options($liste, true); @@ -724,7 +763,7 @@ class ListsModule extends PLModule } function handler_admin_all(&$page) { - $this->changeTpl('lists/admin_all.tpl'); + $page->changeTpl('lists/admin_all.tpl'); $page->assign('xorg_title','Polytechnique.org - Administration - Mailing lists'); $client = new MMList(S::v('uid'), S::v('password'));