Пример #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
 /**
  * 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();
     print "<p>";
     print _("Below are listed the available <em>Collections</em>, organized by type, then name.");
     print "</p>\n<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>";
     $actionRows->add(new Block(ob_get_contents(), STANDARD_BLOCK), "100%", null, CENTER, CENTER);
     ob_end_clean();
     $exhibitionRepositoryType = new Type('System Repositories', 'edu.middlebury.concerto', 'Exhibitions');
     $repositoryManager = Services::getService("Repository");
     // Get all the types
     $types = $repositoryManager->getRepositoryTypes();
     // put the drs into an array and order them.
     $typeArray = array();
     while ($types->hasNext()) {
         $type = $types->next();
         // include all but Exhibitions repository.
         if (!$exhibitionRepositoryType->isEqual($type)) {
             $typeArray[HarmoniType::typeToString($type)] = $type;
         }
     }
     ksort($typeArray);
     // print the Results
     $resultPrinter = new ArrayResultPrinter($typeArray, 2, 20, "printTypeShort");
     $resultPrinter->addLinksStyleProperty(new MarginTopSP("10px"));
     $resultLayout = $resultPrinter->getLayout();
     $actionRows->add($resultLayout, null, null, CENTER, CENTER);
 }
Пример #4
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);
 }
Пример #5
0
 /**
  * Build the content for this action
  * 
  * @return void
  * @access public
  * @since 10/24/05
  */
 function buildContent()
 {
     $actionRows = $this->getActionRows();
     $harmoni = Harmoni::instance();
     $actionRows->add(new Heading(_("Authentication"), 2));
     // Current AuthN Table
     ob_start();
     $authNManager = Services::getService("AuthN");
     $agentManager = Services::getService("Agent");
     $authTypes = $authNManager->getAuthenticationTypes();
     print "\n<table border='2' align='left'>";
     print "\n\t<tr><th colspan='3'><center>";
     print _("Current Authentications: ");
     print "</center>\n\t</th></tr>";
     while ($authTypes->hasNext()) {
         $authType = $authTypes->next();
         $typeString = HarmoniType::typeToString($authType);
         print "\n\t<tr>";
         print "\n\t\t<td><small>";
         print "<a href='#' title='{$typeString}' onclick='alert(\"{$typeString}\")'>";
         print $authType->getKeyword();
         print "</a>";
         print "\n\t\t</small></td>";
         print "\n\t\t<td><small>";
         $userId = $authNManager->getUserId($authType);
         $userAgent = $agentManager->getAgent($userId);
         print '<a title=\'' . _("Agent Id") . ': ' . $userId->getIdString() . '\' onclick=\'Javascript:alert("' . _("Agent Id") . ':\\n\\t' . $userId->getIdString() . '");\'>';
         print $userAgent->getDisplayName();
         print "</a>";
         print "\n\t\t</small></td>";
         print "\n\t\t<td><small>";
         $harmoni->request->startNamespace("polyphony");
         // set where we are before login
         $harmoni->history->markReturnURL("polyphony/login");
         if ($authNManager->isUserAuthenticated($authType)) {
             $url = $harmoni->request->quickURL("auth", "logout_type", array("type" => urlencode($typeString)));
             print "<a href='" . $url . "'>Log Out</a>";
         } else {
             $url = $harmoni->request->quickURL("auth", "login_type", array("type" => urlencode($typeString)));
             print "<a href='" . $url . "'>Log In</a>";
         }
         $harmoni->request->endNamespace();
         print "\n\t\t</small></td>";
         print "\n\t</tr>";
     }
     print "\n</table>";
     $statusBar = new Block(ob_get_contents(), 2);
     $actionRows->add($statusBar, null, null, RIGHT, TOP);
     ob_end_clean();
     ob_start();
     print "\n<ul>" . "\n\t<li><a href='" . $harmoni->request->quickURL("user", "change_password") . "'>" . _("Change 'Harmoni DB' Password") . "</li>";
     $introText = new Block(ob_get_contents(), 2);
     $actionRows->add($introText, "100%", null, CENTER, CENTER);
     ob_end_clean();
     // end of authN links
 }
 /**
  * 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;
 }
Пример #7
0
 /**
  * After being added to a {@link Schema}, it calls associate() to tie us
  * to its type. This way, we can only be added to one Schema.
  * @param ref object $schema The schema to which we are being added.
  * @return void
  * @access public
  */
 function associate($schema)
 {
     // first check if we're already attached to a Schema.
     // if so, we're gonna dump
     if ($this->_associated) {
         throwError(new Error("I'm (label '" . $this->_label . "') already associated with Schema type '" . HarmoniType::typeToString($this->_schema->getType()) . "'. You shouldn't be trying to add me to multiple Schemas. Bad form.", "DataManager", true));
         return false;
     }
     $this->_associated = true;
     $this->_schema = $schema;
     $this->_id = $schema->getID() . "." . $this->_label;
 }
