/**
  * Build the content for this action
  * 
  * @return void
  * @access public
  * @since 4/26/05
  */
 function buildContent()
 {
     $actionRows = $this->getActionRows();
     $harmoni = Harmoni::instance();
     $idManager = Services::getService("Id");
     $repositoryManager = Services::getService("Repository");
     $repository = $repositoryManager->getRepository($idManager->getId("edu.middlebury.concerto.exhibition_repository"));
     $asset = $repository->getAsset($idManager->getId(RequestContext::value('slideshow_id')));
     // Remove it from its set.
     $exhibitionId = $idManager->getId(RequestContext::value('exhibition_id'));
     $setManager = Services::getService("Sets");
     $exhibitionSet = $setManager->getPersistentSet($exhibitionId);
     $exhibitionSet->removeItem($asset->getId());
     // Log the action
     if (Services::serviceRunning("Logging")) {
         $loggingManager = Services::getService("Logging");
         $log = $loggingManager->getLogForWriting("Concerto");
         $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("Delete Node", "Slideshow deleted:\n<br/>&nbsp; &nbsp; &nbsp;" . $asset->getDisplayName());
         $item->addNodeId($asset->getId());
         $item->addNodeId($idManager->getId(RequestContext::value('exhibition_id')));
         $log->appendLogWithTypes($item, $formatType, $priorityType);
     }
     $repository->deleteAsset($idManager->getId(RequestContext::value('slideshow_id')));
     RequestContext::locationHeader($harmoni->request->quickURL("exhibitions", "browse_exhibition", array("exhibition_id" => RequestContext::value('exhibition_id'))));
 }
Exemple #2
0
 /**
  * Answer all the tags in Segue by everyon 
  * 
  * @return object TagIterator
  * @access public
  * @since 11/8/06
  */
 function getTags()
 {
     $harmoni = Harmoni::instance();
     $tagManager = Services::getService("Tagging");
     $tags = $tagManager->getTags(TAG_SORT_ALFA, $this->getNumTags());
     return $tags;
 }
 /**
  * Visit a Block
  * 
  * @param object BlockSiteComponent $siteComponent
  * @return mixed
  * @access public
  * @since 1/26/09
  */
 public function visitBlock(BlockSiteComponent $siteComponent)
 {
     $view = new Participation_View($siteComponent);
     $idMgr = Services::getService('Id');
     $azMgr = Services::getService('AuthZ');
     // get create actions
     if ($azMgr->isUserAuthorized($idMgr->getId('edu.middlebury.authorization.modify'), $siteComponent->getQualifierId()) == TRUE) {
         $this->_actions[] = new Participation_CreateAction($view, $siteComponent);
     }
     // get comment actions
     $commentsManager = CommentManager::instance();
     $comments = $commentsManager->getAllComments($siteComponent->getAsset(), DESC);
     while ($comments->hasNext()) {
         $comment = $comments->next();
         if ($azMgr->isUserAuthorized($idMgr->getId('edu.middlebury.authorization.comment'), $siteComponent->getQualifierId()) == TRUE) {
             $this->_actions[] = new Participation_CommentAction($view, $comment);
         }
     }
     // get history actions
     $pluginManager = Services::getService('PluginManager');
     $plugin = $pluginManager->getPlugin($siteComponent->getAsset());
     if ($plugin->supportsVersioning()) {
         $versions = $plugin->getVersions();
         $firstVersion = 0;
         foreach ($versions as $version) {
             if ($version->getNumber() != 1) {
                 if ($azMgr->isUserAuthorized($idMgr->getId('edu.middlebury.authorization.modify'), $siteComponent->getQualifierId()) == TRUE) {
                     $this->_actions[] = new Participation_HistoryAction($view, $siteComponent, $version);
                 }
             }
         }
     }
 }
