コード例 #1
0
 /**
  * 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);
 }
コード例 #2
0
ファイル: addComponent.act.php プロジェクト: adamfranco/segue
 /**
  * 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)
 {
     $targetCell = $this->getTargetCell();
     $organizer = $this->getTargetOrganizer();
     $componentType = HarmoniType::fromString(RequestContext::value('componentType'));
     if ($componentType->getDomain() == 'segue-multipart') {
         $component = self::createMultipartComponent($director, $componentType, $organizer);
         $this->newIdToSendTo = $component->getId();
     } else {
         $component = $director->createSiteComponent($componentType, $organizer);
     }
     if (!is_null($targetCell)) {
         $oldCellId = $organizer->putSubcomponentInCell($component, $targetCell);
     }
     if (RequestContext::value('displayName')) {
         $component->updateDisplayName(RequestContext::value('displayName'));
     }
     if ($componentType->isEqual(new Type('segue', 'edu.middlebury', 'MenuOrganizer'))) {
         $menuTarget = RequestContext::value('menuTarget');
         if ($menuTarget == 'NewCellInNavOrg') {
             $navOrganizer = $organizer->getParentNavOrganizer();
             $navOrganizer->updateNumColumns($navOrganizer->getNumColumns() + 1);
             $menuTarget = $navOrganizer->getId() . "_cell:" . ($navOrganizer->getLastIndexFilled() + 1);
         }
         $component->updateTargetId($menuTarget);
     }
     // Check the Role of the user. If it is less than 'Editor', make them an editor
     $roleMgr = SegueRoleManager::instance();
     $role = $roleMgr->getUsersRole($component->getQualifierId(), true);
     $editor = $roleMgr->getRole('editor');
     if ($role->isLessThan($editor)) {
         $editor->applyToUser($component->getQualifierId(), true);
     }
 }
コード例 #3
0
 /**
  * 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);
 }
コード例 #4
0
 /**
  * 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;
 }
コード例 #5
0
 /**
  * Execute this action.
  * 
  * @param object Harmoni $harmoni
  * @return mixed
  * @access public
  * @since 4/25/05
  */
 function execute()
 {
     $harmoni = Harmoni::instance();
     $authN = Services::getService("AuthN");
     $harmoni->request->startNamespace("polyphony");
     $authType = HarmoniType::fromString(urldecode($harmoni->request->get("type")));
     $harmoni->request->endNamespace();
     // Try authenticating with this type
     $authN->destroyAuthenticationForType($authType);
     // Send us back to where we were
     $harmoni->history->goBack("polyphony/login");
     $null = null;
     return $null;
 }
コード例 #6
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']);
     //$isAuthenticated = FALSE;
     $authN = Services::getService("AuthN");
     $harmoni->request->startNamespace("polyphony");
     $authType = HarmoniType::fromString(urldecode($harmoni->request->get("type")));
     $harmoni->request->endNamespace();
     if ($authN->isUserAuthenticated($authType)) {
         $harmoni->history->goBack("polyphony/login");
         $null = null;
         return $null;
     } else {
         $harmoni->request->startNamespace("polyphony");
         $currentUrl = $harmoni->request->mkURL();
         $currentUrl->setValue("type", $harmoni->request->get("type"));
         $harmoni->history->markReturnURL("polyphony/authentication", $currentUrl);
         $harmoni->request->endNamespace();
         // Try authenticating with this type
         $authN->authenticateUser($authType);
         // If they are authenticated, return.
         if ($authN->isUserAuthenticated($authType)) {
             $harmoni->history->goBack("polyphony/login");
         } else {
             $harmoni = Harmoni::instance();
             // Set our textdomain
             $defaultTextDomain = textdomain("polyphony");
             $harmoni->request->startNamespace("polyphony");
             $_SESSION['polyphony/login_failed'] = true;
             ob_start();
             print "<p>";
             print _("Log in failed. Either your username or password was invalid for this login type.");
             print "\n<br /><a href='" . $harmoni->history->getReturnURL("polyphony/login") . "'>";
             print _("Go Back");
             print "</a> ";
             print _(" or ");
             print "\n<a href='" . $harmoni->history->getReturnURL("polyphony/authentication") . "'>";
             print _("Try Again.");
             print "</p>";
             $introText = new Block(ob_get_contents(), 3);
             ob_end_clean();
             $harmoni->request->endNamespace();
             // go back to the default text domain
             textdomain($defaultTextDomain);
             return $introText;
         }
     }
 }
コード例 #7
0
ファイル: icon.act.php プロジェクト: adamfranco/segue
 /**
  * Build the content for this action
  * 
  * @return boolean
  * @access public
  * @since 4/26/05
  */
 function execute()
 {
     $harmoni = Harmoni::instance();
     $harmoni->request->startNamespace('plugin_manager');
     $pluginManager = Services::getService("Plugs");
     $icon = $pluginManager->getPluginDir(HarmoniType::fromString(RequestContext::value('type'))) . "/icon.png";
     header("Content-Type: image/png");
     header('Content-Disposition: filename="icon.png"');
     if (!file_exists($icon)) {
         $icon = POLYPHONY_DIR . "/icons/filetypes/tar.png";
     }
     print file_get_contents($icon);
     $harmoni->request->endNamespace();
     exit;
 }
コード例 #8
0
 /**
  * Keeps objects in the plugin manager arrays.
  *
  * This should be removed in beta 12. it is being kept around just to update
  * existing sessions during the version change-over period from beta 9-10 to beta 11.
  *
  * @todo Remove this in Beta 12
  * @return void
  * @access private
  * @since 3/9/06
  */
 private function convertBeta10KeysTo11()
 {
     foreach ($this->_arrays as $arrayName) {
         eval('$array = $this->_' . $arrayName . 'Plugins;');
         foreach ($array as $key => $keystringOrObj) {
             if ($keystringOrObj && is_string($keystringOrObj)) {
                 $array[$keystringOrObj] = HarmoniType::fromString($keystringOrObj);
                 unset($array[$key]);
             }
         }
         eval('$this->_' . $arrayName . 'Plugins = $array;');
     }
     $this->_addTypeDescriptions();
     $this->_cachePluginArrays();
 }
コード例 #9
0
 /**
  * Build the content for this action
  * 
  * @return boolean
  * @access public
  * @since 4/26/05
  */
 function buildContent()
 {
     $actionRows = $this->getActionRows();
     $harmoni = Harmoni::instance();
     // Get the Repository
     $repositoryManager = Services::getService("Repository");
     $idManager = Services::getService("Id");
     // get the search type.
     $searchType = HarmoniType::fromString(urldecode($harmoni->request->get('search_type')));
     // Get the Search criteria
     $searchModules = Services::getService("RepositorySearchModules");
     $searchCriteria = $searchModules->getSearchCriteria($repository, $searchType);
     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, "100%", null, CENTER, CENTER);
     //***********************************
     // Get the assets to display
     //***********************************
     $assetArray = array();
     // Go through all the repositories. if they support the searchType,
     // run the search on them.
     $repositories = $repositoryManager->getRepositories();
     while ($repositories->hasNext()) {
         $repository = $repositories->next();
         $assets = $repository->getAssetsBySearch($searchCriteria, $searchType, new HarmoniProperties(new Type('Repository', 'edu.middlebury', 'null')));
         // add the results to our total results
         while ($assets->hasNext()) {
             $assetArray[] = $assets->next();
         }
     }
     //***********************************
     // print the results
     //***********************************
     $resultPrinter = new ArrayResultPrinter($assetArray, 2, 6, "printAssetShort", $harmoni);
     $resultPrinter->addLinksStyleProperty(new MarginTopSP("10px"));
     $resultLayout = $resultPrinter->getLayout();
     $actionRows->add($resultLayout, null, null, CENTER, CENTER);
 }
