Exemplo n.º 1
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;
 }
Exemplo n.º 2
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");
     $recordStructureId = $this->getRecordStructureId();
     $recordStructure = $this->getRecordStructure();
     $recordStructureIdString = $recordStructureId->getIdString();
     $repositoryId = $this->getRepositoryId();
     $repository = $this->getRepository();
     // 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 RecordStructure", "RecordStructure deleted:\n<br/>&nbsp; &nbsp; &nbsp;" . $recordStructure->getDisplayName());
         $item->addNodeId($recordStructureId);
         $item->addNodeId($repositoryId);
         $log->appendLogWithTypes($item, $formatType, $priorityType);
     }
     $setManager = Services::getService("Sets");
     $set = $setManager->getPersistentSet($repositoryId);
     if ($set->isInSet($recordStructureId)) {
         $set->removeItem($recordStructureId);
     }
     $repository->deleteRecordStructure($recordStructureId, new StatusStars(_("Deleting Schema and associated Records")));
     RequestContext::sendTo($harmoni->history->getReturnUrl("concerto/schema/delete-return/" . $recordStructureIdString));
 }
Exemplo n.º 3
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");
 }
 /**
  * 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);
         }
     }
 }
Exemplo n.º 5
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("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'))));
 }
Exemplo n.º 6
0
 function test_start_stop_restart()
 {
     $this->test_register_service();
     //$this->assertFalse(Services::serviceRunning("DBHandler"));
     // start it!
     $this->assertTrue(Services::startService("DBHandler"));
     $this->assertTrue(Services::serviceRunning("DBHandler"));
     $this->assertTrue(Services::serviceAvailable("DBHandler"));
     // stop it!
     $this->assertTrue(Services::stopService("DBHandler"));
     $this->assertFalse(Services::serviceRunning("DBHandler"));
     $this->assertTrue(Services::serviceAvailable("DBHandler"));
     // restart it! (or, first start it, *then* restart it!)
     $this->assertTrue(Services::startService("DBHandler"));
     $this->assertTrue(Services::serviceRunning("DBHandler"));
     $this->assertTrue(Services::serviceAvailable("DBHandler"));
     $this->assertTrue(Services::restartService("DBHandler"));
     $this->assertTrue(Services::serviceRunning("DBHandler"));
     $this->assertTrue(Services::serviceAvailable("DBHandler"));
 }
Exemplo 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)
 {
     $component = $director->getSiteComponentById(SiteDispatcher::getCurrentNodeId());
     $component->acceptVisitor(new ModifySettingsSiteVisitor());
     /*********************************************************
      * 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 Modified", $component->getComponentClass() . " modified.");
         $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);
     }
 }
 /**
  * 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");
     $repositoryId = $idManager->getId(RequestContext::value('collection_id'));
     $systemAgentId = $idManager->getId('system:concerto');
     $tagGenerator = StructuredMetaDataTagGenerator::instance();
     $tagGenerator->regenerateTagsForRepository($repositoryId, $systemAgentId, 'concerto');
     // Log the success or failure
     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("Regenerated Tags", "Auto-generated tags were regenerated");
         $item->addNodeId($repositoryId);
         $log->appendLogWithTypes($item, $formatType, $priorityType);
     }
     RequestContext::sendTo($harmoni->request->quickURL("collection", "browse", array('collection_id' => RequestContext::value('collection_id'))));
 }
 /**
  * get parameters for createRecord
  * 
  * @param mixed input
  * @return array or false on fatal error
  * @access public
  * @since 7/20/05
  */
 function getSingleAssetRecordList($input)
 {
     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.");
     }
     $idManager = Services::getService("Id");
     $this->_fileStructureId = $idManager->getId("FILE");
     $fileparts = array("File Name", "Thumbnail Data");
     $this->_fileNamePartIds = $this->matchPartStructures($this->_destinationRepository->getRecordStructure($this->_fileStructureId), $fileparts);
     $recordList = array();
     $recordListElement = array();
     $recordListElement['structureId'] = $this->_fileStructureId;
     $recordListElement['partStructureIds'] = $this->_fileNamePartIds;
     $recordListElement['parts'] = array($input, "");
     $recordList[] = $recordListElement;
     $recordListElement = array();
     //printpre($recordList);
     return $recordList;
 }
Exemplo n.º 10
0
 /**
  * Process the changes and build the output
  * 
  * @return void
  * @access public
  * @since 10/25/07
  */
 public function buildContent()
 {
     try {
         ob_start();
         $fileAsset = $this->getFileAsset();
         $fileAssetId = $fileAsset->getId();
         $contentAsset = $this->getContentAsset();
         $repository = $fileAsset->getRepository();
         $repository->deleteAsset($fileAsset->getId());
         // Log the success or failure
         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.");
             $message = "File deleted with id '" . $fileAssetId->getIdString() . "'.";
             $item = new AgentNodeEntryItem("Media Library", $message);
             $item->addNodeId($fileAssetId);
             $item->addNodeId($contentAsset->getId());
             $idManager = Services::getService("Id");
             $director = AssetSiteDirector::forAsset($contentAsset);
             $site = $director->getRootSiteComponent($contentAsset->getId()->getIdString());
             $item->addNodeId($idManager->getId($site->getId()));
             $log->appendLogWithTypes($item, $formatType, $priorityType);
         }
         $error = ob_get_clean();
         if ($error) {
             $this->error($error);
         }
     } catch (Exception $e) {
         $this->error($e->getMessage());
     }
     $this->start();
     print $this->getQuota();
     // No content.
     $this->end();
 }