Exemple #4
0
 /**
  * Visit a Block
  * 
  * @param object BlockSiteComponent $siteComponent
  * @return mixed
  * @access public
  * @since 8/31/07
  */
 public function visitBlock(BlockSiteComponent $siteComponent)
 {
     // check to see if user is authorized to view block
     $authZ = Services::getService("AuthZ");
     $idManager = Services::getService("Id");
     if (!$authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.view_comments"), $idManager->getId($siteComponent->getId()))) {
         return;
     }
     $harmoni = Harmoni::instance();
     //get all comments for site component
     $commentsManager = CommentManager::instance();
     $comments = $commentsManager->getAllComments($siteComponent->getAsset());
     while ($comments->hasNext()) {
         $comment = $comments->next();
         $item = $this->addItem(new RSSItem());
         $item->setTitle($comment->getSubject());
         $item->setLink(SiteDispatcher::quickURL("view", "html", array("node" => $siteComponent->getId())) . "#comment_" . $comment->getIdString(), true);
         $item->setPubDate($comment->getModificationDate());
         $agentMgr = Services::getService("Agent");
         $agent = $comment->getAuthor();
         $item->setAuthor($agent->getDisplayName());
         $item->setCommentsLink(SiteDispatcher::quickURL("view", "html", array("node" => $siteComponent->getId())));
         $pluginMgr = Services::getService("PluginManager");
         $plugin = $pluginMgr->getPlugin($comment->getAsset());
         $item->setDescription($plugin->executeAndGetMarkup());
         // MediaFile eclosures.
         try {
             foreach ($plugin->getRelatedMediaFiles() as $file) {
                 $item->addEnclosure($file->getUrl(), $file->getSize()->value(), $file->getMimeType());
             }
         } catch (UnimplementedException $e) {
         }
     }
 }
 /**
  * Returns a block of XHTML-valid code that contains markup for this specific
  * component. 
  * @param string $fieldName The field name to use when outputting form data or
  * similar parameters/information.
  * @access public
  * @return string
  */
 function getMarkup($fieldName)
 {
     ob_start();
     if (is_object($this->_id)) {
         $repositoryManager = Services::getService('Repository');
         try {
             $asset = $repositoryManager->getAsset($this->_id);
             print "\n<table border='0'>";
             print "\n\t<tr>\n\t\t<td>";
             $thumbnailURL = RepositoryInputOutputModuleManager::getThumbnailUrlForAsset($this->_id);
             if ($thumbnailURL !== FALSE) {
                 //				print "\n\t<br /><a href='".$assetViewUrl."'>";
                 print "\n\t\t<img src='{$thumbnailURL}' alt='Thumbnail Image' class='thumbnail_image' />";
                 //				print "\n\t</a>";
             }
             print "\n\t\t</td>\n\t\t</tr>";
             print "\n\t<tr>\n\t\t<td>";
             print _("Id: ") . $this->_id->getIdString();
             print "\n\t\t</td>\n\t\t</tr>";
             print "\n\t<tr>\n\t\t<td>";
             print _("Name: ") . $asset->getDisplayName();
             print "\n\t\t</td>\n\t\t</tr>";
             print "\n</table>";
         } catch (UnknownIdException $e) {
             print "\n<div style='margin: 10px; padding: 10px; border: 1px dotted;'>";
             print _("The target Asset has been deleted or is no longer available.");
             print "</div>";
         }
     }
     $m = ob_get_contents();
     ob_end_clean();
     return $m;
 }
 /**
  * Check Authorizations
  * 
  * @return boolean
  * @access public
  * @since 4/26/05
  */
 function isAuthorizedToExecute()
 {
     // Check that the user can access this collection
     $authZ = Services::getService("AuthZ");
     $idManager = Services::getService("Id");
     return $authZ->isUserAuthorizedBelow($idManager->getId("edu.middlebury.authorization.view"), $this->getRepositoryId());
 }
 /**
  * Build the content for this action
  * 
  * @return boolean
  * @access public
  * @since 4/26/05
  */
 function buildContent()
 {
     $actionRows = $this->getActionRows();
     $harmoni = Harmoni::instance();
     $repository = $this->getRepository();
     // get the search type.
     $searchType = HarmoniType::fromString(urldecode(RequestContext::value('search_type')));
     // Get the Search criteria
     $searchModules = Services::getService("RepositorySearchModules");
     $searchCriteria = $searchModules->getSearchCriteria($repository, $searchType);
     // function links
     ob_start();
     print _("Collection") . ": ";
     RepositoryPrinter::printRepositoryFunctionLinks($harmoni, $repository);
     $layout = new Block(ob_get_contents(), 2);
     ob_end_clean();
     $actionRows->add($layout, null, null, CENTER, CENTER);
     ob_start();
     print "<p>";
     print _("Some <em>Collections</em>, <em>Exhibitions</em>, <em>Assets</em>, and <em>Slide-Shows</em> may be restricted to certain users or groups of users. Log in above to ensure your greatest access to all parts of the system.");
     print "</p>";
     $introText = new Block(ob_get_contents(), 2);
     ob_end_clean();
     $actionRows->add($introText, null, null, CENTER, CENTER);
     //***********************************
     // Get the assets to display
     //***********************************
     $assets = $repository->getAssetsBySearch($searchCriteria, $searchType, new HarmoniProperties(new Type('Repository', 'edu.middlebury', 'null')));
     //***********************************
     // print the results
     //***********************************
     $resultPrinter = new IteratorResultPrinter($assets, 2, 6, "printAssetShort", $harmoni);
     $resultLayout = $resultPrinter->getLayout();
     $actionRows->add($resultLayout, "100%", null, LEFT, CENTER);
 }
 /**
  * Constructor
  * 
  * @param object BlockSiteComponent $block
  * @return null
  * @access public
  * @since 4/3/06
  */
 function __construct(BlockSiteComponent $block)
 {
     $pluginManager = Services::getService('PluginManager');
     $this->plugin = $pluginManager->getPlugin($block->getAsset());
     $this->agentManager = Services::getService("Agent");
     $this->block = $block;
 }
 /**
  * Execute this action.
  * 
  * @param object Harmoni $harmoni
  * @return mixed
  * @access public
  * @since 4/25/05
  */
 function execute()
 {
     if (!$this->isAuthorizedToExecute()) {
         throw new PermissionDeniedException();
     }
     $harmoni = Harmoni::instance();
     $harmoni->request->startNamespace("harmoni-authentication");
     $query = RequestContext::value("user");
     $harmoni->request->endNamespace();
     header('Content-type: text/plain');
     if (!strlen($query)) {
         exit;
     }
     $authNMethodManager = Services::getService("AuthNMethods");
     $types = $authNMethodManager->getAuthNTypes();
     while ($types->hasNext()) {
         $type = $types->next();
         $method = $authNMethodManager->getAuthNMethodForType($type);
         $foundTokens = $method->getTokensBySearch($query);
         while ($foundTokens->hasNext()) {
             $tokens = $foundTokens->next();
             print $method->getDisplayNameForTokens($tokens) . " (" . $type->getKeyword() . ")|type=\"" . $type->asString() . "\" id=\"" . $tokens->getIdentifier() . "\"\n";
         }
     }
     exit;
 }
 /**
  * Get all the Groups with the specified search criteria and search Type.
  *
  * This method is defined in v.2 of the OSIDs.
  * 
  * @param mixed $searchCriteria
  * @param object Type $groupSearchType
  * @return object AgentIterator
  * @access public
  * @since 11/10/04
  */
 function getGroupsBySearch($searchCriteria)
 {
     $allGroups = array();
     // See if the agent exists as known by harmoni
     $authNMethodManager = Services::getService("AuthNMethodManager");
     $authenticationManager = Services::getService("AuthenticationManager");
     $agentManager = Services::getService("AgentManager");
     $idManager = Services::getService("IdManager");
     $types = $authNMethodManager->getAuthNTypes();
     $idsFound = array();
     while ($types->hasNext()) {
         $type = $types->next();
         $authNMethod = $authNMethodManager->getAuthNMethodForType($type);
         if (!method_exists($authNMethod, "getGroupTokensBySearch")) {
             continue;
         }
         $tokensIterator = $authNMethod->getGroupTokensBySearch($searchCriteria);
         while ($tokensIterator->hasNextObject()) {
             $token = $tokensIterator->nextObject();
             if (!in_array($token->getIdentifier(), $idsFound)) {
                 $allGroups[] = $agentManager->getGroup($idManager->getId($token->getIdentifier()));
                 $idsFound[] = $token->getIdentifier();
             }
         }
     }
     $obj = new HarmoniIterator($allGroups);
     return $obj;
 }
 /**
  * Loop through the authentication types and try to authenticate the user.
  * 
  * @return void
  * @access public
  * @since 8/4/06
  */
 function authenticate()
 {
     $authN = Services::getService("AuthN");
     // Reconfigure the AuthNManager to use HTTP Auth rather than forms
     // :: Start the AuthenticationManager OSID Impl.
     $configuration = $authN->getConfiguration();
     $tokenCollectors = array();
     $authNTypes = $authN->getAuthenticationTypes();
     while ($authNTypes->hasNext()) {
         $tokenCollectors[serialize($authNTypes->next())] = new HTTPAuthNamePassTokenCollector($this->getRelm(), $this->getCancelFunction());
     }
     $configuration->deleteProperty('token_collectors');
     $configuration->addProperty('token_collectors', $tokenCollectors);
     $authN->assignConfiguration($configuration);
     // Authenticate with HTTP Authentication.
     $harmoni = Harmoni::instance();
     $isAuthenticated = FALSE;
     $authTypes = $authN->getAuthenticationTypes();
     while ($authTypes->hasNext() && !$isAuthenticated) {
         $authType = $authTypes->next();
         // Try authenticating with this type
         $authN->authenticateUser($authType);
         // If they are authenticated, quit
         if ($authN->isUserAuthenticated($authType)) {
             $isAuthenticated = TRUE;
         }
     }
 }