コード例 #10
0
 /**
  * Build the content for this action
  * 
  * @return boolean
  * @access public
  * @since 4/26/05
  */
 function buildContent()
 {
     $actionRows = $this->getActionRows();
     $repository = $this->getRepository();
     // The type
     $type = HarmoniType::fromString(urldecode(RequestContext::value('type')));
     // 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);
     // Get the assets to display
     $assets = $repository->getAssetsByType($type);
     // print the results
     $resultPrinter = new IteratorResultPrinter($assets, 2, 6, "printAssetShort", $harmoni);
     $resultLayout = $resultPrinter->getLayout("canView");
     $actionRows->add($resultLayout, null, null, CENTER, CENTER);
 }
コード例 #11
0
 /**
  * Answer a list of parameters to pass through urls
  * 
  * @return array
  * @access public
  * @since 10/16/07
  */
 public static function getUrlParams(Asset $asset)
 {
     $repository = $asset->getRepository();
     $params = array("collection_id" => $repository->getId()->getIdString(), "asset_id" => $asset->getId()->getIdString(), RequestContext::name("starting_number") => RequestContext::value("starting_number"), RequestContext::name("limit_by_type") => RequestContext::value("limit_by_type"), RequestContext::name("order") => RequestContext::value("order"), RequestContext::name("direction") => RequestContext::value("direction"), RequestContext::name("type") => RequestContext::value("type"), RequestContext::name("searchtype") => RequestContext::value("searchtype"));
     if (RequestContext::value("searchtype")) {
         $searchModuleManager = Services::getService("RepositorySearchModules");
         foreach ($searchModuleManager->getCurrentValues(HarmoniType::fromString(RequestContext::value("searchtype"))) as $key => $value) {
             $params[$key] = $value;
         }
     }
     // if we are limiting by type
     if (RequestContext::value("limit_by_type") == 'true') {
         $types = $repository->getAssetTypes();
         $selectedTypes = array();
         while ($types->hasNext()) {
             $type = $types->next();
             if (RequestContext::value("type___" . $type->asString()) == 'true') {
                 $params[RequestContext::name("type___" . $type->asString())] = RequestContext::value("type___" . $type->asString());
             }
         }
     }
     return $params;
 }
コード例 #12
0
ファイル: import.act.php プロジェクト: adamfranco/concerto
 /**
  * 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;
 }
コード例 #13
0
 /**
  * Save the navigation step
  * 
  * @param array $values
  * @return boolean
  * @access public
  * @since 6/5/07
  */
 function saveNavStep($values)
 {
     $director = $this->getSiteDirector();
     $organizer = $this->getSiteComponentForIdString($values['organizerId']);
     $componentType = HarmoniType::fromString($values['type']);
     if ($componentType->getDomain() == 'segue-multipart') {
         $component = addComponentAction::createMultipartComponent($director, $componentType, $organizer);
     } else {
         return false;
     }
     // Check the Role of the user. If it is less than 'Editor', make them an editor
     $roleMgr = SegueRoleManager::instance();
     $role = $roleMgr->getUsersRole($component->getQualifierId(), true);
     $editor = $roleMgr->getRole('editor');
     if ($role->isLessThan($editor)) {
         $editor->applyToUser($component->getQualifierId(), true);
     }
     $this->_newId = $component->getId();
     $this->_newIsNav = true;
     return true;
 }
コード例 #14
0
 /**
  * Answer the directory for the plugin
  * 
  * @return string
  * @access protected
  * @since 6/18/08
  */
 protected function getPluginDir()
 {
     $pluginMgr = Services::getService("PluginManager");
     $dir = rtrim($pluginMgr->getPluginDir(HarmoniType::fromString(RequestContext::value('plugin'))), '/');
     if (!file_exists($dir)) {
         throw new Exception('Unknown Plugin "' . RequestContext::value('plugin') . '".');
     }
     return $dir;
 }
コード例 #15
0
 function saveWizard($cacheName)
 {
     $wizard = $this->getWizard($cacheName);
     $values = $wizard->getAllValues();
     $props = $values["properties"];
     $list = $this->_getAgentList();
     print_r($props);
     $agentManager = Services::getService("Agent");
     $idManager = Services::getService("Id");
     $valuesHandled = array();
     // go through each agent and update all its properties at once
     foreach ($list as $idString) {
         // first clear all their properties, then reset them
         $id = $idManager->getId($idString);
         $agent = $agentManager->getAgentOrGroup($id);
         if (count($list) == 1) {
             $agent->deleteAllProperties();
         }
         foreach ($props as $values) {
             if ($values['type']) {
                 $type = HarmoniType::fromString($values['type']);
             } else {
                 $type = new Type("agent_properties", "harmoni", "custom", "Properties defined outside of an authentication system.");
             }
             $valuesHandled[$type->asString()][$values['key']] = true;
             if (count($list) == 1 || $values['value_update']) {
                 $key = $values['key'];
                 $value = $values['value'];
                 if (count($list) == 1 || !$agent->updateProperty($type, $key, $value)) {
                     $agent->addProperty($type, $key, $value);
                 }
             }
         }
     }
     if (count($list) > 1) {
         // now go through each agent and check if there are any properties that were not handled, delete them
         foreach ($list as $idString) {
             $id = $idManager->getId($idString);
             $agent = $agentManager->getAgentOrGroup($id);
             $properties = $agent->getProperties();
             while ($properties->hasNext()) {
                 $property = $properties->next();
                 $keys = $property->getKeys();
                 $type = $property->getType();
                 $typeString = $type->asString();
                 while ($keys->hasNext()) {
                     $key = $keys->next();
                     if (!isset($valuesHandled[$typeString][$key]) || !$valuesHandled[$typeString][$key]) {
                         $agent->deleteProperty($type, $key);
                     }
                 }
             }
         }
     }
     //		exit(0);
     return true;
 }
コード例 #16
0
ファイル: browse.act.php プロジェクト: adamfranco/concerto
 /**
  * Answer the assets that we are searching for
  * 
  * @return object Iterator
  * @access public
  * @since 5/15/06
  */
 function getAssets()
 {
     $repository = $this->getRepository();
     $searchModuleManager = Services::getService("RepositorySearchModules");
     $searchProperties = new HarmoniProperties(HarmoniType::fromString("repository::harmoni::order"));
     $searchProperties->addProperty("order", $_SESSION["asset_order"]);
     $searchProperties->addProperty("direction", $_SESSION['asset_order_direction']);
     if ($this->_state["limit_by_type"] == 'true' && isset($this->_state['selectedTypes']) && count($this->_state['selectedTypes'])) {
         $searchProperties->addProperty("allowed_types", $this->_state['selectedTypes']);
     }
     if (isset($this->_state['searchtype']) && $searchModuleManager->getSearchCriteria($repository, $this->_state['searchtype'])) {
         $criteria = $searchModuleManager->getSearchCriteria($repository, $this->_state['searchtype']);
         $assets = $repository->getAssetsBySearch($criteria, $this->_state['searchtype'], $searchProperties);
     } else {
         if ($this->_state["limit_by_type"] == 'true' && isset($this->_state['selectedTypes']) && count($this->_state['selectedTypes'])) {
             $assets = new MultiIteratorIterator($null = null);
             foreach (array_keys($this->_state['selectedTypes']) as $key) {
                 $assets->addIterator($repository->getAssetsByType($this->_state['selectedTypes'][$key]));
             }
         } else {
             if ($this->hasRootSearch()) {
                 $criteria = NULL;
                 $assets = $repository->getAssetsBySearch($criteria, new HarmoniType("Repository", "edu.middlebury.harmoni", "RootAssets", ""), $searchProperties);
             } else {
                 $assets = $repository->getAssets();
             }
         }
     }
     return $assets;
 }
