예제 #1
0
 /**
  * Execute the Action
  * 
  * @param object Harmoni $harmoni
  * @return mixed
  * @access public
  * @since 4/3/06
  */
 function execute()
 {
     // redirect
     $harmoni = Harmoni::instance();
     $newUrl = $harmoni->request->mkURLWithPassthrough('view', 'html');
     RequestContext::sendTo($newUrl->write());
 }
예제 #2
0
 /**
  * Execute
  * 
  * @return mixed
  * @access public
  * @since 4/3/08
  */
 public function execute()
 {
     // Add in RequestContext data from URLs that were converted to Segue2 format,
     // but retain Segue1 parameters
     $get = array('action' => 'site');
     $segue1Identifiers = array('site', 'section', 'page', 'story');
     foreach ($segue1Identifiers as $key) {
         if (!isset($get[$key]) && RequestContext::value($key)) {
             $get[$key] = RequestContext::value($key);
         }
     }
     $resolver = Segue1UrlResolver::instance();
     $resolver->resolveGetArray($get);
     // If the resolver didn't forward us, try just going to the site listed.
     if (isset($get['site'])) {
         RequestContext::sendTo(MYURL . "/sites/" . $get['site']);
     } else {
         throw new NullArgumentException("Could no resolve URL, no site specified.");
     }
 }
예제 #3
0
 /**
  * Execture this action
  * 
  * @return void
  * @access public
  * @since 3/18/08
  */
 public function execute()
 {
     $harmoni = Harmoni::instance();
     if (RequestContext::value('user_interface')) {
         $this->setUiModule(RequestContext::value('user_interface'));
     }
     $returnUrl = rawurldecode(RequestContext::value('returnUrl'));
     $oldModule = $harmoni->request->getModuleFromUrl($returnUrl);
     $oldAction = $harmoni->request->getActionFromUrl($returnUrl);
     $newModule = RequestContext::value('user_interface');
     if ($oldModule != $newModule && ($oldModule != "view" && $oldModule != "portal")) {
         if ($oldAction == "arrangeview" || $oldAction == "headerfooter") {
             $returnUrl = str_replace($oldAction, "editview", $returnUrl);
         } else {
             if ($oldModule == "tags") {
                 $returnUrl = str_replace($oldAction, "view", $returnUrl);
             }
         }
         $returnUrl = str_replace($oldModule, $newModule, $returnUrl);
     }
     RequestContext::sendTo($returnUrl);
 }
예제 #4
0
 /**
  * Execute this action.
  * 
  * @param object Harmoni $harmoni
  * @return mixed
  * @access public
  * @since 4/25/05
  */
 function execute()
 {
     $harmoni = Harmoni::instance();
     unset($_SESSION['polyphony/login_failed']);
     // If we are using only cookies, but cookies aren't enabled
     // (and hence not set), print an error message.
     if ($harmoni->config->get("sessionUseOnlyCookies") && !isset($_COOKIE[$harmoni->config->get("sessionName")])) {
         RequestContext::sendTo($harmoni->request->quickURL('auth', 'cookies_required'));
     }
     $isAuthenticated = FALSE;
     $authN = Services::getService("AuthN");
     // authenticate.
     $authTypes = $authN->getAuthenticationTypes();
     while ($authTypes->hasNext()) {
         $authType = $authTypes->next();
         // Try authenticating with this type
         $authN->authenticateUser($authType);
         // If they are authenticated, quit
         if ($authN->isUserAuthenticated($authType)) {
             $isAuthenticated = TRUE;
             break;
         }
     }
     if ($isAuthenticated) {
         // Send us back to where we want to be if we succeeded
         // (usually where we were)
         $harmoni->history->goBack("polyphony/display_login");
     } else {
         $_SESSION['polyphony/login_failed'] = true;
         // send us to where we want to be if we failed
         // (possibly some form of authentication viewer)
         $harmoni->history->goBack("polyphony/login_fail");
     }
     $null = null;
     return $null;
 }
예제 #5
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'));
 }
예제 #6
0
 /**
  * Cancel from this Wizard. This will tear down the wizard and return us
  * to our returnUrl as specified by {@link getReturnUrl()}.
  * 
  * @param string $cacheName
  * @return void
  * @access public
  * @since 4/28/05
  */
 function cancelWizard($cacheName)
 {
     $url = $this->getReturnUrl();
     $this->closeWizard($cacheName);
     RequestContext::sendTo($url);
 }