Exemple #12
0
 /**
  * Answer a links back to the main Segue pages
  * 
  * @return object GUIComponent
  * @access public
  * @since 1/12/07
  */
 function getCommandsComponent()
 {
     $harmoni = Harmoni::instance();
     ob_start();
     print "<div class='commands'>";
     print "<a href='";
     print SiteDispatcher::quickURL('view', 'html');
     print "' title='" . _("Go to View-Mode") . "'>";
     print _("view") . "</a>";
     print " | <a href='";
     print SiteDispatcher::quickURL('ui2', 'editview');
     print "' title='" . _("Go to Edit-Mode") . "'>";
     print _("edit") . "</a>";
     print " | " . _("header/footer");
     print " | <a href='";
     print SiteDispatcher::quickURL('ui2', 'arrangeview');
     print "' title='" . _("Go to Arrange-Mode") . "'>";
     print _("arrange") . "</a>";
     // Add permissions button
     $authZ = Services::getService("AuthZ");
     $idManager = Services::getService("Id");
     // Rather than checking the entire site, we will just check the current node.
     // This forces users who are not site-wide admins to browse to the place where
     // they are administrators in order to see the permissions button, but
     // cuts load-times for non-admins on a given large site from 35s to 1.4s.
     if ($authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.view_authorizations"), SiteDispatcher::getCurrentNode()->getQualifierId())) {
         $url = SiteDispatcher::quickURL("roles", "choose_agent", array("node" => SiteDispatcher::getCurrentNodeId(), "returnModule" => $harmoni->request->getRequestedModule(), "returnAction" => $harmoni->request->getRequestedAction()));
         print " | \n\t<a href='#' onclick='window.location = \"{$url}\".urlDecodeAmpersands(); return false;'>";
         print _("roles") . "</a>";
     }
     print " | " . self::getUiSwitchForm();
     print "</div>";
     $ret = new Component(ob_get_clean(), BLANK, 2);
     return $ret;
 }
