/**
  * This class implements the Singleton pattern. There is only ever
  * one instance of the this class and it is accessed only via the 
  * ClassName::instance() method.
  * 
  * @return object 
  * @access public
  * @since 5/26/05
  * @static
  */
 public static function instance()
 {
     if (!isset(self::$instance)) {
         self::$instance = new SegueRoleManager();
     }
     return self::$instance;
 }
Esempio n. 2
0
 /**
  * Execute this action.
  * 
  * @return void
  * @access public
  * @since 7/28/08
  */
 public function execute()
 {
     if (!$this->isAuthorizedToExecute()) {
         throw new PermissionDeniedException(_("Your are not authorized to move/copy items here."));
     }
     // Clear any output buffers.
     while (ob_get_level()) {
         ob_end_clean();
     }
     $director = SiteDispatcher::getSiteDirector();
     foreach (RequestContext::value('sourceIds') as $sourceId) {
         print "\n<hr/>";
         try {
             $sourceComponent = $director->getSiteComponentById($sourceId);
             switch (RequestContext::value('command')) {
                 case 'copy':
                     $successMessage = _("Successfully copied %1.");
                     $this->copyComponent($sourceComponent);
                     break;
                 case 'move':
                     $successMessage = _("Successfully moved %1.");
                     $this->moveComponent($sourceComponent);
                     break;
                 case 'reference':
                     $successMessage = _("Created a reference to %1.");
                     $this->referenceComponent($sourceComponent);
                     break;
                 default:
                     throw new InvalidArgumentException("Unknown command '" . RequestContext::value('command') . "'");
             }
             // Ensure that the current user is an editor of the component.
             // They may have had implicit Editor and only Author at the destination.
             $roleMgr = SegueRoleManager::instance();
             $editor = $roleMgr->getRole('editor');
             $role = $roleMgr->getUsersRole($sourceComponent->getQualifierId(), true);
             if ($role->isLessThan($editor)) {
                 $editor->applyToUser($sourceComponent->getQualifierId(), true);
             }
             print "\n" . str_replace("%1", htmlspecialchars($sourceComponent->getDisplayName()), $successMessage);
             // Remove from selection?
             if (RequestContext::value('remove_after_use') == 'remove') {
                 $selection = Segue_Selection::instance();
                 $selection->removeSiteComponent($sourceComponent);
             }
         } catch (Exception $e) {
             print "\n" . htmlspecialchars($e->getMessage());
         }
     }
     print "\n<br/><br/>" . _("Done");
     exit;
 }
Esempio n. 3
0
 /**
  * Build a list of the sites for which users are admins
  * 
  * @return null
  */
 protected function buildUserSiteList()
 {
     $slotMgr = SlotManager::instance();
     $slots = $slotMgr->getAllSlots();
     $roleMgr = SegueRoleManager::instance();
     $agentMgr = Services::getService('Agent');
     $increment = round($slots->count() / 100);
     $i = 0;
     $numSites = 0;
     $incomplete = 0;
     $this->slots = array();
     // Get the users who can adminster each slot.
     while ($slots->hasNext()) {
         $i++;
         if ($i % $increment == 0) {
             print '.';
             flush();
         }
         $slot = $slots->next();
         if (!$slot->isAlias() && $slot->siteExists()) {
             $this->slots[$slot->getShortname()] = array('slot' => $slot, 'users' => array());
             $adminIds = $roleMgr->getAgentsWithExplicitRoleAtLeast($roleMgr->getRole('admin'), $slot->getSiteId(), true);
             $numAdmins = 0;
             foreach ($adminIds as $adminId) {
                 // Skip the special groups of
                 // 	edu.middlebury.institute
                 // 	edu.middlebury.agents.users
                 // 	edu.middlebury.agents.anonymous
                 // etc.
                 if (preg_match('/^edu\\.middlebury\\./', $adminId->getIdString())) {
                     continue;
                 }
                 try {
                     $agent = $agentMgr->getAgentOrGroup($adminId);
                     if ($agent->isGroup()) {
                         $numAdmins = $numAdmins + $this->addSlotForGroup($agent, $slot);
                     } else {
                         $numAdmins = $numAdmins + $this->addSlotForAgent($agent, $slot);
                     }
                 } catch (UnknownIdException $e) {
                 }
             }
             if (!$numAdmins) {
                 $this->slotsWithoutAdmins[] = $slot->getShortname();
             }
         }
     }
 }