예제 #7
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));
 }
 /**
  * Sends the browser to the last URL marked with {@link BrowseHistoryManager::markReturnURL markReturnURL()}.
  * @param string $operation The name of the operation under which the URL
  * is stored. 
  * @return void
  * @access public
  */
 function goBack($operation)
 {
     RequestContext::sendTo($this->getReturnURL($operation));
     exit;
 }
예제 #9
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
     $courseManager = Services::getService("CourseManagement");
     $idManager = Services::getService("Id");
     $courseManagementId = $idManager->getId("edu.middlebury.coursemanagement");
     // First, verify that we chose a parent that we can add children to.
     $authZ = Services::getService("AuthZ");
     if ($authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.add_children"), $courseManagementId)) {
         $values = $wizard->getAllValues();
         printpre($values);
         $type = $courseManager->_indexToType($values['namedescstep']['termtype'], 'term');
         $schedule = null;
         $term = $courseManager->createTerm($type, $schedule);
         $term->updateDisplayName($values['namedescstep']['displayname']);
         RequestContext::sendTo($this->getReturnUrl());
         exit;
         return TRUE;
     } else {
         return FALSE;
     }
 }
예제 #10
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
     $courseManager = Services::getService("CourseManagement");
     $idManager = Services::getService("Id");
     $courseManagementId = $idManager->getId("edu.middlebury.coursemanagement");
     // First, verify that we chose a parent that we can add children to.
     $authZ = Services::getService("AuthZ");
     if ($authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.add_children"), $courseManagementId)) {
         $values = $wizard->getAllValues();
         printpre($values);
         $type = new Type("CourseManagement", "edu.middlebury", $values['namedescstep']['keyword'], $values['namedescstep']['description']);
         $courseManager->_typeToIndex($values['namedescstep']['typetype'], $type);
         RequestContext::sendTo($this->getReturnUrl());
         exit;
         return TRUE;
     } else {
         return FALSE;
     }
 }
