예제 #1
0
 function buildContent()
 {
     $harmoni = Harmoni::Instance();
     $basket = Basket::instance();
     $basket->removeAllItems();
     RequestContext::locationHeader($harmoni->request->quickURL("basket", "view"));
 }
예제 #2
0
 /**
  * Build the content for this action
  * 
  * @return boolean
  * @access public
  * @since 5/5/06
  */
 function execute()
 {
     $harmoni = Harmoni::Instance();
     $basket = Basket::instance();
     $basket->removeAllItems();
     print $basket->getSmallBasketHtml();
     exit;
 }
예제 #3
0
 /**
  * Return the heading text for this action, or an empty string.
  * 
  * @return string
  * @access public
  * @since 4/26/05
  */
 function getHeadingText()
 {
     $idManager = Services::getService("Id");
     $repositoryManager = Services::getService("Repository");
     $repository = $repositoryManager->getRepository($idManager->getId("edu.middlebury.concerto.exhibition_repository"));
     $harmoni = Harmoni::Instance();
     $harmoni->request->startNamespace("modify_exhibition");
     $asset = $repository->getAsset($idManager->getId(RequestContext::value('exhibition_id')));
     $harmoni->request->endNamespace();
     return _("Modifying the ") . " <em>" . $asset->getDisplayName() . "</em> " . _("Exhibition");
 }
예제 #4
0
 /**
  * Return the heading text for this action, or an empty string.
  * 
  * @return string
  * @access public
  * @since 6/08/05
  */
 function getHeadingText()
 {
     $harmoni = Harmoni::Instance();
     $idManager = Services::getService("Id");
     $rm = Services::getService("Repository");
     $harmoni->request->startNamespace("import");
     $repository = $rm->getRepository($idManager->getId($harmoni->request->get("collection_id")));
     $asset = $repository->getAsset($idManager->getId($harmoni->request->get("asset_id")));
     $harmoni->request->endNamespace();
     return _("Import data below the <em>" . $asset->getDisplayName() . "</em> Asset in the <em>" . $repository->getDisplayName() . "</em> Collection");
 }
 /**
  * Check Authorizations
  * 
  * @return boolean
  * @access public
  * @since 4/26/05
  */
 function isAuthorizedToExecute()
 {
     // Check that the user can create an asset here.
     $authZ = Services::getService("AuthZ");
     $idManager = Services::getService("Id");
     $harmoni = Harmoni::Instance();
     // 		$harmoni->request->startNamespace("modify_slideshow");
     $return = $authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.view"), $idManager->getId(RequestContext::value('slideshow_id')));
     // 		$harmoni->request->endNamespace();
     return $return;
 }
예제 #6
0
 /**
  * Build the content for this action
  * 
  * @return void
  * @access public
  * @since 4/26/05
  */
 function buildContent()
 {
     $harmoni = Harmoni::Instance();
     $harmoni->request->startNamespace("modify_slideshow");
     $harmoni->request->passthrough("slideshow_id");
     $harmoni->request->passthrough('collection_id');
     $harmoni->request->passthrough('asset_id');
     $actionRows = $this->getActionRows();
     // 		$idManager = Services::getService("Id");
     // 		$slideshowAssetId =$idManager->getId(
     // 			RequestContext::value('slideshow_id'));
     $cacheName = 'modify_slideshow_wizard_' . RequestContext::value('slideshow_id');
     $this->runWizard($cacheName, $actionRows);
     $harmoni->request->endNamespace();
 }
