X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;ds=sidebyside;f=modules%2Fxnetlists.php;h=ae991b48f431d06b038583407410766130af880e;hb=ff82994d23549527fe2e9c9f1214d639b73c0a22;hp=1c59e10d5487a36f9c9f5c259f40f1e6e1c56b48;hpb=6d1747b3dbcf944c995dc2d87e8561c7a66f3aa6;p=platal.git diff --git a/modules/xnetlists.php b/modules/xnetlists.php index 1c59e10..ae991b4 100644 --- a/modules/xnetlists.php +++ b/modules/xnetlists.php @@ -1,6 +1,6 @@ $this->make_hook('lists', AUTH_MDP, 'groupmember'), - '%grp/lists/create' => $this->make_hook('create', AUTH_MDP, 'groupmember'), + '%grp/lists' => $this->make_hook('lists', AUTH_MDP, 'groupmember'), + '%grp/lists/create' => $this->make_hook('create', AUTH_MDP, 'groupmember'), - '%grp/lists/members' => $this->make_hook('members', AUTH_COOKIE), - '%grp/lists/csv' => $this->make_hook('csv', AUTH_COOKIE), - '%grp/lists/annu' => $this->make_hook('annu', AUTH_COOKIE), - '%grp/lists/archives' => $this->make_hook('archives', AUTH_COOKIE), - '%grp/lists/archives/rss' => $this->make_hook('rss', AUTH_PUBLIC), + '%grp/lists/members' => $this->make_hook('members', AUTH_COOKIE), + '%grp/lists/csv' => $this->make_hook('csv', AUTH_COOKIE), + '%grp/lists/annu' => $this->make_hook('annu', AUTH_COOKIE), + '%grp/lists/archives' => $this->make_hook('archives', AUTH_COOKIE), + '%grp/lists/archives/rss' => $this->make_hook('rss', AUTH_PUBLIC), - '%grp/lists/moderate' => $this->make_hook('moderate', AUTH_MDP), - '%grp/lists/admin' => $this->make_hook('admin', AUTH_MDP), - '%grp/lists/options' => $this->make_hook('options', AUTH_MDP), - '%grp/lists/delete' => $this->make_hook('delete', AUTH_MDP), + '%grp/lists/moderate' => $this->make_hook('moderate', AUTH_MDP), + '%grp/lists/admin' => $this->make_hook('admin', AUTH_MDP), + '%grp/lists/options' => $this->make_hook('options', AUTH_MDP), + '%grp/lists/delete' => $this->make_hook('delete', AUTH_MDP), - '%grp/lists/soptions' => $this->make_hook('soptions', AUTH_MDP), - '%grp/lists/check' => $this->make_hook('check', AUTH_MDP), - '%grp/lists/sync' => $this->make_hook('sync', AUTH_MDP), + '%grp/lists/soptions' => $this->make_hook('soptions', AUTH_MDP), + '%grp/lists/check' => $this->make_hook('check', AUTH_MDP), + '%grp/lists/sync' => $this->make_hook('sync', AUTH_MDP), - '%grp/alias/admin' => $this->make_hook('aadmin', AUTH_MDP, 'groupadmin'), - '%grp/alias/create' => $this->make_hook('acreate', AUTH_MDP, 'groupadmin'), + '%grp/alias/admin' => $this->make_hook('aadmin', AUTH_MDP, 'groupadmin'), + '%grp/alias/create' => $this->make_hook('acreate', AUTH_MDP, 'groupadmin'), /* hack: lists uses that */ - 'profile' => $this->make_hook('profile', AUTH_PUBLIC), + 'profile' => $this->make_hook('profile', AUTH_PUBLIC), ); } @@ -99,24 +99,31 @@ class XnetListsModule extends ListsModule $alias = substr($alias, 0, strpos($alias, '@')).'@'.$globals->asso('mail_domain'); XDB::query( 'DELETE FROM r, v - USING x4dat.virtual AS v - LEFT JOIN x4dat.virtual_redirect AS r USING(vid) + USING virtual AS v + LEFT JOIN virtual_redirect AS r USING(vid) WHERE v.alias={?}', $alias); - $page->trigSuccess(Post::v('del_alias')." supprimé !"); + $page->trigSuccess(Post::v('del_alias')." supprimé !"); } $listes = $this->client->get_lists(); - $page->assign('listes',$listes); + $page->assign('listes', $listes); $alias = XDB::iterator( 'SELECT alias,type - FROM x4dat.virtual + FROM virtual WHERE alias LIKE {?} AND type="user" ORDER BY alias', '%@'.$globals->asso('mail_domain')); $page->assign('alias', $alias); $page->assign('may_update', may_update()); + + if (count($listes) > 0 && !$globals->asso('has_ml')) { + XDB::execute("UPDATE groups + SET flags = CONCAT_WS(',', IF(flags = '', NULL, flags), 'has_ml') + WHERE id = {?}", + $globals->asso('id')); + } } function handler_create(&$page) @@ -135,8 +142,8 @@ class XnetListsModule extends ListsModule S::assert_xsrf_token(); } - if (!Post::has('liste')) { - $page->trigError('champs «adresse souhaitée» vide'); + if (!Post::has('liste') || !Post::v('liste')) { + $page->trigError('Le champs « adresse souhaitée Â» est vide.'); return; } @@ -148,7 +155,7 @@ class XnetListsModule extends ListsModule } $new = $liste.'@'.$globals->asso('mail_domain'); - $res = XDB::query('SELECT alias FROM x4dat.virtual WHERE alias={?}', $new); + $res = XDB::query('SELECT alias FROM virtual WHERE alias={?}', $new); if ($res->numRows()) { $page->trigError('cet alias est déjà pris'); @@ -177,12 +184,18 @@ class XnetListsModule extends ListsModule if (!empty($app)) { $app = '-' . $app; } - XDB::execute('INSERT INTO x4dat.virtual (alias,type) + XDB::execute('INSERT INTO virtual (alias,type) VALUES({?},{?})', $liste. $app . '@'.$dom, 'list'); - XDB::execute('INSERT INTO x4dat.virtual_redirect (vid,redirect) + XDB::execute('INSERT INTO virtual_redirect (vid,redirect) VALUES ({?}, {?})', XDB::insertId(), $red . $mdir . '@listes.polytechnique.org'); } + + XDB::execute("UPDATE groups + SET flags = CONCAT_WS(',', IF(flags = '', NULL, flags), 'has_ml') + WHERE id = {?}", + $globals->asso('id')); + pl_redirect('lists/admin/'.$liste); } @@ -209,9 +222,10 @@ class XnetListsModule extends ListsModule $not_in_group_ext = array(); $ann = XDB::fetchColumn('SELECT uid - FROM groupex.membres + FROM group_members WHERE asso_id = {?}', $globals->asso('id')); - $users = User::getBuildUsersWithUIDs($ann, 'promo,full_name'); + $users = User::getBulkUsersWithUIDs($ann); + $not_in_list = array(); foreach ($users as $user) { if (!in_array(strtolower($user->forlifeEmail()), $subscribers)) { @@ -242,22 +256,22 @@ class XnetListsModule extends ListsModule $add = null; } if (!empty($add)) { - XDB::execute('INSERT INTO x4dat.virtual_redirect (vid, redirect) - SELECT vid, {?}, - FROM x4dat.virtual + XDB::execute('INSERT INTO virtual_redirect (vid, redirect) + SELECT vid, {?} + FROM virtual WHERE alias = {?}', strtolower($add), $lfull); $page->trigSuccess($add . ' ajouté.'); } else { - $page->trigError($add . ' n\'existe pas.'); + $page->trigError($add . " n'existe pas."); } } if (Env::has('del_member')) { S::assert_xsrf_token(); XDB::query( - "DELETE FROM x4dat.virtual_redirect - USING x4dat.virtual_redirect - INNER JOIN x4dat.virtual USING(vid) + "DELETE FROM virtual_redirect + USING virtual_redirect + INNER JOIN virtual USING(vid) WHERE redirect={?} AND alias={?}", Env::v('del_member'), $lfull); pl_redirect('alias/admin/'.$lfull); } @@ -296,7 +310,7 @@ class XnetListsModule extends ListsModule } if (!Post::has('liste')) { - $page->trigError('champs «adresse souhaitée» vide'); + $page->trigError('Le champs « adresse souhaitée Â» est vide.'); return; } $liste = Post::v('liste'); @@ -307,14 +321,14 @@ class XnetListsModule extends ListsModule } $new = $liste.'@'.$globals->asso('mail_domain'); - $res = XDB::query('SELECT COUNT(*) FROM x4dat.virtual WHERE alias={?}', $new); + $res = XDB::query('SELECT COUNT(*) FROM virtual WHERE alias = {?}', $new); $n = $res->fetchOneCell(); if ($n) { $page->trigError('cet alias est déjà pris'); return; } - XDB::query('INSERT INTO x4dat.virtual (alias,type) VALUES({?}, "user")', $new); + XDB::query('INSERT INTO virtual (alias,type) VALUES({?}, "user")', $new); pl_redirect("alias/admin/$new"); }