コード例 #17
0
 /**
  * Answer the root assets in the current repository
  * 
  * @return object Iterator
  * @access public
  * @since 4/2/07
  */
 function getRootAssets()
 {
     $repository = $this->getRepository();
     if (!$repository) {
         throw new Exception("Repository not found");
     }
     $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;
 }
コード例 #18
0
 /**
  * creates appropriate object from given ids
  * 
  * @param Id $structureId
  * @param Id $partStructureId
  * @param String $part
  * @return object mixed
  * @access public
  * @since 7/21/05
  */
 function getPartObject($structureId, $partStructureId, $part)
 {
     $structure = $this->_destinationRepository->getRecordStructure($structureId);
     $partStructure = $structure->getPartStructure($partStructureId);
     $type = $partStructure->getType();
     $typeString = $type->getKeyword();
     switch ($typeString) {
         case "shortstring":
         case "string":
             $obj = String::withValue($part);
             return $obj;
             break;
         case "integer":
             $obj = Integer::withValue($part);
             return $obj;
             break;
         case "boolean":
             $obj = Boolean::withValue($part);
             return $obj;
             break;
         case "float":
             $obj = Float::withValue($part);
             return $obj;
             break;
         case "datetime":
             $obj = DateAndTime::fromString($part);
             return $obj;
             break;
         case "type":
             $obj = HarmoniType::fromString($part);
             return $obj;
             break;
         default:
             $this->addError("Unsupported PartStructure DataType: " . HarmoniType::typeToString($type) . ".");
             $false = false;
             return $false;
     }
 }
コード例 #19
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 (!$wizard->validate()) {
         return false;
     }
     // Make sure we have a valid Repository
     $idManager = Services::getService("Id");
     $authZ = Services::getService("AuthZ");
     $properties = $wizard->getAllValues();
     // check if they entered a valid type.
     if ($properties["type"] == "NONE") {
         $domain = $properties["type_domain"];
         $authority = $properties["type_authority"];
         $keyword = $properties["type_keyword"];
         if (!($domain && $authority && $keyword)) {
             return false;
         }
         $desc = $properties["type_description"];
         $theType = new Type($domain, $authority, $keyword, $desc);
     } else {
         $theType = HarmoniType::fromString(urldecode($properties["type"]));
     }
     // empty properties set
     $propObj = new HarmoniProperties(new Type("Properties", "edu.middlebury.polyphony", "Generic"));
     $agents = Services::getService("Agent");
     $group = $agents->createGroup($properties["display_name"], $theType, $properties["description"], $propObj);
     if ($properties["members"] && count($list = unserialize($properties["members"])) > 0) {
         $ids = Services::getService("Id");
         $agents = Services::getService("Agent");
         foreach ($list as $agentId) {
             $id = $ids->getId($agentId);
             if ($agents->isGroup($id)) {
                 $agent = $agents->getGroup($id);
             } else {
                 if ($agents->isAgent($id)) {
                     $agent = $agents->getAgent($id);
                 }
             }
             $group->add($agent);
         }
     }
     return true;
 }
