X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fxnetgrp.php;h=ede566c3ef590d3c9f551067f3f7c4e724b91c05;hb=dcdcd18aeb2b29ddfa7768317b14ca0a277dd654;hp=bbb557adb8f73317a2ab3c102a7ac28d32eb7fac;hpb=1490093c909c086ce8eba3c0f5c24b62ef20cfb3;p=platal.git diff --git a/modules/xnetgrp.php b/modules/xnetgrp.php index bbb557a..ede566c 100644 --- a/modules/xnetgrp.php +++ b/modules/xnetgrp.php @@ -41,7 +41,7 @@ function get_infos($email) if ($res->numRows()) { $user = $res->fetchOneAssoc(); if ($user['origine'] == 'X') { - $res = XDB::query("SELECT nom, prenom, promo, FIND_IN_SET(flags, 'femme') AS sexe + $res = XDB::query("SELECT nom, prenom, promo, FIND_IN_SET('femme', flags) AS sexe FROM auth_user_md5 WHERE user_id = {?}", $user['uid']); $user = array_merge($user, $res->fetchOneAssoc()); @@ -55,7 +55,7 @@ function get_infos($email) CONCAT(b.alias, '@m4x.org') AS email, CONCAT(b.alias, '@polytechnique.org') AS email2, m.perms='admin' AS perms, m.origine, - FIND_IN_SET(u.flags, 'femme') AS sexe + FIND_IN_SET('femme', u.flags) AS sexe FROM auth_user_md5 AS u INNER JOIN aliases AS a ON ( u.user_id = a.id AND a.type != 'homonyme' ) INNER JOIN aliases AS b ON ( u.user_id = b.id AND b.type = 'a_vie' ) @@ -80,16 +80,17 @@ class XnetGrpModule extends PLModule '%grp/edit' => $this->make_hook('edit', AUTH_MDP, 'groupadmin'), '%grp/mail' => $this->make_hook('mail', AUTH_MDP, 'groupadmin'), '%grp/forum' => $this->make_hook('forum', AUTH_MDP, 'groupmember'), - '%grp/annuaire' => $this->make_hook('annuaire', AUTH_MDP), - '%grp/annuaire/vcard' => $this->make_hook('vcard', AUTH_MDP), - '%grp/trombi' => $this->make_hook('trombi', AUTH_MDP), + '%grp/annuaire' => $this->make_hook('annuaire', AUTH_MDP, 'groupannu'), + '%grp/annuaire/vcard' => $this->make_hook('vcard', AUTH_MDP, 'groupmember:groupannu'), + '%grp/trombi' => $this->make_hook('trombi', AUTH_MDP, 'groupannu'), + '%grp/geoloc' => $this->make_hook('geoloc', AUTH_MDP, 'groupannu'), '%grp/subscribe' => $this->make_hook('subscribe', AUTH_MDP), '%grp/unsubscribe' => $this->make_hook('unsubscribe', AUTH_MDP, 'groupmember'), '%grp/change_rights' => $this->make_hook('change_rights', AUTH_MDP), '%grp/admin/annuaire' - => $this->make_hook('admin_annuaire', AUTH_MDP), + => $this->make_hook('admin_annuaire', AUTH_MDP, 'groupadmin'), '%grp/member' => $this->make_hook('admin_member', AUTH_MDP, 'groupadmin'), @@ -158,7 +159,7 @@ class XnetGrpModule extends PLModule FROM groupex.announces AS a INNER JOIN auth_user_md5 AS u USING(user_id) WHERE asso_id = {?} AND peremption >= CURRENT_DATE() - AND FIND_IN_SET(a.flags, 'public')", + AND FIND_IN_SET('public', u.flags)", $globals->asso('id')); } @@ -323,10 +324,20 @@ class XnetGrpModule extends PLModule run_banana($page, 'ForumsBanana', $get); } - function handler_annuaire(&$page) + function handler_annuaire(&$page, $action = null, $subaction = null) { global $globals; - new_annu_page('xnetgrp/annuaire.tpl'); + + if ($action == 'geoloc' || $action == 'trombi') { + $view = new UserSet(); + $view->addMod('trombi', 'Trombinoscope'); + $view->addMod('geoloc', 'Planisphère'); + $view->apply('annuaire', $page, $action, $subaction); + if ($action == 'geoloc' && $subaction) { + return; + } + } + $page->changeTpl('xnetgrp/annuaire.tpl'); $sort = Env::v('order'); switch (Env::v('order')) { @@ -426,26 +437,24 @@ class XnetGrpModule extends PLModule $page->jsonAssign('ann', $ann); } - function handler_trombi(&$page, $action = null, $subaction = null) + function handler_trombi(&$page) { - $view = new UserSet(); - $view->addMod('trombi', 'Trombinoscope', true, array('with_admin' => false, 'with_promo' => true)); - $view->apply('trombi', $page, 'trombi', $action, $subaction); + pl_redirect('annuaire/trombi'); + } + + function handler_geoloc(&$page) + { + pl_redirect('annuaire/geoloc'); } function handler_vcard(&$page, $photos = null) { global $globals; - - if (($globals->asso('pub') == 'public' && is_member()) || may_update()) { - $res = XDB::query('SELECT uid - FROM groupex.membres - WHERE asso_id = {?}', $globals->asso('id')); - $vcard = new VCard($res->fetchColumn(), $photos == 'photos', 'Membre du groupe ' . $globals->asso('nom')); - $vcard->do_page($page); - } else { - return PL_FORBIDDEN; - } + $res = XDB::query('SELECT uid + FROM groupex.membres + WHERE asso_id = {?}', $globals->asso('id')); + $vcard = new VCard($res->fetchColumn(), $photos == 'photos', 'Membre du groupe ' . $globals->asso('nom')); + $vcard->do_page($page); } function handler_subscribe(&$page, $u = null) @@ -948,7 +957,7 @@ class XnetGrpModule extends PLModule IF(u.nom_usage != '', u.nom_usage, u.nom) AS nom, u.prenom, u.promo FROM groupex.announces AS a INNER JOIN auth_user_md5 AS u USING(user_id) - WHERE FIND_IN_SET(a.flags, 'public') AND peremption >= NOW() AND a.asso_id = {?}", + WHERE FIND_IN_SET('public', a.flags) AND peremption >= NOW() AND a.asso_id = {?}", $globals->asso('id')); } $page->assign('asso', $globals->asso()); @@ -1006,17 +1015,28 @@ class XnetGrpModule extends PLModule $promo_min = ($art['public'] ? 0 : $art['promo_min']); $promo_max = ($art['public'] ? 0 : $art['promo_max']); if (is_null($aid)) { + $fulltext = $art['texte']; + if (!empty($art['contact_html'])) { + $fulltext .= "\n\n'''Contacts :'''\\\\\n" . $art['contact_html']; + } + $post = null; + if ($globals->asso('forum')) { + require_once 'banana/forum.inc.php'; + $banana = new ForumsBanana(S::v('forlife')); + $post = $banana->post($globals->asso('forum'), null, + $art['titre'], MiniWiki::wikiToText($fulltext, false, 0, 80)); + } XDB::query("INSERT INTO groupex.announces (user_id, asso_id, create_date, titre, texte, contacts, - peremption, promo_min, promo_max, flags) - VALUES ({?}, {?}, NOW(), {?}, {?}, {?}, {?}, {?}, {?}, {?})", + peremption, promo_min, promo_max, flags, post_id) + VALUES ({?}, {?}, NOW(), {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})", S::i('uid'), $globals->asso('id'), $art['titre'], $art['texte'], $art['contact_html'], - $art['peremption'], $promo_min, $promo_max, $art['public'] ? 'public' : ''); + $art['peremption'], $promo_min, $promo_max, $art['public'] ? 'public' : '', $post); $aid = XDB::insertId(); if ($art['xorg']) { require_once('validations.inc.php'); $article = new EvtReq("[{$globals->asso('nom')}] " . $art['titre'], - MiniWiki::WikiToHTML($art['texte'] . (!empty($art['contact_html']) ? "\n\nContacts :\n" . $art['contact_html'] : "")), + MiniWiki::WikiToHTML($fulltext), $art['promo_min'], $art['promo_max'], $art['peremption'], "", S::v('uid')); $article->submit(); $page->trig("L'affichage sur la page d'accueil de Polytechnique.org est en attente de validation"); @@ -1044,7 +1064,7 @@ class XnetGrpModule extends PLModule if (empty($art) && !is_null($aid)) { $res = XDB::query("SELECT a.*, u.nom, u.prenom, u.promo, l.alias AS forlife, - FIND_IN_SET(a.flags, 'public') AS public + FIND_IN_SET('public', a.flags) AS public FROM groupex.announces AS a INNER JOIN auth_user_md5 AS u USING(user_id) INNER JOIN aliases AS l ON (l.id = u.user_id AND l.type = 'a_vie') @@ -1058,22 +1078,6 @@ class XnetGrpModule extends PLModule } } - $select = ''; - for ($i = 1 ; $i < 30 ; $i++) { - $time = time() + 3600 * 24 * $i; - $p_stamp = date('Ymd', $time); - $year = date('Y', $time); - $month = date('m', $time); - $day = date('d', $time); - - $select .= "\n"; - } - $page->assign('select', $select); - if (is_null($aid)) { $events = XDB::iterator("SELECT * FROM groupex.evenements @@ -1094,14 +1098,14 @@ class XnetGrpModule extends PLModule $page->changeTpl('xnetgrp/announce-admin.tpl'); if (Env::has('del')) { - XDB::execute("DELETE FROM groupex.announces - WHERE id = {?} AND asso_id = {?}", + XDB::execute("DELETE FROM groupex.announces + WHERE id = {?} AND asso_id = {?}", Env::i('del'), $globals->asso('id')); } - $res = XDB::iterator("SELECT a.id, a.titre, a.peremption, a.peremption < CURRENT_DATE() AS perime - FROM groupex.announces AS a - WHERE a.asso_id = {?} - ORDER BY a.peremption DESC", + $res = XDB::iterator("SELECT a.id, a.titre, a.peremption, a.peremption < CURRENT_DATE() AS perime + FROM groupex.announces AS a + WHERE a.asso_id = {?} + ORDER BY a.peremption DESC", $globals->asso('id')); $page->assign('articles', $res); }