Esempio n. 4
0
 /**
  * Save the navigation step
  * 
  * @param array $values
  * @return boolean
  * @access public
  * @since 6/5/07
  */
 function saveNavStep($values)
 {
     $director = $this->getSiteDirector();
     $organizer = $this->getSiteComponentForIdString($values['organizerId']);
     $componentType = HarmoniType::fromString($values['type']);
     if ($componentType->getDomain() == 'segue-multipart') {
         $component = addComponentAction::createMultipartComponent($director, $componentType, $organizer);
     } else {
         return false;
     }
     // Check the Role of the user. If it is less than 'Editor', make them an editor
     $roleMgr = SegueRoleManager::instance();
     $role = $roleMgr->getUsersRole($component->getQualifierId(), true);
     $editor = $roleMgr->getRole('editor');
     if ($role->isLessThan($editor)) {
         $editor->applyToUser($component->getQualifierId(), true);
     }
     $this->_newId = $component->getId();
     $this->_newIsNav = true;
     return true;
 }
Esempio n. 5
0
 /**
  * Process changes to the site components. This is the method that the various
  * actions that modify the site should override.
  * 
  * @param object SiteDirector $director
  * @return void
  * @access public
  * @since 4/14/06
  */
 function processChanges(SiteDirector $director)
 {
     // Get the target organizer's Id & Cell
     $targetId = RequestContext::value('destination');
     preg_match("/^(.+)_cell:(.+)\$/", $targetId, $matches);
     $targetOrgId = $matches[1];
     $targetCell = $matches[2];
     $component = $director->getSiteComponentById(RequestContext::value('component'));
     // Store the existing Role of the user.
     $roleMgr = SegueRoleManager::instance();
     $oldRole = $roleMgr->getUsersRole($component->getQualifierId(), true);
     // If we are moving a navOrganizer, update the target of the menu
     if (preg_match('/^.*NavOrganizerSiteComponent$/i', get_class($component))) {
         $menuOrganizer = $component->getMenuOrganizer();
         $menuOrganizer->updateTargetId(RequestContext::value('destination'));
         return;
     } else {
         if (preg_match('/^.*MenuOrganizerSiteComponent$/i', get_class($component))) {
             $newOrganizer = $director->getSiteComponentById($targetOrgId);
             $currentComponentInCell = $newOrganizer->getSubcomponentForCell($targetCell);
             if (preg_match('/^.*NavBlockSiteComponent$/i', get_class($currentComponentInCell))) {
                 $currentComponentInCell->makeNested($component);
                 return;
             }
         }
     }
     // 		printpre("targetId: ".$targetId);
     // 		printpre("targetOrgId: ".$targetOrgId);
     // 		printpre("targetCell: ".$targetCell);
     // 		printpre("componentId: ".RequestContext::value('component'));
     $filledTargetIds = $director->getFilledTargetIds($targetOrgId);
     $newOrganizer = $director->getSiteComponentById($targetOrgId);
     $oldCellId = $newOrganizer->putSubcomponentInCell($component, $targetCell);
     // 		printpre("oldCellId: ".$oldCellId);
     // If the targetCell was a target for any menus, change their targets
     // to the cell just vacated by the component we swapped with
     if (in_array($targetId, $filledTargetIds)) {
         $menuIds = array_keys($filledTargetIds, $targetId);
         foreach ($menuIds as $menuId) {
             $menuOrganizer = $director->getSiteComponentById($menuId);
             // 				printpre(get_class($menuOrganizer));
             $menuOrganizer->updateTargetId($oldCellId);
         }
     }
     // Update the new role if needed
     $newRole = $roleMgr->getUsersRole($component->getQualifierId(), true);
     if ($newRole->isLessThan($oldRole)) {
         $oldRole->applyToUser($component->getQualifierId(), true);
     }
     /*********************************************************
      * Log the event
      *********************************************************/
     if (Services::serviceRunning("Logging")) {
         $loggingManager = Services::getService("Logging");
         $log = $loggingManager->getLogForWriting("Segue");
         $formatType = new Type("logging", "edu.middlebury", "AgentsAndNodes", "A format in which the acting Agent[s] and the target nodes affected are specified.");
         $priorityType = new Type("logging", "edu.middlebury", "Event_Notice", "Normal events.");
         $item = new AgentNodeEntryItem("Component Moved", $component->getComponentClass() . " moved.");
         $item->addNodeId($component->getQualifierId());
         $site = $component->getDirector()->getRootSiteComponent($component->getId());
         if (!$component->getQualifierId()->isEqual($site->getQualifierId())) {
             $item->addNodeId($site->getQualifierId());
         }
         $log->appendLogWithTypes($item, $formatType, $priorityType);
     }
     // 		exit;
 }
 /**
  * Visit a Site Navigation Block
  * 
  * @param object SiteNavBlockSiteComponent $siteComponent
  * @return mixed
  * @access public
  * @since 8/31/07
  */
 public function visitSiteNavBlock(SiteNavBlockSiteComponent $siteComponent)
 {
     // If there is an implicit role coming from above the site in the authorization
     // hierarchy, make lesser roles disabled.
     $roleMgr = SegueRoleManager::instance();
     $groupImplicitRole = $roleMgr->getGroupImplictRole($this->agentId, $siteComponent->getQualifierId(), true);
     $implicitRole = $roleMgr->getAgentsImplicitRole($this->agentId, $siteComponent->getQualifierId(), true);
     if ($implicitRole->isGreaterThan($roleMgr->getRole('no_access')) && $implicitRole->isGreaterThan($groupImplicitRole)) {
         $this->siteImplicitRole = $implicitRole;
         $message = _("You cannot remove the '%1' role for '%2' because it was set for all of Segue.");
         $message = str_replace("%1", $implicitRole->getDisplayName(), $message);
         $message = str_replace("%2", $this->agent->getDisplayName(), $message);
         $this->siteImplicitRoleMessage = $message;
     }
     $this->addQualifierForSiteComponent($siteComponent, true);
     $siteComponent->getOrganizer()->acceptVisitor($this);
 }