コード例 #20
0
 /**
  * Print links for the various functions that are possible to do with this
  * Repository.
  * 
  * @param object Repository $repository The Repository to print the links for.
  * @return void
  * @access public
  * @date 8/6/04
  * @static
  */
 static function printRepositoryFunctionLinks($harmoni, $repository)
 {
     $authZ = Services::getService("AuthZ");
     $idManager = Services::getService("Id");
     $repositoryId = $repository->getId();
     $links = array();
     $actionString = $harmoni->getCurrentAction();
     $url = $harmoni->request->mkURL();
     $url->setValue("collection_id", $repositoryId->getIdString());
     // Authorization Icon
     print AuthZPrinter::getAZIcon($repositoryId);
     print " &nbsp; ";
     //===== Browse Link =====//
     try {
         // 			$isAuthorized = $authZ->isUserAuthorizedBelow(
         // 				$idManager->getId("edu.middlebury.authorization.view"),
         // 				$repositoryId);
         // Checking down the hierarchy is taking WAY too long for large data sets.
         // Maybe this can be renabled if better authorization implementations come up.
         $isAuthorized = $authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.view"), $repositoryId);
     } catch (UnknownIdException $e) {
         // For non-Harmoni repositories, return true.
         $isAuthorized = true;
     }
     if ($isAuthorized) {
         if ($actionString != "collection.browse") {
             $url->setModuleAction("collection", "browse");
             $links[] = "<a href='" . $url->write() . "'>";
             $links[count($links) - 1] .= _("Browse") . "</a>";
         } else {
             $links[] = _("Browse");
         }
         //===== TypeBrowse Link =====//
         // 			if ($actionString != "collection.typebrowse") {
         // 				$url->setModuleAction("collection", "typebrowse");
         // 				$links[] = "<a href='".$url->write()."'>";
         // 				$links[count($links) - 1] .= _("Browse by Type")."</a>";
         // 			} else {
         // 				$links[] = _("Browse by Type");
         // 			}
         //	//===== Search Link =====//
         // 			if ($actionString != "collection.search") {
         // 				$url->setModuleAction("collection", "search");
         // 				$links[] = "<a href='".$url->write()."'>";
         // 				$links[count($links) - 1] .= _("Search")."</a>";
         // 			} else {
         // 				$links[] = _("search");
         // 			}
     }
     //===== Add Link =====//
     try {
         $isAuthorized = $authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.add_children"), $repositoryId);
     } catch (UnknownIdException $e) {
         $isAuthorized = $authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.add_children"), $idManager->getId("edu.middlebury.authorization.root"));
     }
     if ($isAuthorized) {
         $url->setModuleAction("asset", "create");
         $links[] = "<a href='" . $url->write() . "'>";
         $links[count($links) - 1] .= _("Add") . "</a>";
         //===== Import Link =====//
         $harmoni->request->startNamespace("import");
         $links[] = "<a href='" . $harmoni->request->quickURL("collection", "import", array("collection_id" => $repositoryId->getIdString())) . "'>";
         $links[count($links) - 1] .= _("Import") . "</a>";
         $harmoni->request->endNamespace();
     }
     //===== Export Link =====//
     try {
         // 			$isAuthorized = $authZ->isUserAuthorizedBelow(
         // 				$idManager->getId("edu.middlebury.authorization.view"),
         // 				$repositoryId);
         // Checking down the hierarchy is taking WAY too long for large data sets.
         // Maybe this can be renabled if better authorization implementations come up.
         $isAuthorized = $authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.view"), $repositoryId);
     } catch (UnknownIdException $e) {
         // For non-Harmoni repositories, return true.
         $isAuthorized = true;
     }
     if ($isAuthorized) {
         $harmoni->request->startNamespace('export');
         $links[] = "<a href='" . $harmoni->request->quickURL("collection", "export", array("collection_id" => $repositoryId->getIdString())) . "'>";
         $links[count($links) - 1] .= _("Export") . "</a>";
         $harmoni->request->endNamespace();
     }
     //===== Edit Link =====//
     try {
         $isAuthorized = $authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.modify"), $repositoryId);
     } catch (UnknownIdException $e) {
         $isAuthorized = $authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.modify"), $idManager->getId("edu.middlebury.authorization.root"));
     }
     if ($isAuthorized) {
         $params = array("collection_id" => $repositoryId->getIdString(), RequestContext::name("starting_number") => RequestContext::value("starting_number"), RequestContext::name("limit_by") => RequestContext::value("limit_by"), RequestContext::name("type") => RequestContext::value("type"), RequestContext::name("searchtype") => RequestContext::value("searchtype"));
         if (RequestContext::value("searchtype")) {
             $searchModuleManager = Services::getService("RepositorySearchModules");
             foreach ($searchModuleManager->getCurrentValues(HarmoniType::fromString(RequestContext::value("searchtype"))) as $key => $value) {
                 $params[$key] = $value;
             }
         }
         $harmoni->history->markReturnURL("concerto/collection/edit-return", $harmoni->request->mkURL(null, null, $params));
         $url->setModuleAction("collection", "edit");
         $links[] = "<a href='" . $url->write() . "'>";
         $links[count($links) - 1] .= _("Edit") . "</a>";
     }
     //===== Edit Schemas =====//
     // Check that the user can modify Schemas for this collection
     $recStructFunctions = $authZ->getFunctions(new Type("Authorization", "edu.middlebury.harmoni", "RecordStructures"));
     $canEditStructures = false;
     while ($recStructFunctions->hasNext()) {
         $function = $recStructFunctions->next();
         try {
             if ($authZ->isUserAuthorized($function->getId(), $repositoryId)) {
                 $canEditStructures = true;
             }
         } catch (UnknownIdException $e) {
             // do nothing;
         }
         if ($authZ->isUserAuthorized($function->getId(), $idManager->getId("edu.middlebury.authorization.root"))) {
             $canEditStructures = true;
         }
     }
     if ($canEditStructures) {
         // Schema Editing
         ob_start();
         print "\n<select";
         print " onchange=\"var url = '";
         print $harmoni->request->quickURL("schema", "edit", array("collection_id" => $repositoryId->getIdString(), "recordstructure_id" => "XXXXXXXX"));
         print "'; ";
         print "url = url.replace(/XXXXXXXX/, this.value); ";
         print "url = url.urlDecodeAmpersands(); ";
         print "if (this.value) { ";
         print "window.location = url; ";
         print "} ";
         print "\">";
         print "\n\t<option value=''>" . _("Edit Schema...") . "</option>";
         $localStructures = '';
         $globalStructures = '';
         $fileId = $idManager->getId("FILE");
         $remoteFileId = $idManager->getId("REMOTE_FILE");
         $setManager = Services::getService("Sets");
         $set = $setManager->getPersistentSet($repositoryId);
         $set->reset();
         while ($set->hasNext()) {
             $recStructId = $set->next();
             if (!$recStructId->isEqual($fileId) && !$recStructId->isEqual($remoteFileId)) {
                 ob_start();
                 $recStruct = $repository->getRecordStructure($recStructId);
                 $harmoni->history->markReturnURL("concerto/schema/edit-return/" . $recStructId->getIdString());
                 print "\n\t\t<option value='" . $recStructId->getIdString() . "'";
                 print ">";
                 print $recStruct->getDisplayName();
                 print "</option>";
                 if (preg_match("/^Repository::.+\$/i", $recStructId->getIdString())) {
                     $localStructures .= ob_get_clean();
                 } else {
                     $globalStructures .= ob_get_clean();
                 }
             }
         }
         print "\n\t<optgroup label='" . _("Local Schemas") . "'>";
         print $localStructures;
         print "\n\t</optgroup>";
         print "\n\t<optgroup label='" . _("Global Schemas") . "'>";
         print $globalStructures;
         print "\n\t</optgroup>";
         print "\n</select>";
         $links[] = ob_get_clean();
     }
     //===== Delete Link =====//
     try {
         $isAuthorized = $authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.delete"), $repositoryId);
     } catch (UnknownIdException $e) {
         $isAuthorized = $authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.delete"), $idManager->getId("edu.middlebury.authorization.root"));
     }
     if ($isAuthorized) {
         ob_start();
         print "<a href='Javascript:deleteRepository(\"" . $repositoryId->getIdString() . "\", \"" . $harmoni->request->quickURL("collection", "delete", array("collection_id" => $repositoryId->getIdString())) . "\");'>";
         print _("Delete") . "</a>";
         $links[] = ob_get_contents();
         ob_end_clean();
         print "\n<script type='text/javascript'>\n//<![CDATA[";
         print "\n\tfunction deleteRepository(repositoryId, url) {";
         print "\n\t\tif (confirm(\"" . _("Are you sure you want to delete this Collection and all of its Assets?") . "\") && confirm(\"" . _("Clicking OK will permenantly delete this Collection and all of the Assets in it.\\nAre you REALLY sure you want to delete this Collection and all of its Assets?") . "\")) {";
         print "\n\t\t\twindow.location = url;";
         print "\n\t\t}";
         print "\n\t}";
         print "\n//]]>\n</script>\n";
     }
     print implode("\n\t | ", $links);
 }
コード例 #21
0
 /**
  * Answer an iterator of the latest assets
  * 
  * @param object Repository $repository
  * @return object Iterator
  * @access public
  * @since 8/8/06
  */
 function getAssets($repository)
 {
     $searchModuleManager = Services::getService("RepositorySearchModules");
     $searchProperties = new HarmoniProperties(HarmoniType::fromString("repository::harmoni::order"));
     if (RequestContext::value('order') == 'modification') {
         $searchProperties->addProperty("order", $arg0 = 'ModificationDate');
     } else {
         $searchProperties->addProperty("order", $arg1 = "CreationDate");
     }
     $searchProperties->addProperty("direction", $arg2 = 'DESC');
     $assets = $repository->getAssetsBySearch($criteria = '*', new Type("Repository", "edu.middlebury.harmoni", "Keyword", "Search with a string for keywords."), $searchProperties);
     return $assets;
 }
コード例 #22
0
 /**
  * Collect any tokens that the user may have supplied. Reply NULL if none
  * are found.
  * 
  * @return mixed
  * @access public
  * @since 3/16/05
  */
 function collect()
 {
     $harmoni = Harmoni::instance();
     $harmoni->request->startNamespace("harmoni-authentication");
     $typeString = $harmoni->request->get("type");
     $identifier = $harmoni->request->get("identifier");
     $harmoni->request->endNamespace();
     if (!strlen($typeString) || !strlen($identifier)) {
         return null;
     }
     $authNMethodManager = Services::getService("AuthNMethods");
     $this->type = HarmoniType::fromString($typeString);
     $authNMethod = $authNMethodManager->getAuthNMethodForType($this->type);
     return $authNMethod->createTokensForIdentifier($identifier);
 }
