Example #1
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);
 }
Example #2
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
 }
Example #3
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;
 }
Example #4
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();
 }
 /**
  * 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;
     }
 }
 static function createAgentForm()
 {
     $harmoni = Harmoni::instance();
     print "<center><form action='" . $harmoni->request->quickURL() . "' method='post'>\n\t\t\t\t<table>";
     //switch($GLOBALS["AuthNMethod"]){
     //	case "dbAuthType":
     print "<tr><td>\n\t\t\t\t\t*Username:\n\t\t\t\t</td><td>\n\t\t\t\t\t<input type='text' name='" . RequestContext::name("username") . "' />\n\t\t\t\t</td></tr>\n\t\t\t\t<tr><td>\n\t\t\t\t\t*Password:\n\t\t\t\t</td><td>\n\t\t\t\t\t<input type='password' name='" . RequestContext::name("password") . "' />\n\t\t\t\t</td></tr>";
     //		break;
     //}
     print "<tr><td>\n\t\t\t*" . _("Add to type: ") . "\n\t\t\t</td><td>\n\t\t\t\t<select name='" . RequestContext::name("authn_type") . "'>";
     $authNManager = Services::getService("AuthN");
     $typesIterator = $authNManager->getAuthenticationTypes();
     while ($typesIterator->hasNext()) {
         $tempType = $typesIterator->next();
         $authNMethods = Services::getService("AuthNMethods");
         try {
             $tempMethod = $authNMethods->getAuthNMethodForType($tempType);
             if (!$tempMethod->supportsTokenAddition()) {
                 continue;
             }
             print "<option value='" . HarmoniType::typeToString($tempType) . "'>" . HarmoniType::typeToString($tempType) . "</option>";
         } catch (Exception $e) {
             // Skip if is not available, such as the change-user type
         }
     }
     print "</select>";
     print "</td></tr>";
     print "\t<tr><td>\n\t\t\t\t\tDisplay Name:\n\t\t\t\t</td><td>\n\t\t\t\t\t<input type='text' name='" . RequestContext::name("display_name") . "' />\n\t\t\t\t</td></tr>\n\t<!--\t\t\t<tr><td>\n\t\t\t\t\tDepartment:\n\t\t\t\t</td><td>\n\t\t\t\t\t<input type='text' name='" . RequestContext::name("property_department") . "' />\n\t\t\t\t</td></tr> -->\n\t\t\t\t</table>\t\n\t\t\t\t<input type='submit' value='Create New User' />\n\t\t\t\t<input type='hidden' name='" . RequestContext::name("form_submitted") . "' value='true' />\n\t\t\t\t</form></center>";
 }
Example #7
0
 /**
  * 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'> &nbsp; </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;
 }
Example #8
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;
 }
Example #9
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();
 }
Example #10
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;
}
 /**
  * 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>");
 }
 /**
  * creates appropriate object from given ids
  * 
  * @return object mixed
  * @access public
  * @since 7/21/05
  */
 function getPartObject($part)
 {
     $dtm = Services::getService("DataTypeManager");
     $recordStructure = $this->_parent->getRecordStructure();
     $partStructure = $recordStructure->getPartStructure($this->_info['partStructureId']);
     $type = $partStructure->getType();
     $class = $dtm->primitiveClassForType($type->getKeyword());
     eval('$object = ' . $class . '::fromString($part);');
     if (!is_object($object)) {
         $this->addError("Unsupported PartStructure DataType: " . HarmoniType::typeToString($type) . ".");
         // Log error
         if (Services::serviceRunning("Logging")) {
             $loggingManager = Services::getService("Logging");
             $log = $loggingManager->getLogForWriting("Harmoni");
             $formatType = new Type("logging", "edu.middlebury", "AgentsAndNodes", "A format in which the acting Agent[s] and the target nodes affected are specified.");
             $priorityType = new Type("logging", "edu.middlebury", "Error", "Events involving critical system errors.");
             $item = new AgentNodeEntryItem("PartImport Error", "Unsupported PartStructure DataType: " . HarmoniType::typeToString($type));
             $log->appendLogWithTypes($item, $formatType, $priorityType);
         }
         $false = false;
         return $false;
     }
     return $object;
 }