Exemplo n.º 11
0
 /**
  * Execute the action
  * 
  * @return void
  * @access public
  * @since 7/10/08
  */
 public function execute()
 {
     if (!$this->isAuthorizedToExecute()) {
         throw new PermissionDeniedException();
     }
     $authZ = Services::getService("AuthZ");
     $idManager = Services::getService("Id");
     $hierarchyManager = Services::getService('Hierarchy');
     $site = SiteDispatcher::getCurrentRootNode();
     $hierarchy = $hierarchyManager->getHierarchy($idManager->getId("edu.middlebury.authorization.hierarchy"));
     $infoList = $hierarchy->traverse($idManager->getId($site->getId()), Hierarchy::TRAVERSE_MODE_DEPTH_FIRST, Hierarchy::TRAVERSE_DIRECTION_DOWN, Hierarchy::TRAVERSE_LEVELS_ALL);
     $status = new StatusStars(str_replace('%1', $infoList->count(), _("Rebuilding Implicit AZs on %1 nodes.")));
     $status->initializeStatistics($infoList->count());
     $azCache = $authZ->getAuthorizationCache();
     while ($infoList->hasNext()) {
         $info = $infoList->next();
         $node = $hierarchy->getNode($info->getNodeId());
         // 			printpre("Rebuilding implicit AZs for ".$node->getId()." '".$node->getDisplayName()."'. Ancestors:");
         // 			printpre($node->getAncestorIds());
         $azCache->createHierarchyImplictAZs($node, $node->getAncestorIds());
         $status->updateStatistics();
     }
     printpre("Done.");
     /*********************************************************
      * 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", "Error", "Errors that did not halt execution");
         $item = new AgentNodeEntryItem("Rebuilt Implict AZs", "Hierarchy-Implicit AZs for site '" . $site->getDisplayName() . "' were rebuilt manually.");
         $item->addNodeId($site->getQualifierId());
         $log->appendLogWithTypes($item, $formatType, $priorityType);
     }
 }
Exemplo n.º 12
0
 /**
  * Execute the action
  * 
  * @return void
  * @access public
  * @since 10/9/08
  */
 public function execute()
 {
     if (!$this->isAuthorizedToExecute()) {
         throw new PermissionDeniedException("You must be logged in.");
     }
     $mgr = SlotManager::instance();
     $slot = $mgr->getSlotByShortname(RequestContext::value('slot'));
     $oldTarget = $slot->getAliasTarget();
     $slot->makeNotAlias();
     /*********************************************************
      * 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 Removed", "'" . $slot->getShortname() . "' is no longer an alias of '" . $oldTarget->getShortname() . "'.");
         $item->addNodeId($oldTarget->getSiteId());
         $log->appendLogWithTypes($item, $formatType, $priorityType);
     }
     $harmoni = Harmoni::instance();
     RequestContext::sendTo($harmoni->request->quickURL('portal', 'list'));
 }
Exemplo n.º 13
0
 /**
  * Execute
  * 
  * @return void
  * @access public
  * @since 12/7/07
  */
 public function buildContent()
 {
     $harmoni = Harmoni::instance();
     $harmoni->request->startNamespace("slots");
     $name = strtolower(RequestContext::value("name"));
     $harmoni->request->passthrough("name");
     $harmoni->request->endNamespace();
     $slotMgr = SlotManager::instance();
     $slot = $slotMgr->getSlotByShortname($name);
     if ($slot->siteExists()) {
         throw new PermissionDeniedException("You cannot delete a placeholder that has an existing site.");
     }
     $slotMgr->deleteSlot($name);
     // Log this change
     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("Delete Placeholder", "Placeholder deleted:  '" . $name . "'.");
         $log->appendLogWithTypes($item, $formatType, $priorityType);
     }
     $harmoni->request->sendTo($this->getReturnUrl());
 }
Exemplo n.º 14
0
 /**
  * Create a new personal slot if our form was submitted.
  * 
  * @return void
  * @access private
  * @since 4/1/08
  */
 private function createNewSlotIfRequested()
 {
     $authN = Services::getService("AuthN");
     $harmoni = Harmoni::instance();
     // Creation of new personal slots.
     $harmoni->request->startNamespace('personal_slot');
     if (RequestContext::value('slot_postfix') && PersonalSlot::hasPersonal()) {
         try {
             $newSlotname = PersonalSlot::getPersonalShortname($authN->getFirstUserId()) . "-" . RequestContext::value('slot_postfix');
             // Replace delimiting marks with an underscore
             $newSlotname = preg_replace('/[\\s\\/=+.,()]+/i', '_', $newSlotname);
             // Remove anything left over (other than letters/numbers/-/_)
             $newSlotname = preg_replace('/[^a-z0-9_-]/i', '', $newSlotname);
             $slot = new PersonalSlot(strtolower($newSlotname));
             $slot->addOwner($authN->getFirstUserId());
         } catch (OperationFailedException $e) {
             $harmoni->request->endNamespace();
             if ($e->getCode() == Slot::OWNER_EXISTS) {
                 throw new OperationFailedException("Placeholder '" . strtolower($newSlotname) . "' already exists.");
             } else {
                 throw $e;
             }
         }
         // Log this change.
         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 Placeholder", "New placeholder created:  '" . $slot->getShortname() . "'.");
             $log->appendLogWithTypes($item, $formatType, $priorityType);
         }
     }
     $harmoni->request->endNamespace();
 }
Exemplo n.º 15
0
 function moreGranulesFromXML()
 {
     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.");
     }
     $moreXML = $this->_import->documentElement->getElementsByTagName("repositoryfile");
     $granules = 0;
     for ($i = 0; $i < $moreXML->getLength(); $i++) {
         $element = $moreXML->item($i);
         $path = $element->getText();
         if (!preg_match("#^([a-zA-Z]+://|[a-zA-Z]+:\\|/)#", $path)) {
             $path = $element->ownerDocument->xmlPath . $path;
         }
         $import = new DOMIT_Document();
         // attempt to load (parse) the xml file
         if ($import->loadXML($path)) {
             if (!$import->documentElement->hasChildNodes()) {
                 $this->addError("There are no Importables in this file");
                 // log error
                 $item = new AgentNodeEntryItem("XMLImporter Error", "No Importables in the file: " . htmlspecialchars($path) . ".");
                 if (isset($log)) {
                     $log->appendLogWithTypes($item, $formatType, $priorityType);
                 }
             } else {
                 $nodes = $import->documentElement->getElementsByTagName($this->_granule);
                 $granules += $nodes->getLength();
             }
         } else {
             // any errors encountered by DOMIT in parsing handled here
             $this->addError("DOMIT error: " . $import->getErrorCode() . "<br/>\t meaning: " . $import->getErrorString() . "<br/>");
             $item = new AgentNodeEntryItem("XMLImporter DOMIT Error", "Error Code: " . $import->getErrorCode() . ", meaning: " . $import->getErrorString() . ".");
             if (isset($log)) {
                 $log->appendLogWithTypes($item, $formatType, $priorityType);
             }
         }
     }
     return $granules;
 }
Exemplo n.º 16
0
 /**
  * The Require Service function checks for required service availability.
  * 
  * The function first checks for service availabilty, and then attempts to
  * start the service if it's available. If either action fails, it stops
  * script execution. If $start=false then the function will only check for 
  * availability.
  * @param string $name The name of the service.
  * @param boolean $start If we should attempt to start the service or not.
  * @access public
  * @static
  * @return ref object The started service object. (if start=true)
  * @deprecated 2004/07/28 Use {@link startManagerAsService()} and {@link getService()} instead.
  **/
 static function requireService($service, $start = true)
 {
     $backtrace = debug_backtrace();
     print "\n<br/><strong>Warning: Method call, Services::requireService(), is deprecated. Please use Services::startManagerAsService() and/or Services::getService() instead. ";
     print $backtrace[0]['file'] . " (Line " . $backtrace[0]['line'] . ")";
     print "</strong><br/>\n";
     $error = false;
     if (!Services::serviceAvailable($service)) {
         $error = true;
     } else {
         if ($start && !Services::serviceRunning($service) && !Services::startService($service)) {
             $error = true;
         }
     }
     if ($error) {
         // if we have the error Handler, throw a pretty error with that,
         // otherwise, use the die() function.
         if ($GLOBALS[SERVICES_OBJECT]->available('ErrorHandler')) {
             throwError(new Error("A required Service <b>\"{$service}\"</b> " . ($start ? "could not be started" : "is not available"), "Services", 1));
         } else {
             $debug = debug_backtrace();
             $str = "<B>FATAL ERROR</b><br /><br />";
             $str .= "A required Service <b>\"{$service}\"</b> ";
             $str .= $start ? "could not be started" : "is not available";
             $str .= ".<br /><br />\n";
             $str .= "<b>Debug backtrace:</b>\n";
             $str .= "<pre>\n";
             $str .= print_r($debug, true);
             $str .= "\n</pre>\n";
             die($str);
         }
     }
     if ($start) {
         return Services::getService($service);
     }
 }