コード例 #23
0
ファイル: browse.act.php プロジェクト: adamfranco/concerto
 /**
  * Build the content for this action
  * 
  * @return boolean
  * @access public
  * @since 4/26/05
  */
 function buildContent()
 {
     $actionRows = $this->getActionRows();
     $harmoni = Harmoni::instance();
     $idManager = Services::getService("Id");
     $repositoryManager = Services::getService("Repository");
     $exhibitionRepositoryId = $idManager->getId("edu.middlebury.concerto.exhibition_repository");
     $repository = $repositoryManager->getRepository($exhibitionRepositoryId);
     // If the Repository supports searching of root assets, just get those
     $hasRootSearch = FALSE;
     $rootSearchType = new HarmoniType("Repository", "edu.middlebury.harmoni", "RootAssets", "");
     $searchTypes = $repository->getSearchTypes();
     while ($searchTypes->hasNext()) {
         if ($rootSearchType->isEqual($searchTypes->next())) {
             $hasRootSearch = TRUE;
             break;
         }
     }
     ob_start();
     print "<p>";
     print _("Some <em>Exhibitions</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>";
     $authZ = Services::getService("AuthZ");
     //===== Create Link =====//
     if ($authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.add_children"), $exhibitionRepositoryId)) {
         print "\n<p>";
         print "\n\t<a href='" . $harmoni->request->quickURL("exhibitions", "create_exhibition") . "'>" . _("Create a new <em>Exhibition</em>") . "</a>";
         //===== Import Link =====//
         // 			$harmoni->request->startNamespace("import");
         // 			print  "\t|\t<a href='".
         // 				$harmoni->request->quickURL("exhibitions", "import_exhibition").
         // 				"'>".
         // 				_("Import <em>Exhibition(s)</em>").
         // 				"</a>";
         // 			$harmoni->request->endNamespace();
         print "\n</p>";
     }
     $introText = new Block(ob_get_contents(), STANDARD_BLOCK);
     ob_end_clean();
     $actionRows->add($introText, "100%", null, CENTER, CENTER);
     //***********************************
     // Get the assets to display
     //***********************************
     if ($hasRootSearch) {
         $criteria = NULL;
         $searchProperties = new HarmoniProperties(HarmoniType::fromString("repository::harmoni::order"));
         $searchProperties->addProperty("order", $arg = "DisplayName");
         unset($arg);
         $searchProperties->addProperty("direction", $arg = "ASC");
         unset($arg);
         $assets = $repository->getAssetsBySearch($criteria, $rootSearchType, $searchProperties);
     } else {
         $assets = $repository->getAssets();
     }
     //***********************************
     // print the results
     //***********************************
     $resultPrinter = new IteratorResultPrinter($assets, 1, 20, "printAssetShort", $harmoni);
     $resultLayout = $resultPrinter->getLayout("canView");
     $actionRows->add($resultLayout, "100%", null, LEFT, CENTER);
 }
コード例 #24
0
 /**
  * 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)
 {
     $this->_searchField->update($fieldName . "_query");
     $this->_searchButton->update($fieldName . "_go");
     // check if we have any new checked agents to add to our list.
     $values = RequestContext::value($fieldName . "_checked");
     if (is_array($values)) {
         // remove the dummy '' value.
         $key = array_search('', $values);
         if ($key !== false) {
             unset($values[$key]);
         }
         $this->_agentsSelected = array_unique($values);
     }
     // check if the user selected an action
     $action = RequestContext::value($fieldName . "_action");
     if ($action) {
         $this->_actionSelected = $action;
     }
     // perform the search, if necessary.
     if ($this->_searchButton->getAllValues()) {
         $query = $this->_searchField->getAllValues();
         $type = HarmoniType::fromString(urldecode($this->_searchTypeSelector->getAllValues()));
         $agentManager = Services::getService("Agent");
         $list = $agentManager->getAgentsBySearch($query, $type);
         $this->_searchResults = array();
         // clear the array
         $this->_resultPrinter = null;
         while ($list->hasNext()) {
             $this->_searchResults[] = $list->next();
         }
         $this->_resultPrinter = new AgentBrowserResultPrinter($this->_searchResults, 1, 10, array("WAgentBrowser", "printAgent"), $fieldName);
         $this->_resultPrinter->overridePageNumber(1);
         $this->_resultPrinter->setOptions($this->_options);
     }
     $this->_resultPrinter->_selected = $this->_agentsSelected;
 }
コード例 #25
0
 /**
  * Answer the interface markup needed to display the comments attached to the
  * given asset.
  * 
  * @param object Asset $asset
  * @return string
  * @access public
  * @since 7/3/07
  */
 function getMarkup($asset)
 {
     $harmoni = Harmoni::instance();
     $harmoni->request->startNamespace('comments');
     if (RequestContext::value('order')) {
         $this->setDisplayOrder(RequestContext::value('order'));
     }
     if (RequestContext::value('displayMode')) {
         $this->setDisplayMode(RequestContext::value('displayMode'));
     }
     try {
         if (RequestContext::value('create_new_comment')) {
             $comment = $this->createRootComment($asset, HarmoniType::fromString(RequestContext::value('plugin_type')));
             $comment->updateSubject(RequestContext::value('title'));
             $comment->enableEditForm();
         }
         if (RequestContext::value('reply_parent') && RequestContext::value('plugin_type')) {
             $idManager = Services::getService('Id');
             $comment = $this->createReply($idManager->getId(RequestContext::value('reply_parent')), HarmoniType::fromString(RequestContext::value('plugin_type')));
             $comment->updateSubject(RequestContext::value('title'));
             $comment->enableEditForm();
         }
         if (RequestContext::value('delete_comment')) {
             $idManager = Services::getService('Id');
             try {
                 $this->deleteComment($idManager->getId(RequestContext::value('delete_comment')));
             } catch (Exception $e) {
                 // In case we have a delete_comment id in the url that no longer exists,
                 // just catch any exceptions. See the following bug:
                 // http://sourceforge.net/tracker/index.php?func=detail&aid=1798996&group_id=82171&atid=565234
             }
         }
     } catch (PermissionDeniedException $e) {
         $messages = $e->getMessage();
     }
     $this->addHead();
     ob_start();
     if (isset($messages)) {
         print "\n<div class='error'>" . $messages . "</div>";
     }
     if ($this->canComment($asset->getId())) {
         // New comment
         print "\n<div style='float: left;'>";
         $url = SiteDispatcher::mkURL();
         $url->setValue('create_new_comment', 'true');
         print "\n\t<button ";
         print "onclick=\"CommentPluginChooser.run(this, '" . $url->write() . "#" . RequestContext::name('current') . "', ''); return false;\">";
         print _("New Post") . "</button>";
         print "\n<div class='comment_help'>";
         print _("Discussion posts can be edited or deleted until they are replied-to.");
         print " (" . Help::link('Discussion') . ")";
         print "</div>";
         print "\n</div>";
     }
     if ($this->canViewComments($asset->getId())) {
         // print the ordering form
         if ($this->isSortingEnabled()) {
             print "\n\n<form action='" . SiteDispatcher::quickURL() . "#" . RequestContext::name('top') . "' method='post'  style='float: right; text-align: right;'>";
             print "\n\t\t<select name='" . RequestContext::name('displayMode') . "'>";
             print "\n\t\t\t<option value='threaded'" . ($this->getDisplayMode() == 'threaded' ? " selected='selected'" : "") . ">";
             print _("Threaded") . "</option>";
             print "\n\t\t\t<option value='flat'" . ($this->getDisplayMode() == 'flat' ? " selected='selected'" : "") . ">";
             print _("Flat") . "</option>";
             print "\n\t\t</select>";
             print "\n\t\t<select name='" . RequestContext::name('order') . "'>";
             print "\n\t\t\t<option value='" . ASC . "'" . ($this->getDisplayOrder() == ASC ? " selected='selected'" : "") . ">";
             print _("Oldest First") . "</option>";
             print "\n\t\t\t<option value='" . DESC . "'" . ($this->getDisplayOrder() == DESC ? " selected='selected'" : "") . ">";
             print _("Newest First") . "</option>";
             print "\n\t\t</select>";
             print "\n\t<input type='submit' value='" . _("Change") . "'/>";
             print "\n</form>";
             print "\n<div style='clear: both;'> &nbsp; </div>";
         }
         // Print out the Comments
         print "\n<div id='" . RequestContext::name('comments') . "'>";
         if ($this->getDisplayMode() == 'flat') {
             $comments = $this->getAllComments($asset, $this->getDisplayOrder());
         } else {
             $comments = $this->getRootComments($asset, $this->getDisplayOrder());
         }
         while ($comments->hasNext()) {
             $comment = $comments->next();
             // If this is a work in progress that has not had content added yet,
             // do not display it.
             if ($comment->hasContent() || $comment->isAuthor()) {
                 print $comment->getMarkup($this->getDisplayMode() == 'threaded' ? true : false);
             }
         }
         print "\n</div>";
     } else {
         print "\n<div>" . _("You are not authorized to view discussion posts.") . "</div>";
     }
     $harmoni->request->endNamespace();
     return ob_get_clean();
 }
コード例 #26
0
ファイル: create.act.php プロジェクト: adamfranco/concerto
 /**
  * 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;
     }
 }
コード例 #27
0
ファイル: browse.act.php プロジェクト: adamfranco/polyphony
    /**
     * Build the content for this action
     * 
     * @return void
     * @access public
     * @since 4/26/05
     */
    function buildContent()
    {
        $defaultTextDomain = textdomain("polyphony");
        $actionRows = $this->getActionRows();
        $harmoni = Harmoni::instance();
        $harmoni->request->startNamespace("polyphony-logs");
        $harmoni->request->passthrough('log', 'priority', 'startYear', 'startMonth', 'startDay', 'startHour', 'endYear', 'endMonth', 'endDay', 'endHour', 'agent_id', 'node_id', 'category');
        $agentManager = Services::getService("Agent");
        $idManager = Services::getService("Id");
        $hierarchyManager = Services::getService("Hierarchy");
        /*********************************************************
         * the log search form
         *********************************************************/
        // Log header
        $actionRows->add(new Heading(_("Logs"), 2), "100%", null, LEFT, CENTER);
        $loggingManager = Services::getService("Logging");
        $log = $loggingManager->getLogForWriting("test_log");
        $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", "normal", "An action which involves reading.");
        // Links to other logs
        $logNames = $loggingManager->getLogNamesForReading();
        ob_start();
        if (RequestContext::value("log")) {
            $currentLogName = RequestContext::value("log");
        }
        while ($logNames->hasNext()) {
            $logName = $logNames->next();
            if (!isset($currentLogName)) {
                $currentLogName = $logName;
            }
            if ($logName != $currentLogName) {
                print "\n<a href='";
                print $harmoni->request->quickURL("logs", "browse", array("log" => $logName));
                print "'>" . $logName . "</a>";
            } else {
                print $logName;
            }
            if ($logNames->hasNext()) {
                print " | ";
            }
        }
        print " \n\t<table border='0'>\n\t\t<tr>\n\t\t\t<th valign='top'>" . _("Date Range: ") . "</th>\n\t\t\t<td>\n\n";
        $startDate = $this->getStartDate();
        $endDate = $this->getEndDate();
        $this->printDateRangeForm($startDate, $endDate);
        print "\n\n\t\t\t</td>\n\t\t</tr>\n";
        print "\n\t\t<tr>\n\t\t\t<th>" . _("Filters:") . "</th>\n\t\t\t<td>\n";
        if (RequestContext::value('agent_id')) {
            print "\n\t\t\t";
            $id = $idManager->getId(RequestContext::value('agent_id'));
            $url = $harmoni->request->mkURL("logs", "browse");
            $url->setValue('agent_id', null);
            $agent = $agentManager->getAgent($id);
            print $agent->getDisplayName();
            print "\n\t\t\t\t<input type='button' onclick='window.location=\"";
            print str_replace('&amp;', '&', $url->write());
            print "\"' value='X'/>";
        }
        if (RequestContext::value('agent_id') && RequestContext::value('node_id')) {
            print "\n\t\t\t &nbsp; &nbsp; &nbsp; &nbsp; ";
        }
        if (RequestContext::value('node_id')) {
            print "\n\t\t\t";
            $id = $idManager->getId(RequestContext::value('node_id'));
            $url = $harmoni->request->mkURL("logs", "browse");
            $url->setValue('node_id', null);
            try {
                $node = $hierarchyManager->getNode($id);
                if ($node->getDisplayName()) {
                    print $node->getDisplayName();
                } else {
                    print _("Id: ") . $nodeId->getIdString();
                }
            } catch (UnknownIdException $e) {
                print $id->getIdString();
            } catch (UnimplementedException $e) {
                print $id->getIdString();
            }
            print "\n\t\t\t\t<input type='button' onclick='window.location=\"";
            print str_replace('&amp;', '&', $url->write());
            print "\"' value='X'/>";
        }
        if ((RequestContext::value('agent_id') || RequestContext::value('node_id')) && RequestContext::value('category')) {
            print "\n\t\t\t &nbsp; &nbsp; &nbsp; &nbsp; ";
        }
        if (RequestContext::value('category')) {
            print "\n\t\t\t";
            $url = $harmoni->request->mkURL("logs", "browse");
            $url->setValue('category', null);
            print urldecode(RequestContext::value('category'));
            print "\n\t\t\t\t<input type='button' onclick='window.location=\"";
            print str_replace('&amp;', '&', $url->write());
            print "\"' value='X'/>";
        }
        print "\n<br/><br/>";
        if (isset($currentLogName)) {
            $log = $loggingManager->getLogForReading($currentLogName);
            if (method_exists($log, 'getCategories')) {
                print "\n\t\t\t\t<form action='";
                $url = $harmoni->request->mkURL('logs', 'browse');
                $url->setValue('category', null);
                print $url->write();
                print "' method='post'>";
                print "\n\t\t\t\t\t<input type='submit' value='" . _('Set Category Filter:') . "'/>";
                print "\n\t\t\t\t\t<select name='" . RequestContext::name('category') . "'>";
                foreach ($log->getCategories() as $category) {
                    print "\n\t\t\t\t\t\t<option value='{$category}'>{$category}</option>";
                }
                print "\n\t\t\t\t\t</select>";
                print "\n\t\t\t\t</form>";
            }
        }
        print "\n\t\t\t\t<form action='";
        $url = $harmoni->request->mkURL('logs', 'browse');
        $url->setValue('node_id', null);
        print $url->write();
        print "' method='post'>";
        print "\n\t\t\t\t\t<input type='submit' value='" . _('Set Node Id Filter:') . "'/>";
        print "\n\t\t\t\t\t<input name='" . RequestContext::name('node_id') . "' type='text'/>";
        print "\n\t\t\t\t</form>";
        print "\n\t\t\t\t<form action='";
        $url = $harmoni->request->mkURL('logs', 'browse');
        $url->setValue('agent_id', null);
        print $url->write();
        print "' method='post'>";
        print "\n\t\t\t\t\t<input type='submit' value='" . _('Set Agent Id Filter:') . "'/>";
        print "\n\t\t\t\t\t<input name='" . RequestContext::name('agent_id') . "' type='text'/>";
        print "\n\t\t\t\t</form>";
        print "\n\t\t\t</td></tr>";
        print "\n\t</table>";
        $actionRows->add(new Block(ob_get_clean(), STANDARD_BLOCK), "100%", null, LEFT, TOP);
        // --- The Current log ---
        if (isset($currentLogName)) {
            $log = $loggingManager->getLogForReading($currentLogName);
            $actionRows->add(new Heading($log->getDisplayName(), 3), "100%", null, LEFT, CENTER);
            ob_start();
            // Links to other priorities
            print "<strong>" . _("Priority: ") . "</strong>";
            if (RequestContext::value("priority")) {
                $currentPriorityType = HarmoniType::fromString(RequestContext::value("priority"));
                $entries = $log->getEntries($formatType, $currentPriorityType);
                if (!$entries->hasNext()) {
                    unset($currentPriorityType, $entries);
                }
            }
            $priorityTypes = $loggingManager->getPriorityTypes();
            $priorityLinks = array();
            while ($priorityTypes->hasNext()) {
                $priorityType = $priorityTypes->next();
                // Only print priority types with entries
                $entries = $log->getEntries($formatType, $priorityType);
                if ($entries->hasNext()) {
                    if (!isset($currentPriorityType)) {
                        $currentPriorityType = $priorityType;
                    }
                    if (!$priorityType->isEqual($currentPriorityType)) {
                        $string = "\n<a href='";
                        $string .= $harmoni->request->quickURL("logs", "browse", array("log" => RequestContext::value("log"), "priority" => $priorityType->asString()));
                        $string .= "'>" . $priorityType->getKeyword() . "</a>";
                    } else {
                        $string = $priorityType->getKeyword();
                    }
                    $priorityLinks[] = $string;
                }
                unset($entries);
            }
            print implode(" | ", $priorityLinks);
            if (isset($currentPriorityType)) {
                // Entries
                print <<<END
\t\t
\t\t<script type='text/javascript'>
\t\t\t/* <![CDATA[ */
\t\t
\t\t\tfunction showTrace(buttonElement) {
\t\t\t\tnewWindow = window.open("", "traceWindow", 'toolbar=no,width=600,height=500,resizable=yes,scrollbars=yes,status=no')
\t\t\t\t// the next sibling is text, the one after that is our hidden div
\t\t\t\tnewWindow.document.write(buttonElement.nextSibling.nextSibling.innerHTML)
\t\t\t\tnewWindow.document.bgColor="lightpink"
\t\t\t\tnewWindow.document.close() 
\t\t\t}
\t\t
\t\t\t/* ]]> */
\t\t</script>
\t\t
END;
                // Do a search if needed
                if (!$startDate->isEqualTo($this->minDate()) || !$endDate->isEqualTo(DateAndTime::tomorrow()) || RequestContext::value('agent_id') || RequestContext::value('node_id') || RequestContext::value('category')) {
                    $criteria = array();
                    $criteria['start'] = $startDate;
                    $criteria['end'] = $endDate;
                    if (RequestContext::value('agent_id')) {
                        $criteria['agent_id'] = $idManager->getId(RequestContext::value('agent_id'));
                    }
                    if (RequestContext::value('node_id')) {
                        $criteria['node_id'] = $idManager->getId(RequestContext::value('node_id'));
                    }
                    if (RequestContext::value('category')) {
                        $criteria['category'] = urldecode(RequestContext::value('category'));
                    }
                    $searchType = new Type("logging_search", "edu.middlebury", "Date-Range/Agent/Node");
                    $entries = $log->getEntriesBySearch($criteria, $searchType, $formatType, $currentPriorityType);
                } else {
                    $entries = $log->getEntries($formatType, $currentPriorityType);
                }
                $headRow = "\n\t\t<tr>\n\t\t\t<th>timestamp</th>\n\t\t\t<th>category</th>\n\t\t\t<th>description</th>\n\t\t\t<th>trace</th>\n\t\t\t<th>agents</th>\n\t\t\t<th>nodes</th>\n\t\t</tr>";
                $resultPrinter = new TableIteratorResultPrinter($entries, $headRow, 20, "printLogRow", 1);
                print $resultPrinter->getTable();
            }
            if (isset($currentLogName) && isset($currentPriorityType)) {
                $url = $harmoni->request->quickURL('logs', 'browse_rss', array("log" => $currentLogName, "priority" => $currentPriorityType->asString()));
                $title = $currentLogName . " " . $currentPriorityType->getKeyword() . " " . _("Logs");
                $outputHandler = $harmoni->getOutputHandler();
                $outputHandler->setHead($outputHandler->getHead() . "\n\t\t<link rel='alternate' type='application/rss+xml'" . " title='" . $title . "' href='" . $url . "'/>");
                print "\n\t\t<div style='text-align: right'>";
                print "\n\t\t<a href='" . $url . "' style='white-space: nowrap;' title='" . $title . "'>";
                print "\n\t\t\t<img src='" . POLYPHONY_PATH . "icons/rss_icon02.png' border='0' alt='RSS Icon'/>";
                print "\n\t\t\t" . _("Subscribe to the RSS feed of this log");
                print "\n\t\t</a>";
                print "\n\t\t</div>";
            }
            $actionRows->add(new Block(ob_get_clean(), STANDARD_BLOCK), "100%", null, LEFT, TOP);
        }
        textdomain($defaultTextDomain);
        $harmoni->request->endNamespace();
    }
コード例 #28
0
 function makeNewAgent($userName, $password, $displayName, $propertiesArray)
 {
     //authentication handling
     $authNMethodManager = Services::getService("AuthNMethodManager");
     $tokenMappingManager = Services::getService("AgentTokenMapping");
     //find the authn type.  This is set in a hidden field in the form at the moment but could easily be changed to a drop down menu
     $authNType = HarmoniType::fromString(RequestContext::value('authn_type'));
     //for passing to the token handler
     $newTokensPassed["username"] = RequestContext::value("username");
     $newTokensPassed["password"] = RequestContext::value("password");
     //find what authentication method is associated with this type
     $authNMethod = $authNMethodManager->getAuthNMethodForType($authNType);
     //get tokens object for authentication type
     $tokens = $authNMethod->createTokensObject();
     //set the values of the tokens to the array we just created
     $tokens->initializeForTokens($newTokensPassed);
     //if a mapping already exists, there is alreadya a user with this name
     $mappingExists = $tokenMappingManager->getMappingForTokens($tokens, $authNType);
     if ($mappingExists) {
         print "This username is already in use, please choose another.";
         return false;
     }
     //the type for the user
     $userType = new HarmoniType("Agents", "edu.middlebury.harmoni", "User");
     //property manager is used for storing properties to the database
     $propertyManager = Services::getService("Property");
     //convert the array of properties we have to a properties object
     $propertyObject = $propertyManager->convertArrayToObject($propertiesArray, $userType);
     $agentManager = Services::getService("Agent");
     //create the agent entries and build an agent object
     $agent = $agentManager->createAgent($displayName, $userType, $propertyObject);
     //get the id and create a link between the agent and its authentication info
     $id = $agent->getId();
     $mapping = $tokenMappingManager->createMapping($id, $tokens, $authNType);
     //tell the specific AuthNMethod to add the tokens
     $authNMethod->addTokens($tokens);
     return $agent;
 }
コード例 #29
0
ファイル: add.act.php プロジェクト: adamfranco/concerto
 /**
  * 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 (!$wizard->validate()) {
         return false;
     }
     // Make sure we have a valid Repository
     $idManager = Services::getService("Id");
     $authZ = Services::getService("AuthZ");
     $repository = $this->getRepository();
     $properties = $wizard->getAllValues();
     if (isset($properties['parentstep']['parent']) && $properties['parentstep']['parent'] && $properties['parentstep']['parent'] != 'NONE') {
         $parentId = $idManager->getId($properties['parentstep']['parent']);
         $authorizedToAddToParent = $authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.add_children"), $parentId);
     }
     // First, verify that we chose a parent that we can add children to.
     if (!$properties['parentstep']['parent'] || $properties['parentstep']['parent'] == 'NONE' || isset($parentId) && $authorizedToAddToParent) {
         // Get the type from the select if one is specified
         if (is_string($properties['typestep']['type'])) {
             $typeString = urldecode($properties['typestep']['type']);
             $assetType = HarmoniType::fromString($typeString);
         } else {
             if (is_array($properties['typestep']['type']) && $properties['typestep']['type']['type_domain'] && $properties['typestep']['type']['type_authority'] && $properties['typestep']['type']['type_keyword']) {
                 $domain = $properties['typestep']['type']['type_domain'];
                 $authority = $properties['typestep']['type']['type_authority'];
                 $keyword = $properties['typestep']['type']['type_keyword'];
                 $description = $properties['typestep']['type']['type_description'];
                 if (!($domain && $authority && $keyword)) {
                     $wizard->setStep("typestep");
                     return false;
                 }
                 $assetType = new Type($domain, $authority, $keyword, $description);
             } else {
                 $assetType = new Type("Asset Types", "edu.middlebury", "Generic Asset", "This is an <em>Asset</em> of unspecified type.");
             }
         }
         $asset = $repository->createAsset($properties['namedescstep']['display_name'], $properties['namedescstep']['description'], $assetType);
         $assetId = $asset->getId();
         $this->_assetId = $assetId;
         if (isset($properties['contentstep']['content'])) {
             $content = Blob::withValue($properties['contentstep']['content']);
             try {
                 $asset->updateContent($content);
             } catch (UnimplementedException $e) {
                 $this->saveMessages[] = _("Could set Asset content.") . " " . _("Not supported by this repository.");
             }
         }
         // 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']));
         // Add our parent if we have specified one.
         if ($properties['parentstep']['parent'] && $properties['parentstep']['parent'] != 'NONE') {
             $parentId = $idManager->getId($properties['parentstep']['parent']);
             $parentAsset = $repository->getAsset($parentId);
             $parentAsset->addAsset($assetId);
         }
         // 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("Create Node", "Asset added");
             $item->addNodeId($assetId);
             $item->addNodeId($repository->getId());
             $log->appendLogWithTypes($item, $formatType, $priorityType);
         }
         return TRUE;
     } else {
         $wizard->setStep("parentstep");
         return FALSE;
     }
 }
コード例 #30
0
 /**
  * Build the rss feed
  * 
  * @return void
  * @access public
  * @since 8/8/06
  */
 function buildFeed()
 {
     $defaultTextDomain = textdomain("polyphony");
     $harmoni = Harmoni::instance();
     $harmoni->request->startNamespace("polyphony-logs");
     $harmoni->request->passthrough('log', 'priority', 'startYear', 'startMonth', 'startDay', 'startHour', 'endYear', 'endMonth', 'endDay', 'endHour', 'agent_id', 'node_id', 'category');
     $agentManager = Services::getService("Agent");
     $idManager = Services::getService("Id");
     $hierarchyManager = Services::getService("Hierarchy");
     $loggingManager = Services::getService("Logging");
     $formatType = new Type("logging", "edu.middlebury", "AgentsAndNodes", "A format in which the acting Agent[s] and the target nodes affected are specified.");
     if (RequestContext::value("log")) {
         $currentLogName = RequestContext::value("log");
     } else {
         $logNames = $loggingManager->getLogNamesForReading();
         $currentLogName = $logNames->next();
     }
     // --- The Current log ---
     if (isset($currentLogName) && $currentLogName) {
         $log = $loggingManager->getLogForReading($currentLogName);
         // Priority Type
         if (RequestContext::value("priority")) {
             $currentPriorityType = HarmoniType::fromString(RequestContext::value("priority"));
         } else {
             $priorityTypes = $loggingManager->getPriorityTypes();
             $currentPriorityType = $priorityTypes->next();
         }
         // --- The Current log with Priority type ---
         if (isset($currentPriorityType) && $currentPriorityType) {
             // Do a search if needed
             if (RequestContext::value('agent_id') || RequestContext::value('node_id') || RequestContext::value('category')) {
                 $criteria = array();
                 $criteria['start'] = $this->minDate();
                 $criteria['end'] = DateAndTime::tomorrow();
                 if (RequestContext::value('agent_id')) {
                     $criteria['agent_id'] = $idManager->getId(RequestContext::value('agent_id'));
                 }
                 if (RequestContext::value('node_id')) {
                     $criteria['node_id'] = $idManager->getId(RequestContext::value('node_id'));
                 }
                 if (RequestContext::value('category')) {
                     $criteria['category'] = urldecode(RequestContext::value('category'));
                 }
                 $searchType = new Type("logging_search", "edu.middlebury", "Date-Range/Agent/Node");
                 $entries = $log->getEntriesBySearch($criteria, $searchType, $formatType, $currentPriorityType);
                 if ($entries->hasNext()) {
                     $firstEntry = $entries->next();
                 }
                 $entries = $log->getEntriesBySearch($criteria, $searchType, $formatType, $currentPriorityType);
             } else {
                 $entries = $log->getEntries($formatType, $currentPriorityType);
                 if ($entries->hasNext()) {
                     $firstEntry = $entries->next();
                 }
                 $entries = $log->getEntries($formatType, $currentPriorityType);
             }
         }
     }
     $this->setTitle($currentLogName . " " . $currentPriorityType->getKeyword() . " " . _("Logs"));
     $this->setLink($harmoni->request->quickURL('logs', 'browse'));
     $this->addCategory("Logs");
     ob_start();
     print $currentLogName . " " . _("logs of priority,");
     print " " . $currentPriorityType->getKeyword();
     if (RequestContext::value('agent_id')) {
         print "\n<p style='text-indent: 0.5in'>";
         print _("Limited to agent: ");
         $id = $idManager->getId(RequestContext::value('agent_id'));
         $agent = $agentManager->getAgent($id);
         print $agent->getDisplayName();
         print "</p>";
     }
     if (RequestContext::value('node_id')) {
         print "\n<p style='text-indent: 0.5in'>";
         print _("Limited to node: ");
         $id = $idManager->getId(RequestContext::value('node_id'));
         try {
             $node = $hierarchyManager->getNode($id);
             if ($node->getDisplayName()) {
                 print $node->getDisplayName();
             } else {
                 print _("Id: ") . $nodeId->getIdString();
             }
         } catch (UnknownIdException $e) {
             print $id->getIdString();
         } catch (UnimplementedException $e) {
             print $id->getIdString();
         }
         print "</p>";
     }
     if (RequestContext::value('category')) {
         print "\n<p style='text-indent: 0.5in'>";
         print _("Limited to category: ");
         print urldecode(RequestContext::value('category'));
         print "</p>";
     }
     $this->setDescription(ob_get_clean());
     $i = 0;
     while ($entries->hasNext() && $i < 30) {
         $this->addEntry($entries->next());
         $i++;
     }
     textdomain($defaultTextDomain);
 }