Esempio n. 7
0
 /**
  * Process changes to the site components. This is the method that the various
  * actions that modify the site should override.
  * 
  * @param object SiteDirector $director
  * @return void
  * @access public
  * @since 4/14/06
  */
 function processChanges(SiteDirector $director)
 {
     $targetCell = $this->getTargetCell();
     $organizer = $this->getTargetOrganizer();
     $componentType = HarmoniType::fromString(RequestContext::value('componentType'));
     if ($componentType->getDomain() == 'segue-multipart') {
         $component = self::createMultipartComponent($director, $componentType, $organizer);
         $this->newIdToSendTo = $component->getId();
     } else {
         $component = $director->createSiteComponent($componentType, $organizer);
     }
     if (!is_null($targetCell)) {
         $oldCellId = $organizer->putSubcomponentInCell($component, $targetCell);
     }
     if (RequestContext::value('displayName')) {
         $component->updateDisplayName(RequestContext::value('displayName'));
     }
     if ($componentType->isEqual(new Type('segue', 'edu.middlebury', 'MenuOrganizer'))) {
         $menuTarget = RequestContext::value('menuTarget');
         if ($menuTarget == 'NewCellInNavOrg') {
             $navOrganizer = $organizer->getParentNavOrganizer();
             $navOrganizer->updateNumColumns($navOrganizer->getNumColumns() + 1);
             $menuTarget = $navOrganizer->getId() . "_cell:" . ($navOrganizer->getLastIndexFilled() + 1);
         }
         $component->updateTargetId($menuTarget);
     }
     // Check the Role of the user. If it is less than 'Editor', make them an editor
     $roleMgr = SegueRoleManager::instance();
     $role = $roleMgr->getUsersRole($component->getQualifierId(), true);
     $editor = $roleMgr->getRole('editor');
     if ($role->isLessThan($editor)) {
         $editor->applyToUser($component->getQualifierId(), true);
     }
 }