Exemplo n.º 17
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 1/28/08
  */
 public function saveWizard($cacheName)
 {
     $wizard = $this->getWizard($cacheName);
     if (!$wizard->validate()) {
         return false;
     }
     $values = $wizard->getAllValues();
     // 		printpre($values);
     // 		return false;
     try {
         if (!defined('DATAPORT_TMP_DIR')) {
             throw new Exception("DATAPORT_TMP_DIR must be defined in the Segue configuration.");
         }
         $archivePath = $values['mode']['backup_file']['tmp_name'];
         $archiveName = basename($archivePath);
         $decompressDir = DATAPORT_TMP_DIR . '/' . $archiveName . '_source';
         if (!$values['mode']['backup_file']['size']) {
             throw new Exception("File upload error - archive was not successfully uploaded and has no size.");
         }
         $this->decompressArchive($archivePath, $decompressDir);
         // Do the import
         $director = SiteDispatcher::getSiteDirector();
         $doc = new Harmoni_DOMDocument();
         $doc->load($decompressDir . "/site.xml");
         // Validate the document contents
         $doc->schemaValidateWithException(MYDIR . "/doc/raw/dtds/segue2-site.xsd");
         $mediaDir = $decompressDir;
         switch ($values['mode']['trust']) {
             case 'all':
                 $class = 'DomImportSiteVisitor';
                 break;
             case 'time_only':
                 $class = 'UntrustedAgentDomImportSiteVisitor';
                 break;
             default:
                 $class = 'UntrustedAgentAndTimeDomImportSiteVisitor';
         }
         $importer = new $class($doc, $mediaDir, $director);
         if ($values['mode']['roles'] == '1') {
             $importer->enableRoleImport();
         }
         if ($values['mode']['comments'] == '0') {
             $importer->disableCommentImport();
         }
         if (isset($values['owners'])) {
             $idMgr = Services::getService('Id');
             foreach ($values['owners']['admins'] as $adminIdString) {
                 $importer->addSiteAdministrator($idMgr->getId($adminIdString));
             }
         }
         $importer->enableStatusOutput();
         $site = $importer->importAtSlot($values['mode']['slotname']);
         // Delete the uploaded file
         unlink($archivePath);
         // Delete the decompressed Archive
         $this->deleteRecursive($decompressDir);
     } catch (Exception $importException) {
         // Delete the uploaded file
         try {
             if (file_exists($archivePath)) {
                 unlink($archivePath);
             }
         } catch (Exception $deleteException) {
             print "\n<div>\n\t";
             print $deleteException->getMessage();
             print "\n</div>";
         }
         // Delete the decompressed Archive
         try {
             if (file_exists($decompressDir)) {
                 $this->deleteRecursive($decompressDir);
             }
         } catch (Exception $deleteException) {
             print "\n<div>\n\t";
             print $deleteException->getMessage();
             print "\n</div>";
         }
         print "\n<div>\n\t";
         print $importException->getMessage();
         // 			print HarmoniErrorHandler::printDebugBacktrace($importException->getTrace());
         print "\n</div>";
         $wizard->backupFile->setValue(array('name' => null, 'size' => null, 'type' => null));
         /*********************************************************
          * Log the failure
          *********************************************************/
         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", "Error", "Recoverable errors.");
             $item = new AgentNodeEntryItem("Create Site", "Failure in importing site for placeholder, '" . $values['mode']['slotname'] . "'. " . $importException->getMessage());
             $item->setBacktrace($importException->getTrace());
             $item->addTextToBactrace("Archive Upload: " . printpre($values['mode']['backup_file'], true));
             $log->appendLogWithTypes($item, $formatType, $priorityType);
         }
         return false;
     }
     /*********************************************************
      * 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("Create Site", "Site imported for placeholder, '" . $values['mode']['slotname'] . "'.");
         $item->addNodeId($site->getQualifierId());
         $log->appendLogWithTypes($item, $formatType, $priorityType);
     }
     return true;
 }
Exemplo n.º 18
0
 /**
  * Looks for discrepencies between imported data and current data
  * 
  * @access public
  * @since 9/12/05
  */
 function update()
 {
     $modified = false;
     if (isset($this->_info['name']) && !is_null($this->_info['name']) && $this->_info['name'] != $this->_object->getDisplayName()) {
         $modified = true;
         $this->_object->updateDisplayName($this->_info['name']);
     }
     if (isset($this->_info['description']) && !is_null($this->_info['description']) && $this->_info['description'] != $this->_object->getDescription()) {
         $modified = true;
         $this->_object->updateDescription($this->_info['description']);
     }
     if (Services::serviceRunning("Logging") && $modified) {
         $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", "Event_Notice", "Normal Events.");
         $item = new AgentNodeEntryItem("Modified Node", "Asset: " . htmlspecialchars($this->_myId->getIdString()) . " modified.");
         $item->addNodeId($this->_myId);
         $log->appendLogWithTypes($item, $formatType, $priorityType);
     }
     // 		if (isset($this->_info['effectivedate']) &&
     // 			(DateAndTime::fromString($this->_info['effectivedate']) !=
     // 			$this->_object->getEffectiveDate()))
     // 			$this->_object->updateEffectiveDate(DateAndTime::fromString(
     // 				$this->_info['effectivedate']));
     // 		if (isset($this->_info['effectivedate']) &&
     // 			(DateAndTime::fromString($this->_info['expirationdate']) !=
     // 			$this->_object->getExpirationDate()))
     // 			$this->_object->updateExpirationDate(DateAndTime::fromString(
     // 				$this->_info['expirationdate']));
 }
Exemplo n.º 19
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;
 }
