From: Stéphane Jacob Date: Fri, 7 Jan 2011 13:44:53 +0000 (+0100) Subject: Merge branch 'xorg/master' into xorg/f/xnet-accounts X-Git-Tag: xorg/1.1.0~26^2~26 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=ce0d7be772306674fadaf020511871aba1683816;p=platal.git Merge branch 'xorg/master' into xorg/f/xnet-accounts --- ce0d7be772306674fadaf020511871aba1683816 diff --cc classes/user.php index b503dfe,f54d61b..1f4d873 --- a/classes/user.php +++ b/classes/user.php @@@ -569,40 -613,27 +613,44 @@@ class User extends PlUse WHERE uid = {?}', $this->id()); } - return $this->groups; - } - - public function groupNames($institutions = false) - { - if ($institutions) { - $where = ' AND (g.cat = \'GroupesX\' OR g.cat = \'Institutions\')'; + if (!$institutions && !$onlyPublic) { + return $this->groups; } else { - $where = ''; + $result = array(); + foreach ($this->groups as $id=>$data) { + if ($institutions) { + if ($data['cat'] != Group::CAT_GROUPESX && $data['cat'] != Group::CAT_INSTITUTIONS) { + continue; + } + } + if ($onlyPublic) { + if ($data['pub'] != 'public') { + continue; + } + } + $result[$id] = $data; + } + return $result; } - return XDB::fetchAllAssoc('SELECT g.diminutif, g.nom, g.site - FROM group_members AS gm - LEFT JOIN groups AS g ON (g.id = gm.asso_id) - WHERE gm.uid = {?}' . $where, - $this->id()); } + public function groupCount() + { + return XDB::fetchOneCell('SELECT COUNT(DISTINCT(asso_id)) + FROM group_members + WHERE uid = {?}', + $this->id()); + } + + public function inGroup($asso_id) + { + $res = XDB::fetchOneCell('SELECT COUNT(*) + FROM group_members + WHERE uid = {?} AND asso_id = {?}', + $this->id(), $asso_id); + return ($res > 0); + } + /** * Clears a user. * *always deletes in: account_lost_passwords, register_marketing, diff --cc modules/xnetgrp.php index bce331c,66acde1..8a04125 --- a/modules/xnetgrp.php +++ b/modules/xnetgrp.php @@@ -905,13 -885,7 +920,13 @@@ class XnetGrpModule extends PLModul return PL_NOT_FOUND; } + if (!$user->inGroup($globals->asso('id'))) { + pl_redirect('annuaire'); + } + + $page->changeTpl('xnetgrp/membres-edit.tpl'); + - $mmlist = new MMList($user, $globals->asso('mail_domain')); + $mmlist = new MMList(S::user(), $globals->asso('mail_domain')); if (Post::has('change')) { S::assert_xsrf_token(); @@@ -1028,8 -999,9 +1047,11 @@@ } } + $res = XDB::rawFetchAllAssoc('SHOW COLUMNS FROM group_members LIKE \'position\''); + $positions = str_replace(array('enum(', ')', '\''), '', $res[0]['Type']); + + $page->addJsLink('password.js'); + $page->assign('onlyGroup', ($user->groupCount() == 1)); $page->assign('user', $user); $page->assign('listes', $mmlist->get_lists($user->forlifeEmail())); $page->assign('alias', $user->emailAliases($globals->asso('mail_domain'), 'user', true));