/** * Save a role for a hierarchy node * * @param object SiteComponent $component * @param object SegueRole $role * @return <##> * @access public * @since 11/16/07 */ public function saveRole(SiteComponent $component, SegueRole $role) { $roleMgr = SegueRoleManager::instance(); $idMgr = Services::getService("Id"); $agentId = $this->getAgentId(); $componentId = $idMgr->getId($component->getId()); // Ensure that Everyone or Institute are not set to admin $everyoneId = $idMgr->getId('edu.middlebury.agents.everyone'); $instituteId = $idMgr->getId('edu.middlebury.institute'); if ($agentId->isEqual($everyoneId) || $agentId->isEqual($instituteId)) { if ($role->getIdString() == 'admin') { $role = $roleMgr->getRole('editor'); } } // printpre("Saving role '".$role->getIdString()."' for ".$agentId." at ".$component->getDisplayName()); // Find the parent node. $parent = $component->getParentComponent(); if ($parent) { $parentQualifierId = $parent->getQualifierId(); $parentRole = $roleMgr->getAgentsRole($agentId, $parentQualifierId, true); } // Apply the role or clear it if it is less than the implicitly given role. try { if (isset($parentRole) && $role->isLessThanOrEqualTo($parentRole)) { $roleMgr->clearRoleAZs($agentId, $componentId); // printpre("Clearing duplicate role '".$role->getIdString()."' for ".$agentId." at ".$component->getDisplayName()); } else { $role->apply($agentId, $componentId); } } catch (PermissionDeniedException $e) { } return true; }
/** * Answer true if this role is equal to the role passed * * @param object SegueRole $role * @return boolean * @access public * @since 11/5/07 */ public function isEqualTo(SegueRole $role) { if ($role->getIdString() == $this->getIdString()) { return true; } return false; }