/**
  * Constructor
  * 
  * @param mixed $entryItem
  * @param object Type $formatType
  * @param object Type $priorityType
  * @return object
  * @access public
  * @since 3/1/06
  */
 function HarmoniEntry($timestamp, $category, $description, $backtrace, $agents, $nodes, $formatType, $priorityType)
 {
     ArgumentValidator::validate($timestamp, ExtendsValidatorRule::getRule("DateAndTime"));
     ArgumentValidator::validate($category, StringValidatorRule::getRule());
     ArgumentValidator::validate($description, StringValidatorRule::getRule());
     ArgumentValidator::validate($backtrace, StringValidatorRule::getRule());
     ArgumentValidator::validate($agents, ArrayValidatorRule::getRule());
     ArgumentValidator::validate($nodes, ArrayValidatorRule::getRule());
     ArgumentValidator::validate($formatType, ExtendsValidatorRule::getRule("Type"));
     ArgumentValidator::validate($priorityType, ExtendsValidatorRule::getRule("type"));
     $this->_timestamp = $timestamp;
     $this->_formatType = $formatType;
     $this->_priorityType = $priorityType;
     $this->_entryItem = new AgentNodeEntryItem($category, $description);
     $this->_entryItem->setBacktrace($backtrace);
     $idManager = Services::getService("Id");
     foreach ($agents as $idString) {
         if ($idString) {
             $this->_entryItem->addAgentId($idManager->getId($idString));
         }
     }
     foreach ($nodes as $idString) {
         if ($idString) {
             $this->_entryItem->addNodeId($idManager->getId($idString));
         }
     }
 }
 /**
  * Initialize this object for a set of authentication tokens.
  * 
  * @param mixed $tokens
  * @return void
  * @access public
  * @since 3/1/05
  */
 function initializeForTokens($tokens)
 {
     ArgumentValidator::validate($tokens, ArrayValidatorRule::getRule());
     ArgumentValidator::validate($tokens['username'], StringValidatorRule::getRule());
     ArgumentValidator::validate($tokens['password'], StringValidatorRule::getRule());
     $this->_tokens = $tokens;
     $this->_identifier = $tokens['username'];
 }
 /**
  * Initialize this object for a set of authentication tokens. Set the 
  * password to the encrypted version.
  * 
  * @param mixed $tokens
  * @return void
  * @access public
  * @since 3/1/05
  */
 function initializeForTokens($tokens)
 {
     ArgumentValidator::validate($tokens, ArrayValidatorRule::getRule());
     ArgumentValidator::validate($tokens['username'], StringValidatorRule::getRule());
     ArgumentValidator::validate($tokens['password'], StringValidatorRule::getRule());
     $this->_tokens = $tokens;
     $this->_identifier = $tokens['username'];
     $this->_tokens['password'] = crypt($tokens['password'], $this->_configuration->getProperty('crypt_salt'));
 }
 /**
  * Answer an internal Url string with the array values added as parameters.
  * 
  * @param array $parameters Associative array ('name' => 'value')
  * @return string
  * @access public
  * @since 1/13/06
  */
 public final function url($parameters = array())
 {
     ArgumentValidator::validate($parameters, OptionalRule::getRule(ArrayValidatorRule::getRule()));
     $url = $this->_baseUrl->deepCopy();
     if (is_array($parameters) && count($parameters)) {
         $url->setValues($parameters);
     }
     return $url->write();
 }
 /**
  * Set the value of the child components
  * 
  * @param array $value
  * @access public
  * @return void
  */
 function setValue($value)
 {
     ArgumentValidator::validate($value, ArrayValidatorRule::getRule());
     $children = $this->getChildren();
     foreach (array_keys($children) as $key) {
         if (isset($value[$key])) {
             $children[$key]->setValue($value[$key]);
         }
     }
 }
 /**
  * Constructor
  * 
  * @param string $category
  * @param string $description
  * @param optional array $nodeIds
  * @return object
  * @access public
  * @since 3/2/06
  */
 function __construct($category, $description, $nodeIds = array())
 {
     ArgumentValidator::validate($category, StringValidatorRule::getRule());
     ArgumentValidator::validate($description, StringValidatorRule::getRule());
     ArgumentValidator::validate($nodeIds, ArrayValidatorRule::getRule());
     $this->_category = htmlspecialchars($category);
     $this->_description = HtmlString::getSafeHtml($description);
     $this->_nodeIds = $nodeIds;
     $this->_agentIds = array();
     $this->_backtrace = '';
     $this->_additionalBactraceText = '';
 }
 /**
  * Initialize this object for a set of authentication tokens. Set the 
  * password to the encrypted version.
  * 
  * @param mixed $tokens
  * @return void
  * @access public
  * @since 3/1/05
  */
 function initializeForTokens($tokens)
 {
     ArgumentValidator::validate($tokens, ArrayValidatorRule::getRule());
     ArgumentValidator::validate($tokens['username'], StringValidatorRule::getRule());
     ArgumentValidator::validate($tokens['password'], StringValidatorRule::getRule());
     $this->_tokens = $tokens;
     $this->_identifier = $tokens['username'];
     // set the password to the encrypted version.
     $dbc = Services::getService("DatabaseManager");
     $dbId = $this->_configuration->getProperty('database_id');
     $passwordQuery = new SelectQuery();
     $passwordQuery->addColumn("SHA1('" . addslashes($tokens['password']) . "')", "encryptedPassword");
     $passwordResult = $dbc->query($passwordQuery, $dbId);
     $this->_tokens['password'] = $passwordResult->field("encryptedPassword");
     $passwordResult->free();
 }
 /**
  * Assign the configuration of this Manager. Valid configuration options are as
  * follows:
  *		default_language	string	(ex: 'en_US')
  *		applications		array of strings (
  *								application_name => language_file_directory,
  *	 							...,
  * 								...,
  *							)
  *		
  * 
  * @param object Properties $configuration (original type: java.util.Properties)
  * 
  * @throws object OsidException An exception with one of the following
  *		   messages defined in org.osid.OsidException:	{@link
  *		   org.osid.OsidException#OPERATION_FAILED OPERATION_FAILED},
  *		   {@link org.osid.OsidException#PERMISSION_DENIED
  *		   PERMISSION_DENIED}, {@link
  *		   org.osid.OsidException#CONFIGURATION_ERROR
  *		   CONFIGURATION_ERROR}, {@link
  *		   org.osid.OsidException#UNIMPLEMENTED UNIMPLEMENTED}, {@link
  *		   org.osid.OsidException#NULL_ARGUMENT NULL_ARGUMENT}
  * 
  * @access public
  */
 function assignConfiguration(Properties $configuration)
 {
     $this->_configuration = $configuration;
     ArgumentValidator::validate($configuration->getProperty('default_language'), StringValidatorRule::getRule(), true);
     ArgumentValidator::validate($configuration->getProperty('applications'), ArrayValidatorRule::getRule(), true);
     // Get the current Language settings from the session if they exist.
     if (isset($_SESSION['__CurrentLanguage'])) {
         $this->setLanguage($_SESSION['__CurrentLanguage']);
     } else {
         $this->setLanguage($configuration->getProperty('default_language'));
     }
     foreach ($configuration->getProperty('applications') as $application => $languageDir) {
         ArgumentValidator::validate($application, StringValidatorRule::getRule(), true);
         ArgumentValidator::validate($languageDir, StringValidatorRule::getRule(), true);
         $this->addApplication($application, $languageDir);
     }
 }
 /**
  * Constructor
  * 
  * @param object $iterator The iterator to print.
  * @param integer $numColumns The number of result columns to print on each page.
  * @param integer $numResultsPerPage The number of iterator items to print on a page.
  * @param string $callbackFunction The name of the function that will be called to
  *			to print each result.
  * @param optional mixed $callbackArgs Any additional arguements will be stored
  *			and passed on to the callback function.
  * @access public
  * @date 8/5/04
  */
 function EmbeddedArrayResultPrinter($array, $numColumns, $numResultsPerPage, $callbackFunction)
 {
     ArgumentValidator::validate($array, ArrayValidatorRule::getRule());
     ArgumentValidator::validate($numColumns, IntegerValidatorRule::getRule());
     ArgumentValidator::validate($numResultsPerPage, IntegerValidatorRule::getRule());
     // 		if (is_array($callbackFunction))
     // 			ArgumentValidator::validate($callbackFunction[1], new StringValidatorRule);
     // 		else
     // 			ArgumentValidator::validate($callbackFunction, new StringValidatorRule);
     $this->_array = $array;
     $this->_numColumns = $numColumns;
     $this->_pageSize = $numResultsPerPage;
     $this->_callbackFunction = $callbackFunction;
     $this->_callbackParams = array();
     $args = func_get_args();
     for ($i = 4; $i < count($args); $i++) {
         $this->_callbackParams[] = $args[$i];
     }
 }
 /**
  * Constructor
  * 
  * @param object $iterator The iterator to print.
  * @param integer $numColumns The number of result columns to print on each page.
  * @param integer $numResultsPerPage The number of iterator items to print on a page.
  * @param mixed $callbackFunction The name of the function that will be called to
  *			to print each result. If null, the first parameter is assumed to be an
  *			array of gui components that can be rendered without further processing.
  * @param optional mixed $callbackArgs Any additional arguements will be stored
  *			and passed on to the callback function.
  * @access public
  * @date 8/5/04
  */
 function ArrayResultPrinter($array, $numColumns, $numResultsPerPage, $callbackFunction = NULL)
 {
     ArgumentValidator::validate($array, ArrayValidatorRule::getRule());
     ArgumentValidator::validate($numColumns, IntegerValidatorRule::getRule());
     ArgumentValidator::validate($numResultsPerPage, IntegerValidatorRule::getRule());
     //		ArgumentValidator::validate($callbackFunction, StringValidatorRule::getRule());
     if (is_null($callbackFunction)) {
         ArgumentValidator::validate($array, ArrayValidatorRuleWithRule::getRule(ExtendsValidatorRule::getRule("ComponentInterface")));
     }
     $this->_array = $array;
     $this->_numColumns = $numColumns;
     $this->_pageSize = $numResultsPerPage;
     $this->_callbackFunction = $callbackFunction;
     $this->_callbackParams = array();
     $args = func_get_args();
     for ($i = 4; $i < count($args); $i++) {
         $this->_callbackParams[] = $args[$i];
     }
     $this->_resultLayout = new TableLayout($this->_numColumns);
     $this->_resultLayout->printEmptyCells = false;
     $this->_linksStyleCollection = new StyleCollection("*.result_page_links", "result_page_links", "Result Page Links", "Links to other pages of results.");
     // 		$this->_linksStyleCollection->addSP(new MarginTopSP("10px"));
 }
 /**
  * Initialize this object for a set of authentication tokens. The identifier
  * is the user's CN, but they may have passed a username or email as part 
  * of their tokens instead.
  * 
  * @param mixed $tokens
  * @return void
  * @access public
  * @since 3/1/05
  */
 function initializeForTokens($tokens)
 {
     ArgumentValidator::validate($tokens, ArrayValidatorRule::getRule());
     ArgumentValidator::validate($tokens['username'], StringValidatorRule::getRule());
     ArgumentValidator::validate($tokens['password'], StringValidatorRule::getRule());
     $this->_tokens = $tokens;
     $this->_tokens['password'] = $tokens['password'];
     // See if we were passed a system name instead of a full DN as this
     // is probably the case. First try the 'main system name' in case
     // a broader search returns more results.
     $primaryLoginFields = $this->_configuration->getProperty('login_fields');
     foreach ($primaryLoginFields as $loginField) {
         $dns = $this->_connector->getUserDNsBySearch($loginField . "=" . $tokens['username']);
         // 			printpre($loginField."=".$tokens['username']);
         if (count($dns) == 1) {
             $this->_identifier = $dns[0];
             $this->_tokens['username'] = $dns[0];
             return;
         }
     }
     // If we haven't found it, just leave it alone as it might be the DN
     // itself.
     $this->_identifier = $tokens['username'];
 }
 /**
  * Assign the configuration of this Manager. Valid configuration options are as
  * follows:
  *	database_index			integer
  *	database_name			string
  * 
  * @param object Properties $configuration (original type: java.util.Properties)
  * 
  * @throws object OsidException An exception with one of the following
  *		   messages defined in org.osid.OsidException:	{@link
  *		   org.osid.OsidException#OPERATION_FAILED OPERATION_FAILED},
  *		   {@link org.osid.OsidException#PERMISSION_DENIED
  *		   PERMISSION_DENIED}, {@link
  *		   org.osid.OsidException#CONFIGURATION_ERROR
  *		   CONFIGURATION_ERROR}, {@link
  *		   org.osid.OsidException#UNIMPLEMENTED UNIMPLEMENTED}, {@link
  *		   org.osid.OsidException#NULL_ARGUMENT NULL_ARGUMENT}
  * 
  * @access public
  */
 function assignConfiguration(Properties $configuration)
 {
     $this->_configuration = $configuration;
     $hierarchyId = $configuration->getProperty('hierarchy_id');
     $agentFlavor = $configuration->getProperty('defaultAgentFlavor');
     // ** parameter validation
     ArgumentValidator::validate($hierarchyId, StringValidatorRule::getRule(), true);
     ArgumentValidator::validate($agentFlavor, StringValidatorRule::getRule(), true);
     // ** end of parameter validation
     $idManager = Services::getService("Id");
     $this->_hierarchyId = $idManager->getId($hierarchyId);
     $this->_agentFlavor = $agentFlavor;
     $hierarchyManager = Services::getService("Hierarchy");
     $hierarchy = $hierarchyManager->getHierarchy($this->_hierarchyId);
     if ($this->_configuration->getProperty('group_ip_ranges')) {
         ArgumentValidator::validate($this->_configuration->getProperty('group_ip_ranges'), ArrayValidatorRule::getRule());
         $stringRule = NonzeroLengthStringValidatorRule::getRule();
         $rangeRule = RegexValidatorRule::getRule('/^([0-9]{1,3}|\\*|[0-9]{1,3}-[0-9]{1,3})\\.([0-9]{1,3}|\\*|[0-9]{1,3}-[0-9]{1,3})\\.([0-9]{1,3}|\\*|[0-9]{1,3}-[0-9]{1,3})\\.([0-9]{1,3}|\\*|[0-9]{1,3}-[0-9]{1,3})$/');
         foreach ($this->_configuration->getProperty('group_ip_ranges') as $groupIdString => $range) {
             ArgumentValidator::validate($groupIdString, $stringRule);
             ArgumentValidator::validate($range, $rangeRule);
         }
     }
     // initialize our Agent Search Types
     $this->_agentSearches = array();
     $this->_agentSearches["Agent & Group Search::edu.middlebury.harmoni::TokenSearch"] = new TokenSearch();
     $this->_agentSearches["Agent & Group Search::edu.middlebury.harmoni::AgentPropertiesSearch"] = new AgentPropertiesSearch($this->_configuration->getProperty('database_index'));
     // initialize our Group Search Types
     $this->_groupSearches = array();
     $this->_groupSearches["Agent & Group Search::edu.middlebury.harmoni::AncestorGroups"] = new AncestorGroupSearch($hierarchy);
     $this->_groupSearches["Agent & Group Search::edu.middlebury.harmoni::RootGroups"] = new RootGroupSearch($hierarchy);
     $this->_groupSearches["Agent & Group Search::edu.middlebury.harmoni::TokenSearch"] = $this->_agentSearches["Agent & Group Search::edu.middlebury.harmoni::TokenSearch"];
     $this->_groupSearches["Agent & Group Search::edu.middlebury.harmoni::AgentPropertiesSearch"] = $this->_agentSearches["Agent & Group Search::edu.middlebury.harmoni::AgentPropertiesSearch"];
     $this->_everyoneGroup = new EveryoneGroup($hierarchy, $hierarchy->getNode($this->_everyoneId));
 }