Esempio n. 8
0
 /**
  * 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;
 }
Esempio n. 9
0
 /**
  * Create the wizard
  * 
  * @return object Wizard
  * @access public
  * @since 11/14/07
  */
 public function createWizard()
 {
     // Instantiate the wizard, then add our steps.
     $wizard = SingleStepWizard::withText("<div>\n" . "<table width='100%' border='0' cellpadding='0' cellspacing='2'>\n" . "<tr>\n" . "<td align='left' width='50%'>\n" . "[[_cancel]]\n" . "</td>\n" . "<td align='right' width='50%'>\n" . "</td></tr></table>" . "</div>\n" . "<hr/>\n" . "<div>\n" . "[[_steps]]" . "</div>\n");
     $wizard->_returnModule = RequestContext::value('returnModule');
     $wizard->_returnAction = RequestContext::value('returnAction');
     $cancelButton = $wizard->getChild('_cancel');
     $cancelButton->setLabel(_("Close"));
     $step = $wizard->addStep("agents", new WizardStep());
     ob_start();
     print "\n<h2>" . _("Roles") . "</h2>";
     print "\n<p>";
     print _("Choose a user or group to edit roles for.");
     print "\n</p>\n";
     $agentMgr = Services::getService("Agent");
     $idMgr = Services::getService("Id");
     $harmoni = Harmoni::instance();
     $roleMgr = SegueRoleManager::instance();
     $everyoneId = $idMgr->getId("edu.middlebury.agents.everyone");
     $instituteId = $idMgr->getId("edu.middlebury.institute");
     $membersId = $this->getSite()->getMembersGroup()->getId();
     $agents = array();
     $agents[] = $agentMgr->getGroup($everyoneId);
     $agents[] = $agentMgr->getGroup($instituteId);
     $agents[] = $agentMgr->getGroup($membersId);
     $agentIdsWithRoles = $roleMgr->getAgentsWithRoleAtLeast($roleMgr->getRole('reader'), $this->getSiteId(), true);
     foreach ($agentIdsWithRoles as $id) {
         if (!$id->isEqual($everyoneId) && !$id->isEqual($instituteId) && !$id->isEqual($membersId)) {
             // We ran into a case where roles weren't clearing when an agent
             // was deleted, log this issue and skip rather than crashing the
             // choose agent screen.
             try {
                 $agents[] = $agentMgr->getAgentOrGroup($id);
             } catch (UnknownIdException $e) {
                 HarmoniErrorHandler::logException($e, 'Segue');
             }
         }
     }
     if (count($agents)) {
         print "\n<table width='100%' class='search_results' cellspacing='0'>";
         $i = 0;
         foreach ($agents as $agent) {
             print "\n\t<tr class='search_result_item'>";
             print "\n\t\t<td class='color{$i}'>";
             print "\n\t\t\t<a href='#' onclick=\"AgentInfoPanel.run('" . addslashes($agent->getId()->getIdString()) . "', '" . addslashes($agent->getDisplayName()) . "', this); return false;\">";
             print $agent->getDisplayName();
             print "</a>";
             // print out site members
             if ($agent->getId()->isEqual($membersId)) {
                 $harmoni->request->forget('returnAction');
                 $harmoni->request->forget('returnModule');
                 $harmoni->request->forget('agent');
                 $url = SiteDispatcher::quickURL('agent', 'modify_members');
                 $harmoni->request->passthrough('returnAction');
                 $harmoni->request->passthrough('returnModule');
                 $harmoni->request->passthrough('agent');
                 print "\n\t\t\t <button onclick='window.location = \"{$url}\".urlDecodeAmpersands(); return false;'>" . _("Add/Remove Members") . "</button>";
                 print " (" . Help::link('Site-Members') . ")";
                 print "\n<br/>";
                 print "\n<span style='font-size: smaller'>";
                 print _("This is a custom group of users that are associated with this site. Users and groups can manually be made site-members or users can self-register using the 'Join Site' plugin if it is enabled.");
                 print "</span>";
                 $membersGroup = $this->getSite()->getMembersGroup();
                 $subGroups = $membersGroup->getGroups(true);
                 print "\n<table width='100%' class='search_results' cellspacing='0'>";
                 while ($subGroups->hasNext()) {
                     print "\n\t<tr class='search_result_item'>";
                     print "\n\t\t<td>";
                     print "&nbsp;&nbsp;" . $subGroups->next()->getDisplayName();
                     print "\n\t\t</td></tr>";
                 }
                 $members = $membersGroup->getMembers(false);
                 while ($members->hasNext()) {
                     print "\n\t<tr class='search_result_item'>";
                     print "\n\t\t<td>";
                     print "&nbsp;&nbsp;" . $members->next()->getDisplayName();
                     print "\n\t\t</td></tr>";
                 }
                 print "\n</table><br/>";
             }
             print "\n\t\t</td>";
             print "\n\t\t<td valign='top' class='color{$i}' style='text-align: right; white-space: nowrap;'>";
             $url = SiteDispatcher::quickURL('roles', 'modify', array('node' => SiteDispatcher::getCurrentNodeId(), 'agent' => $agent->getId()->getIdString()));
             print "\n\t\t\t<button onclick='window.location = \"{$url}\".urlDecodeAmpersands(); return false;'>" . _("Modify Roles &raquo;") . "</button>";
             print "\n\t\t</td>";
             print "\n\t</tr>";
             $i = intval(!$i);
         }
         print "\n</table>";
     }
     $property = $step->addComponent("search", new WSearchField());
     $property->setSearchSource(new AgentSearchSource());
     print "\n<div style='margin-top: 20px; border-top: 1px solid; padding: 5px;'>";
     print "\n<h3>" . _("Assign roles to other users/groups") . "</h3>";
     print _("Search for other users/groups.  Once found you will be able to assign roles to these other users/groups.  To assign roles to students in a class, type in the course code (e.g. span0101a-f08)") . "<br/><br/>";
     print _("User/group name: ") . " [[search]]";
     print "</div>";
     $step->setContent(ob_get_clean());
     return $wizard;
 }
 /**
  * Save the permissions
  * 
  * @param array $values
  * @return boolean
  * @access public
  * @since 11/5/07
  */
 public function savePermissionsStep(array $values)
 {
     $roles = $values['perms_table'];
     $roleMgr = SegueRoleManager::instance();
     $idMgr = Services::getService("Id");
     $component = $this->getSiteComponent();
     $componentId = $idMgr->getId($component->getId());
     $everyoneId = $idMgr->getId('edu.middlebury.agents.everyone');
     $instituteId = $idMgr->getId('edu.middlebury.institute');
     $everyoneRole = $roleMgr->getRole($roles['everyone']);
     // Ensure that Everyone is not set to admin
     if ($everyoneRole->getIdString() == 'admin') {
         $everyoneRole = $roleMgr->getRole('editor');
     }
     $instituteRole = $roleMgr->getRole($roles['institute']);
     // Ensure that Institute is not set to admin
     if ($instituteRole->getIdString() == 'admin') {
         $instituteRole = $roleMgr->getRole('editor');
     }
     // Find the parent node.
     $parent = $component->getParentComponent();
     $parentQualifierId = $parent->getQualifierId();
     $parentEveryoneRole = $roleMgr->getAgentsRole($everyoneId, $parentQualifierId);
     $parentInstituteRole = $roleMgr->getAgentsRole($instituteId, $parentQualifierId);
     // Apply the Everyone Role.
     try {
         if ($everyoneRole->isEqualTo($parentEveryoneRole)) {
             $roleMgr->clearRoleAZs($everyoneId, $componentId);
         } else {
             $everyoneRole->apply($everyoneId, $componentId);
         }
         // If the roles are equal, clear out the explicit institute AZs
         // as institute users will get implicit AZs from Everyone
         if ($instituteRole->isEqualTo($everyoneRole) || $instituteRole->isEqualTo($parentInstituteRole)) {
             $roleMgr->clearRoleAZs($instituteId, $componentId);
         } else {
             $instituteRole->apply($instituteId, $componentId);
         }
     } catch (PermissionDeniedException $e) {
     }
     return true;
 }
