function getVisitorLoginLink() { $harmoni = Harmoni::instance(); $authN = Services::getService("AuthN"); // Visitor Registration Link $authTypes = $authN->getAuthenticationTypes(); $hasVisitorType = false; $visitorType = new Type("Authentication", "edu.middlebury.harmoni", "Visitors"); while ($authTypes->hasNext()) { $authType = $authTypes->next(); if ($visitorType->isEqual($authType)) { $hasVisitorType = true; break; } } if ($hasVisitorType && !$authN->isUserAuthenticatedWithAnyType()) { $harmoni->request->startNamespace('polyphony'); $url = $harmoni->request->mkURL("auth", "login_type"); $url->setValue("type", urlencode($visitorType->asString())); // Add return info to the visitor registration url $visitorReturnModules = array('view', 'ui1', 'ui2', 'versioning'); if (in_array($harmoni->request->getRequestedModule(), $visitorReturnModules)) { $url->setValue('returnModule', $harmoni->request->getRequestedModule()); $url->setValue('returnAction', $harmoni->request->getRequestedAction()); $url->setValue('returnKey', 'node'); $url->setValue('returnValue', SiteDispatcher::getCurrentNodeId()); } $harmoni->request->endNamespace(); return "\n\t<a href='" . $url->write() . "'>" . _("Visitor Login") . "</a>"; } return null; }
/** * 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); }
/** * Check Authorizations * * @return boolean * @access public * @since 6/4/08 */ function isAuthorizedToExecute() { $authNManager = Services::getService("AuthN"); $authTypes = $authNManager->getAuthenticationTypes(); $visitorType = new Type("Authentication", "edu.middlebury.harmoni", "Visitors"); while ($authTypes->hasNext()) { $authType = $authTypes->next(); if ($visitorType->isEqual($authType)) { return true; } } return false; }
/** * 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 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(); // Get the Repositoriess $repositoryManager = Services::getService("Repository"); $allRepositories = $repositoryManager->getRepositories(); $exhibitionRepositoryType = new Type('System Repositories', 'edu.middlebury.concerto', 'Exhibitions'); // put the drs into an array and order them. // @todo, do authorization checking $repositoryArray = array(); $repositoryTitles = array(); while ($allRepositories->hasNext()) { $repository = $allRepositories->next(); // include all but Exhibitions repository. if (!$exhibitionRepositoryType->isEqual($repository->getType())) { $id = $repository->getId(); $repositoryTitles[$id->getIdString()] = $repository->getDisplayName(); $repositoryArray[$id->getIdString()] = $repository; } } array_multisort($repositoryTitles, SORT_ASC, SORT_STRING, $repositoryArray); // print the Results $resultPrinter = new ArrayResultPrinter($repositoryArray, 1, 20, "printRepositoryShort", $harmoni); $resultPrinter->addLinksStyleProperty(new MarginTopSP("10px")); $resultLayout = $resultPrinter->getLayout('canView'); $actionRows->add($resultLayout, "100%", null, LEFT, CENTER); }
/** * Answer the Site asset for a content asset * * @param object Asset $asset * @return object Asset * @access protected * @since 2/26/07 */ protected function getSiteAsset(Asset $asset) { $siteType = new Type('segue', 'edu.middlebury', 'SiteNavBlock'); if ($siteType->isEqual($asset->getAssetType())) { return $asset; } else { $parents = $asset->getParents(); while ($parents->hasNext()) { $result = $this->getSiteAsset($parents->next()); if ($result) { return $result; } } } return false; }
/** * Perform a search of the specified Type and get all the Assets that * satisfy the SearchCriteria. Iterators return a set, one at a time. * * @param object mixed $searchCriteria (original type: java.io.Serializable) * @param object Type $searchType * @param object Properties $searchProperties * * @return object AssetIterator * * @throws object RepositoryException An exception with one of * the following messages defined in * org.osid.repository.RepositoryException may be thrown: {@link * org.osid.repository.RepositoryException#OPERATION_FAILED * OPERATION_FAILED}, {@link * org.osid.repository.RepositoryException#PERMISSION_DENIED * PERMISSION_DENIED}, {@link * org.osid.repository.RepositoryException#CONFIGURATION_ERROR * CONFIGURATION_ERROR}, {@link * org.osid.repository.RepositoryException#UNIMPLEMENTED * UNIMPLEMENTED}, {@link * org.osid.repository.RepositoryException#NULL_ARGUMENT * NULL_ARGUMENT}, {@link * org.osid.repository.RepositoryException#UNKNOWN_TYPE * UNKNOWN_TYPE} * * @access public */ function getAssetsBySearch($searchCriteria, Type $searchType, Properties $searchProperties) { if ($searchProperties->getType()->isEqual(new Type('Repository', 'edu.middlebury', 'null'))) { $searchProperties = null; } // Check that we support the searchType $supported = FALSE; foreach (array_keys($this->_searchTypes) as $key) { if ($searchType->isEqual($this->_searchTypes[$key])) { $supported = TRUE; $searchName = $key; break; } } if ($supported) { $search = new $searchName($this); $assetIds = $search->searchAssets($searchCriteria, $searchProperties); // get the assets for the resuting ids $assets = array(); // Order if (is_object($searchProperties) && $searchProperties->getProperty("order") == "DisplayName") { foreach ($assetIds as $key => $id) { $asset = $this->getAsset($assetIds[$key], FALSE); $assets[$asset->getDisplayName() . $id->getIdString()] = $asset; } } else { if (is_object($searchProperties) && $searchProperties->getProperty("order") == "Id") { foreach ($assetIds as $key => $id) { $assets[$assetIds[$key]->getIdString()] = $this->getAsset($assetIds[$key], FALSE); } } else { if (is_object($searchProperties) && $searchProperties->getProperty("order") == "ModificationDate") { foreach ($assetIds as $key => $id) { $asset = $this->getAsset($assetIds[$key], FALSE); $date = $asset->getModificationDate(); $assets[$date->asString() . $id->getIdString()] = $asset; } } else { if (is_object($searchProperties) && $searchProperties->getProperty("order") == "CreationDate") { foreach ($assetIds as $key => $id) { $asset = $this->getAsset($assetIds[$key], FALSE); $date = $asset->getCreationDate(); $assets[$date->asString() . $id->getIdString()] = $asset; } } else { foreach ($assetIds as $key => $id) { $assets[] = $this->getAsset($assetIds[$key], FALSE); } } } } } // Filter based on type // This can probably be moved to the search modules to improve // performance by eliminating these assets before they are otherwise // operated on. if (is_object($searchProperties) && is_array($searchProperties->getProperty("allowed_types")) && count($searchProperties->getProperty("allowed_types"))) { $allowedTypes = $searchProperties->getProperty("allowed_types"); foreach (array_keys($assets) as $key) { $type = $assets[$key]->getAssetType(); $allowed = FALSE; foreach (array_keys($allowedTypes) as $typeKey) { if ($type->isEqual($allowedTypes[$typeKey])) { $allowed = TRUE; break; } } if (!$allowed) { unset($assets[$key]); } } } // Order Direction if (is_object($searchProperties) && $searchProperties->getProperty("direction") == "DESC") { krsort($assets); } else { ksort($assets); } // create an AssetIterator and return it $assetIterator = new HarmoniAssetIterator($assets); return $assetIterator; } else { throwError(new Error(RepositoryException::UNKNOWN_TYPE() . " " . $searchType->getDomain() . "::" . $searchType->getAuthority() . "::" . $searchType->getKeyword(), "Repository", 1)); } }
/** * Answer the Content asset that a comment is attached to * * @param object Id $commentId * @return object Asset * @access public * @static * @since 11/9/07 */ public function getParentComment() { $commentManager = CommentManager::instance(); $commentContainerType = new Type('segue', 'edu.middlebury', 'comment_container', 'A container for Segue Comments'); $parent = $this->_asset->getParents()->next(); if ($commentContainerType->isEqual($parent->getAssetType())) { return null; } else { return $commentManager->getComment($parent); } }
/** * Return the ReadableLog Entries in a last-in, first-out (LIFO) order. * Limit by the search criteria. * * Warning: NOT IN OSID * * @param mixed $searchCriteria * @param object Type $searchType * @param object Type $formatType * @param object Type $priorityType * * @return object EntryIterator * * @throws object LoggingException An exception with one of the * following messages defined in org.osid.logging.LoggingException * may be thrown: {@link * org.osid.logging.LoggingException#UNIMPLEMENTED UNIMPLEMENTED}, * {@link org.osid.logging.LoggingException#OPERATION_FAILED * OPERATION_FAILED}, {@link * org.osid.logging.LoggingException#CONFIGURATION_ERROR * CONFIGURATION_ERROR}, {@link * org.osid.logging.LoggingException#PERMISSION_DENIED * PERMISSION_DENIED}, {@link * org.osid.logging.LoggingException#NULL_ARGUMENT NULL_ARGUMENT}, * {@link org.osid.logging.LoggingException#UNKNOWN_TYPE * UNKNOWN_TYPE} * * @access public */ function getEntriesBySearch($searchCriteria, Type $searchType, Type $formatType, Type $priorityType) { $validType = new Type("logging_search", "edu.middlebury", "Date-Range/Agent/Node"); if (!$validType->isEqual($searchType)) { throwError(new Error("Invalid search type, " . $searchType->asString() . ".", "Logging")); } $iterator = new SearchEntryIterator($this->_name, $searchCriteria, $formatType, $priorityType, $this->_dbIndex); return $iterator; }
/** * Get all CanonicalCourses of the specified Type. * * @param object Type $courseType * * @return object CanonicalCourseIterator * * @throws object CourseManagementException An exception * with one of the following messages defined in * org.osid.coursemanagement.CourseManagementException may be * thrown: {@link * org.osid.coursemanagement.CourseManagementException#OPERATION_FAILED * OPERATION_FAILED}, {@link * org.osid.coursemanagement.CourseManagementException#PERMISSION_DENIED * PERMISSION_DENIED}, {@link * org.osid.coursemanagement.CourseManagementException#CONFIGURATION_ERROR * CONFIGURATION_ERROR}, {@link * org.osid.coursemanagement.CourseManagementException#UNIMPLEMENTED * UNIMPLEMENTED}, {@link * org.osid.coursemanagement.CourseManagementException#NULL_ARGUMENT * NULL_ARGUMENT}, {@link * org.osid.coursemanagement.CourseManagementException#UNKNOWN_TYPE * UNKNOWN_TYPE} * * @access public */ function getCanonicalCoursesByType(Type $courseType) { $cm = Services::getService("CourseManagement"); //get the children $node = $this->_node; $nodeType = $node->getType(); $children = $node->getChildren(); //iterate throught the children $array = array(); while ($children->hasNextNode()) { $child = $children->nextNode(); $currNodeType = $child->getType(); //If this node is also a CanonicalCourse if ($currNodeType->isEqual($nodeType)) { $id = $child->getId(); $course = $cm->getCanonicalCourse($id); if ($courseType->isEqual($course->getCourseType())) { $array[] = $cm->getCanonicalCourse($id); } } } //convert to an iterator and return $ret = new HarmoniCanonicalCourseIterator($array); return $ret; }
/** * Get the Properties of this Type associated with this Group. * * @param object Type $propertiesType * * @return object Properties * * @throws object AgentException An exception with one of the * following messages defined in org.osid.agent.AgentException may * be thrown: {@link * org.osid.agent.AgentException#OPERATION_FAILED * OPERATION_FAILED}, {@link * org.osid.agent.AgentException#PERMISSION_DENIED * PERMISSION_DENIED}, {@link * org.osid.agent.AgentException#CONFIGURATION_ERROR * CONFIGURATION_ERROR}, {@link * org.osid.agent.AgentException#UNIMPLEMENTED UNIMPLEMENTED}, * {@link org.osid.agent.AgentException#NULL_ARGUMENT * NULL_ARGUMENT}, {@link * org.osid.agent.AgentException#UNKNOWN_TYPE UNKNOWN_TYPE} * * @access public */ function getPropertiesByType(Type $propertiesType) { if (!$propertiesType->isEqual(new Type('GroupProperties', 'edu.middlebury', 'LDAP Properties'))) { throw new UnknownTypeException("Unsupported Properties type."); } if (!isset($_SESSION['LDAP_GROUP_PROPERTIES'][$this->_idString])) { $properties = new HarmoniProperties(new Type('GroupProperties', 'edu.middlebury', 'LDAP Properties')); $properties->addProperty('identifier', $this->_idString); $propertiesFields = $this->_configuration->getProperty('group_properties_fields'); if (is_array($propertiesFields)) { $fieldsToFetch = array(); foreach ($propertiesFields as $propertyKey => $fieldName) { $fieldsToFetch[] = $fieldName; } $info = $this->_authNMethod->_connector->getInfo($this->_idString, $fieldsToFetch); if (!$info) { // store a null so that we won't keep trying to fetch data. $_SESSION['LDAP_GROUP_PROPERTIES'][$this->_idString] = null; throw new OperationFailedException("Could not fetch LDAP group info."); } foreach ($propertiesFields as $propertyKey => $fieldName) { if (isset($info[$fieldName])) { if (count($info[$fieldName]) <= 1) { $properties->addProperty($propertyKey, $info[$fieldName][0]); } else { $properties->addProperty($propertyKey, $info[$fieldName]); } } } } $_SESSION['LDAP_GROUP_PROPERTIES'][$this->_idString] = $properties; } if (is_null($_SESSION['LDAP_GROUP_PROPERTIES'][$this->_idString])) { throw new OperationFailedException("Could not fetch LDAP group info."); } return $_SESSION['LDAP_GROUP_PROPERTIES'][$this->_idString]; }
/** * Create a new Wizard for this action. Caching of this Wizard is handled by * {@link getWizard()} and does not need to be implemented here. * * @return object Wizard * @access public * @since 4/28/05 */ function createWizard() { $repository = $this->getRepository(); // Instantiate the wizard, then add our steps. $wizard = SimpleStepWizard::withDefaultLayout(); // :: Step One :: $stepOne = $wizard->addStep("namedesc", new WizardStep()); $stepOne->setDisplayName(_("Name & Description")); // Create the properties. $displayNameProp = $stepOne->addComponent("display_name", new WTextField()); $displayNameProp->setErrorRule(new WECNonZeroRegex("[\\w]+")); $displayNameProp->setErrorText(_("A value for this field is required.")); $descriptionProp = $stepOne->addComponent("description", WTextArea::withRowsAndColumns(5, 30)); $formatProp = $stepOne->addComponent("format", new WTextField()); $formatProp->setValue("Plain Text - UTF-8 encoding"); $formatProp->setErrorRule(new WECNonZeroRegex("[\\w]+")); $formatProp->setErrorText(_("A value for this field is required.")); $formatProp->setSize(25); // Create the step text ob_start(); print "\n<h2>" . _("Name") . "</h2>"; print "\n" . _("The Name for this Schema: "); print "\n<br />[[display_name]]"; print "\n<h2>" . _("Description") . "</h2>"; print "\n" . _("The Description for this Schema: "); print "\n<br />[[description]]"; print "\n<h2>" . _("Format") . "</h2>"; print "\n" . _("The format of data that is entered into the fields: "); print "\n<br /><em>" . _("'Plain Text - ASCII encoding', 'XML', etc.") . "</em>"; print "\n<br />[[format]]"; print "\n<div style='width: 400px'> </div>"; $stepOne->setContent(ob_get_contents()); ob_end_clean(); // :: Add Elements :: $elementStep = $wizard->addStep("elementstep", new WizardStep()); $elementStep->setDisplayName(_("Fields")); $multField = $elementStep->addComponent("elements", new WOrderedRepeatableComponentCollection()); $multField->setAddLabel(_("Add New Field")); $multField->setRemoveLabel(_("Remove Field")); $property = $multField->addComponent("display_name", new WTextField()); $property->setErrorRule(new WECNonZeroRegex("[\\w]+")); $property->setErrorText(_("A value for this property is required.")); $property->setSize(20); $property = $multField->addComponent("description", WTextArea::withRowsAndColumns(2, 30)); $property = $multField->addComponent("type", new WSelectList()); $defaultType = new Type("Repository", "edu.middlebury.harmoni", "shortstring"); $property->setValue(urlencode(HarmoniType::typeToString($defaultType, " :: "))); // We are going to assume that all RecordStructures have the same PartStructureTypes // in this Repository. This will allow us to list PartStructureTypes before // the RecordStructure is actually created. $recordStructures = $repository->getRecordStructures(); if (!$recordStructures->hasNext()) { throwError(new Error("No RecordStructures available.", "Concerto")); } $dmpType = new Type("RecordStructures", "edu.middlebury.harmoni", "DataManagerPrimatives", "RecordStructures stored in the Harmoni DataManager."); $orderedTypes = array("Repository :: edu.middlebury.harmoni :: shortstring" => _("Short String ----- text with max-length of 256 characters"), "Repository :: edu.middlebury.harmoni :: string" => _("String ---------- text with unlimited length"), "Repository :: edu.middlebury.harmoni :: datetime" => _("Date [and Time] -- a date or more precise point in time"), "Repository :: edu.middlebury.harmoni :: integer" => _("Integer --------- a whole number: 1, 2, 3, etc"), "Repository :: edu.middlebury.harmoni :: float" => _("Float ----------- a decimal/scientific-notation number"), "Repository :: edu.middlebury.harmoni :: boolean" => _("Boolean --------- true or false (yes/no)"), "Repository :: edu.middlebury.harmoni :: blob" => _("BLOB ----------- Binary Large OBject, for binary data"), "Repository :: edu.middlebury.harmoni :: okitype" => _("O.K.I. Type ------ 'domain :: authority :: keyword' triplet")); $unorderedTypes = array(); while ($recordStructures->hasNext()) { // we want just the datamanager structure types, so just // get the first structure that has Format "DataManagerPrimatives" $tmpRecordStructure = $recordStructures->next(); if ($dmpType->isEqual($tmpRecordStructure->getType())) { $types = $tmpRecordStructure->getPartStructureTypes(); while ($types->hasNext()) { $type = $types->next(); $typeString = $type->asString(" :: "); if (!array_key_exists($typeString, $orderedTypes)) { $unorderedTypes[$typeString] = $typeString; } } break; } } foreach ($orderedTypes as $typeString => $desc) { $property->addOption(urlencode($typeString), $desc); } foreach ($unorderedTypes as $typeString => $desc) { $property->addOption(urlencode($typeString), $desc); } $property = $multField->addComponent("mandatory", new WCheckBox()); $property->setChecked(false); $property->setLabel(_("yes")); $property = $multField->addComponent("repeatable", new WCheckBox()); // $property->setChecked(false); $property->setLabel(_("yes")); // $property =$multField->addComponent( // "populatedbydr", // new WCheckBox()); // $property->setChecked(false); // $property->setLabel(_("yes")); $property = $multField->addComponent("authoritative_values", WTextArea::withRowsAndColumns(10, 40)); // We don't have any PartStructures yet, so we can't get them. ob_start(); print "\n<table border=\"0\">"; print "\n<tr><td>"; print _("DisplayName") . ": "; print "\n</td><td>"; print "[[display_name]]"; print "\n</td></tr>"; print "\n<tr><td>"; print _("Description") . ": "; print "\n</td><td>"; print "[[description]]"; print "\n</td></tr>"; print "\n<tr><td style='color: red;'>"; print _("Type") . "... "; print "\n *</td><td>"; print "[[type]]"; print "\n</td></tr>"; print "\n<tr><td>"; print _("isMandatory? "); print "\n</td><td>"; print "[[mandatory]]"; print "\n</td></tr>"; print "\n<tr><td style='color: red;'>"; print _("isRepeatable? "); print "\n *</td><td>"; print "[[repeatable]]"; print "\n</td></tr>"; // print "\n<tr><td>"; // print _("isPopulatedByRepository? "); // print "\n</td><td>"; // print "[[populatedbydr]]"; // print "\n</td></tr>"; print "\n<tr><td>"; print _("Authoritative Values: "); print "\n</td><td>"; print "[[authoritative_values]]"; print "\n</td></tr>"; print "</table>"; $multField->setElementLayout(ob_get_contents()); ob_end_clean(); ob_start(); print "<h2>" . _("Fields") . "</h2>"; print "\n<p>" . _("Here you can modify the properties of fields and add new fields to the schema.") . "</p>"; print "\n<p>" . _("<strong>Important:</strong> Properties marked with an asterisk (<span style='color: red'>*</span>) can not be changed after the field is created.") . "</p>"; print "[[elements]]"; $elementStep->setContent(ob_get_contents()); ob_end_clean(); return $wizard; }
/** * Create a Group with the display name, Type, description, and Properties * specified. All but description are immutable. * * @param string $displayName * @param object Type $groupType * @param string $description * @param object Properties $properties * * @return object Group * * @throws object AgentException An exception with one of the * following messages defined in org.osid.agent.AgentException may * be thrown: {@link * org.osid.agent.AgentException#OPERATION_FAILED * OPERATION_FAILED}, {@link * org.osid.agent.AgentException#PERMISSION_DENIED * PERMISSION_DENIED}, {@link * org.osid.agent.AgentException#CONFIGURATION_ERROR * CONFIGURATION_ERROR}, {@link * org.osid.agent.AgentException#UNIMPLEMENTED UNIMPLEMENTED}, * {@link org.osid.agent.AgentException#NULL_ARGUMENT * NULL_ARGUMENT}, {@link * org.osid.agent.AgentException#UNKNOWN_TYPE UNKNOWN_TYPE} * * @access public */ function createGroup($displayName, Type $groupType, $description, Properties $properties, Id $id = null) { // ** parameter validation ArgumentValidator::validate($displayName, StringValidatorRule::getRule(), true); ArgumentValidator::validate($description, StringValidatorRule::getRule(), true); // ensure that we aren't using the type of one of the AuthNTypes // which would confict with external directories. // :: Add External Groups $authNMethodManager = Services::getService("AuthNMethodManager"); $types = $authNMethodManager->getAuthNTypes(); while ($types->hasNext()) { if ($groupType->isEqual($types->next())) { throwError(new Error(AgentException::PERMISSION_DENIED(), "GroupManager", true)); } } // ** end of parameter validation // create a new unique id for the group if (is_object($id) && method_exists($id, 'getIdString')) { $groupId = $id; } else { $idManager = Services::getService("Id"); $groupId = $idManager->createId(); } // 1. Create the node $hierarchyManager = Services::getService("Hierarchy"); $hierarchy = $hierarchyManager->getHierarchy($this->_hierarchyId); $groupNode = $hierarchy->createNode($groupId, $this->_allGroupsId, $groupType, $displayName, $description); // 2. Store the properties of the group. $propertyManager = Services::getService("Property"); $propertiesId = $propertyManager->storeProperties($groupId->getIdString(), $properties); // create the group object to return $group = new HarmoniGroup($hierarchy, $groupNode); // update our cache for isGroup if (isset($this->_groupTreeIds) && is_array($this->_groupTreeIds)) { $this->_groupTreeIds[$groupId->getIdString()] = $groupId; } return $group; }
/** * Perform a search of the specified Type and get all the Assets that * satisfy the SearchCriteria. Iterators return a set, one at a time. * * @param object mixed $searchCriteria (original type: java.io.Serializable) * @param object Type $searchType * @param object Properties $searchProperties * * @return object AssetIterator * * @throws object RepositoryException An exception with one of * the following messages defined in * org.osid.repository.RepositoryException may be thrown: {@link * org.osid.repository.RepositoryException#OPERATION_FAILED * OPERATION_FAILED}, {@link * org.osid.repository.RepositoryException#PERMISSION_DENIED * PERMISSION_DENIED}, {@link * org.osid.repository.RepositoryException#CONFIGURATION_ERROR * CONFIGURATION_ERROR}, {@link * org.osid.repository.RepositoryException#UNIMPLEMENTED * UNIMPLEMENTED}, {@link * org.osid.repository.RepositoryException#NULL_ARGUMENT * NULL_ARGUMENT}, {@link * org.osid.repository.RepositoryException#UNKNOWN_TYPE * UNKNOWN_TYPE} * * @access public */ function getAssetsBySearch($searchCriteria, Type $searchType, Properties $searchProperties) { if ($searchType->isEqual(new Type("Repository", "edu.middlebury.harmoni", "Keyword", "Search with a string for keywords."))) { if (!is_string($searchCriteria)) { throw new OperationFailedException('search criteria should be a string.'); } // Convert the criteria to the proper character set. $encoding = $this->config['encoding']; if (!is_null($encoding)) { $searchCriteria = iconv('UTF-8', $encoding, $searchCriteria); } $query = new SelectQuery(); $query->addTable($this->config['table']); $query->addColumn($this->config['id_column']); $query->addWhereLike($this->config['id_column'], '%' . $searchCriteria . '%'); foreach ($this->config['columns'] as $column) { $query->addColumn($column); $query->addWhereLike($column, '%' . $searchCriteria . '%', _OR); } if ($this->config['order_column']) { $query->addOrderBy($this->config['order_column'], $this->config['order_direction']); } return new SimpleTableAssetIterator($this, $this->config, $this->dbc->query($query, $this->dbIndex)); } else { if ($searchType->isEqual(new Type("Repository", "edu.middlebury.harmoni", "RootAssets", "Search for just the 'root' or 'top level' assets which are not assets of other assets."))) { return $this->getAssets(); } else { throw new UnknownTypeException('UNKNOWN_TYPE'); } } }
/** * Build the content for this action * * @return void * @access public * @since 10/24/05 */ function buildContent() { $actionRows = $this->getActionRows(); $harmoni = Harmoni::instance(); if (RequestContext::value('login_failed')) { $actionRows->add(new Heading("<span style='color: red;'>" . _("Error: Login Failed. Either your username or password was invalid.") . "</span>", 2)); } $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(); // Visitor Registration Link $authTypes = $authNManager->getAuthenticationTypes(); $hasVisitorType = false; $visitorType = new Type("Authentication", "edu.middlebury.harmoni", "Visitors"); while ($authTypes->hasNext()) { $authType = $authTypes->next(); if ($visitorType->isEqual($authType)) { $hasVisitorType = true; break; } } if ($hasVisitorType && !$authNManager->isUserAuthenticatedWithAnyType()) { ob_start(); print "\n<ul>" . "\n\t<li><a href='" . $harmoni->request->quickURL("user", "visitor_reg") . "'>" . _("Visitor Registration") . "</a></li>" . "\n</ul>"; $actionRows->add(new Block(ob_get_clean(), STANDARD_BLOCK), "100%", null, CENTER, CENTER); } // Change Password ob_start(); $authTypes = $authNManager->getAuthenticationTypes(); while ($authTypes->hasNext()) { $authType = $authTypes->next(); if ($authNManager->isUserAuthenticated($authType)) { $methodMgr = Services::getService("AuthNMethodManager"); try { $method = $methodMgr->getAuthNMethodForType($authType); if ($method->supportsTokenUpdates()) { print "\n\t<li><a href='" . $harmoni->request->quickURL("user", "change_password") . "'>"; $keyword = $authType->getKeyword(); print str_replace('%1', $keyword, dgettext("polyphony", "Change '%1' Password")); print "</a></li>"; } } catch (Exception $e) { } } } $passLinks = ob_get_clean(); if (strlen($passLinks)) { $actionRows->add(new Block("\n<ul>" . $passLinks . "\n</ul>", STANDARD_BLOCK), "100%", null, CENTER, CENTER); } }
/** * Build the rss feed * * @return void * @access public * @since 8/10/06 */ function buildFeed() { $harmoni = Harmoni::instance(); $repositoryManager = Services::getService('Repository'); $authZManager = Services::getService("AuthZ"); $idManager = Services::getService("IdManager"); $repositoryId = $idManager->getId("edu.middlebury.concerto.exhibition_repository"); $repository = $repositoryManager->getRepository($repositoryId); if (RequestContext::value('exhibition_id')) { $exhibitionAssetId = $idManager->getId(RequestContext::value('exhibition_id')); $exhibitionAsset = $repository->getAsset($exhibitionAssetId); } else { $exhibitionAssetId = null; $exhibitionAsset = null; } if ($exhibitionAsset) { $title = $exhibitionAsset->getDisplayName(); $this->setDescription($exhibitionAsset->getDescription()); $this->setLink($harmoni->request->quickURL('exhibitions', 'browse_exhibition', array('exhibition_id' => $exhibitionAssetId->getIdString()))); } else { $title = _("All of Concerto"); $this->setDescription(_("Slideshows from across all of Concerto.")); $this->setLink($harmoni->request->quickURL('exhibitions', 'browse')); } if (RequestContext::value('order') == 'modification') { $title .= " - " . _("Recently Changed Slideshows"); } else { $title .= " - " . _("Newest Slideshows"); } $this->setTitle($title); $slideshowAssets = $this->getAssets($repository); $i = 0; $exhibitionAssetType = new Type("Asset Types", "edu.middlebury.concerto", "Exhibition"); while ($slideshowAssets->hasNext() && $i < 20) { $slideshowAsset = $slideshowAssets->next(); $slideshowAssetId = $slideshowAsset->getId(); // Limit to only one exhibition if necessary $include = true; if (is_object($exhibitionAssetId)) { $parents = $slideshowAsset->getParents(); while ($parents->hasNext()) { $parent = $parents->next(); if ($exhibitionAssetType->isEqual($parent->getAssetType()) && !$exhibitionAssetId->isEqual($parent->getId())) { $include = false; } } } // Check Authorization if ($include && $authZManager->isUserAuthorized($idManager->getId("edu.middlebury.authorization.view"), $slideshowAssetId)) { $this->addItem($this->getAssetItem($slideshowAsset)); $i++; } } }
/** * Answer the Content asset that a comment is attached to * * @param object Id $commentId * @return object Asset * @access public * @static * @since 11/9/07 */ public static function getCommentParentAsset(CommentNode $comment) { $manager = CommentManager::instance(); $commentContainerType = new Type('segue', 'edu.middlebury', 'comment_container', 'A container for Segue Comments'); $parent = $comment->_asset->getParents()->next(); while (!$commentContainerType->isEqual($parent->getAssetType())) { $parent = $parent->getParents()->next(); } return $parent->getParents()->next(); }
/** * Validate the type passed to ensure that it is one of our supported ones. * An error will be thrown if the type is invalid. * * @param object Type $type * @return void * @access private * @since 3/15/05 */ function _checkType(Type $type) { $typeValid = FALSE; $authNTypes = $this->getAuthenticationTypes(); while ($authNTypes->hasNext()) { if ($type->isEqual($authNTypes->next())) { $typeValid = TRUE; break; } } if (!$typeValid) { throw new UnknownTypeException($this->_getTypeString($type)); } }
/** * Create a CourseGradeRecord for the specified Agent (student), * CourseOffering, CourseGradeType, and CourseGrade. Note that the intent * is that this is a summative grade. * * @param object Id $agentId * @param object Id $courseOfferingId * @param object Type $courseGradeType * @param object mixed $courseGrade (original type: java.io.Serializable) * * @return object CourseGradeRecord * * @throws object CourseManagementException An exception * with one of the following messages defined in * org.osid.coursemanagement.CourseManagementException may be * thrown: {@link * org.osid.coursemanagement.CourseManagementException#OPERATION_FAILED * OPERATION_FAILED}, {@link * org.osid.coursemanagement.CourseManagementException#PERMISSION_DENIED * PERMISSION_DENIED}, {@link * org.osid.coursemanagement.CourseManagementException#CONFIGURATION_ERROR * CONFIGURATION_ERROR}, {@link * org.osid.coursemanagement.CourseManagementException#UNIMPLEMENTED * UNIMPLEMENTED}, {@link * org.osid.coursemanagement.CourseManagementException#NULL_ARGUMENT * NULL_ARGUMENT}, {@link * org.osid.coursemanagement.CourseManagementException#UNKNOWN_TYPE * UNKNOWN_TYPE}, {@link * org.osid.coursemanagement.CourseManagementException#UNKNOWN_ID * UNKNOWN_ID} * * @access public */ function createCourseGradeRecord(Id $agentId, Id $courseOfferingId, Type $courseGradeType, $courseGrade) { $idManager = Services::getService("IdManager"); $dbManager = Services::getService("DatabaseManager"); $courseOffering = $this->getCourseOffering($courseOfferingId); if ($courseGradeType != null && !$courseGradeType->isEqual($courseOffering->getGradeType())) { throwError(new Error("Cannot create a CourseGradeRecord if the GradeType differs from the CourseOffering", "CourseManagementManager", true)); } $query = new InsertQuery(); $query->setTable('cm_grade_rec'); $query->setColumns(array('fk_student_id', 'fk_cm_offer', 'name', 'grade')); $values[] = "'" . addslashes($agentId->getIdString()) . "'"; $values[] = "'" . addslashes($courseOfferingId->getIdString()) . "'"; $values[] = "'CourseGradeRecord'"; $values[] = "'" . addslashes($courseGrade) . "'"; $query->addRowOfValues($values); $query->setAutoIncrementColumn('id', 'cm_grade_rec_id_seq'); $result = $dbManager->query($query); $id = $result->getLastAutoIncrementValue(); $ret = new HarmoniCourseGradeRecord($idManager->getId($id)); return $ret; }
/** * Get the Properties of this Type associated with this Group. * * @param object Type $propertiesType * * @return object Properties * * @throws object AgentException An exception with one of the * following messages defined in org.osid.agent.AgentException may * be thrown: {@link * org.osid.agent.AgentException#OPERATION_FAILED * OPERATION_FAILED}, {@link * org.osid.agent.AgentException#PERMISSION_DENIED * PERMISSION_DENIED}, {@link * org.osid.agent.AgentException#CONFIGURATION_ERROR * CONFIGURATION_ERROR}, {@link * org.osid.agent.AgentException#UNIMPLEMENTED UNIMPLEMENTED}, * {@link org.osid.agent.AgentException#NULL_ARGUMENT * NULL_ARGUMENT}, {@link * org.osid.agent.AgentException#UNKNOWN_TYPE UNKNOWN_TYPE} * * @access public */ function getPropertiesByType(Type $propertiesType) { if (!$propertiesType->isEqual(new Type('GroupProperties', 'edu.middlebury', 'CAS Properties'))) { throw new UnknownTypeException("Unsupported Properties type."); } if (!isset($this->properties)) { $result = $this->_authNMethod->_queryDirectory('get_group', array('id' => $this->_id->getIdString())); if ($result) { $elements = $result->getElementsByTagNameNS('http://www.yale.edu/tp/cas', 'entry'); if ($elements->length) { $this->properties = $this->_authNMethod->_getPropertiesFromCASEntry($elements->item(0)); } else { $this->properties = new HarmoniProperties(new Type('GroupProperties', 'edu.middlebury', 'CAS Properties')); } } else { $this->properties = new HarmoniProperties(new Type('GroupProperties', 'edu.middlebury', 'CAS Properties')); } } return $this->properties; }
/** * Get all the Assets of the specified AssetType in this Repository. * Iterators return a set, one at a time. * * @param object Type $assetType * * @return object AssetIterator * * @throws object RepositoryException An exception with one of * the following messages defined in * org.osid.repository.RepositoryException may be thrown: {@link * org.osid.repository.RepositoryException#OPERATION_FAILED * OPERATION_FAILED}, {@link * org.osid.repository.RepositoryException#PERMISSION_DENIED * PERMISSION_DENIED}, {@link * org.osid.repository.RepositoryException#CONFIGURATION_ERROR * CONFIGURATION_ERROR}, {@link * org.osid.repository.RepositoryException#UNIMPLEMENTED * UNIMPLEMENTED}, {@link * org.osid.repository.RepositoryException#NULL_ARGUMENT * NULL_ARGUMENT}, {@link * org.osid.repository.RepositoryException#UNKNOWN_TYPE * UNKNOWN_TYPE} * * @access public */ function getAssetsByType(Type $assetType) { $assets = array(); $children = $this->_node->getChildren(); while ($children->hasNext()) { $child = $children->next(); if ($assetType->isEqual($child->getType())) { $assets[] = $this->_repository->getAsset($child->getId()); } } $obj = new HarmoniAssetIterator($assets); return $obj; }
/** * Add the slideshow hierarchy to the menu for the selected Id. * * @param object Menu $mainMenu * @param object Id $assetId * @return void * @access public * @since 5/22/06 */ function addSlideshowHierarchy($mainMenu, $assetId, $viewMode = true) { $idManager = Services::getService("Id"); $repositoryManager = Services::getService("Repository"); $harmoni = Harmoni::instance(); list($module, $action) = explode(".", $harmoni->request->getRequestedModuleAction()); $exhibitionRepositoryId = $idManager->getId("edu.middlebury.concerto.exhibition_repository"); $exhibitionRepository = $repositoryManager->getRepository($exhibitionRepositoryId); $asset = $exhibitionRepository->getAsset($assetId); $assets = array(); $assets[] = $asset; $this->addFirstParents($asset, $assets); $slideshowType = new HarmoniType("Asset Types", "edu.middlebury.concerto", "Slideshow", "Slide-Shows are ordered collections of slides that contain captions and may reference media Assets."); $altSlideshowType = new HarmoniType("exhibitions", "edu.middlebury.concerto", "slideshow", "Slide-Shows are ordered collections of slides that contain captions and may reference media Assets."); $exhibitionType = new Type("Asset Types", "edu.middlebury.concerto", "Exhibition", "Exhibition Assets are containers for Slideshows."); $j = 0; for ($i = count($assets) - 1; $i >= 0; $i--) { $currentAssetId = $assets[$i]->getId(); if ($slideshowType->isEqual($assets[$i]->getAssetType()) || $altSlideshowType->isEqual($assets[$i]->getAssetType())) { if ($viewMode) { $mainMenu->add(new MenuItemLink($assets[$i]->getDisplayName(), $harmoni->request->quickURL("exhibitions", 'browseSlideshow', array('asset_id' => $currentAssetId->getIdString())), $action == "browseSlideshow" ? TRUE : FALSE, $j + 3), "100%", null, LEFT, CENTER); } else { $harmoni->request->startNamespace("modify_slideshow"); $mainMenu->add(new MenuItemLink($assets[$i]->getDisplayName(), $harmoni->request->quickURL("exhibitions", 'modify_slideshow', array('slideshow_id' => $currentAssetId->getIdString())), $action == "modify_slideshow" && RequestContext::value('slideshow_id') == $currentAssetId->getIdString() ? TRUE : FALSE, $j + 3), "100%", null, LEFT, CENTER); $harmoni->request->endNamespace(); } } else { if ($exhibitionType->isEqual($assets[$i]->getAssetType())) { $mainMenu->add(new MenuItemLink($assets[$i]->getDisplayName(), $harmoni->request->quickURL("exhibitions", 'browse_exhibition', array('exhibition_id' => $currentAssetId->getIdString())), $viewMode && $action == "browse_exhibition" ? TRUE : FALSE, $j + 3), "100%", null, LEFT, CENTER); } else { $mainMenu->add(new MenuItemLink($assets[$i]->getDisplayName(), '', FALSE, $j + 3), "100%", null, LEFT, CENTER); } } $j++; } }
/** * Answer the files attached to a site component. * * @param object CommentNode $comment * @access protected */ protected function addCommentAttachedMedia(CommentNode $comment) { $mediaAssetType = new Type('segue', 'edu.middlebury', 'media_file', 'A file that is uploaded to Segue.'); $children = $comment->getAsset()->getAssets(); while ($children->hasNext()) { $child = $children->next(); if ($mediaAssetType->isEqual($child->getAssetType())) { try { $this->addMediaAsset($child); } catch (PermissionDeniedException $e) { } catch (OperationFailedException $e) { } } } }
/** * Answer an XML representation of the files attached to a site component. * * @param object BlockSiteComponent $siteComponent * @access protected */ protected function recordAttachedMedia(BlockSiteComponent $siteComponent, $pageId = null) { if (is_null($pageId)) { $pageId = $siteComponent->getId(); } $mediaAssetType = new Type('segue', 'edu.middlebury', 'media_file', 'A file that is uploaded to Segue.'); $children = $siteComponent->getAsset()->getAssets(); while ($children->hasNext()) { $child = $children->next(); if ($mediaAssetType->isEqual($child->getAssetType())) { try { $this->recordMediaAsset($child, $pageId); } catch (PermissionDeniedException $e) { } catch (OperationFailedException $e) { } } } }
/** * Answer an iterator of the latest assets. * * @return object Iterator * @access public * @since 8/8/06 */ function getAssets() { $authZManager = Services::getService("AuthZ"); $idManager = Services::getService("IdManager"); $assetsByDate = array(); $repositoryManager = Services::getService('Repository'); $repositories = $repositoryManager->getRepositories(); $exhibitionRepositoryType = new Type('System Repositories', 'edu.middlebury.concerto', 'Exhibitions'); while ($repositories->hasNext()) { $repository = $repositories->next(); if (!$exhibitionRepositoryType->isEqual($repository->getType()) && $authZManager->isUserAuthorized($idManager->getId("edu.middlebury.authorization.view"), $repository->getId())) { $assets = parent::getAssets($repository); $i = 0; while ($assets->hasNext() && $i < $this->_numInFeed) { $asset = $assets->next(); $assetId = $asset->getId(); if (RequestContext::value('order') == 'modification') { $date = $asset->getModificationDate(); } else { $date = $asset->getCreationDate(); } $j = 0; while (isset($assetsByDate[$date->asString() . " " . $j])) { $j++; } $assetsByDate[$date->asString() . " " . $j] = $asset; $i++; } } } krsort($assetsByDate); $iterator = new HarmoniIterator($assetsByDate); return $iterator; }
/** * Get the Properties of this Type associated with this Agent. * * @param object Type $propertiesType * * @return object Properties * * @throws object AgentException An exception with one of the * following messages defined in org.osid.agent.AgentException may * be thrown: {@link * org.osid.agent.AgentException#OPERATION_FAILED * OPERATION_FAILED}, {@link * org.osid.agent.AgentException#PERMISSION_DENIED * PERMISSION_DENIED}, {@link * org.osid.agent.AgentException#CONFIGURATION_ERROR * CONFIGURATION_ERROR}, {@link * org.osid.agent.AgentException#UNIMPLEMENTED UNIMPLEMENTED}, * {@link org.osid.agent.AgentException#NULL_ARGUMENT * NULL_ARGUMENT}, {@link * org.osid.agent.AgentException#UNKNOWN_TYPE UNKNOWN_TYPE} * * @access public */ function getPropertiesByType(Type $propertiesType) { $propertyManager = Services::getService("Property"); $propertiesArray = $propertyManager->retrieveProperties($this->_idString); //if we don't have an object of the type, we'll want to return Null so we know that $propertiesOfType = null; foreach (array_keys($propertiesArray) as $key) { if ($propertiesType->isEqual($propertiesArray[$key]->getType())) { $propertiesOfType = $propertiesArray[$key]; } } return $propertiesOfType; }