Example #13
0
 /**
  * Specifies the values that the will be assigned to the columns specified with setColumns().
  *
  * @param array The values that the will be assigned to the columns specified with setColumns().
  * @access public
  */
 function setValues($values)
 {
     // ** parameter validation
     $arrayRule = ArrayValidatorRule::getRule();
     ArgumentValidator::validate($values, $arrayRule, true);
     // ** end of parameter validation
     $this->_values = $values;
 }
Example #14
0
 /**
  * Sets the GROUP BY and HAVING clause.
  * 
  * This method sets the GROUP BY clause of the SELECT statement. In addition,
  * if $condition is specified, it includes the HAVING clause. If the method is never
  * called, no GROUP BY or HAVING clause will be included.
  * @param array $columns An array of the columns to group by. Ideally, the
  * columns should be in the list provided by setColumns().
  * @param string $condition An optional condition to be included in the
  * HAVING clause.
  * @access public
  */
 function setGroupBy($columns, $condition = "")
 {
     // ** parameter validation
     $arrayRule = ArrayValidatorRule::getRule();
     $stringRule = StringValidatorRule::getRule();
     ArgumentValidator::validate($columns, $arrayRule, true);
     ArgumentValidator::validate($condition, $stringRule, true);
     // ** end of parameter validation
     $this->group($columns);
     if ($conditition) {
         $this->having($condition);
     }
 }