Esempio n. 11
0
 /**
  * Save our results. Tearing down and unsetting the Wizard is handled by
  * in {@link runWizard()} and does not need to be implemented here.
  * 
  * @param string $cacheName
  * @return boolean TRUE if save was successful and tear-down/cleanup of the
  *		Wizard should ensue.
  * @access public
  * @since 4/28/05
  */
 function saveWizard($cacheName)
 {
     $wizard = $this->getWizard($cacheName);
     if (!$wizard->validate()) {
         return false;
     }
     $idManager = Services::getService("Id");
     $properties = $wizard->getAllValues();
     /*********************************************************
      * Create the site from the template
      *********************************************************/
     $templateMgr = Segue_Templates_TemplateManager::instance();
     $template = $templateMgr->getTemplate($properties['template_step']['template']);
     $site = $template->createSite($this->getSlot(), $properties['namedescstep']['display_name'], $properties['namedescstep']['description']);
     $this->_siteId = $site->getId();
     $siteId = $idManager->getId($site->getId());
     /*********************************************************
      * // Check the Role of the creator and make sure it is 'admin'
      *********************************************************/
     $roleMgr = SegueRoleManager::instance();
     $role = $roleMgr->getUsersRole($site->getQualifierId(), true);
     $admin = $roleMgr->getRole('admin');
     if ($role->isLessThan($admin)) {
         $admin->applyToUser($site->getQualifierId(), true);
     }
     /*********************************************************
      * Set site-wide roles for other users
      *********************************************************/
     foreach ($properties['roles']['roles'] as $agentIdString => $roleId) {
         if ($agentIdString == 'edu.middlebury.site-members.temp') {
             $agentId = $site->getMembersGroup()->getId();
         } else {
             $agentId = $idManager->getId($agentIdString);
         }
         $role = $roleMgr->getRole($roleId);
         $role->apply($agentId, $site->getQualifierId());
     }
     /*********************************************************
      * // Check the Role again of the creator and make sure it is 'admin'
      *********************************************************/
     $roleMgr = SegueRoleManager::instance();
     $role = $roleMgr->getUsersRole($site->getQualifierId(), true);
     $admin = $roleMgr->getRole('admin');
     if ($role->isLessThan($admin)) {
         $admin->applyToUser($site->getQualifierId(), true);
     }
     /*********************************************************
      * Add any specified users to the site-members group.
      *********************************************************/
     $members = $properties['roles']['site_members'];
     $membersGroup = $site->getMembersGroup();
     $agentMgr = Services::getService('Agent');
     foreach ($members as $idString => $name) {
         $membersGroup->add($agentMgr->getAgentOrGroup($idManager->getId($idString)));
     }
     /*********************************************************
      * Theme
      *********************************************************/
     $this->saveThemeStep($properties['theme'], $site);
     /*********************************************************
      * Log the success or failure
      *********************************************************/
     $slot = $this->getSlot();
     if (Services::serviceRunning("Logging")) {
         $loggingManager = Services::getService("Logging");
         $log = $loggingManager->getLogForWriting("Segue");
         $formatType = new Type("logging", "edu.middlebury", "AgentsAndNodes", "A format in which the acting Agent[s] and the target nodes affected are specified.");
         $priorityType = new Type("logging", "edu.middlebury", "Event_Notice", "Normal events.");
         $item = new AgentNodeEntryItem("Create Site", "Site added for placeholder, '" . $slot->getShortname() . "'.");
         $item->addNodeId($siteId);
         $log->appendLogWithTypes($item, $formatType, $priorityType);
     }
     return TRUE;
 }
 /**
  * Answer an array of the administrators of this Site.
  * 
  * @return array of Agent objects
  * @access protected
  * @since 2/19/09
  */
 protected function getAdministrators()
 {
     $admins = array();
     $agentMgr = Services::getService('Agent');
     $roleMgr = SegueRoleManager::instance();
     $agentIdsWithRoles = $roleMgr->getAgentsWithRoleAtLeast($roleMgr->getRole('admin'), $this->getSiteNode()->getQualifierId(), true);
     foreach ($agentIdsWithRoles as $id) {
         // We ran into a case where roles weren't clearing when an agent
         // was deleted, log this issue and skip rather than crashing the
         // choose agent screen.
         try {
             $admins[] = $agentMgr->getAgentOrGroup($id);
         } catch (UnknownIdException $e) {
             HarmoniErrorHandler::logException($e, 'Segue');
         }
     }
     return $admins;
 }
 /**
  * Apply a Role to a site component
  * 
  * @param object BlockSiteComponent $siteComponent
  * @param object DOMElement $element
  * @return void
  * @access protected
  * @since 1/25/08
  */
 protected function applyRole(BlockSiteComponent $siteComponent, DOMElement $element)
 {
     $roleMgr = SegueRoleManager::instance();
     $role = $roleMgr->getRole($element->getAttribute('role'));
     $role->apply($this->getAgentId($element->getAttribute('agent_id')), $siteComponent->getQualifierId(), true);
 }
