public function usersLogin()
 {
     Logger::debug('main', 'UsersGroup_dynamic::usersLogin');
     $static = parent::usersLogin();
     $ls = Abstract_Liaison_dynamic::load('UsersGroup', NULL, $this->getUniqueID());
     $dynamic = array();
     if (is_array($ls)) {
         foreach ($ls as $l) {
             $dynamic[] = $l->element;
         }
     }
     return array_unique(array_merge($static, $dynamic));
 }
Exemplo n.º 2
0
 public function usersGroups()
 {
     Logger::debug('main', 'USER::UsersGroups');
     $result = array();
     // add the default user group is enable
     $prefs = Preferences::getInstance();
     if (!$prefs) {
         Logger::critical('main', 'USER::UsersGroups get prefs failed');
         die_error('get Preferences failed', __FILE__, __LINE__);
     }
     $user_default_group = $prefs->get('general', 'user_default_group');
     $userGroupDB = UserGroupDB::getInstance();
     $static = Abstract_Liaison::load('UsersGroup', $this->attributes['login'], NULL);
     if (is_null($static)) {
         Logger::error('main', 'User::usersGroups load(' . $this->attributes['login'] . ') is null');
         return $result;
     }
     if ($userGroupDB->isDynamic()) {
         $dynamic = Abstract_Liaison_dynamic::load('UsersGroup', $this->attributes['login'], NULL);
         if (is_null($dynamic)) {
             $dynamic = array();
         }
     } else {
         $dynamic = array();
     }
     $rows = array_unique(array_merge($static, $dynamic));
     if (!is_null($user_default_group) && $user_default_group !== '-1' && $user_default_group !== '') {
         $g = $userGroupDB->import($user_default_group);
         // safe because even if  group = -1, the import failed safely
         if (is_object($g)) {
             $result[$user_default_group] = $g;
         }
     }
     foreach ($rows as $lug) {
         $g = $userGroupDB->import($lug->group);
         if (is_object($g)) {
             $result[$lug->group] = $g;
         } else {
             Logger::error('main', 'USER::usersGroups user group (\'' . $lug->group . '\') not ok');
         }
     }
     return $result;
 }