예제 #7
0
 /**
  * Answer the root assets in the current repository
  * 
  * @return object Iterator
  * @access public
  * @since 4/2/07
  */
 function getRootAssets()
 {
     $harmoni = Harmoni::Instance();
     $idManager = Services::getService("Id");
     $rm = Services::getService("Repository");
     $harmoni->request->startNamespace("import");
     $repository = $rm->getRepository($idManager->getId($harmoni->request->get("collection_id")));
     $harmoni->request->endNamespace();
     $criteria = NULL;
     $searchProperties = new HarmoniProperties(HarmoniType::fromString("repository::harmoni::order"));
     $searchProperties->addProperty("order", $orderBy = 'DisplayName');
     $searchProperties->addProperty("direction", $direction = 'ASC');
     unset($orderBy, $direction);
     $assets = $repository->getAssetsBySearch($criteria, new HarmoniType("Repository", "edu.middlebury.harmoni", "RootAssets", ""), $searchProperties);
     return $assets;
 }
예제 #8
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();
     $idManager = Services::getService("Id");
     $wizard = $this->getWizard($cacheName);
     $properties = $wizard->getAllValues();
     $repositoryId = $idManager->getId(RequestContext::value('collection_id'));
     $exporter = XMLRepositoryExporter::withCompression($properties['compression']);
     $dir = $exporter->export($repositoryId);
     $this->_archiveFile = $exporter->compressWithStatus();
     $this->_archiveFileKey = str_replace('.', '', basename($this->_archiveFile, $properties['compression']));
     // 		printpre($this->_archiveFile);
     // For security, only files listed in the following array will be allowed
     // to be downloaded.
     if (!isset($_SESSION['EXPORTED_FILES'])) {
         $_SESSION['EXPORTED_FILES'] = array();
     }
     $_SESSION['EXPORTED_FILES'][$this->_archiveFileKey] = array('file' => $this->_archiveFile, 'name' => basename($properties['filepath'] . $properties['compression']), 'mime' => 'application/x-gzip');
     return TRUE;
 }
예제 #9
0
 /**
  * Build the content for this action
  * 
  * @return void
  * @access public
  * @since 9/27/05
  */
 function buildContent()
 {
     $harmoni = Harmoni::Instance();
     $centerPane = $this->getActionRows();
     $authN = Services::getService("AuthN");
     $authTypes = $authN->getAuthenticationTypes();
     $uniqueString = "";
     while ($authTypes->hasNext()) {
         $authType = $authTypes->next();
         $uniqueString .= "_" . $authN->getUserId($authType);
     }
     $cacheName = 'export_asset_wizard' . $uniqueString;
     $this->runWizard($cacheName, $centerPane);
 }
 /**
  * Answer the URL for the file 
  * 
  * @param string $idString of the 'associated file'
  * @param string $fname the 'FILE_NAME'
  * @return string
  * @access public
  * @since 1/26/06
  */
 public final function getFileURL($idString, $fname)
 {
     $harmoni = Harmoni::Instance();
     $idManager = Services::getService("Id");
     $repositoryId = $idManager->getId("edu.middlebury.segue.sites_repository");
     $assetId = $this->_asset->getId();
     $harmoni->request->StartNamespace('polyphony-repository');
     $url = $harmoni->request->quickURL("repository", "viewfile", array("repository_id" => $repositoryId->getIdString(), "asset_id" => $assetId->getIdString(), "record_id" => $idString, "file_name" => $fname));
     $harmoni->request->endNamespace();
     return $url;
 }
 /**
  * Exporter of a list of assets, for selective asset exporting
  * 
  * @param array $idList a list of asset id's
  * @return string $file is the directory where all the data is written
  * @access public
  * @since 12/13/05
  */
 function exportList($idList)
 {
     $harmoni = Harmoni::Instance();
     $repositoryManager = Services::getService("Repository");
     $listOfRS = array();
     $idListRS = array();
     $this->_fileDir = $this->_tmpDir;
     // prepare all the things we need to export
     foreach ($idList as $assetId) {
         $asset = $repositoryManager->getAsset($assetId);
         // build the list of recordstructures
         $this->buildRSList($asset, $idListRS, $listOfRS);
     }
     // get the xml file ready
     $this->setupXML($this->_fileDir);
     fwrite($this->_xml, "<repository>\n");
     // export the necessary recordstructures
     foreach ($listOfRS as $rS) {
         $exporter = new XMLRecordStructureExporter($this->_xml);
         $exporter->export($rS);
         unset($exporter);
     }
     // clean up after the recordstructures
     unset($listOfRS, $idListRS);
     // export the assets
     $this->_status = new StatusStars(_("Exporting all Assets in the Collection"));
     $this->_status->initializeStatistics(count($idList), 100);
     foreach ($idList as $assetId) {
         $asset = $repositoryManager->getAsset($assetId);
         $this->export($asset);
         $this->_status->updateStatistics();
     }
     fwrite($this->_xml, "</repository>");
     fclose($this->_xml);
     return $this->_tmpDir;
 }