Esempio n. 14
0
 /**
  * Answer the site-wide header customized for this site.
  * 
  * @return string
  */
 public function getSegueSiteHeader()
 {
     if (!defined('SITE_OWNER_MESSAGE') || !$this->isAuthorizedToExecute()) {
         return str_replace('[[SITE_OWNER_MESSAGE]]', '', SEGUE_SITE_HEADER);
     }
     // Build the owner list.
     $admins = array();
     $roleMgr = SegueRoleManager::instance();
     $adminIds = $roleMgr->getAgentsWithExplicitRoleAtLeast($roleMgr->getRole('editor'), SiteDispatcher::getCurrentRootNode()->getQualifierId(), true);
     $adminstratorsGroupId = new HarmoniId('1');
     $agentMgr = Services::getService('Agent');
     foreach ($adminIds as $adminId) {
         if (!$adminId->isEqual($adminstratorsGroupId)) {
             try {
                 $admins[] = $agentMgr->getAgent($adminId)->getDisplayName();
             } catch (UnknownIdException $e) {
                 // Ignore missing agents.
             }
         }
     }
     if (count($admins) <= 2) {
         $adminString = implode(' and ', $admins);
     } else {
         $admins[count($admins) - 1] = 'and ' . $admins[count($admins) - 1];
         $adminString = implode(', ', $admins);
     }
     return str_replace('[[SITE_OWNER_MESSAGE]]', str_replace('[[SITE_OWNERS]]', $adminString, SITE_OWNER_MESSAGE), SEGUE_SITE_HEADER);
 }