Exemplo n.º 20
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 all properties validate then go through the steps nessisary to
     // save the data.
     if ($wizard->validate()) {
         $properties = $wizard->getAllValues();
         $repository = $this->getRepository();
         // Create the info Structure
         $recordStructure = $repository->createRecordStructure($properties['namedesc']['display_name'], $properties['namedesc']['description'], $properties['namedesc']['format'], $properties['namedesc']['display_name']);
         Debug::printAll();
         $recordStructureId = $recordStructure->getId();
         // Create a set for the RecordStructure
         $setManager = Services::getService("Sets");
         $set = $setManager->getPersistentSet($recordStructureId);
         // Store up the positions for later setting after all of the ids have
         // been added to the set and we can do checking to make sure that
         // the specified positions are valid.
         $positions = array();
         // Create the PartStructures
         $partStructureProperties = $properties['elementstep']['elements'];
         foreach (array_keys($partStructureProperties) as $index) {
             $type = HarmoniType::fromString(urldecode($partStructureProperties[$index]['type']), " :: ");
             $partStructure = $recordStructure->createPartStructure($partStructureProperties[$index]['display_name'], $partStructureProperties[$index]['description'], $type, $partStructureProperties[$index]['mandatory'] ? TRUE : FALSE, $partStructureProperties[$index]['repeatable'] ? TRUE : FALSE, FALSE);
             // Authoritative values
             $valuesString = trim($partStructureProperties[$index]['authoritative_values']);
             if ($valuesString) {
                 $authoritativeStrings = explode("\n", $valuesString);
                 array_walk($authoritativeStrings, "removeExcessWhitespace");
                 // Remove and missing values
                 $authoritativeValues = $partStructure->getAuthoritativeValues();
                 while ($authoritativeValues->hasNext()) {
                     $value = $authoritativeValues->next();
                     if (!in_array($value->asString(), $authoritativeStrings)) {
                         $partStructure->removeAuthoritativeValue($value);
                     }
                 }
                 // Add new values
                 foreach ($authoritativeStrings as $valueString) {
                     if ($valueString) {
                         $partStructure->addAuthoritativeValueAsString($valueString);
                     }
                 }
             }
             $partStructureId = $partStructure->getId();
             // Add the PartStructureId to the set
             if (!$set->isInSet($partStructureId)) {
                 $set->addItem($partStructureId);
             }
         }
         // Log the success or failure
         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("Modify Node", "RecordStructure created:\n<br/>&nbsp; &nbsp; &nbsp; " . $recordStructure->getDisplayName());
             $item->addNodeId($repository->getId());
             $log->appendLogWithTypes($item, $formatType, $priorityType);
         }
         return TRUE;
     } else {
         return FALSE;
     }
 }
Exemplo n.º 21
0
 /**
  * Create a new file asset
  * 
  * @return object Asset
  * @access public
  * @since 1/26/07
  */
 function createFileAsset()
 {
     $contentAsset = $this->getContentAsset();
     $asset = MediaAsset::createForContentAsset($contentAsset);
     if (!($displayName = RequestContext::value('displayName'))) {
         $displayName = $_FILES['media_file']['name'];
     }
     if (!($description = RequestContext::value('description'))) {
         $description = '';
     }
     // Check the quota
     $slot = $this->getSlot();
     if ($this->getQuotaUsed() + $_FILES['media_file']['size'] > $slot->getMediaQuota()->value()) {
         throw new Exception("Cannot add File, {$displayName}, quota of " . $slot->getMediaQuota()->asString() . " exceeded.");
     }
     // Create the asset
     $asset->updateDisplayName($displayName);
     $asset->updateDescription($description);
     try {
         $this->addFileRecord($asset);
     } catch (Exception $e) {
         HarmoniErrorHandler::logException($e, 'Segue');
         $this->nonFatalError($e->getMessage(), get_class($e));
     }
     try {
         $this->addDublinCoreRecord($asset);
     } catch (Exception $e) {
         HarmoniErrorHandler::logException($e, 'Segue');
         $this->nonFatalError($e->getMessage(), get_class($e));
     }
     // Log the success or failure
     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("Media Library", "File uploaded with id '" . $asset->getId()->getIdString() . "' and filename '" . $_FILES['media_file']['name'] . "'");
         $item->addNodeId($asset->getId());
         $item->addNodeId($contentAsset->getId());
         $idManager = Services::getService("Id");
         $director = AssetSiteDirector::forAsset($contentAsset);
         $site = $director->getRootSiteComponent($contentAsset->getId()->getIdString());
         $item->addNodeId($idManager->getId($site->getId()));
         $log->appendLogWithTypes($item, $formatType, $priorityType);
     }
     return $asset;
 }
 /**
  * Sets the node's internal information
  * 
  * @access public
  * @since 10/6/05
  */
 function getNodeInfo()
 {
     $dbHandler = Services::getService("DBHandler");
     // 		$dbIndexConcerto =$dbHandler->addDatabase(new
     // 			MySQLDatabase("localhost", "whitey_concerto", "test", "test"));
     $query = new SelectQuery();
     $query->addTable("xml_id_matrix");
     $query->addColumn("conc_id");
     $query->addColumn("xml_id");
     $id = $this->_node->getAttribute("xml:id");
     $query->addWhere("xml_id = '" . addslashes($id) . "'");
     //$dbHandler->connect($dbIndexConcerto);
     $results = $dbHandler->query($query, IMPORTER_CONNECTION);
     if ($results->getNumberOfRows() == 1) {
         $result = $results->next();
         $idManager = Services::getService("Id");
         $this->_info['recordStructureId'] = $idManager->getId($result['conc_id']);
     } else {
         $this->addError("Bad XML IDREF: " . $id);
         // Log the success or failure
         if (Services::serviceRunning("Logging")) {
             $loggingManager = Services::getService("Logging");
             $log = $loggingManager->getLogForWriting("Harmoni");
             $formatType = new Type("logging", "edu.middlebury", "AgentsAndNonNodes", "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.");
             $item = new AgentNodeEntryItem("RecordImport Error", "Bad XML IDREF: " . htmlspecialchars($id));
             $item->addNodeId($this->_parent->getId());
             $log->appendLogWithTypes($item, $formatType, $priorityType);
         }
     }
     $results->free();
 }
 /**
  * Confirm an email address
  * 
  * @param object AuthNTokens $email
  * @param string $confirmationCode
  * @return boolean True on success
  * @access public
  * @since 6/4/08
  */
 public function confirmEmail(AuthNTokens $authNTokens, $confirmationCode)
 {
     $dbc = Services::getService("DatabaseManager");
     $dbId = $this->_configuration->getProperty('database_id');
     $authenticationTable = $this->_configuration->getProperty('authentication_table');
     $usernameField = $this->_configuration->getProperty('username_field');
     $passwordField = $this->_configuration->getProperty('password_field');
     $query = new UpdateQuery();
     $query->setTable($authenticationTable);
     $query->addValue("email_confirmed", "1");
     $query->addWhereEqual($usernameField, $authNTokens->getUsername());
     $query->addWhereEqual('confirmation_code', $confirmationCode);
     $result = $dbc->query($query, $dbId);
     if ($result->getNumberOfRows()) {
         $confirmed = TRUE;
     } else {
         $confirmed = FALSE;
     }
     // Log the success or failure
     if (Services::serviceRunning("Logging")) {
         $loggingManager = Services::getService("Logging");
         $log = $loggingManager->getLogForWriting("Authentication");
         $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.");
         $properties = $this->getPropertiesForTokens($authNTokens);
         if ($confirmed) {
             $item = new AgentNodeEntryItem("Visitor Registration Confirmed", "Visitor Registration Confirmed: <br/>&nbsp;&nbsp;&nbsp;&nbsp;Name: " . htmlspecialchars($properties->getProperty('name')) . " <br/>&nbsp;&nbsp;&nbsp;&nbsp;Email: " . htmlspecialchars($authNTokens->getIdentifier()));
         } else {
             $priorityType = new Type("logging", "edu.middlebury", "User_Error", "Events that indicate errors in user supplied data.");
             $item = new AgentNodeEntryItem("Visitor Registration Failed", "Visitor Registration email confirmation failed. Confirmation code/email mis-match: <br/>&nbsp;&nbsp;&nbsp;&nbsp;Name: " . htmlspecialchars($properties->getProperty('name')) . " <br/>&nbsp;&nbsp;&nbsp;&nbsp;Email: " . htmlspecialchars($authNTokens->getIdentifier()));
         }
         $log->appendLogWithTypes($item, $formatType, $priorityType);
     }
     return $confirmed;
 }