function getVisitorLoginLink()
{
    $harmoni = Harmoni::instance();
    $authN = Services::getService("AuthN");
    // Visitor Registration Link
    $authTypes = $authN->getAuthenticationTypes();
    $hasVisitorType = false;
    $visitorType = new Type("Authentication", "edu.middlebury.harmoni", "Visitors");
    while ($authTypes->hasNext()) {
        $authType = $authTypes->next();
        if ($visitorType->isEqual($authType)) {
            $hasVisitorType = true;
            break;
        }
    }
    if ($hasVisitorType && !$authN->isUserAuthenticatedWithAnyType()) {
        $harmoni->request->startNamespace('polyphony');
        $url = $harmoni->request->mkURL("auth", "login_type");
        $url->setValue("type", urlencode($visitorType->asString()));
        // Add return info to the visitor registration url
        $visitorReturnModules = array('view', 'ui1', 'ui2', 'versioning');
        if (in_array($harmoni->request->getRequestedModule(), $visitorReturnModules)) {
            $url->setValue('returnModule', $harmoni->request->getRequestedModule());
            $url->setValue('returnAction', $harmoni->request->getRequestedAction());
            $url->setValue('returnKey', 'node');
            $url->setValue('returnValue', SiteDispatcher::getCurrentNodeId());
        }
        $harmoni->request->endNamespace();
        return "\n\t<a href='" . $url->write() . "'>" . _("Visitor Login") . "</a>";
    }
    return null;
}
 /**
  * Constructor
  * 
  * @return object
  * @access public
  * @since 7/20/05
  */
 function TabAssetIterator($srcDir, $parentRepositoryImporter)
 {
     if (Services::serviceRunning("Logging")) {
         $loggingManager = Services::getService("Logging");
         $log = $loggingManager->getLogForWriting("Harmoni");
         $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", "Error", "Events involving critical system errors.");
     }
     if (file_exists($srcDir . "metadata.txt") && ($meta = fopen($srcDir . "metadata.txt", "r"))) {
         fgets($meta);
         fgets($meta);
         while ($line = preg_replace("/[\n\r]*\$/", "", fgets($meta))) {
             $metadata = explode("\t", $line);
             $this->_assetList[] = $metadata;
         }
         if (count($this->_assetList) == 0) {
             $parentRepositoryImporter->addError("There are no assets to import in: " . $srcDir . "metadata.txt.");
             if (isset($log)) {
                 $item = new AgentNodeEntryItem("TabImporter Error", "There are no assets to import in: {$srcDir}/metadata.txt.");
                 $log->appendLogWithTypes($item, $formatType, $priorityType);
             }
         }
         fclose($meta);
         $this->_current = 0;
     } else {
         $parentRepositoryImporter->addError("Tab-Delimited parse failed: " . $srcDir . "metadata.txt does not exist or is unreadable.");
         if (isset($log)) {
             $item = new AgentNodeEntryItem("TabImporter Error", "Tab-Delimited parse failed: {$srcDir}/metadata.txt does not exist or is unreadable.");
             $log->appendLogWithTypes($item, $formatType, $priorityType);
         }
     }
 }
 /**
  * Answer the plugin content for a block
  * 
  * @param object BlockSiteComponent $block
  * @return string
  * @access public
  * @since 1/7/08
  */
 function getPluginContent($block)
 {
     if ($block->getId() != $this->_node->getId()) {
         return parent::getPluginContent($block);
     }
     $harmoni = Harmoni::instance();
     $pluginManager = Services::getService('PluginManager');
     $plugin = $pluginManager->getPlugin($block->getAsset());
     ob_start();
     print "\n<form action='" . SiteDispatcher::quickURL('versioning', 'compare_versions', array('node' => SiteDispatcher::getCurrentNodeId())) . "' method='post'>";
     print "\n\t<div style='float: right;'>";
     print "\n\t<input type='submit' value='" . _("Compare Selected Revisions &raquo;") . "'";
     if (count($plugin->getVersions()) <= 1) {
         print " disabled='disabled'";
     }
     print "/>";
     print "\n\t</div>";
     print "\n\t<div style='float: left;'>\n\t\t<a href='" . $harmoni->history->getReturnURL('view_history_' . $block->getId()) . "'>";
     print "\n\t\t\t<input type='button' value='" . _("&laquo; Go Back") . "'/>\n\t\t</a>\n\t</div>";
     print "\n\t\t<input type='hidden' name='module' value='versioning'/>";
     print "\n\t<input type='hidden' name='action' value='compare_versions'/>";
     print "\n\t<input type='hidden' name='node' value='" . SiteDispatcher::getCurrentNodeId() . "'/>";
     print $this->getVersionTable($plugin);
     print "\n</form>";
     print $this->getVersionChoiceJS();
     return ob_get_clean();
 }
 /**
  * Build the content for this action
  * 
  * @return boolean
  * @access public
  * @since 4/26/05
  */
 function buildContent()
 {
     $actionRows = $this->getActionRows();
     $harmoni = Harmoni::instance();
     ob_start();
     CollectionsPrinter::printFunctionLinks();
     print "<p>";
     print _("Below are listed the available <em>Collections</em>, organized by type, then name.");
     print "</p>\n<p>";
     print _("Some <em>Collections</em>, <em>Exhibitions</em>, <em>Assets</em>, and <em>Slide-Shows</em> may be restricted to certain users or groups of users. Log in above to ensure your greatest access to all parts of the system.");
     print "</p>";
     $actionRows->add(new Block(ob_get_contents(), STANDARD_BLOCK), "100%", null, CENTER, CENTER);
     ob_end_clean();
     $exhibitionRepositoryType = new Type('System Repositories', 'edu.middlebury.concerto', 'Exhibitions');
     $repositoryManager = Services::getService("Repository");
     // Get all the types
     $types = $repositoryManager->getRepositoryTypes();
     // put the drs into an array and order them.
     $typeArray = array();
     while ($types->hasNext()) {
         $type = $types->next();
         // include all but Exhibitions repository.
         if (!$exhibitionRepositoryType->isEqual($type)) {
             $typeArray[HarmoniType::typeToString($type)] = $type;
         }
     }
     ksort($typeArray);
     // print the Results
     $resultPrinter = new ArrayResultPrinter($typeArray, 2, 20, "printTypeShort");
     $resultPrinter->addLinksStyleProperty(new MarginTopSP("10px"));
     $resultLayout = $resultPrinter->getLayout();
     $actionRows->add($resultLayout, null, null, CENTER, CENTER);
 }
 /**
  * Constructor
  * 
  * @param mixed $entryItem
  * @param object Type $formatType
  * @param object Type $priorityType
  * @return object
  * @access public
  * @since 3/1/06
  */
 function HarmoniEntry($timestamp, $category, $description, $backtrace, $agents, $nodes, $formatType, $priorityType)
 {
     ArgumentValidator::validate($timestamp, ExtendsValidatorRule::getRule("DateAndTime"));
     ArgumentValidator::validate($category, StringValidatorRule::getRule());
     ArgumentValidator::validate($description, StringValidatorRule::getRule());
     ArgumentValidator::validate($backtrace, StringValidatorRule::getRule());
     ArgumentValidator::validate($agents, ArrayValidatorRule::getRule());
     ArgumentValidator::validate($nodes, ArrayValidatorRule::getRule());
     ArgumentValidator::validate($formatType, ExtendsValidatorRule::getRule("Type"));
     ArgumentValidator::validate($priorityType, ExtendsValidatorRule::getRule("type"));
     $this->_timestamp = $timestamp;
     $this->_formatType = $formatType;
     $this->_priorityType = $priorityType;
     $this->_entryItem = new AgentNodeEntryItem($category, $description);
     $this->_entryItem->setBacktrace($backtrace);
     $idManager = Services::getService("Id");
     foreach ($agents as $idString) {
         if ($idString) {
             $this->_entryItem->addAgentId($idManager->getId($idString));
         }
     }
     foreach ($nodes as $idString) {
         if ($idString) {
             $this->_entryItem->addNodeId($idManager->getId($idString));
         }
     }
 }
 /**
  * Constructor
  * 
  * @param integer dbIndex The database connection as returned by the DBHandler.
  * @return object
  * @access public
  * @since 2/8/05
  */
 function __construct()
 {
     $idManager = Services::getService("Id");
     $this->id = $idManager->getId("edu.middlebury.agents.anonymous");
     $this->type = new Type("Agents", "edu.middlebury.harmoni", "Any/Anonymous", _("Special users that can represent anyone or unknown users."));
     $this->propertiesArray = array();
 }
 /**
  * Answer the html string for an icon that displays authorization state
  * 
  * @param object Id $qualifierId
  * @return string
  * @access public
  * @static
  * @since 11/29/06
  */
 static function getAZIcon($qualifierId)
 {
     ob_start();
     $authZ = Services::getService("AuthZ");
     $idManager = Services::getService("Id");
     try {
         $isAuthorized = $authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.view_authorizations"), $qualifierId);
     } catch (UnknownIdException $e) {
         $isAuthorized = $authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.view_authorizations"), $idManager->getId("edu.middlebury.authorization.root"));
     }
     if ($isAuthorized) {
         $onclick = "onclick=\"AuthZViewer.run('" . addslashes($qualifierId->getIdString()) . "', this);\" style='cursor: pointer;' ";
     } else {
         $onclick = '';
     }
     try {
         $isPublicAuthorized = $authZ->isAuthorized($idManager->getId("edu.middlebury.agents.everyone"), $idManager->getId("edu.middlebury.authorization.view"), $qualifierId);
     } catch (UnknownIdException $e) {
         $isPublicAuthorized = true;
     }
     if ($isPublicAuthorized) {
         print "\n<img class='az_icon' src='" . POLYPHONY_PATH . "/icons/view_public.gif' alt='" . "Public-Viewable" . "' title='" . "Public-Viewable" . "' " . $onclick . "/> ";
     } else {
         if ($authZ->isAuthorized($idManager->getId("edu.middlebury.agents.users"), $idManager->getId("edu.middlebury.authorization.view"), $qualifierId) || $authZ->isAuthorized($idManager->getId("edu.middlebury.institute"), $idManager->getId("edu.middlebury.authorization.view"), $qualifierId)) {
             print "\n<img class='az_icon' src='" . POLYPHONY_PATH . "/icons/view_institute.gif' alt='" . "Institution-Viewable" . "' title='" . "Institution-Viewable" . "' " . $onclick . "/> ";
         } else {
             print "\n<img class='az_icon' src='" . POLYPHONY_PATH . "/icons/view_limited.gif' alt='" . "Viewable by some people" . "' title='" . "Viewable by some people" . "' " . $onclick . "/> ";
         }
     }
     return ob_get_clean();
 }
 /**
  * Create a new PrimitiveIO object that allows for selection from an authority
  * list
  * 
  * @param <##>
  * @return <##>
  * @access public
  * @since 5/1/06
  */
 static function createComponentForPartStructure($partStruct)
 {
     ArgumentValidator::validate($partStruct, ExtendsValidatorRule::getRule("PartStructure"));
     $partStructType = $partStruct->getType();
     // get the datamanager data type
     $dataType = $partStructType->getKeyword();
     // 		printpre($dataType);
     $authoritativeValues = $partStruct->getAuthoritativeValues();
     if ($authoritativeValues->hasNext()) {
         $authZManager = Services::getService("AuthZ");
         $idManager = Services::getService("Id");
         if ($authZManager->isUserAuthorized($idManager->getId("edu.middlebury.authorization.modify_authority_list"), $partStruct->getRepositoryId())) {
             $component = new PrimitiveIO_AuthoritativeContainer();
             $component->setSelectComponent(PrimitiveIOManager::createAuthoritativeComponent($dataType));
             $component->setNewComponent(PrimitiveIOManager::createComponent($dataType));
         } else {
             $component = PrimitiveIOManager::createAuthoritativeComponent($dataType);
         }
         while ($authoritativeValues->hasNext()) {
             $component->addOptionFromSObject($authoritativeValues->next());
         }
     } else {
         // get the simple component for this data type
         $component = PrimitiveIOManager::createComponent($dataType);
     }
     return $component;
 }
