/** * Small helper to get the GUID of the user's first group. This is used mainly to populate * the owner field during DBa object create calls * * @return mixed GUID of the first group found or false */ function get_first_group_guid() { if (!is_null($this->_direct_groups)) { if (empty($this->_direct_groups)) { // User is not member of any groups return false; } return $this->_direct_groups[key($this->_direct_groups)]->get_storage()->guid; } //Not yet initialized, try to load one midgard group $mc = new midgard_collector('midgard_member', 'uid', $this->_storage->id); $mc->add_constraint('gid', '<>', 0); $mc->set_key_property('gid'); $mc->set_limit(1); @$mc->execute(); $result = $mc->list_keys(); if (!empty($result)) { if ($group = midcom::get('auth')->get_group(key($result))) { return $group->get_storage()->guid; } } $this->_load_all_groups(); if (!empty($this->_direct_groups)) { return $this->_direct_groups[key($this->_direct_groups)]->get_storage()->guid; } return false; }