Exemplo n.º 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");
     if (RequestContext::value('collection_id')) {
         $collectionId = $idManager->getId(RequestContext::value('collection_id'));
         $repository = $repositoryManager->getRepository($collectionId);
     } else {
         if (RequestContext::value('asset_id')) {
             $parentAssetId = $idManager->getId(RequestContext::value('asset_id'));
             $parentAsset = $repositoryManager->getAsset($parentAssetId);
             $repository = $parentAsset->getRepository();
         } else {
             if (count($this->getAssetIds())) {
                 $assetIds = $this->getAssetIds();
                 $firstAsset = $repositoryManager->getAsset(current($assetIds));
                 $repository = $firstAsset->getRepository();
             }
         }
     }
     // 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.");
     }
     $itemsToDelete = array();
     $assetIds = $this->getAssetIds();
     $status = new StatusStars(_("Deleting Assets"));
     $status->initializeStatistics(count($assetIds));
     foreach ($assetIds as $id) {
         $asset = $repository->getAsset($id);
         // Record the Tagged item to delete.
         $itemsToDelete[] = TaggedItem::forId($id, 'concerto');
         if (isset($log)) {
             $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($id);
         $status->updateStatistics();
     }
     // Remove this asset from the tagging manager
     $tagManager = Services::getService('Tagging');
     $tagManager->deleteItems($itemsToDelete, 'concerto');
     $harmoni->history->goBack("concerto/asset/delete-return");
 }
