/** * Answer an array of RSS link info. * * @param object SiteComponent $siteComponent * @return array * @access private * @since 3/11/08 * @static */ private static function getLinks(SiteComponent $siteComponent) { $harmoni = Harmoni::instance(); $harmoni->request->startNamespace(null); $links = array(); // Content RSS $links[] = array('url' => SiteDispatcher::quickUrl("rss", "content", array('node' => $siteComponent->getId())), 'label' => _('Content RSS'), 'title' => _("Content RSS for") . " " . htmlentities(strip_tags($siteComponent->getDisplayName()))); // Comments RSS $links[] = array('url' => SiteDispatcher::quickUrl("rss", "comments", array('node' => $siteComponent->getId())), 'label' => _('Discussion RSS'), 'title' => _("Discussion RSS for") . " " . htmlentities(strip_tags($siteComponent->getDisplayName()))); $harmoni->request->endNamespace(); return $links; }
/** * Add a qualifierId * * @param object SiteComponent $siteComponent * @return void * @access private * @since 11/14/07 */ private function addQualifierForSiteComponent(SiteComponent $siteComponent, $isRoot = false) { $qualifierId = $siteComponent->getQualifierId(); $authZ = Services::getService('AuthZ'); $idMgr = Services::getService('Id'); // Skip if we've added it already if (in_array($qualifierId->getIdString(), $this->qualifierIdsAdded)) { return; } $this->qualifierIdsAdded[] = $qualifierId->getIdString(); // Skip any printing of the node if the current user has no authorization // to view the node or any descendents. if (!$authZ->isUserAuthorized($idMgr->getId("edu.middlebury.authorization.view"), $qualifierId) && !$authZ->isUserAuthorizedBelow($idMgr->getId("edu.middlebury.authorization.view_authorizations"), $qualifierId)) { return; } $roleMgr = SegueRoleManager::instance(); $valuesHidden = false; try { $role = $roleMgr->getAgentsRole($this->agentId, $qualifierId); } catch (PermissionDeniedException $e) { $role = $roleMgr->getAgentsRole($this->agentId, $qualifierId, true); $valuesHidden = true; } // Create the property with the current role $title = strip_tags($siteComponent->getDisplayName()); if (!strlen($title)) { $title = _("Untitled"); } if ($isRoot) { $this->property->addField($qualifierId->getIdString(), $title, $role->getIdString(), ">="); } else { $parentQualifierId = $siteComponent->getParentComponent()->getQualifierId(); $this->property->addChildField($parentQualifierId->getIdString(), $qualifierId->getIdString(), $title, $role->getIdString(), ">="); } // Make the values hidden if the current user has no authorization // to view the authorizations of the node. if ($valuesHidden) { $this->property->makeValuesHidden($qualifierId->getIdString()); } // Disable options that are precluded by implicit authorizations // coming from group membership. $groupRole = $roleMgr->getGroupImplictRole($this->agentId, $qualifierId, true); try { $groupIds = $groupRole->getAgentsCausing(); $names = array(); $agentMgr = Services::getService("Agent"); foreach ($groupIds as $id) { $group = $agentMgr->getAgentOrGroup($id); if ($group->getDisplayName()) { $names[] = "'" . $group->getDisplayName() . "'"; } else { $names[] = "'" . $id->getIdString() . "'"; } } $groupNames = ' (' . implode(", ", $names) . ")"; } catch (Exception $e) { $groupNames = ''; } foreach ($roleMgr->getRoles() as $role) { if ($role->isLessThan($groupRole)) { $message = _("You cannot remove the '%1' role because '%2' is a member a group%3 that has been given the '%1' role."); $message = str_replace("%1", $groupRole->getDisplayName(), $message); $message = str_replace("%2", $this->agent->getDisplayName(), $message); $message = str_replace("%3", $groupNames, $message); $this->property->makeDisabled($qualifierId->getIdString(), $role->getIdString(), $message); } } // Disable options that are precluded by implicit authorizations // coming from above the site in the AuthZ hierarchy. foreach ($roleMgr->getRoles() as $role) { if ($role->isLessThan($this->siteImplicitRole)) { $this->property->makeDisabled($qualifierId->getIdString(), $role->getIdString(), $this->siteImplicitRoleMessage); } } // Disable options where modify_authorization is not allowed. $authN = Services::getService('AuthN'); $adminRole = $roleMgr->getRole('admin'); if (!$authZ->isUserAuthorized($idMgr->getId("edu.middlebury.authorization.modify_authorizations"), $qualifierId)) { foreach ($roleMgr->getRoles() as $role) { $this->property->makeDisabled($qualifierId->getIdString(), $role->getIdString(), _("You are not authorized to change authorization here.")); } } else { if ($authN->getFirstUserId()->isEqual($this->agentId)) { foreach ($roleMgr->getRoles() as $role) { if ($role->isLessThan($adminRole)) { $this->property->makeDisabled($qualifierId->getIdString(), $role->getIdString(), _("You cannot remove your own Administrator access.")); } } } } // Disable the Administrator role for everyone and institute. $nonAdminAgents = array(); $nonAdminAgents[] = $idMgr->getId('edu.middlebury.agents.everyone'); $nonAdminAgents[] = $idMgr->getId('edu.middlebury.agents.anonymous'); $nonAdminAgents[] = $idMgr->getId('edu.middlebury.agents.users'); $nonAdminAgents[] = $idMgr->getId('edu.middlebury.institute'); foreach ($nonAdminAgents as $agentId) { if ($agentId->isEqual($this->agentId)) { $message = _("You cannot give the '%1' role to '%2' for security reasons."); $message = str_replace("%1", $adminRole->getDisplayName(), $message); $message = str_replace("%2", $this->agent->getDisplayName(), $message); $this->property->makeDisabled($qualifierId->getIdString(), 'admin', $message); break; } } }
/** * Print Node info html * * @param object SiteComponent $siteComponent * @return void * @access protected * @since 3/17/08 */ protected function printNodeInfo(SiteComponent $siteComponent, $inMenu = false) { $harmoni = Harmoni::instance(); print $this->getTabs() . "\t"; if ($siteComponent->getId() == SiteDispatcher::getCurrentNodeId()) { print "<div class='info current'>"; } else { print "<div class='info'>"; } print $this->getTabs() . "\t\t"; print "<div class='title'>"; $nodeUrl = SiteDispatcher::quickURL('view', 'html', array('node' => $siteComponent->getId())); if (!$inMenu) { print "<a href='" . $nodeUrl . "' "; print ' onclick="'; print "if (window.opener) { "; print "window.opener.location = this.href; "; print "return false; "; print '}" '; print " title='" . _("View this node") . "'>"; } print $siteComponent->getDisplayName(); if (!$inMenu) { print "</a>"; } print "</div>"; $nodeDescription = HtmlString::withValue($siteComponent->getDescription()); $nodeDescription->stripTagsAndTrim(5); print $this->getTabs() . "\t\t"; print "<div class='description'>" . $nodeDescription->stripTagsAndTrim(20) . "</div>"; print $this->getTabs() . "\t"; print "</div>"; }
/** * Print delete controls * * @param SiteComponent $siteComponent * @param string $typeDisplay * @return void * @access public * @since 4/17/06 */ function getDelete($siteComponent, $typeDisplay) { ob_start(); $authZ = Services::getService("AuthZ"); $idManager = Services::getService("Id"); $harmoni = Harmoni::instance(); if ($authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.delete"), $siteComponent->getQualifierId())) { $message = _("Are you sure that you wish to delete this component and all of its children?"); $url = $harmoni->request->quickURL('ui1', 'deleteComponent', array('node' => $siteComponent->getId(), 'returnNode' => SiteDispatcher::getCurrentNodeId(), 'returnAction' => $this->action)); print "\n\t\t\t\t\t<a href='#' onclick=\""; print "DeletePanel.run({"; print "id: '" . $siteComponent->getId() . "', "; print "type: '" . $typeDisplay . "', "; print "displayName: '" . addslashes(str_replace('"', '"', strip_tags($siteComponent->getDisplayName()))) . "'"; print "}, "; print "'" . SiteDispatcher::getCurrentNodeId() . "', "; print "'ui1', '" . $this->action . "', this); "; print "return false; "; print "\">"; print _("delete"); print "</a>"; } return ob_get_clean(); }
/** * Print displayName controls * * @param SiteComponent $siteComponent * @return void * @access public * @since 4/17/06 */ function applyDisplayName($siteComponent) { if (RequestContext::value('displayName') && RequestContext::value('displayName') != $siteComponent->getDisplayName()) { $siteComponent->updateDisplayName(RequestContext::value('displayName')); } }
/** * Print displayName controls * * @param SiteComponent $siteComponent * @return void * @access public * @since 4/17/06 */ function printDisplayName($siteComponent) { print "\n\t\t\t\t<tr><td class='ui2_settingborder'>"; print "\n\t\t\t\t<div class='ui2_settingtitle'>"; print _('Title: ') . "\n\t\t\t\t</div>"; print "\n\t\t\t\t</td><td class='ui2_settingborder'>"; print "<input type='text' size='25' class='ui2_field' "; print " name='" . RequestContext::name('displayName') . "'"; $authZ = Services::getService("AuthZ"); $idManager = Services::getService("Id"); if (!$authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.modify"), $siteComponent->getQualifierId())) { print " readonly='readonly'"; } print " value=\"" . str_replace('"', '"', htmlspecialchars($siteComponent->getDisplayName())) . "\"/>"; // print "</div>"; print "\n\t\t\t\t</td></tr>"; }