Exemple #21
0
 /**
  * Execute the action
  * 
  * @return void
  * @access public
  * @since 10/9/08
  */
 public function execute()
 {
     header('Content-Type: text/plain;');
     try {
         if (!$this->isAuthorizedToExecute()) {
             throw new PermissionDeniedException("You must be logged in.");
         }
         $mgr = SlotManager::instance();
         $slot = $mgr->getSlotByShortname(RequestContext::value('slot'));
         $slot->makeAlias($mgr->getSlotByShortname(RequestContext::value('target_slot')));
         print _("Success");
         /*********************************************************
          * Log the success
          *********************************************************/
         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("Alias Made", "'" . $slot->getShortname() . "' has been made an alias of '" . RequestContext::value('target_slot') . "'.");
             $item->addNodeId($slot->getSiteId());
             $log->appendLogWithTypes($item, $formatType, $priorityType);
         }
     } catch (OperationFailedException $e) {
         print $e->getMessage();
     } catch (UnknownIdException $e) {
         print $e->getMessage();
     }
     exit;
 }
 /**
  * Build the content for this action
  * 
  * @return boolean
  * @access public
  * @since 4/26/05
  */
 function buildContent()
 {
     $actionRows = $this->getActionRows();
     $harmoni = Harmoni::instance();
     $repository = $this->getRepository();
     // function links
     ob_start();
     print _("Collection") . ": ";
     RepositoryPrinter::printRepositoryFunctionLinks($harmoni, $repository);
     $layout = new Block(ob_get_contents(), 3);
     ob_end_clean();
     $actionRows->add($layout, "100%", null, LEFT, CENTER);
     $repositoryManager = Services::getService("Repository");
     // Get all the types
     $types = $repository->getAssetTypes();
     // put the drs into an array and order them.
     $typeArray = array();
     while ($types->hasNext()) {
         $type = $types->next();
         $typeArray[$type->getDomain() . " " . $type->getAuthority() . " " . $type->getKeyword()] = $type;
     }
     ksort($typeArray);
     // print the Results
     $resultPrinter = new ArrayResultPrinter($typeArray, 2, 20, "printTypeShort", $repository->getId());
     $resultPrinter->addLinksStyleProperty(new MarginTopSP("10px"));
     $resultLayout = $resultPrinter->getLayout();
     $actionRows->add($resultLayout, "100%", null, LEFT, CENTER);
 }
 /**
  * Exporter of partstructures
  * 
  * Adds partstructure elements to the xml, which contain the necessary
  * information to create the same partstructure.
  * 
  * @access public
  * @since 12/6/06
  */
 function getFileParts()
 {
     $idManager = Services::getService("Id");
     $this->_info = array();
     $FILE_URL_ID = $idManager->getId("FILE_URL");
     $FILE_NAME_ID = $idManager->getId("FILE_NAME");
     $FILE_SIZE_ID = $idManager->getId("FILE_SIZE");
     $FILE_DIME_ID = $idManager->getId("DIMENSIONS");
     $MIME_TYPE_ID = $idManager->getId("MIME_TYPE");
     $THUMB_DATA_ID = $idManager->getId("THUMBNAIL_DATA");
     $THUMB_MIME_ID = $idManager->getId("THUMBNAIL_MIME_TYPE");
     $THUMB_DIME_ID = $idManager->getId("THUMBNAIL_DIMENSIONS");
     $parts = $this->_object->getPartsByPartStructure($FILE_URL_ID);
     if ($parts->count() == 1) {
         $part = $parts->next();
         $this->_info['f_url'] = $part->getValue();
     }
     $parts = $this->_object->getPartsByPartStructure($FILE_NAME_ID);
     if ($parts->count() == 1) {
         $part = $parts->next();
         $path = $this->_fileDir . "/" . $part->getValue();
         // CHECK FOR FILE NAME UNIQUENESS HERE
         // 			$this->_dataFile = fopen($path, "wb");
         $this->_info['f_name'] = basename($path);
     }
     $parts = $this->_object->getPartsByPartStructure($FILE_SIZE_ID);
     if ($parts->count() == 1) {
         $part = $parts->next();
         $this->_info['f_size'] = $part->getValue();
     }
     $parts = $this->_object->getPartsByPartStructure($FILE_DIME_ID);
     if ($parts->count() == 1) {
         $part = $parts->next();
         $this->_info['f_dime'] = $part->getValue();
     }
     $parts = $this->_object->getPartsByPartStructure($MIME_TYPE_ID);
     if ($parts->count() == 1) {
         $part = $parts->next();
         $this->_info['f_mime'] = $part->getValue();
     }
     $path = $this->_fileDir . "/THUMB_" . $this->_info['f_name'];
     $this->_info['t_name'] = basename($path);
     $this->_thumbFile = fopen($path, "wb");
     $parts = $this->_object->getPartsByPartStructure($THUMB_DATA_ID);
     if ($parts->count() == 1) {
         $part = $parts->next();
         fwrite($this->_thumbFile, $part->getValue());
         fclose($this->_thumbFile);
     }
     $parts = $this->_object->getPartsByPartStructure($THUMB_MIME_ID);
     if ($parts->count() == 1) {
         $part = $parts->next();
         $this->_info['t_mime'] = $part->getValue();
     }
     $parts = $this->_object->getPartsByPartStructure($THUMB_DIME_ID);
     if ($parts->count() == 1) {
         $part = $parts->next();
         $this->_info['t_dime'] = $part->getValue();
     }
 }