Example #13
0
 /**
  * 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);
     }
 }
Example #14
0
 /**
  * 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()
 {
     // Instantiate the wizard, then add our steps.
     ob_start();
     print "<h2>" . _("Create Group") . "</h2>";
     print "<b>" . _("Display name") . "</b>: [[display_name]]<br/>";
     print "<b>" . _("Description") . " (" . _("optional") . ")" . "</b>: <br/>[[description]] <br/>";
     print "<b>" . _("Type") . "</b>: [[type]] (" . _("or use fields below to create a new type") . ")<br/>";
     print "<br/>";
     print "<b>" . _("Type domain") . "</b>: [[type_domain]]<br/>";
     print "<b>" . _("Type authority") . "</b>: [[type_authority]]<br/>";
     print "<b>" . _("Type keyword") . "</b>: [[type_keyword]]<br/>";
     print "<b>" . _("Type description") . "</b>:<br/> [[type_description]]<br/>";
     print "<div align='right'>[[_cancel]]\n[[_save]]</div>";
     print "[[members]]";
     if (RequestContext::value("agents") && count($list = unserialize(RequestContext::value("agents"))) > 0 && is_array($list)) {
         // print out a list of agents
         print "<div>" . _("The group will be created with the following members:") . "<ul>\n";
         $agentManager = Services::getService("Agent");
         $idManager = Services::getService("Id");
         foreach ($list as $idString) {
             $id = $idManager->getId($idString);
             if ($agentManager->isGroup($id)) {
                 $agent = $agentManager->getGroup($id);
                 $name = _("Group") . ": " . $agent->getDisplayName();
             } else {
                 if ($agentManager->isAgent($id)) {
                     $agent = $agentManager->getAgent($id);
                     $name = _("Agent") . ": " . $agent->getDisplayName();
                 }
             }
             print "<li>{$name}</li>\n";
         }
         print "</ul></div>";
     }
     $wizard = SimpleWizard::withText(ob_get_contents());
     ob_end_clean();
     // Create the properties.
     $displayNameProp = $wizard->addComponent("display_name", new WTextField());
     $displayNameProp->setErrorText(_("A value for this field is required."));
     $displayNameProp->setErrorRule(new WECNonZeroRegex("[\\w]+"));
     $descriptionProp = $wizard->addComponent("description", WTextArea::withRowsAndColumns(3, 50));
     $property = $wizard->addComponent("type", new WSelectList());
     $property->addOption("NONE", _("Use Fields Below..."));
     $agentMgr = Services::getService("Agent");
     $types = $agentMgr->getGroupTypes();
     while ($types->hasNext()) {
         $type = $types->next();
         $typeKey = urlencode(HarmoniType::typeToString($type));
         $property->addOption($typeKey, HarmoniType::typeToString($type));
     }
     $property->setValue("NONE");
     $property = $wizard->addComponent("type_domain", new WTextField());
     $property->setStartingDisplayText(_("Domain, i.e. 'groups'"));
     $property = $wizard->addComponent("type_authority", new WTextField());
     $property->setStartingDisplayText(_("Authority, i.e. 'edu.middlebury'"));
     $property = $wizard->addComponent("type_keyword", new WTextField());
     $property->setStartingDisplayText(_("Keyword, i.e 'classes"));
     $property = $wizard->addComponent("type_description", WTextArea::withRowsAndColumns(3, 50));
     $wizard->addComponent("_save", WSaveButton::withLabel(_("Create Group")));
     $wizard->addComponent("_cancel", new WCancelButton());
     $members = $wizard->addComponent("members", new WHiddenField());
     if (RequestContext::value("agents")) {
         // the members of the group to be created. an array of agent ids
         $members->setValue(RequestContext::value("agents"));
     }
     return $wizard;
 }
Example #15
0
 /**
  * This method will give you a url to access files in a 'public'
  * subdirectory of your plugin. 
  *
  * Example, status_image.gif in an 'Assignment' plugin by Example University:
  *
  * File Structure
  *		Assignment/
  *			EduExampleAssignmentPlugin.class.php
  *			icon.png
  *			public/
  *				status_image.gif
  *	
  * Usage: print $this->getPublicFileUrl('status_image.gif');
  * 
  * @param string $filename.
  * @return string
  * @access public
  * @since 6/18/08
  */
 private function getPublicFileUrl($filename)
 {
     $harmoni = Harmoni::instance();
     $harmoni->request->startNamespace(null);
     $url = $harmoni->request->quickURL('plugin_manager', 'public_file', array('plugin' => HarmoniType::typeToString(new Type('SeguePlugins', 'edu.middlebury', 'AudioPlayer')), 'file' => $filename));
     $harmoni->request->endNamespace();
     return $url;
 }
