/** * Build the content for this action * * @return boolean * @access public * @since 4/26/05 */ function buildContent() { $actionRows = $this->getActionRows(); $harmoni = Harmoni::instance(); ob_start(); CollectionsPrinter::printFunctionLinks(); $layout = new Block(ob_get_contents(), STANDARD_BLOCK); ob_end_clean(); $actionRows->add($layout, null, null, CENTER, CENTER); $type = HarmoniType::fromString(urldecode(RequestContext::value('type'))); $repositoryManager = Services::getService("Repository"); // Get the Repositories $allRepositories = $repositoryManager->getRepositoriesByType($type); // put the repositories into an array and order them. // @todo, do authorization checking $repositoryArray = array(); while ($allRepositories->hasNext()) { $repository = $allRepositories->next(); $repositoryArray[$repository->getDisplayName()] = $repository; } ksort($repositoryArray); // print the Results $resultPrinter = new ArrayResultPrinter($repositoryArray, 2, 20, "printrepositoryShort", $harmoni); $resultPrinter->addLinksStyleProperty(new MarginTopSP("10px")); $resultLayout = $resultPrinter->getLayout(); $actionRows->add($resultLayout, null, null, CENTER, CENTER); }
/** * Answer the comment object * * @return object * @access public * @since 7/11/07 */ function getComment() { $idManager = Services::getService("Id"); $commentId = $idManager->getId(RequestContext::value('comment_id')); $commentManager = CommentManager::instance(); return $commentManager->getComment($commentId); }
/** * Answer the Tag for this action * * @return object Tag * @access public * @since 12/8/06 */ function getTag() { if (!isset($this->_tag)) { $this->_tag = new Tag(RequestContext::value('tag')); } return $this->_tag; }
/** * Build the content for this action * * @return boolean * @access public * @since 4/26/05 */ function buildContent() { $actionRows = $this->getActionRows(); $harmoni = Harmoni::instance(); $repository = $this->getRepository(); // get the search type. $searchType = HarmoniType::fromString(urldecode(RequestContext::value('search_type'))); // Get the Search criteria $searchModules = Services::getService("RepositorySearchModules"); $searchCriteria = $searchModules->getSearchCriteria($repository, $searchType); // function links ob_start(); print _("Collection") . ": "; RepositoryPrinter::printRepositoryFunctionLinks($harmoni, $repository); $layout = new Block(ob_get_contents(), 2); ob_end_clean(); $actionRows->add($layout, null, null, CENTER, CENTER); ob_start(); print "<p>"; print _("Some <em>Collections</em>, <em>Exhibitions</em>, <em>Assets</em>, and <em>Slide-Shows</em> may be restricted to certain users or groups of users. Log in above to ensure your greatest access to all parts of the system."); print "</p>"; $introText = new Block(ob_get_contents(), 2); ob_end_clean(); $actionRows->add($introText, null, null, CENTER, CENTER); //*********************************** // Get the assets to display //*********************************** $assets = $repository->getAssetsBySearch($searchCriteria, $searchType, new HarmoniProperties(new Type('Repository', 'edu.middlebury', 'null'))); //*********************************** // print the results //*********************************** $resultPrinter = new IteratorResultPrinter($assets, 2, 6, "printAssetShort", $harmoni); $resultLayout = $resultPrinter->getLayout(); $actionRows->add($resultLayout, "100%", null, LEFT, CENTER); }
/** * Tells the wizard component to update itself - this may include getting * form post data or validation - whatever this particular component wants to * do every pageload. * @param string $fieldName The field name to use when outputting form data or * similar parameters/information. * @access public * @return boolean - TRUE if everything is OK */ function update($fieldName) { $val = RequestContext::value($fieldName); if ($val !== null && (!$this->_startingDisplay || $val != $this->_startingDisplay)) { $string = HtmlString::fromString($val); $string->cleanXSS(); $this->_value = $string->asString(); if (trim($this->_value) != trim($val)) { $this->_origErrorText = $this->getErrorText(); $this->setErrorText(dgettext('polyphony', "The value you entered has been reformatted to meet XHTML validity standards.")); // Add both error text if validation failed as well. if (!$this->validate()) { $this->setErrorText($this->getErrorText() . " " . $this->_origErrorText); } $this->_showError = true; // Add a dummy rule if needed. if (!$this->getErrorRule()) { $this->setErrorRule(new WECRegex('.*')); } } else { // Reset the original error text. if (isset($this->_origErrorText)) { $this->setErrorText($this->_origErrorText); } } } return $this->validate(); }
/** * Execute * * @return void * @access public * @since 3/21/08 */ public function buildContent() { $rows = $this->getActionRows(); $message = _("The file that you requested, '%1', does not exist in this site."); $message = str_replace('%1', RequestContext::value('filename'), $message); $rows->add(new Block($message, HIGHLIT_BLOCK)); }
/** * 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; }
/** * Execute this action. * * @param object Harmoni $harmoni * @return mixed * @access public * @since 4/25/05 */ function execute() { if (!$this->isAuthorizedToExecute()) { throw new PermissionDeniedException(); } $harmoni = Harmoni::instance(); $harmoni->request->startNamespace("harmoni-authentication"); $query = RequestContext::value("user"); $harmoni->request->endNamespace(); header('Content-type: text/plain'); if (!strlen($query)) { exit; } $authNMethodManager = Services::getService("AuthNMethods"); $types = $authNMethodManager->getAuthNTypes(); while ($types->hasNext()) { $type = $types->next(); $method = $authNMethodManager->getAuthNMethodForType($type); $foundTokens = $method->getTokensBySearch($query); while ($foundTokens->hasNext()) { $tokens = $foundTokens->next(); print $method->getDisplayNameForTokens($tokens) . " (" . $type->getKeyword() . ")|type=\"" . $type->asString() . "\" id=\"" . $tokens->getIdentifier() . "\"\n"; } } exit; }
/** * Execute this action. * * @return void * @access public * @since 08/11/08 */ public function execute() { $this->start(); try { if (!$this->isAuthorizedToExecute()) { $this->error(_("You are not authorized to search."), "PermissionDenied"); } if (!isset($_SESSION['portal_searches'])) { $_SESSION['portal_searches'] = array(); } $folder = new SearchPortalFolder(RequestContext::value('query')); $usingOld = false; foreach ($_SESSION['portal_searches'] as $searchFolder) { if ($searchFolder->getIdString() == $folder->getIdString() && $folder->getAgentId()->isEqual($searchFolder->getAgentId())) { $folder = $searchFolder; $usingOld = true; break; } } // run the search if needed. if (!$usingOld) { $folder->search(); } $_SESSION['portal_searches'][] = $folder; print "\n\t<search id=\"" . $folder->getIdString() . "\"/>"; } catch (Exception $e) { $this->error($e->getMessage(), get_class($e)); } $this->end(); }
/** * Tells the wizard component to update itself - this may include getting * form post data or validation - whatever this particular component wants to * do every pageload. * * @param string $fieldName The field name to use when outputting form data or * similar parameters/information. * @access public * @return boolean - TRUE if everything is OK * @since 12/12/07 */ public function update($fieldName) { // Update the list with any subtractions $removeId = RequestContext::value($fieldName . "_remove"); if ($removeId) { foreach ($this->list as $key => $result) { if ($removeId == $result->getIdString()) { $this->removeFromList($key); break; } } } // Update the list with any additions $addId = RequestContext::value($fieldName . "_add"); if ($addId) { foreach ($this->searchResults as $result) { if ($addId == $result->getIdString()) { $this->addToList($result); break; } } } // update the search field parent::update($fieldName); }
/** * Execute * * @return void * @access public * @since 3/26/08 */ public function execute() { if (!$this->isAuthorizedToExecute()) { throw new PermissionDeniedException('This command can only be run by admins or from the command-line.'); } header("Content-Type: text/plain"); if (RequestContext::value('help') || RequestContext::value('h') || RequestContext::value('?')) { throw new HelpRequestedException("Usage:\n\t" . $_SERVER['argv'][0] . " [-h|--help] [-t|--test]\n\t\n\t-h,--help Print out this help text.\n\t-t,--test Run in test mode. Equivalent to adding `define('MIGRATION_REMINDER_EMAIL_TEST_ONLY', true);` to the config.\n"); } if (RequestContext::value('t') || RequestContext::value('test')) { if (defined('MIGRATION_REMINDER_EMAIL_TEST_ONLY') && !MIGRATION_REMINDER_EMAIL_TEST_ONLY) { throw new ConfigurationErrorException("-t or --test was specified, but the configuration has set MIGRATION_REMINDER_EMAIL_TEST_ONLY to false.\nDo not specify a value for MIGRATION_REMINDER_EMAIL_TEST_ONLY in the configuration if you wish to\nbe able to switch between test mode and real mode with -t/--test."); } define('MIGRATION_REMINDER_EMAIL_TEST_ONLY', true); } while (ob_get_level()) { ob_end_flush(); } flush(); if (!defined('MIGRATION_REMINDER_EMAIL_TEST_ONLY')) { define('MIGRATION_REMINDER_EMAIL_TEST_ONLY', false); } if (MIGRATION_REMINDER_EMAIL_TEST_ONLY) { print "In test mode. Email will be sent to " . MIGRATION_REMINDER_EMAIL_TEST_RECIPIENT . " rather than real recipients.\n"; } else { print "Site reminders will be sent to real recipients.\n"; } $this->buildUserSiteList(); $this->emailUsers(); exit; }
/** * Execute * * @return void * @access public * @since 7/31/08 */ public function execute() { try { if (!RequestContext::value('id')) { throw new InvalidArgumentException("Id is expected."); } $selection = Segue_Selection::instance(); $director = SiteDispatcher::getSiteDirector(); $component = $director->getSiteComponentById(RequestContext::value('id')); if ($selection->isSiteComponentInSet($component)) { $selection->removeSiteComponent($component); } $this->start(); $selection->reset(); while ($selection->hasNext()) { $siteComponent = $selection->nextSiteComponent(); print "\n\t<siteComponent type='" . $siteComponent->getComponentClass() . "' "; if (method_exists($siteComponent, 'isSection')) { if ($siteComponent->isSection()) { print "navType='Section' "; } else { print "navType='Page' "; } } print "id='" . $siteComponent->getId() . "' "; print "displayName=\"" . str_replace('"', '"', preg_replace('/\\s+/', ' ', strip_tags($siteComponent->getDisplayName()))) . "\" "; print "/>"; } $this->end(); } catch (Exception $e) { HarmoniErrorHandler::logException($e); $this->error($e->getMessage(), get_class($e)); } }
/** * Execute this action. * * @return mixed * @access public * @since 12/13/06 */ function execute() { switch (RequestContext::value('package')) { case 'harmoni': $currentPackage = 'harmoni'; $file = HARMONI_BASE . "docs/changelog.html"; $source = file_get_contents($file); break; case 'polyphony': $currentPackage = 'polyphony'; $file = POLYPHONY . "/docs/changelog.html"; $source = file_get_contents($file); break; case 'viewer': $currentPackage = 'viewer'; $file = VIEWER_URL . "/README.txt"; $source = "<html>\n\t<head>\n\t\t<title>Viewer Changelog</title>\n\t</head>\n\t<body>\n\t\t<pre>" . htmlentities(file_get_contents($file)) . "</pre>\n\t</body>\n</html>\n"; break; default: $currentPackage = 'concerto'; $file = MYDIR . "/doc/changelog.html"; $source = file_get_contents($file); break; } $menu = $this->generateMenu($currentPackage); // insert the menu into the file print str_replace('<body>', '<body>' . $menu, $source); exit; }
/** * Tells the wizard component to update itself - this may include getting * form post data or validation - whatever this particular component wants to * do every pageload. * @param string $fieldName The field name to use when outputting form data or * similar parameters/information. * @access public * @return boolean - TRUE if everything is OK */ function update($fieldName) { $val = RequestContext::value($fieldName); if ($val !== false && $val !== null) { $this->_value = $val; } }
function execute() { $harmoni = Harmoni::instance(); // Get services $idManager = Services::getService("Id"); $authZ = Services::getService("AuthZ"); $harmoni->request->startNamespace("polyphony-authorizations"); // Get info passed to this action via the URL $operation = RequestContext::value("operation"); $functionIdString = RequestContext::value("functionId"); $qualifierIdString = RequestContext::value("qualifierId"); $agentList = array(); if (RequestContext::value("mult")) { $agentList = unserialize(urldecode(RequestContext::value("agents"))); } else { $agentList = array(RequestContext::value("agentId")); } // Process authorizations if ($operation == 'create') { // Get Ids from these strings $functionId = $idManager->getId($functionIdString); $qualifierId = $idManager->getId($qualifierIdString); foreach ($agentList as $agentIdString) { $authZ->createAuthorization($idManager->getId($agentIdString), $functionId, $qualifierId); } } else { if ($operation == 'delete') { // Get Ids from these strings $functionId = $idManager->getId($functionIdString); $qualifierId = $idManager->getId($qualifierIdString); foreach ($agentList as $agentIdString) { $authorizations = $authZ->getExplicitAZs($idManager->getId($agentIdString), $functionId, $qualifierId, false); while ($authorizations->hasNext()) { $authorization = $authorizations->next(); /* $qualifier =$authorization->getQualifier(); $function =$authorization->getFunction(); $qualifierId =$qualifier->getId(); $functionId =$function->getId(); print "auth -> function: ".$functionId->getIdString().", qualifier: ".$qualifierId->getIdString()."<br/>"; */ $authZ->deleteAuthorization($authorization); } } } else { if ($operation == 'delete_all') { // clear all authorizations for the users selected foreach ($agentsList as $agentIdString) { $authorizations = $authZ->getAllExplicitAZsForAgent($idManager->getId($agentIdString), false); while ($authorizations->hasNext()) { $authorization = $authorizations->next(); $authZ->deleteAuthorization($authorization); } } } } } $harmoni->request->endNamespace(); $harmoni->history->goBack("polyphony/agents/process_authorizations"); }
/** * Answer the title of this result set * * @return string * @access public * @since 4/8/08 */ public function getResultTitle() { $tag = RequestContext::value('tag'); $title = str_replace('%1', "<strong>" . $tag . "</strong>", _("'%1' tag added by you within site %2 ")); $node = SiteDispatcher::getCurrentRootNode(); $title = str_replace('%2', $node->acceptVisitor(new BreadCrumbsVisitor($node)), $title); return new Heading($title, 2); }
/** * Tells the wizard component to update itself - this may include getting * form post data or validation - whatever this particular component wants to * do every pageload. * @param string $fieldName The field name to use when outputting form data or * similar parameters/information. * @access public * @return boolean - TRUE if everything is OK */ function update($fieldName) { $val = RequestContext::value($fieldName); if ($val !== '' && $val !== null) { // advance the step! $this->_stepContainer->setStepByKey($val); } }
/** * Tells the wizard component to update itself - this may include getting * form post data or validation - whatever this particular component wants to * do every pageload. * @param string $fieldName The field name to use when outputting form data or * similar parameters/information. * @access public * @return boolean - TRUE if everything is OK */ function update($fieldName) { $val = RequestContext::value($fieldName); if ($val !== null && (!$this->_startingDisplay || $val != $this->_startingDisplay)) { $this->_value = $val; } return $this->validate(); }
/** * Print out the update Rows. * * @return void * @access protected * @since 6/12/08 */ protected function printUpdateRows() { $name = RequestContext::value("update"); if (!in_array($name, $this->updateClasses)) { throw new UnknownIdException("No update with name '{$name}'."); } $this->printRow($name); }
/** * Answer the theme * * @return object Segue_Templates_Template * @access protected * @since 5/13/08 */ protected function getTemplate() { if (!isset($this->template)) { $templateMgr = Segue_Templates_TemplateManager::instance(); $this->template = $templateMgr->getTemplate(RequestContext::value('template')); } return $this->template; }
/** * Constructor * * @return object * @access public * @since 10/26/05 */ function editAction() { $this->_init(); // $this->_recStructsToIgnore[] = 'FILE'; $assetList = RequestContext::value("assets"); $this->_cacheName = 'edit_asset_wizard_' . preg_replace("/[^a-zA-Z0-9]/", "_", $assetList); $this->_loadAssets(explode(",", RequestContext::value("assets"))); }
/** * Constructor * * @return object * @access public * @since 10/26/05 */ function multieditAction() { $this->_init(); $this->_recStructsToIgnore[] = 'FILE'; $assetList = RequestContext::value("assets"); $this->_cacheName = 'edit_asset_wizard_' . md5($assetList); $this->_loadAssets(explode(",", $assetList)); }
/** * Build the content for this action * * @return boolean * @access public * @since 4/26/05 */ function execute() { $harmoni = Harmoni::instance(); // Get the plugin asset id $harmoni->request->startNamespace('plugin_manager'); $id = RequestContext::value('plugin_id'); if (RequestContext::value('extended') == 'true') { $showExtended = true; } else { $showExtended = false; } // Get the plugin asset object $repositoryManager = Services::getService("Repository"); $idManager = Services::getService("Id"); $repository = $repositoryManager->getRepository($idManager->getId("edu.middlebury.segue.sites_repository")); $asset = $repository->getAsset($idManager->getId($id)); $pluginManager = Services::getService("Plugs"); $plugin = $pluginManager->getPlugin($asset); if (RequestContext::value('module') && RequestContext::value('action')) { $plugin->setLocalModuleAndAction(RequestContext::value('module'), RequestContext::value('action')); } $harmoni->request->endNamespace(); header("Content-type: text/xml"); print "<plugin"; if (!is_object($plugin)) { print ">\n"; print "\t<markup>\n\t\t<![CDATA["; print $plugin; print "]]>\n\t</markup>\n"; } else { if ($showExtended) { $markup = $plugin->executeAndGetExtendedMarkup(TRUE); } else { $markup = $plugin->executeAndGetMarkup(TRUE); } if ($plugin->hasExtendedMarkup()) { print " hasExtendedMarkup='true'"; } else { print " hasExtendedMarkup='false'"; } print " id='" . $plugin->getId() . "'"; print ">\n"; print "\t<markup"; if ($showExtended) { print " type='extended'"; } else { print " type='primary'"; } print ">"; print "\n\t\t<![CDATA["; // CDATA sections cannot contain ']]>' and therefor cannot be nested // get around this by replacing the ']]>' tags in the markup. print preg_replace('/\\]\\]>/', '}}>', $markup); print "]]>\n\t</markup>\n"; } print "</plugin>"; exit; }
/** * Tells the wizard component to update itself - this may include getting * form post data or validation - whatever this particular component wants to * do every pageload. * @param string $fieldName The field name to use when outputting form data or * similar parameters/information. * @access public * @return boolean - TRUE if everything is OK */ function update($fieldName) { parent::update($fieldName); $val = RequestContext::value($fieldName); $option = stripslashes(RequestContext::value($fieldName . "_option")); if ($val) { $this->_option = $option; } }
/** * Execute this action. * * @param object Harmoni $harmoni * @return mixed * @access public * @since 11/10/06 */ function execute() { $harmoni = Harmoni::instance(); $harmoni->request->startNamespace("polyphony-tags"); $itemId = RequestContext::value('item_id'); $system = RequestContext::value('system'); $harmoni->request->endNamespace(); $item = TaggedItem::forId($itemId, $system); $this->writeXmlResponse($item->getTags()); }
/** * Check Authorizations * * @return boolean * @access public * @since 6/08/05 */ function isAuthorizedToExecute() { $harmoni = Harmoni::instance(); $authZ = Services::getService("AuthZ"); $idManager = Services::getService("Id"); $harmoni->request->startNamespace('import'); $return = $authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.add_children"), $idManager->getId(RequestContext::value('asset_id'))); $harmoni->request->endNamespace(); // Check that the user can create an asset here. return $return; }
/** * Answer the organizer that we will be inserting into. * * @return object OrganizerSiteComponent * @access protected * @since 1/15/09 */ protected function getTargetOrganizer() { if (!isset($this->_organizer)) { $director = SiteDispatcher::getSiteDirector(); $refNode = $director->getSiteComponentById(RequestContext::value('refNode')); // Find the right organizer above our refNode to place the type of component we want $componentType = HarmoniType::fromString(RequestContext::value('componentType')); $this->_organizer = self::getOrganizerForComponentType($refNode, $componentType); } return $this->_organizer; }
/** * Answer the number of tags to show * * @return integer * @access public * @since 12/5/06 */ function getNumTags() { if (RequestContext::value('num_tags') !== null) { $_SESSION['__NUM_TAGS'] = intval(RequestContext::value('num_tags')); } else { if (!isset($_SESSION['__NUM_TAGS'])) { $_SESSION['__NUM_TAGS'] = 100; } } return $_SESSION['__NUM_TAGS']; }
/** * Tells the wizard component to update itself - this may include getting * form post data or validation - whatever this particular component wants to * do every pageload. * * @param string $fieldName The field name to use when outputting form data or * similar parameters/information. * @access public * @return boolean - TRUE if everything is OK * @since 11/27/07 */ public function update($fieldName) { $term = RequestContext::value($fieldName); if (!isset($this->searchSource)) { throw new Exception("No SearchSource set for field {$fieldName}"); } if (!is_null($term) && $term != $this->searchTerm) { $this->searchTerm = $term; $this->searchResults = $this->searchSource->getResults($term); } }
/** * 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 8/22/07 */ function processChanges(SiteDirector $director) { $harmoni = Harmoni::instance(); $harmoni->request->startNamespace("reorder"); // Get our component $block = $director->getSiteComponentById(RequestContext::value('node')); // The reordering is in the Flow Organizer, so get the parent of our node $organizer = $block->getParentComponent(); // Do the reordering $organizer->putSubcomponentInCell($block, RequestContext::value('position')); $harmoni->request->endNamespace(); }