/** * Returns collection of owa_user entities that are allowed for current user * @return owa_user[] */ public function getAssignedUsers() { if (!$this->get('id')) { throw new Exception('no site data loaded!'); } if (!isset(self::$cachedAssignedUsers[$this->get('id')])) { $db = owa_coreAPI::dbSingleton(); $db->selectFrom('owa_site_user'); $db->selectColumn('*'); $db->where('site_id', $this->get('id')); $relations = $db->getAllRows(); $result = array(); if (is_array($relations)) { foreach ($relations as $row) { $userEntity = owa_coreApi::entityFactory('base.user'); $userEntity->load($row['user_id']); $result[] = $userEntity; } } self::$cachedAssignedUsers[$this->get('id')] = $result; } return self::$cachedAssignedUsers[$this->get('id')]; }
private function setAllowedSitesList($site_ids) { $list = array(); if (!empty($site_ids)) { foreach ($site_ids as $row) { $siteEntity = owa_coreApi::entityFactory('base.site'); $siteEntity->load($row['site_id']); $list[$siteEntity->get('site_id')] = $siteEntity; } } $this->assignedSites = $list; $this->isAssignedSitesListLoaded = true; }
function __construct() { //parent::__construct(); $this->user = owa_coreApi::entityFactory('base.user'); }