Example #15
0
 /**
  * Imports the contents of a registered mutable <code>StyleProperty</code>.
  * The input to this method should be an output obtained from calling
  * <code>exportRegisteredSP</code> on the same <code>StyleProperty</code>.
  * @access public
  * @param integer id The id of the <code>StyleProperty</code> as returned
  * by <code>registerSP()</code>.
  * @param mixed importData The contens of the <code>StyleProperty</code> as exported by
  * <code>exportRegisteredSP()</code>.
  * @return ref object The updated <code>StyleProperty</code> object.
  **/
 function importRegisteredSP($id, $importData)
 {
     // ** parameter validation
     $rule = ArrayValidatorRule::getRule();
     ArgumentValidator::validate($importData, $rule, true);
     // ** end of parameter validation
     // first, get the style property and its style components
     $sp = $this->getRegisteredSP($id);
     $scs = $sp->getSCs();
     // if the number of style components is different from the number
     // of elements in the importData array, then it's no good!
     if (count($importData) != count($scs)) {
         $err = "Invalid import data or invalid style property id!";
         throwError(new Error($err, "GUIManager", true));
         return;
     }
     // now set the value of each style component
     foreach (array_keys($importData) as $i => $key) {
         $scs[$key]->setValue($importData[$key]);
     }
     // now see if there is a post import method set for this style property
     // if yes, run it
     if (isset($this->_postImportMethods[$id])) {
         $this->{$this->_postImportMethods[$id]}();
     }
     return $sp;
 }
