Merge branch 'xorg/master' into xorg/f/xnet-accounts
authorStéphane Jacob <sj@m4x.org>
Fri, 7 Jan 2011 13:44:53 +0000 (14:44 +0100)
committerStéphane Jacob <sj@m4x.org>
Fri, 7 Jan 2011 13:44:53 +0000 (14:44 +0100)
1  2 
classes/user.php
classes/xnetpage.php
configs/mails.conf
htdocs/javascript/password.js
modules/xnet.php
modules/xnetgrp.php
templates/xnet/skin.tpl
templates/xnetgrp/membres-del.tpl
templates/xnetgrp/membres-edit.tpl

@@@ -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,
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -905,13 -885,7 +920,13 @@@ class XnetGrpModule extends PLModul
              return PL_NOT_FOUND;
          }
  
-         $mmlist = new MMList($user, $globals->asso('mail_domain'));
 +        if (!$user->inGroup($globals->asso('id'))) {
 +            pl_redirect('annuaire');
 +        }
 +
 +        $page->changeTpl('xnetgrp/membres-edit.tpl');
 +
+         $mmlist = new MMList(S::user(), $globals->asso('mail_domain'));
  
          if (Post::has('change')) {
              S::assert_xsrf_token();
              }
          }
  
+         $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));
Simple merge
Simple merge
Simple merge