/** * Finds all admins who are not assigned with domain. * * Finds all admins and iterate through then making an array of 'id' => 'username' * If admin inactive username will be append by '(inactive)' then we iterate * through domain admins and removing all array elements which id is already in domain admins list. * * @param \Entities\Domain $domain Domain to look for admins * @retun array */ public function getNotAssignedForDomain($domain) { $adminNames = []; foreach ($this->findBy(["super" => false]) as $admin) { $adminNames[$admin->getId()] = $admin->getActive() ? $admin->getUsername() : $admin->getUsername() . " (inactive)"; } foreach ($domain->getAdmins() as $admin) { if (isset($adminNames[$admin->getId()])) { unset($adminNames[$admin->getId()]); } } return $adminNames; }
/** * {@inheritDoc} */ public function _getPreferences() { $this->__initializer__ && $this->__initializer__->__invoke($this, '_getPreferences', array()); return parent::_getPreferences(); }
/** * Check to see if this user is linked to a given domain (does not check for super - see below) * * This function is slightly misnamed as it does not check if your are a super admin (`isSuper()`) * but rather whether you are linked to a domain or not. So a use case in practice would be: * * if( $admin->isSuper() || $admin->canManageDomain( $domain ) ) ...; * * * @param \Entities\Domain $domain The domain object * @return boolean */ public function canManageDomain($domain) { foreach ($this->getDomains() as $d) { if ($domain->getId() == $d->getId()) { return true; } } return false; }