Esempio n. 15
0
 /**
  * Save the type step
  * 
  * @param array $values1
  * @return boolean
  * @access public
  * @since 6/4/07
  */
 function saveContentStep($values)
 {
     $director = $this->getSiteDirector();
     $organizer = $this->getSiteComponentForIdString($values['organizerId']);
     $componentType = HarmoniType::fromString($values['type']);
     $component = $director->createSiteComponent($componentType, $organizer);
     // Check the Role of the user. If it is less than 'Editor', make them an editor
     $roleMgr = SegueRoleManager::instance();
     $role = $roleMgr->getUsersRole($component->getQualifierId(), true);
     $editor = $roleMgr->getRole('editor');
     if ($role->isLessThan($editor)) {
         $editor->applyToUser($component->getQualifierId(), true);
     }
     $this->_newId = $component->getId();
     return true;
 }
Esempio n. 16
0
 /**
  * Answer true if this role is a sub-set of the role passed
  * 
  * @param object SegueRole $role
  * @return boolean
  * @access public
  * @since 11/5/07
  */
 public function isLessThan($role)
 {
     if (!$role instanceof SegueRole) {
         throw new Exception("Parameter must be a role.");
     }
     if ($this->isEqualTo($role)) {
         return false;
     }
     $mgr = SegueRoleManager::instance();
     foreach ($mgr->getRoles() as $currentRole) {
         // If we first hit the us rule, before hitting the other rule, then we are less.
         if ($this->getIdString() == $currentRole->getIdString()) {
             return true;
         } else {
             if ($role->getIdString() == $currentRole->getIdString()) {
                 return false;
             }
         }
     }
     throw new Exception("Unknown Role '" . $role->getIdString() . "'.");
 }