Exemple #24
0
 /**
  * Build the content for this action
  * 
  * @return void
  * @access public
  * @since 4/26/05
  */
 function buildContent()
 {
     $actionRows = $this->getActionRows();
     $harmoni = Harmoni::instance();
     $idManager = Services::getService("Id");
     $repositoryManager = Services::getService("Repository");
     $repository = $repositoryManager->getRepository($idManager->getId(RequestContext::value('collection_id')));
     $asset = $repository->getAsset($idManager->getId(RequestContext::value('asset_id')));
     // Remove this asset from the tagging manager
     $tagManager = Services::getService('Tagging');
     $tagManager->deleteItems(TaggedItem::forId($asset->getId(), 'concerto'));
     // Log the action
     if (Services::serviceRunning("Logging")) {
         $loggingManager = Services::getService("Logging");
         $log = $loggingManager->getLogForWriting("Concerto");
         $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("Delete Node", "Asset deleted:\n<br/>&nbsp; &nbsp; &nbsp;" . $asset->getDisplayName());
         $item->addNodeId($asset->getId());
         $item->addNodeId($repository->getId());
         $log->appendLogWithTypes($item, $formatType, $priorityType);
     }
     $repository->deleteAsset($idManager->getId(RequestContext::value('asset_id')));
     $harmoni->history->goBack("concerto/asset/delete-return");
 }
 /**
  * Answer an iterator of the latest assets.
  * 
  * @return object Iterator
  * @access public
  * @since 8/8/06
  */
 function getAssets()
 {
     $authZManager = Services::getService("AuthZ");
     $idManager = Services::getService("IdManager");
     $assetsByDate = array();
     $repositoryManager = Services::getService('Repository');
     $repositories = $repositoryManager->getRepositories();
     $exhibitionRepositoryType = new Type('System Repositories', 'edu.middlebury.concerto', 'Exhibitions');
     while ($repositories->hasNext()) {
         $repository = $repositories->next();
         if (!$exhibitionRepositoryType->isEqual($repository->getType()) && $authZManager->isUserAuthorized($idManager->getId("edu.middlebury.authorization.view"), $repository->getId())) {
             $assets = parent::getAssets($repository);
             $i = 0;
             while ($assets->hasNext() && $i < $this->_numInFeed) {
                 $asset = $assets->next();
                 $assetId = $asset->getId();
                 if (RequestContext::value('order') == 'modification') {
                     $date = $asset->getModificationDate();
                 } else {
                     $date = $asset->getCreationDate();
                 }
                 $j = 0;
                 while (isset($assetsByDate[$date->asString() . " " . $j])) {
                     $j++;
                 }
                 $assetsByDate[$date->asString() . " " . $j] = $asset;
                 $i++;
             }
         }
     }
     krsort($assetsByDate);
     $iterator = new HarmoniIterator($assetsByDate);
     return $iterator;
 }
 /**
  * Get the ids of the assets that match the search criteria
  * 
  * @param mixed $searchCriteria
  * @return array
  * @access public
  * @since 11/2/04
  */
 function searchAssets($searchCriteria)
 {
     $matchingIds = array();
     $recordMgr = Services::getService("RecordManager");
     $schemaMgr = Services::getService("SchemaManager");
     $repositoryMgr = Services::getService("Repository");
     $schema = $schemaMgr->getSchemaByID($searchCriteria['RecordStructureId']->getIdString());
     if ($searchCriteria['AuthoritativeValue']->asString() == '__NonMatching__') {
         $authoritativeValueArray = array();
         $recordStructure = $this->_repository->getRecordStructure($searchCriteria['RecordStructureId']);
         $partStructure = $recordStructure->getPartStructure($searchCriteria['PartStructureId']);
         $criteria = new FieldValueSearch($searchCriteria['RecordStructureId']->getIdString(), $schema->getFieldLabelFromID($searchCriteria['PartStructureId']->getIdString()), $partStructure->getAuthoritativeValues(), SEARCH_TYPE_NOT_IN_LIST);
     } else {
         $criteria = new FieldValueSearch($searchCriteria['RecordStructureId']->getIdString(), $schema->getFieldLabelFromID($searchCriteria['PartStructureId']->getIdString()), $searchCriteria['AuthoritativeValue'], SEARCH_TYPE_EQUALS);
     }
     // Get the asset Ids to limit to.
     $allAssets = $this->_repository->getAssets();
     $idStrings = array();
     while ($allAssets->hasNext()) {
         $asset = $allAssets->next();
         $id = $asset->getId();
         $idStrings[] = $id->getIdString();
     }
     // Run the search
     $matchingIds = array_unique($recordMgr->getRecordSetIDsBySearch($criteria, $idStrings));
     // Ensure uniqueness and convert the ids to id objects.
     $matchingIds = array_unique($matchingIds);
     sort($matchingIds);
     $idManager = Services::getService("Id");
     for ($i = 0; $i < count($matchingIds); $i++) {
         $matchingIds[$i] = $idManager->getId($matchingIds[$i]);
     }
     // Return the array
     return $matchingIds;
 }
 /**
  * Add the creator column to the dr_asset_info table.
  * 
  * @param int $dbIndex
  * @return void
  * @access public
  * @since 10/8/07
  */
 public static function harmoni_0_12_4_update($dbIndex)
 {
     $dbc = Services::getService("DBHandler");
     try {
         $dbc->query(new GenericSQLQuery("DROP INDEX log_entry_timestamp_index"), $dbIndex);
         printpre("Dropping index 'log_entry_timestamp_index'.");
     } catch (DatabaseException $e) {
         // 			printpre("NOT dropping index 'log_entry_timestamp_index'.");
         // 			printpre($e->getMessage());
     }
     try {
         $dbc->query(new GenericSQLQuery('CREATE INDEX log_entry_format_index ON log_entry (log_name, fk_format_type, fk_priority_type, "timestamp");'), $dbIndex);
         printpre("Creating index 'log_entry_format_index'.");
     } catch (DatabaseException $e) {
         // 			printpre("NOT creating index 'log_entry_format_index'.");
         // 			printpre($e->getMessage());
     }
     try {
         $dbc->query(new GenericSQLQuery('CREATE INDEX log_agent_fk_entry_index ON log_agent (fk_entry);'), $dbIndex);
         printpre("Creating index 'log_agent_fk_entry_index'.");
     } catch (DatabaseException $e) {
         // 			printpre("NOT creating index 'log_agent_fk_entry_index'.");
         // 			printpre($e->getMessage());
     }
     try {
         $dbc->query(new GenericSQLQuery('CREATE INDEX log_node_fk_entry_index ON log_node (fk_entry);'), $dbIndex);
         printpre("Creating index 'log_node_fk_entry_index'.");
     } catch (DatabaseException $e) {
         // 			printpre("NOT creating index 'log_node_fk_entry_index'.");
         // 			printpre($e->getMessage());
     }
 }