Пример #8
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;
 }
Пример #9
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;
         }
     }
 }
Пример #10
0
 /**
  * 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;
 }
Пример #11
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);
 }
Пример #12
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);
 }
Пример #13
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");
     ob_start();
     CollectionsPrinter::printFunctionLinks();
     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>";
     $actionRows->add(new Block(ob_get_contents(), STANDARD_BLOCK), "100%", null, CENTER, CENTER);
     ob_end_clean();
     // Print out the search types
     ob_start();
     // Get all the drs and all of their search types
     $searchModules = Services::getService("RepositorySearchModules");
     $searchArray = array();
     $repositories = $repositoryManager->getRepositories();
     while ($repositories->hasNext()) {
         $repository = $repositories->next();
         $searchTypes = $repository->getSearchTypes();
         while ($searchTypes->hasNext()) {
             $searchType = $searchTypes->next();
             $typeString = HarmoniType::typeToString($searchType);
             if (!isset($searchArray[$typeString])) {
                 $searchArray[$typeString] = $searchType;
             }
         }
     }
     // print out the types
     foreach (array_keys($searchArray) as $typeString) {
         $searchType = $searchArray[$typeString];
         print "\n<h3>" . $typeString . "</h3>";
         $harmoni = Harmoni::instance();
         print "\n" . $searchModules->createSearchForm($repository, $searchType, $harmoni->request->quickURL("collections", "searchresults", array("search_type" => urlencode($typeString))));
     }
     $actionRows->add(new Block(ob_get_contents(), STANDARD_BLOCK), "100%", null, LEFT, CENTER);
     ob_end_clean();
 }
Пример #14
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;
 }
Пример #15
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;
 }
Пример #16
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;
 }
Пример #17
0
 /**
  * Answer the root assets in the current repository
  * 
  * @return object Iterator
  * @access public
  * @since 4/2/07
  */
 function getRootAssets()
 {
     $harmoni = Harmoni::Instance();
     $idManager = Services::getService("Id");
     $rm = Services::getService("Repository");
     $harmoni->request->startNamespace("import");
     $repository = $rm->getRepository($idManager->getId($harmoni->request->get("collection_id")));
     $harmoni->request->endNamespace();
     $criteria = NULL;
     $searchProperties = new HarmoniProperties(HarmoniType::fromString("repository::harmoni::order"));
     $searchProperties->addProperty("order", $orderBy = 'DisplayName');
     $searchProperties->addProperty("direction", $direction = 'ASC');
     unset($orderBy, $direction);
     $assets = $repository->getAssetsBySearch($criteria, new HarmoniType("Repository", "edu.middlebury.harmoni", "RootAssets", ""), $searchProperties);
     return $assets;
 }
Пример #18
0
function printTypeShort($type, $repositoryId)
{
    ob_start();
    $typeString = HarmoniType::typeToString($type, " :: ");
    $harmoni = Harmoni::instance();
    print "<a href='" . $harmoni->request->quickURL("collection", "browsetype", array("collection_id" => $repositoryId->getIdString(), "asset_type" => urlencode($typeString))) . "'>";
    print "\n\t<strong>";
    print $typeString;
    print "</strong>";
    print "</a>";
    $layout = new Block(ob_get_contents(), 4);
    ob_end_clean();
    return $layout;
}
Пример #19
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;
 }
Пример #20
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;
 }
 function CanonicalCourseAssetType()
 {
     parent::HarmoniType("Harmoni", "ClassManagement", "CanonicalCourse");
 }
Пример #22
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 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;
     }
 }
 function __construct()
 {
     parent::__construct("authorization", "edu.middlebury.harmoni", "qualifier");
 }
 /**
  * Exporter of Assets
  * 
  * @access public
  * @since 10/17/05
  */
 function exportAssets()
 {
     $hasRootSearch = FALSE;
     $rootSearchType = new HarmoniType("Repository", "edu.middlebury.harmoni", "RootAssets", "");
     $searchTypes = $this->_object->getSearchTypes();
     while ($searchTypes->hasNext()) {
         if ($rootSearchType->isEqual($searchTypes->next())) {
             $hasRootSearch = TRUE;
             break;
         }
     }
     if ($hasRootSearch) {
         $criteria = NULL;
         $children = $this->_object->getAssetsBySearch($criteria, $rootSearchType, new HarmoniProperties(new Type('Repository', 'edu.middlebury', 'null')));
     } else {
         $children = $this->_object->getAssets();
     }
     $this->_status = new StatusStars(str_replace('%1', $this->_object->getDisplayName(), _("Exporting all Assets in the Collection, '%1'")));
     $this->_status->initializeStatistics($children->count(), 100);
     while ($children->hasNext()) {
         $child = $children->next();
         $exporter = XMLAssetExporter::withDir($this->_xml, $this->_repDir);
         $exporter->export($child);
         $this->_status->updateStatistics();
     }
     unset($exporter);
 }