Example #16
0
 /**
  * Add a partStructure Collection to a multField
  * 
  * @param <##>
  * @return void
  * @access public
  * @since 4/24/06
  */
 function addPartStructureCollection($multField, $partStructure)
 {
     $collection = array();
     $partStructureId = $partStructure->getId();
     $collection['id'] = $partStructureId->getIdString();
     $collection['display_name'] = $partStructure->getDisplayName();
     $collection['description'] = $partStructure->getDescription();
     $type = $partStructure->getType();
     $collection['type'] = urlencode(HarmoniType::typeToString($type, " :: "));
     $collection['orig_type'] = urlencode(HarmoniType::typeToString($type, " :: "));
     $collection['mandatory'] = $partStructure->isMandatory();
     $collection['repeatable'] = $partStructure->isRepeatable();
     // 		$collection['populatedbydr'] = $partStructure->isPopulatedByRepository();
     $authoritativeValues = $partStructure->getAuthoritativeValues();
     $collection['authoritative_values'] = '';
     while ($authoritativeValues->hasNext()) {
         $value = $authoritativeValues->next();
         $collection['authoritative_values'] .= preg_replace('/[\\n\\r]/', '', $value->asString());
         $collection['authoritative_values'] .= "\n";
     }
     $tagGenerator = StructuredMetaDataTagGenerator::instance();
     $collection['autoGenTags'] = $tagGenerator->shouldGenerateTagsForPartStructure($partStructure->getRepositoryId(), $partStructureId);
     // Allow conversion of the type if the user is authorized to convert_rec_structs
     $authZManager = Services::getService("AuthZ");
     $idManager = Services::getService("Id");
     if (preg_match("/^Repository::.+\$/i", $partStructureId->getIdString()) && $authZManager->isUserAuthorized($idManager->getId("edu.middlebury.authorization.convert_rec_struct"), $partStructure->getRepositoryId()) && $authZManager->isUserAuthorized($idManager->getId("edu.middlebury.authorization.modify"), $partStructure->getRepositoryId()) || $authZManager->isUserAuthorized($idManager->getId("edu.middlebury.authorization.convert_rec_struct"), $idManager->getId("edu.middlebury.authorization.root")) && $authZManager->isUserAuthorized($idManager->getId("edu.middlebury.authorization.modify"), $idManager->getId("edu.middlebury.authorization.root"))) {
         $newCollection = $multField->addValueCollection($collection, true);
         // Allow conversion of type
         $newCollection['type']->addConfirm(_("Are you sure that you want to change the type of this field?\\n\\nConverting ShortStrings to Strings is usually safe, but other conversion may cause data truncation or data loss if there are records for this collection that contain values that cannot be mapped directly to the new data type. Please consult the following guide.\\n\\n-- Safe Conversions --\\nShortString => String \\nShortString => Blob\\nString => Blob  \\nDateTime => ShortString \\nDateTime => String \\nInteger => ShortString \\nInteger => String  \\nFloat => ShortString \\nFloat => String  \\nOKI Type => ShortString \\nOKI Type => String \\n\\n\\n-- Conversions that may be truncated --\\nString => ShortString \\n\\n\\n-- Conversions that may or may not work --\\nShortString => DateTime \\nShortString => Integer \\nShortString => Float \\nShortString => OKI Type \\nString => DateTime \\nString => Integer \\nString => Float \\nString => OKI Type \\nBlob => ShortString \\nBlob => String"));
         if (!preg_match("/^Repository::.+\$/i", $partStructureId->getIdString())) {
             $newCollection['type']->addConfirm(_("This is a global Schema, changing the type will modify all Collections. Continue?"));
         }
         // If a part structure is not repeatable, it can be made repeatable, but
         // not unmade repeatable without proper authorization.
         if ($partStructure->isRepeatable()) {
             $newCollection['repeatable']->addConfirm(_('Removing the the \\\'isRepeatable\\\' flag for this field may cause any existing repeatable values to become inaccessable or corrupted. Only remove this flag if you are absolutely sure that there are NO Assets that have multiple values for this field.\\n\\nAre you sure that you want to continue?'));
         }
     } else {
         $newCollection = $multField->addValueCollection($collection, false);
         $newCollection['type']->setEnabled(false, true);
         // If a part structure is not repeatable, it can be made repeatable, but
         // not unmade repeatable.
         if ($partStructure->isRepeatable()) {
             $newCollection['repeatable']->setEnabled(false, true);
         }
     }
     $newCollection['_remove']->addConfirm(_("Removing this Field will delete all Record values (in all Assets) that use this Field.\\n\\nAre you sure that you want to continue?"));
 }