Exemple #28
0
 /**
  * Answer the tags
  * 
  * @return object TagIterator
  * @access public
  * @since 11/8/06
  */
 function getTags()
 {
     $tagManager = Services::getService("Tagging");
     $tags = $tagManager->getTags(TAG_SORT_ALFA, $this->getNumTags());
     // 		printpre($tags);
     return $tags;
 }
 /**
  * Build the content for this action
  * 
  * @return boolean
  * @access public
  * @since 4/26/05
  */
 function buildContent()
 {
     $actionRows = $this->getActionRows();
     $harmoni = Harmoni::instance();
     ob_start();
     CollectionsPrinter::printFunctionLinks();
     $layout = new Block(ob_get_contents(), STANDARD_BLOCK);
     ob_end_clean();
     $actionRows->add($layout, null, null, CENTER, CENTER);
     $type = HarmoniType::fromString(urldecode(RequestContext::value('type')));
     $repositoryManager = Services::getService("Repository");
     // Get the Repositories
     $allRepositories = $repositoryManager->getRepositoriesByType($type);
     // put the repositories into an array and order them.
     // @todo, do authorization checking
     $repositoryArray = array();
     while ($allRepositories->hasNext()) {
         $repository = $allRepositories->next();
         $repositoryArray[$repository->getDisplayName()] = $repository;
     }
     ksort($repositoryArray);
     // print the Results
     $resultPrinter = new ArrayResultPrinter($repositoryArray, 2, 20, "printrepositoryShort", $harmoni);
     $resultPrinter->addLinksStyleProperty(new MarginTopSP("10px"));
     $resultLayout = $resultPrinter->getLayout();
     $actionRows->add($resultLayout, null, null, CENTER, CENTER);
 }
 /**
  * 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)
 {
     $component = $director->getSiteComponentById(SiteDispatcher::getCurrentNodeId());
     // Do not allow delete of the root menu.
     if (method_exists($component, 'isRootMenu')) {
         if ($component->isRootMenu()) {
             $this->returnToCallerPage();
             exit;
         }
     }
     $this->findSafeReturnNode($director, $component);
     $organizer = $component->getParentComponent();
     if ($organizer) {
         $organizer->detatchSubcomponent($component);
     }
     $rootSiteComponent = $director->getRootSiteComponent(SiteDispatcher::getCurrentNodeId());
     // If we are deleting the site unhitch it from the slot
     if ($rootSiteComponent->getId() == SiteDispatcher::getCurrentNodeId()) {
         $slotMgr = SlotManager::instance();
         $idMgr = Services::getService("Id");
         try {
             $slot = $slotMgr->getSlotBySiteId($idMgr->getId(SiteDispatcher::getCurrentNodeId()));
             $slot->deleteSiteId();
         } catch (Exception $e) {
         }
     }
     $director->deleteSiteComponent($component);
 }