Exemplo n.º 25
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);
     // Make sure we have a valid Repository
     $authZ = Services::getService("AuthZ");
     $idManager = Services::getService("Id");
     $repositoryManager = Services::getService("Repository");
     $repository = $repositoryManager->getRepository($idManager->getId("edu.middlebury.concerto.exhibition_repository"));
     $slideshowAsset = $repository->getAsset($idManager->getId(RequestContext::value('slideshow_id')));
     $properties = $wizard->getAllValues();
     $status = new StatusStars(_("Saving Slideshow"));
     $status->initializeStatistics(count($properties['slidestep']['slides']) + 2);
     // First, verify that we chose a parent that we can add children to.
     if ($authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.modify"), $slideshowAsset->getId())) {
         $slideshowAssetId = $slideshowAsset->getId();
         $this->_slideshowAssetId = $slideshowAssetId;
         // Update the Name and description
         if ($properties['namedescstep']['display_name']) {
             $slideshowAsset->updateDisplayName($properties['namedescstep']['display_name']);
         }
         if ($properties['namedescstep']['description']) {
             $slideshowAsset->updateDescription($properties['namedescstep']['description']);
         }
         // Update the effective/expiration dates
         // 			if ($properties['datestep']['effective_date'])
         // 				$slideshowAsset->updateEffectiveDate(
         // 					DateAndTime::fromString(
         // 					$properties['datestep']['effective_date']));
         // 			if ($properties['datestep']['expiration_date'])
         // 				$slideshowAsset->updateExpirationDate(
         // 					DateAndTime::fromString(
         // 					$properties['datestep']['expiration_date']));
         // --- Slides ---
         $slideAssetType = new HarmoniType("Asset Types", "edu.middlebury.concerto", "Slide", "Slides are components of Slide-Shows that contain captions and may reference media Assets.");
         $slideRecordStructId = $idManager->getId("Repository::edu.middlebury.concerto.exhibition_repository::edu.middlebury.concerto.slide_record_structure");
         $targetIdPartStructId = $idManager->getId("Repository::edu.middlebury.concerto.exhibition_repository::edu.middlebury.concerto.slide_record_structure.edu.middlebury.concerto.slide_record_structure.target_id");
         $textPositionPartStructId = $idManager->getId("Repository::edu.middlebury.concerto.exhibition_repository::edu.middlebury.concerto.slide_record_structure.edu.middlebury.concerto.slide_record_structure.text_position");
         $displayMetadataPartStructId = $idManager->getId("Repository::edu.middlebury.concerto.exhibition_repository::edu.middlebury.concerto.slide_record_structure.edu.middlebury.concerto.slide_record_structure.display_metadata");
         $setManager = Services::getService("Sets");
         $pSlideOrder = $setManager->getPersistentSet($slideshowAssetId);
         $slideIterator = $slideshowAsset->getAssets();
         // ---- Add/Update Slides in new order (hopefully)
         $existingSlides = array();
         while ($slideIterator->hasNext()) {
             $currentSlide = $slideIterator->next();
             $id = $currentSlide->getId();
             $existingSlides[] = $id->getIdString();
         }
         $pSlideOrder->removeAllItems();
         $status->updateStatistics();
         foreach ($properties['slidestep']['slides'] as $slideProperties) {
             // 				print get_class($slideProperties['slideId']).": ".$slideProperties['title'];
             if (!isset($slideProperties['slideId'])) {
                 // ---- Clean the inputs ----
                 if (isset($slideProperties['title'])) {
                     $title = $slideProperties['title'];
                 } else {
                     $title = '';
                 }
                 if (isset($slideProperties['caption'])) {
                     $caption = $slideProperties['caption'];
                 } else {
                     $caption = '';
                 }
                 if (isset($slideProperties['text_position'])) {
                     $textPosition = String::withValue($slideProperties['text_position']);
                 } else {
                     $textPosition = String::withValue('');
                 }
                 if (isset($slideProperties['show_target_metadata'])) {
                     $displayMetadata = Boolean::withValue($slideProperties['show_target_metadata']);
                 } else {
                     $displayMetadata = Boolean::false();
                 }
                 if (isset($slideProperties['_assetId'])) {
                     $targetId = String::withValue($slideProperties['_assetId']->getIdString());
                 } else {
                     $targetId = String::withValue('');
                 }
                 // ---- Create the asset ----
                 $slideAsset = $repository->createAsset($title, $caption, $slideAssetType);
                 $slideAssetId = $slideAsset->getId();
                 $slideshowAsset->addAsset($slideAssetId);
                 // Add it to the order field
                 $pSlideOrder->addItem($slideAssetId);
                 // ---- Set the additional info ----
                 $slideRecord = $slideAsset->createRecord($slideRecordStructId);
                 $slideRecord->createPart($textPositionPartStructId, $textPosition);
                 $slideRecord->createPart($displayMetadataPartStructId, $displayMetadata);
                 $slideRecord->createPart($targetIdPartStructId, $targetId);
             } else {
                 if (in_array($slideProperties['slideId']->getIdString(), $existingSlides)) {
                     $slideAsset = $repository->getAsset($slideProperties['slideId']);
                     $slideAsset->updateDisplayName($slideProperties['title']);
                     $slideAsset->updateDescription($slideProperties['caption']);
                     $textPositionIterator = $slideAsset->getPartsByPartStructure($textPositionPartStructId);
                     if ($textPositionIterator->hasNext()) {
                         $part = $textPositionIterator->next();
                         $part->updateValue(new String($slideProperties['text_position']));
                     }
                     $showMetadataIterator = $slideAsset->getPartsByPartStructure($displayMetadataPartStructId);
                     if ($showMetadataIterator->hasNext()) {
                         $part = $showMetadataIterator->next();
                         $part->updateValue(new Boolean($slideProperties['show_target_metadata']));
                     }
                     $pSlideOrder->addItem($slideProperties['slideId']);
                     $records = $slideAsset->getRecordsByRecordStructure($slideRecordStructId);
                     $slideRecord = $records->next();
                 }
             }
             $status->updateStatistics();
         }
         // ==== Remove slide assets no longer in slideshow ----
         foreach ($existingSlides as $older) {
             $old = $idManager->getId($older);
             if (!$pSlideOrder->isInSet($old)) {
                 $slideshowAsset->removeAsset($old, false);
                 $repository->deleteAsset($old);
             }
         }
         $status->updateStatistics();
         // Log the success or failure
         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("Modify Node", "Slideshow Modified");
             $item->addNodeId($slideshowAssetId);
             $log->appendLogWithTypes($item, $formatType, $priorityType);
         }
         return TRUE;
     } else {
         return FALSE;
     }
 }
 /**
  * get parameters for createRecord
  * 
  * @param mixed input
  * @return array or false on fatal error
  * @access public
  * @since 7/20/05
  */
 function getSingleAssetRecordList($input)
 {
     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.");
     }
     $idManager = Services::getService("Id");
     $this->_fileStructureId = $idManager->getId("FILE");
     $fileparts = array("File Name", "Thumbnail Data");
     $this->_fileNamePartIds = $this->matchPartStructures($this->_destinationRepository->getRecordStructure($this->_fileStructureId), $fileparts);
     if (!isset($this->_structureId)) {
         $import = new DOMIT_Document();
         if (!isset($this->_schemaPath)) {
             $this->_schemaPath = $this->getSchemaPath($this->_srcDir);
             if (!$this->_schemaPath) {
                 $this->_schemaPath = DEFAULT_EXIF_SCHEMA;
             }
         }
         if ($import->loadXML($this->_schemaPath)) {
             if (!$import->documentElement->hasChildNodes()) {
                 $this->addError("There are no schemas defined in : " . $this->_schemaPath);
                 if (isset($log)) {
                     $item = new AgentNodeEntryItem("ExifImporter Error", "There are no schemas defined in: " . $this->_schemaPath);
                     $log->appendLogWithTypes($item, $formatType, $priorityType);
                 }
                 return false;
             }
         } else {
             $this->addError("XML parse failed: " . $this->_schemaPath . " does not exist or contains poorly formed XML.");
             if (isset($log)) {
                 $item = new AgentNodeEntryItem("ExifImporter DOMIT Error", "XML parse failed: " . $this->_schemaPath . " does not exist or contains poorly formed XML.");
                 $log->appendLogWithTypes($item, $formatType, $priorityType);
             }
             return false;
         }
         $istructuresList = $import->documentElement->childNodes;
         $this->_structureId = array();
         $this->_partsFinal = array();
         $this->_valuesFinal = array();
         foreach ($istructuresList as $istructure) {
             $valuesPreFinal = array();
             $partStructuresArray = array();
             if ($istructure->nodeName == "recordStructure") {
                 //match the structure
                 $ipartStructures = $istructure->childNodes;
                 if ($ipartStructures[0]->getText() != "") {
                     $matchedSchema = $idManager->getId($ipartStructures[0]->getText());
                 } else {
                     $matchedSchema = $this->matchSchema($ipartStructures[1]->getText(), $this->_destinationRepository);
                 }
                 if ($matchedSchema == false) {
                     $this->addError("Schema: " . $ipartStructures[1]->getText() . " does not exist");
                     if (isset($log)) {
                         $item = new AgentNodeEntryItem("ExifImporter \n\t\t\t\t\t\t\t\tError", "Schema: " . $ipartStructures[1]->getText() . " does not exist.");
                         $log->appendLogWithTypes($item, $formatType, $priorityType);
                     }
                     return false;
                 } else {
                     $this->_structureId[] = $matchedSchema;
                 }
                 //match the partstructures
                 foreach ($ipartStructures as $ipartStructure) {
                     if ($ipartStructure->nodeName == "partStructure") {
                         $ivaluesArray = $ipartStructure->childNodes;
                         if ($ivaluesArray[0]->getText() != "") {
                             $matchedId = $idManager->getId($ivaluesArray[0]->getText());
                         } else {
                             $matchedId = $this->getPartIdByName($ivaluesArray[1]->getText(), $matchedSchema);
                         }
                         if ($matchedId == false) {
                             $this->addError("Part " . $ivaluesArray[1]->getText() . " does not exist.");
                             if (isset($log)) {
                                 $item = new AgentNodeEntryItem("ExifImporter Error", "Part " . $ivaluesArray[1] . " does not exist.");
                                 $log->appendLogWithTypes($item, $formatType, $priorityType);
                             }
                             return false;
                         }
                         $partStructuresArray[] = $matchedId;
                         $repeatableValueArray = array();
                         foreach ($ivaluesArray as $ivalueField) {
                             if ($ivalueField->nodeName == "value") {
                                 $valueArray = array();
                                 $ivaluesChildren = $ivalueField->childNodes;
                                 foreach ($ivaluesChildren as $ivalue) {
                                     if ($ivalue->nodeName == "exifElement") {
                                         $valueArray[] = "exif::" . $ivalue->getText();
                                     }
                                     if ($ivalue->nodeName == "text") {
                                         $valueArray[] = "text::" . $ivalue->getText();
                                     }
                                 }
                                 $repeatableValueArray[] = $valueArray;
                             }
                         }
                         $valuesPreFinal[$matchedId->getIdString()] = $repeatableValueArray;
                     }
                     $this->_valuesFinal[$matchedSchema->getIdString()] = $valuesPreFinal;
                 }
                 $this->_partsFinal[$matchedSchema->getIdString()] = $partStructuresArray;
             }
         }
     }
     $recordList = array();
     $recordListElement = array();
     $headerData = get_jpeg_header_data($input);
     $fileMetaData1 = $this->extractPhotoshopMetaData();
     $fileMetaData2 = $this->extractExifMetaData($input);
     $fileMetaData = array_merge($fileMetaData1, $fileMetaData2);
     $recordListElement['structureId'] = $this->_fileStructureId;
     $recordListElement['partStructureIds'] = $this->_fileNamePartIds;
     $recordListElement['parts'] = array($input, "");
     $recordList[] = $recordListElement;
     $recordListElement = array();
     foreach ($this->_structureId as $structureId) {
         $parts = array();
         $recordListElement['structureId'] = $structureId;
         $recordListElement['partStructureIds'] = $this->_partsFinal[$structureId->getIdString()];
         $partValuesArray = $this->_valuesFinal[$structureId->getIdString()];
         foreach ($partValuesArray as $key => $repeatablePartsArray) {
             $partValues = array();
             foreach ($repeatablePartsArray as $partsComponentsArray) {
                 // If we have a single entry in the value field, create
                 // multiple part values for any repeated source values.
                 if (count($partsComponentsArray) == 1) {
                     $checkExifField = explode("::", $partsComponentsArray[0]);
                     // An Exif Value
                     if ($checkExifField[0] == "exif") {
                         if (isset($fileMetaData[$checkExifField[1]])) {
                             //multi-valued source values
                             if (is_array($fileMetaData[$checkExifField[1]])) {
                                 foreach ($fileMetaData[$checkExifField[1]] as $sourceValue) {
                                     $partValues[] = $this->getPartObject($structureId, $idManager->getId($key), $sourceValue);
                                 }
                             } else {
                                 $partValues[] = $this->getPartObject($structureId, $idManager->getId($key), $fileMetaData[$checkExifField[1]]);
                             }
                         }
                     } else {
                         $partValues[] = $this->getPartObject($structureId, $idManager->getId($key), $checkExifField[1]);
                     }
                 } else {
                     $data = "";
                     foreach ($partsComponentsArray as $partComponent) {
                         $checkExifField = explode("::", $partComponent);
                         // An Exif Value
                         if ($checkExifField[0] == "exif") {
                             if (isset($fileMetaData[$checkExifField[1]])) {
                                 if (is_array($fileMetaData[$checkExifField[1]])) {
                                     $data .= implode(", ", $fileMetaData[$checkExifField[1]]);
                                 } else {
                                     $data .= $fileMetaData[$checkExifField[1]];
                                 }
                             }
                         } else {
                             $data .= $checkExifField[1];
                         }
                     }
                     $partValues[] = $this->getPartObject($structureId, $idManager->getId($key), $data);
                 }
             }
             $parts[] = $partValues;
         }
         $recordListElement['parts'] = $parts;
         $recordList[] = $recordListElement;
     }
     // 		printpre($recordList);
     // 		exit;
     return $recordList;
 }
 /**
  * builds asset in repository from assetinfo and records from recordlist
  *
  * @param array assetInfo
  * @param array recordList
  * @return asset or false on fatal error
  * @access public
  * @since 7/18/05
  *
  */
 function buildAsset($info)
 {
     $assetInfo = $info['assetInfo'];
     $recordList = $info['recordList'];
     $childAssetList = $info['childAssetList'];
     $buildOrderedSet = $info['buildOrderedSet'];
     $idManager = Services::getService("Id");
     $mime = Services::getService("MIME");
     $FILE_ID = $idManager->getId("FILE");
     $FILE_DATA_ID = $idManager->getId("FILE_DATA");
     $FILE_NAME_ID = $idManager->getId("FILE_NAME");
     $MIME_TYPE_ID = $idManager->getId("MIME_TYPE");
     $THUMBNAIL_DATA_ID = $idManager->getId("THUMBNAIL_DATA");
     $THUMBNAIL_MIME_TYPE_ID = $idManager->getId("THUMBNAIL_MIME_TYPE");
     $asset = $this->_destinationRepository->createAsset($assetInfo['displayName'], $assetInfo['description'], $assetInfo['type']);
     $assetId = $asset->getId();
     // log creation
     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", "Event_Notice", "Normal Events.");
         $item = new AgentNodeEntryItem("Create Node", "Asset: " . $assetId->getIdString() . " created.");
         $item->addNodeId($assetId);
         $item->addNodeId($this->_destinationRepository->getId());
         $log->appendLogWithTypes($item, $formatType, $priorityType);
     }
     $this->addGoodAssetId($asset->getId());
     RecordManager::setCacheMode(false);
     if (is_array($recordList)) {
         foreach ($recordList as $entry) {
             $assetRecord = $asset->createRecord($entry['structureId']);
             $j = 0;
             // 				printpre("creating record for: "); printpre($entry['structureId']);
             foreach ($entry['partStructureIds'] as $id) {
                 if (!$entry['structureId']->isEqual($FILE_ID)) {
                     if (isset($entry['parts'][$j])) {
                         if (is_array($entry['parts'][$j])) {
                             for ($k = 0; $k < count($entry['parts'][$j]); $k++) {
                                 $assetRecord->createPart($id, $entry['parts'][$j][$k]);
                             }
                         } else {
                             $assetRecord->createPart($id, $entry['parts'][$j]);
                         }
                     }
                     $j++;
                 } else {
                     if ($entry['structureId']->isEqual($FILE_ID)) {
                         $filename = basename(trim($entry['parts'][0]));
                         $mimetype = $mime->getMIMETypeForFileName($filename);
                         $assetRecord->createPart($FILE_DATA_ID, file_get_contents($this->_srcDir . $filename));
                         $assetRecord->createPart($FILE_NAME_ID, basename($filename));
                         $assetRecord->createPart($MIME_TYPE_ID, $mimetype);
                         $imageProcessor = Services::getService("ImageProcessor");
                         if (isset($entry['parts'][1]) && $entry['parts'][1] != "") {
                             $assetRecord->createPart($THUMBNAIL_DATA_ID, file_get_contents($this->_srcDir . $entry['parts'][1]));
                         } else {
                             if ($imageProcessor->isFormatSupported($mimetype)) {
                                 try {
                                     $thumbData = $imageProcessor->generateThumbnailData($mimetype, file_get_contents($this->_srcDir . $filename));
                                 } catch (ImageProcessingFailedException $e) {
                                     $thumbData = null;
                                 }
                                 if ($thumbData) {
                                     $assetRecord->createPart($THUMBNAIL_DATA_ID, $thumbData);
                                     $assetRecord->createPart($THUMBNAIL_MIME_TYPE_ID, $imageProcessor->getThumbnailFormat());
                                 }
                             }
                         }
                         break;
                     }
                 }
             }
         }
     }
     if (!is_null($childAssetList)) {
         $stop = $this->assetBuildingIteration(new HarmoniIterator($childAssetList), $asset, $buildOrderedSet);
         if (!$stop) {
             return $stop;
         }
         // false
     }
     return $asset;
 }