Пример #25
0
    /**
     * 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();
    }
Пример #26
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;
 }
 /**
  * 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;
     }
 }
Пример #28
0
 /**
  * Loads the definition data from the database, if not already done.
  * @return bool FALSE on error.
  */
 function load()
 {
     // load our fields from the database
     if ($this->loaded()) {
         //			throwError( new Error("Already loaded from the database for type ".HarmoniType::typeToString($this->_type).".","DataSetTypeDefinition",true));
         return true;
     }
     // attempt to get our ID from the SchemaManager
     if (!$this->_isCreatedByManager) {
         throwError(new Error("The Schema object of type '" . HarmoniType::typeToString($this->_type) . "'\n\t\t\t\twas not meant to interface with the database.", "DataManager", true));
         return false;
     }
     $query = new SelectQuery();
     $query->addTable("dm_schema_field");
     $query->addColumn("id", "", "dm_schema_field");
     $query->addColumn("name", "", "dm_schema_field");
     $query->addColumn("mult", "", "dm_schema_field");
     $query->addColumn("required", "", "dm_schema_field");
     $query->addColumn("active", "", "dm_schema_field");
     $query->addColumn("fieldtype", "", "dm_schema_field");
     $query->addColumn("description", "", "dm_schema_field");
     $query->setWhere("fk_schema='" . addslashes($this->_id) . "'");
     $dbHandler = Services::getService("DatabaseManager");
     $result = $dbHandler->query($query, DATAMANAGER_DBID);
     if (!$result) {
         throwError(new UnknownDBError("DataManager"));
     }
     $rows = array();
     while ($result->hasMoreRows()) {
         $rows[] = $result->getCurrentRow();
         $result->advanceRow();
     }
     $result->free();
     $this->populate($rows);
     return true;
 }
Пример #29
0
 function _loadPlugins()
 {
     // cache the installed plugins
     $db = Services::getService("DBHandler");
     $pm = Services::getService("Plugs");
     $query = new SelectQuery();
     $query->addTable("plugin_type");
     $query->addColumn("*");
     $query->addOrderBy('type_id');
     $results = $db->query($query, IMPORTER_CONNECTION);
     $dis = array();
     $en = array();
     while ($results->hasNext()) {
         $result = $results->next();
         $pluginType = new Type($result['type_domain'], $result['type_authority'], $result['type_keyword']);
         $class = $this->getPluginClass($pluginType);
         if (class_exists($class)) {
             $pluginType = new Type($pluginType->getDomain(), $pluginType->getAuthority(), $pluginType->getKeyword(), call_user_func(array($class, 'getPluginDescription')));
         }
         if ($result['type_enabled'] == 1) {
             $this->_enabledPlugins[HarmoniType::typeToString($pluginType)] = $pluginType;
         } else {
             $this->_disabledPlugins[HarmoniType::typeToString($pluginType)] = $pluginType;
         }
     }
     $this->_cachePluginArrays();
 }
 /**
  * This method will add the Javascript contained in a file in the plugin's
  * 'public' subdirectory to the <head> of the page the plugin
  * is displayed on.
  *
  * Example, assignment_functions.js in an 'Assignment' plugin by Example University:
  *
  * File Structure
  *		Assignment/
  *			EduExampleAssignmentPlugin.class.php
  *			icon.png
  *			public/
  *				status_image.gif
  *				assignment_styles.css
  *				assignment_functions.js
  *	
  * Usage: $this->addHeadJavascript('assignment_functions.js');
  * 
  * @param string $filename
  * @return void
  * @access public
  * @since 6/18/08
  */
 public final function addHeadJavascript($filename)
 {
     $harmoni = Harmoni::instance();
     // Get the file url
     $harmoni->request->startNamespace(null);
     $url = $harmoni->request->quickURL('plugin_manager', 'public_file', array('plugin' => HarmoniType::typeToString($this->_asset->getAssetType()), 'file' => $filename));
     $harmoni->request->endNamespace();
     // If this file has been added already, don't add it again.
     if (in_array($url, self::$headJs)) {
         return;
     } else {
         self::$headJs[] = $url;
     }
     // Add the js to the head
     $outputHandler = $harmoni->getOutputHandler();
     $outputHandler->setHead($outputHandler->getHead() . "\n\t\t<script type='text/javascript' src='{$url}'></script>");
 }