Example #1
0
 /**
  * Get the group's custom params
  *
  * @param   integer  $group_id
  * @return  object
  */
 protected function _params($group_id)
 {
     if (!$this->_params) {
         $this->_params = \Hubzero\Plugin\Params::getCustomParams($group_id, 'groups', $this->_name);
     }
     return $this->_params;
 }
Example #2
0
 /**
  * Get a list of collections for a user
  *
  * - If no type or type='member', returns an array of collections
  *   that user created.
  * - If type='group', returns an array of collections in the groups
  *   the user is a member of.
  *
  * @param   string $type What type ot get collections for [group, member]
  * @return  array
  */
 public function mine($type = '')
 {
     $user = User::getInstance();
     $tbl = new Tables\Collection($this->_db);
     switch (strtolower(trim($type))) {
         case 'group':
         case 'groups':
             $collections = array();
             $usergroups = $user->groups('members');
             $usergroups_manager = $user->groups('managers');
             if ($usergroups) {
                 if ($usergroups_manager) {
                     foreach ($usergroups_manager as $manager_group) {
                         foreach ($usergroups as $user_group) {
                             if ($user_group->gidNumber == $manager_group->gidNumber) {
                                 $user_group->manager = $manager_group->manager;
                             }
                         }
                     }
                 }
                 foreach ($usergroups as $usergroup) {
                     $groups = $tbl->getRecords(array('object_type' => 'group', 'object_id' => $usergroup->gidNumber, 'state' => 1));
                     if ($groups) {
                         if (!isset($usergroup->params) || !is_object($usergroup->params)) {
                             $usergroup->params = Params::getCustomParams($usergroup->gidNumber, 'groups', 'collections');
                         }
                         foreach ($groups as $s) {
                             if (!isset($collections[$s->group_alias])) {
                                 $collections[$s->group_alias] = array();
                             }
                             if ($usergroup->params->get('create_post', 0) == 1 && !$usergroup->manager) {
                                 continue;
                             }
                             /*if ($s->access == 4 && !$usergroup->manager)
                             		{
                             			continue;
                             		}*/
                             $collections[$s->group_alias][] = $s;
                             asort($collections[$s->group_alias]);
                         }
                     }
                 }
             }
             asort($collections);
             break;
         case 'member':
         default:
             $collections = $tbl->getRecords(array('object_type' => 'member', 'object_id' => $user->get('id'), 'state' => 1));
             break;
     }
     return $collections;
 }