Exemplo n.º 28
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 copy this site here."));
     }
     $srcSlot = $this->getSourceSlot();
     $srcSiteAsset = $this->getSourceSiteAsset();
     $director = SiteDispatcher::getSiteDirector();
     $srcComponent = $director->getSiteComponentFromAsset($srcSiteAsset);
     $destSlot = $this->getDestSlot();
     if (RequestContext::value('command') == 'copy') {
         try {
             /*********************************************************
              * Export the Site
              *********************************************************/
             $exportDir = DATAPORT_TMP_DIR . "/" . $srcSlot->getShortname() . "-" . str_replace(':', '_', DateAndTime::now()->asString());
             mkdir($exportDir);
             // Do the export
             $visitor = new DomExportSiteVisitor($exportDir);
             $visitor->enableStatusOutput(_("Exporting from original location."));
             $srcComponent->acceptVisitor($visitor);
             $doc = $visitor->doc;
             // Validate the result
             // 			printpre(htmlentities($doc->saveXMLWithWhitespace()));
             // 			$tmp = new Harmoni_DomDocument;
             // 			$tmp->loadXML($doc->saveXMLWithWhitespace());
             // 			$tmp->schemaValidateWithException(MYDIR."/doc/raw/dtds/segue2-site.xsd");
             $doc->schemaValidateWithException(MYDIR . "/doc/raw/dtds/segue2-site.xsd");
             // 			printpre($this->listDir($exportDir));
             // 			throw new Exception('test');
             /*********************************************************
              * Import the site
              *********************************************************/
             $importer = new DomImportSiteVisitor($doc, $exportDir, $director);
             if (RequestContext::value('copy_permissions') == 'true') {
                 $importer->enableRoleImport();
             }
             if (RequestContext::value('copy_discussions') != 'true') {
                 $importer->disableCommentImport();
             }
             // 			if (isset($values['owners'])) {
             // 				$idMgr = Services::getService('Id');
             // 				foreach($values['owners']['admins'] as $adminIdString)
             // 					$importer->addSiteAdministrator($idMgr->getId($adminIdString));
             // 			}
             $importer->enableStatusOutput(_("Importing into new location"));
             $importer->makeUserSiteAdministrator();
             $site = $importer->importAtSlot($destSlot->getShortname());
             // Delete the decompressed Archive
             $this->deleteRecursive($exportDir);
             /*********************************************************
              * 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("Copy Site", "Site copied from placeholder, '" . $srcSlot->getShortname() . "' to '" . $destSlot->getShortname() . "'.");
                 $item->addNodeId($site->getQualifierId());
                 $log->appendLogWithTypes($item, $formatType, $priorityType);
             }
         } catch (Exception $e) {
             $this->deleteRecursive($exportDir);
             if (file_exists($exportDir . ".tar.gz")) {
                 unlink($exportDir . ".tar.gz");
             }
             throw $e;
         }
     } else {
         // Detach the site from the source slot.
         $srcSlot->deleteSiteId();
         // Attach the site to the dest slot.
         $destSlot->setSiteId($srcSiteAsset->getId());
         // Make the source an alias of the destination so that links still work.
         $srcSlot->makeAlias($destSlot);
         /*********************************************************
          * 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("Move Site", "Site moved from placeholder, '" . $srcSlot->getShortname() . "' to '" . $destSlot->getShortname() . "'.");
             $item->addNodeId($destSlot->getSiteId());
             $log->appendLogWithTypes($item, $formatType, $priorityType);
         }
     }
     // Remove from selection?
     if (RequestContext::value('remove_after_use') == 'remove') {
         $selection = Segue_Selection::instance();
         $selection->removeSiteComponent($srcComponent);
     }
     print "\n" . _("Done");
     exit;
 }
Exemplo n.º 29
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)
 {
     $harmoni = Harmoni::instance();
     $harmoni->request->startNamespace('modify_exhibition');
     $harmoni->request->passthrough('exhibition_id');
     $wizard = $this->getWizard($cacheName);
     // Make sure we have a valid Repository
     $idManager = Services::getService("Id");
     $authZ = Services::getService("AuthZ");
     $repositoryManager = Services::getService("Repository");
     $exhibitionRepositoryId = $idManager->getId("edu.middlebury.concerto.exhibition_repository");
     $repository = $repositoryManager->getRepository($exhibitionRepositoryId);
     $asset = $repository->getAsset($idManager->getId(RequestContext::value('exhibition_id')));
     $properties = $wizard->getAllValues();
     $assetType = new Type("Asset Types", "edu.middlebury.concerto", "Exhibition", "Exhibition Assets are containers for Slideshows.");
     $asset->updateDisplayName($properties['namedescstep']['display_name']);
     $asset->updateDescription($properties['namedescstep']['description']);
     $assetId = $asset->getId();
     $this->_assetId = $assetId;
     // Update the effective/expiration dates
     if ($properties['datestep']['effective_date']) {
         $asset->updateEffectiveDate(DateAndTime::fromString($properties['datestep']['effective_date']));
     }
     if ($properties['datestep']['expiration_date']) {
         $asset->updateExpirationDate(DateAndTime::fromString($properties['datestep']['expiration_date']));
     }
     // Log the success or failure
     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("Modify Node", "Exhibition Modified");
         $item->addNodeId($asset->getId());
         $log->appendLogWithTypes($item, $formatType, $priorityType);
     }
     $harmoni->request->endNamespace();
     return TRUE;
 }
Exemplo n.º 30
0
 /**
  * Build the content for this action
  * 
  * @return void
  * @access public
  * @since 8/15/06
  */
 function buildContent()
 {
     $harmoni = Harmoni::instance();
     $idManager = Services::getService("Id");
     $repositoryManager = Services::getService("Repository");
     $repository = $repositoryManager->getRepository($idManager->getId("edu.middlebury.concerto.exhibition_repository"));
     $exhibitionId = $idManager->getId(RequestContext::value('exhibition_id'));
     $exhibition = $repository->getAsset($exhibitionId);
     $slideshowId = $idManager->getId(RequestContext::value('slideshow_id'));
     $slideshowAsset = $repository->getAsset($slideshowId);
     $setManager = Services::getService("Sets");
     $exhibitionSet = $setManager->getPersistentSet($exhibitionId);
     $oldPosition = $exhibitionSet->getPosition($slideshowId);
     $newPosition = RequestContext::value('new_position');
     // Out of range Error Condition
     if ($newPosition < 0 || $newPosition >= $exhibitionSet->count()) {
         // Log the error
         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", "Error", "Errors.");
             $item = new AgentNodeEntryItem("Reorder Slideshows Failed", "Out of range error: Slideshow in the " . $exhibition->getDisplayName() . " exhibition could not be moved from position {$oldPosition} to {$newPosition} (" . $exhibitionSet->count() . " items in the set).");
             $item->addNodeId($exhibition->getId());
             $log->appendLogWithTypes($item, $formatType, $priorityType);
         }
     } else {
         $exhibitionSet->moveToPosition($slideshowId, $newPosition);
         // 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("Reorder Slideshows", "Slideshows in the " . $exhibition->getDisplayName() . " exhibition have been reorderd.");
             $item->addNodeId($exhibition->getId());
             $log->appendLogWithTypes($item, $formatType, $priorityType);
         }
         // Remove any missing slideshows
         $slideshowsIdStrings = array();
         $slideshows = $exhibition->getAssets();
         while ($slideshows->hasNext()) {
             $slideshow = $slideshows->next();
             $slideshowId = $slideshow->getId();
             $slideshowsIdStrings[] = $slideshowId->getIdString();
         }
         $itemsToRemove = array();
         $exhibitionSet->reset();
         while ($exhibitionSet->hasNext()) {
             $itemId = $exhibitionSet->next();
             if (!in_array($itemId->getIdString(), $slideshowsIdStrings)) {
                 $itemsToRemove[] = $itemId;
             }
         }
         foreach ($itemsToRemove as $id) {
             $exhibitionSet->removeItem($id);
         }
     }
     RequestContext::locationHeader($harmoni->request->quickURL("exhibitions", "browse_exhibition", array("exhibition_id" => $exhibitionId->getIdString())));
 }