Ejemplo n.º 1
0
 /**
  * Get the groups ow a wishlist owner
  *
  * @param   integer  $listid        List ID
  * @param   string   $controlgroup  Control group name
  * @param   object   $wishlist      Wishlist
  * @param   integer  $native        Get groups assigned to this wishlist?
  * @param   array    $groups        List of gorups
  * @return  mixed    False if errors, array on success
  */
 public function get_owner_groups($listid, $controlgroup = '', $wishlist = null, $native = 0, $groups = array())
 {
     if ($listid === NULL) {
         return false;
     }
     $wishgroups = array();
     $obj = new Wishlist($this->_db);
     // if tool, get tool group
     if (!$wishlist) {
         $wishlist = $obj->get_wishlist($listid);
     }
     if (isset($wishlist->resource) && $wishlist->resource->type == 7) {
         $toolgroup = $obj->getToolDevGroup($wishlist->referenceid);
         if ($toolgroup) {
             $groups[] = $toolgroup;
         }
     }
     // if primary list, add all site admins
     if ($controlgroup && $wishlist->category == 'general') {
         $instance = Group::getInstance($controlgroup);
         if (is_object($instance)) {
             $gid = $instance->get('gidNumber');
             if ($gid) {
                 $groups[] = $gid;
             }
         }
     }
     // if private group list, add the group
     if ($wishlist->category == 'group') {
         $groups[] = $wishlist->referenceid;
     }
     // get groups assigned to this wishlist
     if (!$native) {
         $sql = "SELECT o.groupid FROM `#__wishlist_ownergroups` AS o WHERE o.wishlist=" . $this->_db->quote($listid);
         $this->_db->setQuery($sql);
         $wishgroups = $this->_db->loadObjectList();
         if ($wishgroups) {
             foreach ($wishgroups as $wg) {
                 if (Group::exists($wg->groupid)) {
                     $groups[] = $wg->groupid;
                 }
             }
         }
     }
     $groups = array_unique($groups);
     sort($groups);
     return $groups;
 }