/** * Get a list of every group that $user is in. * * @param string $user The user to get groups for. * @param boolean $parentGroups Also return the parents of any groups? * * @return array An array of all groups the user is in. */ function getGroupMemberships($user, $parentGroups = false) { Horde::logMessage('getGroupMemberships', __FILE__, __LINE__, PEAR_LOG_DEBUG); if ($this->_server->connect(Auth::getAuth(), Auth::getCredential('password'))) { $groups = array(); $criteria = array(); array_push($criteria, array('conjunction' => 'AND', 'key' => 'login', 'value' => strtolower($user), 'expression' => 'EQUALS')); array_push($criteria, array('conjunction' => 'AND', 'key' => 'isAccount', 'value' => 1, 'expression' => 'EQUALS')); $flags = array('limit' => 1, 'revolve' => 'NO'); $result = $this->_server->search('Contact', $criteria, 128, $flags); if (is_array($result)) { $result = $result[0]; if (is_array($result['_MEMBERSHIP'])) { foreach ($result['_MEMBERSHIP'] as $assignment) { $teamId = $assignment['targetObjectId']; $team = $this->_getGroup($teamId); if (isset($team['name'])) { array_push($groups, $team['name']); } else { PEAR::raiseError(_("Invalid object in zOGI response.")); } } } } else { PEAR::raiseError(_("Invalid zOGI server version detected.")); } } else { PEAR::raiseError(_("Cannot retrieve contacts teams.")); } Horde::logMessage(sprintf('User a member of %d groups', count($groups)), __FILE__, __LINE__, PEAR_LOG_DEBUG); return $groups; }
function _init() { $this->_server = new ZOGI(); $this->_limit = $this->_params['limit']; $this->_entity = $this->_params['entity']; if (!$this->_server->connect(Auth::getAuth(), Auth::getCredential('password'))) { return PEAR::raiseError(_('Connection failure')); } return; }