Example #16
0
 /**
  * Assign the configuration of this Manager. Valid configuration options are as
  * follows:
  *	database_index			integer
  *	database_name			string
  *	default_theme			object Theme
  *
  * @param object Properties $configuration (original type: java.util.Properties)
  *
  * @throws object OsidException An exception with one of the following
  *		   messages defined in org.osid.OsidException:	{@link
  *		   org.osid.OsidException#OPERATION_FAILED OPERATION_FAILED},
  *		   {@link org.osid.OsidException#PERMISSION_DENIED
  *		   PERMISSION_DENIED}, {@link
  *		   org.osid.OsidException#CONFIGURATION_ERROR
  *		   CONFIGURATION_ERROR}, {@link
  *		   org.osid.OsidException#UNIMPLEMENTED UNIMPLEMENTED}, {@link
  *		   org.osid.OsidException#NULL_ARGUMENT NULL_ARGUMENT}
  *
  * @access public
  */
 function assignConfiguration(Properties $configuration)
 {
     $this->_configuration = $configuration;
     $dbIndex = $configuration->getProperty('database_index');
     $dbName = $configuration->getProperty('database_name');
     $theme = $configuration->getProperty('default_theme');
     $id = $configuration->getProperty('default_state_id');
     $arrayOfDefaultThemes = $configuration->getProperty('array_of_default_themes');
     // ** parameter validation
     ArgumentValidator::validate($dbIndex, IntegerValidatorRule::getRule(), true);
     ArgumentValidator::validate($theme, ExtendsValidatorRule::getRule("ThemeInterface"), true);
     ArgumentValidator::validate($arrayOfDefaultThemes, ArrayValidatorRule::getRule(), true);
     // ** end of parameter validation
     $this->_dbName = $dbName;
     $this->_dbIndex = $dbIndex;
     $this->_themeList = $arrayOfDefaultThemes;
     $this->setTheme($theme);
 }