예제 #12
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 10/24/05
  */
 function saveWizard($cacheName)
 {
     $harmoni = Harmoni::Instance();
     $authN = Services::getService("AuthN");
     $tokenM = Services::getService("AgentTokenMapping");
     $wizard = $this->getWizard($cacheName);
     $properties = $wizard->getAllValues();
     $type = $this->getMethod()->getType();
     $id = $authN->getUserId($type);
     $it = $tokenM->getMappingsForAgentId($id);
     while ($it->hasNext()) {
         $mapping = $it->next();
         if ($mapping->getAuthenticationType() == $type) {
             $tokens = $mapping->getTokens();
         }
     }
     if (isset($tokens)) {
         $method = $this->getMethod();
         $uname = $tokens->getUsername();
         // Validate the old password
         $oldTokens = $method->createTokens(array('username' => $uname, 'password' => $properties['old_password']));
         if (!$method->authenticateTokens($oldTokens)) {
             $error = "Invalid old password";
             $localizedError = dgettext("polyphony", "Invalid old password, please try again.") . "\n<br/>";
         } else {
             if ($properties['new_password'] != '' && $properties['new_password'] == $properties['n_p_again']) {
                 // Log the action
                 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.");
                     $item = new AgentNodeEntryItem("Modify Agent", "Password changed for:\n<br/>&nbsp; &nbsp; &nbsp;" . htmlspecialchars($uname) . "\n<br/>&nbsp; &nbsp; &nbsp;" . htmlspecialchars($type->getKeyword()));
                     $item->addAgentId($id);
                     $log->appendLogWithTypes($item, $formatType, $priorityType);
                 }
                 $t_array = array("username" => $uname, "password" => $properties['new_password']);
                 $authNTokens = $method->createTokens($t_array);
                 // Add it to the system and login with new password
                 if ($method->supportsTokenUpdates()) {
                     $method->updateTokens($tokens, $authNTokens);
                     $harmoni->request->startNamespace("harmoni-authentication");
                     $harmoni->request->set("username", $uname);
                     $harmoni->request->set("password", $properties['new_password']);
                     $harmoni->request->endNamespace();
                     $authN->authenticateUser($type);
                     return TRUE;
                 }
             } else {
                 $error = "Invalid new password";
                 $localizedError = dgettext("polyphony", "Invalid new password, please try again.") . "\n<br/>";
             }
         }
     }
     if (isset($error)) {
         // Log the action
         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", "Error", "Normal events.");
             $item = new AgentNodeEntryItem("Modify Agent", "Password change error:\n<br/>&nbsp; &nbsp; &nbsp;" . htmlspecialchars($error) . "\n<br/>for:\n<br/>&nbsp; &nbsp; &nbsp;" . $uname . "\n<br/>&nbsp; &nbsp; &nbsp;" . htmlspecialchars($type->getKeyword()));
             $item->addAgentId($id);
             $log->appendLogWithTypes($item, $formatType, $priorityType);
         }
         $this->closeWizard($cacheName);
         RequestContext::locationHeader($harmoni->request->quickURL("user", "change_password", array("error" => $localizedError)));
     }
 }