예제 #11
0
 /**
  * Execute
  * 
  * @return mixed
  * @access public
  * @since 2/4/08
  */
 public function buildContent()
 {
     try {
         $status = new StatusStars(_("Preparing Site Import"));
         $status->initializeStatistics(4);
         $destPath = DATAPORT_TMP_DIR . "/Segue1Conversion-" . $this->getDestSlotName();
         mkdir($destPath);
         $destFilePath = $destPath . '/media';
         mkdir($destFilePath);
         $status->updateStatistics();
         // Download and convert the site
         $doc = $this->convertFrom1To2($destFilePath, 'media');
         // 			printpre(htmlentities($doc->saveXMLWithWhitespace()));
         // 			throw new Exception('test');
         $doc->schemaValidateWithException(MYDIR . "/doc/raw/dtds/segue2-site.xsd");
         $status->updateStatistics();
         // Debug output
         // 			$outputDoc2 = new Harmoni_DOMDocument;
         // 			$outputDoc2->loadXML($doc->saveXMLWithWhitespace());
         // 			printpre(htmlentities($outputDoc2->saveXML()));
         // 			throw new Exception('test');
         // Add the user as the owner
         $authN = Services::getService("AuthN");
         $slotMgr = SlotManager::instance();
         $slot = $slotMgr->getSlotByShortname($this->getDestSlotName());
         $slot->addOwner($authN->getFirstUserId());
         // Make the slot personal if it matches the personal naming scheme.
         $userName = PersonalSlot::getPersonalShortname($authN->getFirstUserId());
         if ($slot->getType() != Slot::personal && preg_match('/^' . $userName . '(-.+)?$/', $this->getDestSlotName())) {
             $slot = $slotMgr->convertSlotToType($slot, Slot::personal);
         }
         $status->updateStatistics();
         // Import the converted site
         $director = SiteDispatcher::getSiteDirector();
         $importer = new Segue1MappingImportSiteVisitor($doc, $destPath, $director);
         $status->updateStatistics();
         $importer->enableStatusOutput();
         $importer->makeUserSiteAdministrator();
         $importer->enableRoleImport();
         $importer->setOrigenSlotname($this->getSourceSlotName());
         $importer->setDestinationSlotname($this->getDestSlotName());
         $site = $importer->importAtSlot($this->getDestSlotName());
         // Set the media quota if it is bigger than our default
         $quota = $importer->getMediaQuota();
         if ($quota > $slot->getMediaQuota()->value()) {
             $slot->setMediaQuota(ByteSize::withValue($quota));
         }
         // Delete the output directory
         try {
             if (file_exists($destPath)) {
                 $this->deleteRecursive($destPath);
             }
         } catch (Exception $deleteException) {
             print "\n<div>\n\t";
             print $deleteException->getMessage();
             print "\n</div>";
         }
         /*********************************************************
          * 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, '" . $this->getDestSlotName() . "', from Segue 1 placeholder, '" . $this->getSourceSlotName() . "'.");
             $item->addNodeId($site->getQualifierId());
             $log->appendLogWithTypes($item, $formatType, $priorityType);
         }
         $harmoni = Harmoni::instance();
         RequestContext::sendTo($harmoni->request->quickURL('dataport', 'choose_site'));
     } catch (Exception $importException) {
         // Delete the output directory
         try {
             if (file_exists($destPath)) {
                 $this->deleteRecursive($destPath);
             }
         } catch (Exception $deleteException) {
             print "\n<div>\n\t";
             print $deleteException->getMessage();
             print "\n</div>";
         }
         /*********************************************************
          * 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, '" . $this->getDestSlotName() . "', from Segue 1 placeholder, '" . $this->getSourceSlotName() . "'.");
             $log->appendLogWithTypes($item, $formatType, $priorityType);
         }
         throw $importException;
     }
 }
 /**
  * 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'))));
 }
예제 #13
0
 /**
  * Execute the Action
  * 
  * @param object Harmoni $harmoni
  * @return mixed
  * @access public
  * @since 4/3/06
  */
 function execute()
 {
     $harmoni = Harmoni::instance();
     /*********************************************************
      * Split sites based on their location-category
      *********************************************************/
     try {
         $rootSiteComponent = SiteDispatcher::getCurrentRootNode();
     } catch (UnknownIdException $e) {
         // For non-existant node exceptions, redirect to the site root.
         if ($e->getCode() == 289743 && RequestContext::value('node') && RequestContext::value('site')) {
             $url = SiteDispatcher::quickURL($harmoni->request->getRequestedModule(), $harmoni->request->getRequestedAction(), array('site' => RequestContext::value('site')));
             $errorPrinter = SegueErrorPrinter::instance();
             $message = "<strong>" . _("The node you requested does not exist or has been deleted. Click %1 to go to the %2.") . "</strong>";
             $message = str_replace('%1', "<a href='" . $url . "'>" . _("here") . "</a>", $message);
             $message = str_replace('%2', "<a href='" . $url . "'>" . _("main page of the site") . "</a>", $message);
             $errorPrinter->handExceptionWithRedirect($e, 404, $message);
             exit;
         } else {
             if (RequestContext::value('site')) {
                 $slotMgr = SlotManager::instance();
                 $slot = $slotMgr->getSlotByShortname(RequestContext::value('site'));
                 // Redirect to the new URL if this site has been migrated
                 if ($redirectUrl = $slot->getMigratedRedirectUrl()) {
                     header("HTTP/1.1 301 Moved Permanently");
                     header('Location: ' . $redirectUrl);
                     exit;
                 }
                 throw $e;
             } else {
                 throw $e;
             }
         }
     }
     try {
         $slot = $rootSiteComponent->getSlot();
         // Redirect to the new URL if this site has been migrated
         if ($redirectUrl = $slot->getMigratedRedirectUrl()) {
             header("HTTP/1.1 301 Moved Permanently");
             header('Location: ' . $redirectUrl);
             exit;
         }
         if (SiteDispatcher::getBaseUrlForSlot($slot) != MYURL) {
             RequestContext::sendTo(SiteDispatcher::quickUrl());
         } else {
             /*********************************************************
              * Ensure that the requested node is a member of the site
              * listed in the URL.
              *********************************************************/
             if (!RequestContext::value('site') || RequestContext::value('site') != $slot->getShortname()) {
                 /*********************************************************
                  * This is added in Segue 2.1.0 for testing that all 
                  * Segue-generated links are producing the correct URLs.
                  * This should be removed here and in
                  *		segue/config/debug_default.conf.php
                  * after testing is complete.
                  *********************************************************/
                 if (defined('DEBUG_LOG_WRONG_SITE') && DEBUG_LOG_WRONG_SITE == true && isset($_SERVER['HTTP_REFERER']) && preg_match('#^' . str_replace('.', '\\.', MYURL) . '#', $_SERVER['HTTP_REFERER'])) {
                     HarmoniErrorHandler::logException(new WrongSiteException("Expecting site '" . $slot->getShortname() . "', saw '" . RequestContext::value('site') . "' in the url. Links to wrong sites should not be generated by Segue. If the link on the referrer page was written by Segue (and not a user), submit a bug report. Sending to " . SiteDispatcher::quickUrl()));
                 }
                 RequestContext::sendTo(SiteDispatcher::quickUrl());
             }
         }
         // Mark the site as viewed
         Segue_AccessLog::instance()->touch($slot->getShortname());
     } catch (UnknownIdException $e) {
         // No slot for the site....
     }
     $authZ = Services::getService("AuthZ");
     $recordManager = Services::getService("RecordManager");
     //
     // Begin Optimizations
     //
     // The code below queues up authorizations for all visible nodes,
     // as well as pre-fetches all of the RecordSets that have data
     // specific to the visible nodes.
     $visibleComponents = SiteDispatcher::getSiteDirector()->getVisibleComponents(SiteDispatcher::getCurrentNodeId());
     $preCacheIds = array();
     foreach ($visibleComponents as $component) {
         $id = $component->getQualifierId();
         $authZ->getIsAuthorizedCache()->queueId($id);
         $preCacheIds[] = $id->getIdString();
     }
     $recordManager->preCacheRecordsFromRecordSetIDs($preCacheIds);
     //
     // End Optimizations
     //
     $mainScreen = new Container(new YLayout(), BLOCK, BACKGROUND_BLOCK);
     $allWrapper = $this->addHeaderControls($mainScreen);
     $this->addSiteContent($mainScreen);
     $this->addFooterControls($allWrapper);
     if (defined('SEGUE_SITE_FOOTER')) {
         $allWrapper->add(new UnstyledBlock(SEGUE_SITE_FOOTER), "100%", null, CENTER, BOTTOM);
     }
     $this->mainScreen = $mainScreen;
     return $allWrapper;
 }
예제 #14
0
 /**
  * Resolve an array of GET parameters
  * 
  * @param array $get
  * @return void
  * @access public
  * @since 3/20/08
  */
 public function resolveGetArray(array $get)
 {
     $harmoni = Harmoni::instance();
     if (!count($get)) {
         throw new Exception("Could not resolve Segue 1 site, no parameters specified.");
     }
     // Send to an imported version if it exists
     $segue1Identifiers = array('story', 'page', 'section', 'site');
     foreach ($segue1Identifiers as $identifier) {
         if (isset($get[$identifier]) && $get[$identifier]) {
             try {
                 $newId = $this->getSegue2IdForOld($identifier, $get[$identifier]);
                 RequestContext::sendTo($harmoni->request->quickURL('view', 'html', array('node' => $newId)));
             } catch (UnknownIdException $e) {
             }
         }
     }
     // Send to a Segue 2 site with the same site-name if that exists.
     if (isset($get['site']) && $get['site']) {
         $slotMgr = SlotManager::instance();
         $slot = $slotMgr->getSlotByShortname($get['site']);
         if ($slot->siteExists()) {
             RequestContext::sendTo($harmoni->request->quickURL('view', 'html', array('site' => $get['site'])));
         }
     }
     // Send to the old Segue 1 instance if it is configured.
     if (defined('DATAPORT_SEGUE1_URL')) {
         // If segue 1 doesn't know about the site, just return and show segue2-specific
         // errors
         if (!$this->isGetValidInSegue1($get)) {
             return false;
         }
         // If segue 1 knows about
         $segue1Url = rtrim(DATAPORT_SEGUE1_URL, '/') . '/index.php?';
         foreach ($get as $key => $value) {
             $segue1Url .= '&' . $key . '=' . rawurlencode($value);
         }
         RequestContext::sendTo($segue1Url);
     }
 }
예제 #15
0
 /**
  * Execute the Action
  * 
  * @param object Harmoni $harmoni
  * @return mixed
  * @access public
  * @since 4/3/06
  */
 function execute()
 {
     // redirect
     RequestContext::sendTo(SiteDispatcher::quickURL('view', 'html'));
 }