function buildContent() { $harmoni = Harmoni::Instance(); $basket = Basket::instance(); $basket->removeAllItems(); RequestContext::locationHeader($harmoni->request->quickURL("basket", "view")); }
/** * Build the content for this action * * @return boolean * @access public * @since 4/26/05 */ function buildContent() { $actionRows = $this->getActionRows(); $harmoni = Harmoni::instance(); $harmoni->request->startNamespace("basket"); $idManager = Services::getService("Id"); $authZ = Services::getService("AuthZ"); $basket = Basket::instance(); $assetId = $idManager->getId(RequestContext::value("asset_id")); $basket->moveUp($assetId); $harmoni->request->endNamespace(); RequestContext::locationHeader($harmoni->request->quickURL("basket", "view")); }
/** * 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()))); }
/** * Return the browser to the page from whence they came * * @return void * @access public * @since 10/16/06 */ function returnToCallerPage() { $harmoni = Harmoni::instance(); if (!($returnAction = RequestContext::value('returnAction'))) { $returnAction = 'editview'; } if (isset($this->newIdToSendTo)) { $node = $this->newIdToSendTo; } else { $node = RequestContext::value('returnNode'); } RequestContext::locationHeader(SiteDispatcher::quickURL($harmoni->request->getRequestedModule(), $returnAction, array("node" => $node))); }
/** * Prompt the user to supply their tokens * * @return void * @access public * @since 3/16/05 */ function prompt() { RequestContext::locationHeader($this->_url); }
$authZManager->createAuthorization($adminGroup->getId(), $function->getId(), $allOfSegueId); // Administration Functions $type = new Type("Authorization", "edu.middlebury.harmoni", "Group Administration", "Functions for administering groups."); $id = $idManager->getId("edu.middlebury.authorization.create_group"); $function = $authZManager->createFunction($id, "Create Groups", "Add Groups to the system.", $type, $qualifierHierarchyId); $authZManager->createAuthorization($adminGroup->getId(), $function->getId(), $allOfSegueId); $id = $idManager->getId("edu.middlebury.authorization.delete_group"); $function = $authZManager->createFunction($id, "Delete Groups", "Remove Groups from the system.", $type, $qualifierHierarchyId); $authZManager->createAuthorization($adminGroup->getId(), $function->getId(), $allOfSegueId); $id = $idManager->getId("edu.middlebury.authorization.modify_group_membership"); $function = $authZManager->createFunction($id, "Modify Group Membership", "Modify Group membership.", $type, $qualifierHierarchyId); $authZManager->createAuthorization($adminGroup->getId(), $function->getId(), $allOfSegueId); /********************************************************* * Add a site for the administrator user to use for testing * new installations. *********************************************************/ $slotMgr = SlotManager::instance(); $testSlot = $slotMgr->getSlotByShortname('jadministrator-test_site'); $testSlot->addOwner($adminAgent->getId()); $testSlot->setLocationCategory('community'); $slotMgr->convertSlotToType($testSlot, Slot::personal); // Set the 'personal' folder as the last visited so that admins logging into // a new install will see their personal test site. UserData::instance()->setPreference('segue_portal_last_folder', 'personal'); // print "\n<br> ...done"; $_SESSION['table_setup_complete'] = TRUE; unset($_SESSION['installation_underway']); // $dbHandler->commitTransaction($dbID); RequestContext::locationHeader($_SERVER['REQUEST_URI']); } }
/** * 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"); $setManager = Services::getService("Sets"); $this->_repository = $repositoryManager->getRepository($idManager->getId("edu.middlebury.concerto.exhibition_repository")); $exhibitionId = $idManager->getId(RequestContext::value('exhibition_id')); $exhibition = $this->_repository->getAsset($exhibitionId); $oldSlideshowId = $idManager->getId(RequestContext::value('slideshow_id')); $oldSlideshowAsset = $this->_repository->getAsset($oldSlideshowId); // Duplicate the Slideshow $newSlideshow = $this->_repository->createAsset($oldSlideshowAsset->getDisplayName() . " " . _("Copy"), $oldSlideshowAsset->getDescription(), $oldSlideshowAsset->getAssetType()); $newSlideshowId = $newSlideshow->getId(); $exhibition->addAsset($newSlideshow->getId()); // Duplicate each slide $newSlideOrder = $setManager->getPersistentSet($newSlideshow->getId()); $slideIterator = $oldSlideshowAsset->getAssets(); $slideOrder = $setManager->getPersistentSet($oldSlideshowId); $orderedSlides = array(); $orderlessSlides = array(); while ($slideIterator->hasNext()) { $slideAsset = $slideIterator->next(); $slideId = $slideAsset->getId(); if ($slideOrder->isInSet($slideId)) { $orderedSlides[$slideOrder->getPosition($slideId)] = $slideAsset; } else { $orderlessSlides[] = $slideAsset; } } ksort($orderedSlides); foreach ($orderedSlides as $slide) { $newSlide = $this->duplicateSlide($newSlideshow, $slide); $newSlideOrder->addItem($newSlide->getId()); } foreach ($orderlessSlides as $slide) { $newSlide = $this->duplicateSlide($newSlideshow, $slide); $newSlideOrder->addItem($newSlide->getId()); } // Move the copy to the correct position $exhibitionSet = $setManager->getPersistentSet($exhibitionId); $oldPosition = $exhibitionSet->getPosition($oldSlideshowId); $exhibitionSet->addItem($newSlideshow->getId()); $exhibitionSet->moveToPosition($newSlideshow->getId(), $oldPosition + 1); // Go to the editing screen $harmoni->request->startNamespace('modify_slideshow'); $url = $harmoni->request->quickURL("exhibitions", "modify_slideshow", array("slideshow_id" => $newSlideshowId->getIdString())); $harmoni->request->endNamespace(); RequestContext::locationHeader($url); }
/** * Send the browser to the url specified. Location headers will be sent if * possible, otherwise a javascript redirect will be printed outside of * all output buffers * * @param string $url * @return void * @access public * @static * @since 6/14/06 */ static function sendTo($url) { // use headers if possible if (!headers_sent()) { RequestContext::locationHeader($url); } else { $harmoni = Harmoni::instance(); // get rid of all output buffers; $harmoni->request->ob_jump(); $unescapedurl = preg_replace("/&/", "&", $url); $label = _("You should be automatically redirected. If not, click here to continue."); print <<<END \t<script type='text/javascript'> \t/* <![CDATA[ */ \t\t \t\twindow.location = '{$unescapedurl}'; \t\t \t/* ]]> */ \t</script> \t<a href='{$url}'>{$label}</a> \t END; $harmoni->request->ob_land(); exit; } }
/** * 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"); $repositoryId = $idManager->getId(RequestContext::value('collection_id')); $repository = $repositoryManager->getRepository($repositoryId); $displayName = $repository->getDisplayName(); // Delete all of the tags for the assets in the repository $itemsToDelete = array(); $assets = $repository->getAssets(); while ($assets->hasNext()) { $asset = $assets->next(); $itemsToDelete[] = TaggedItem::forId($asset->getId(), 'concerto'); } $tagManager = Services::getService('Tagging'); $tagManager->deleteItems($itemsToDelete, 'concerto'); $repositoryManager->deleteRepository($idManager->getId(RequestContext::value('collection_id'))); // 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("Delete Node", "Repository deleted:\n<br/> " . $displayName); $item->addNodeId($repositoryId); $log->appendLogWithTypes($item, $formatType, $priorityType); } RequestContext::locationHeader($harmoni->request->quickURL("collections", "namebrowse")); }
/** * 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('exhibition_id'))); // 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", "Exhibition deleted:\n<br/> " . $asset->getDisplayName()); $item->addNodeId($asset->getId()); $log->appendLogWithTypes($item, $formatType, $priorityType); } $repository->deleteAsset($idManager->getId(RequestContext::value('exhibition_id'))); RequestContext::locationHeader($harmoni->request->quickURL("exhibitions", "browse")); }
/** * 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(); // print "Now Saving: "; // printpre($properties); // Save the Repository $id = $this->getRepositoryId(); $repository = $this->getRepository(); $repository->updateDisplayName($properties['namedesc']['display_name']); $repository->updateDescription($properties['namedesc']['description']); // Save the Schema settings. // Get the set for this Repository $setManager = Services::getService("Sets"); $set = $setManager->getPersistentSet($id); // get an iterator of all RecordStructures $recordStructures = $repository->getRecordStructures(); // 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(); $existingStructures = array(); $numStructures = 0; // Go through each RecordStructure while ($recordStructures->hasNext()) { $recordStructure = $recordStructures->next(); $recordStructureId = $recordStructure->getId(); // If the box is checked, make sure that the ID is in the set $fieldName = "schema_" . str_replace(".", "__", $recordStructureId->getIdString()); if (isset($properties['schema'][$fieldName]) && $properties['schema'][$fieldName]) { if (!$set->isInSet($recordStructureId)) { $set->addItem($recordStructureId); } if ($position = $properties['schema'][$fieldName . "_position"]) { $positions[$position - 1] = $recordStructureId; } // Store some info so that we can check that all structures are valid. $existingStructures[] = $recordStructureId->getIdString(); $numStructures++; } else { if ($set->isInSet($recordStructureId)) { $set->removeItem($recordStructureId); } } } // Go through the positions and set them all. ksort($positions); $countPositions = $set->count(); foreach (array_keys($positions) as $position) { if ($position < 0 || $position >= $countPositions) { // move to the last position $set->moveToPosition($positions[$position], $countPositions - 1); } else { $set->moveToPosition($positions[$position], $position); } } // Remove any RecordStructures from the set that may have been removed/ // made-not-available by some other application. if ($numStructures != $set->count()) { $set->reset(); while ($set->hasNext()) { $id = $set->next(); if (!in_array($id->getIdString(), $existingStructures)) { $set->removeItem($id); } } } // 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", "Repository modified"); $item->addNodeId($repository->getId()); $log->appendLogWithTypes($item, $formatType, $priorityType); } // Move to Schema creation if that button is pressed. if ($properties['schema']['_create_schema']) { $this->closeWizard($cacheName); $harmoni = Harmoni::instance(); RequestContext::locationHeader($harmoni->request->quickURL("schema", "create", array("collection_id" => $id->getIdString()))); exit(0); } // Move to Schema deletion if that button is pressed. $recordStructures = $repository->getRecordStructures(); while ($recordStructures->hasNext()) { $recordStructure = $recordStructures->next(); $recordStructureId = $recordStructure->getId(); $field = '_delete_schema__' . str_replace('.', '_', $recordStructureId->getIdString()); if (isset($properties['schema'][$field]) && $properties['schema'][$field]) { $this->closeWizard($cacheName); $harmoni = Harmoni::instance(); RequestContext::locationHeader($harmoni->request->quickURL("schema", "delete", array("collection_id" => $id->getIdString(), "recordstructure_id" => $recordStructureId->getIdString()))); exit(0); } $field = 'duplicate_schema__' . str_replace('.', '_', $recordStructureId->getIdString()); if (isset($properties['schema'][$field]) && $properties['schema'][$field]) { $this->closeWizard($cacheName); $harmoni = Harmoni::instance(); RequestContext::locationHeader($harmoni->request->quickURL("schema", "duplicate", array("collection_id" => $id->getIdString(), "recordstructure_id" => $recordStructureId->getIdString(), "copy_records" => 'false'))); exit(0); } $field = 'duplicate_copy_records__' . str_replace('.', '_', $recordStructureId->getIdString()); if (isset($properties['schema'][$field]) && $properties['schema'][$field]) { $this->closeWizard($cacheName); $harmoni = Harmoni::instance(); RequestContext::locationHeader($harmoni->request->quickURL("schema", "duplicate", array("collection_id" => $id->getIdString(), "recordstructure_id" => $recordStructureId->getIdString(), "copy_records" => 'true'))); exit(0); } } return TRUE; } else { return FALSE; } }
/** * 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/> " . htmlspecialchars($uname) . "\n<br/> " . 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/> " . htmlspecialchars($error) . "\n<br/>for:\n<br/> " . $uname . "\n<br/> " . 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))); } }
/** * Return the browser to the page from whence they came * * @return void * @access public * @since 10/16/06 */ function returnToCallerPage() { $harmoni = Harmoni::instance(); if ($this->_returnNode) { if (!($action = RequestContext::value('returnAction'))) { $action = "editview"; } RequestContext::locationHeader(SiteDispatcher::quickURL($harmoni->request->getRequestedModule(), $action, array("node" => $this->_returnNode))); } else { RequestContext::locationHeader($harmoni->request->quickURL("portal", "list")); } }