/**
  * Sets the display name of this menu item.
  * @access public
  * @param string text The new display name.
  **/
 function setDisplayName($text)
 {
     // ** parameter validation
     ArgumentValidator::validate($text, StringValidatorRule::getRule(), true);
     // ** end of parameter validation
     $this->_text = $text;
 }
 function test_generic_sc()
 {
     $error = "This Error should be here!";
     $rule = StringValidatorRule::getRule();
     $sc = new StyleComponent("catch me", $rule, null, null, $error, "Generic", "For Testing Purposes");
     $this->assertIdentical("catch me", $sc->getValue());
     $this->assertIdentical("Generic", $sc->getDisplayName());
     $this->assertIdentical("For Testing Purposes", $sc->getDescription());
     $this->assertIdentical($rule, $sc->_rule);
     $this->assertIdentical($error, $sc->_errorDescription);
     $this->assertFalse($sc->hasOptions());
     $sc = new StyleComponent(5, $rule, null, null, $error, "Generic", "For Testing Purposes");
     $error = "This one as well!";
     $options = array("red", "blue", "green");
     $sc = new StyleComponent("catch me", null, $options, true, $error, "Generic", "For Testing Purposes");
     $sc = new StyleComponent("blue", null, $options, true, $error, "Generic", "For Testing Purposes");
     $this->assertIdentical("blue", $sc->getValue());
     $this->assertIdentical("Generic", $sc->getDisplayName());
     $this->assertIdentical("For Testing Purposes", $sc->getDescription());
     $this->assertIdentical($options, $sc->_options);
     $this->assertIdentical($error, $sc->_errorDescription);
     $this->assertTrue($sc->hasOptions());
     $options1 = $sc->getOptions();
     $this->assertIdentical($options, $options1);
 }
 /**
  * The constructor.
  * @param object id The id of this Authorization
  * @param ref object agentId The Id of the agent.
  * @param ref object functionId The Id of the function.
  * @param ref object qualifierId The Id of the qualifier.
  * @param integer effectiveDate The date when the authorization becomes effective.
  * @param integer expirationDate The date when the authorization expires.
  * @param boolean explicit Specifies whether this Authorization is explicit or not.
  * @access public
  */
 function __construct($id, Id $agentId, Id $functionId, Id $qualifierId, $explicit, AuthZ2_AuthorizationCache $cache, $effectiveDate = NULL, $expirationDate = NULL)
 {
     // ** parameter validation
     ArgumentValidator::validate($id, OptionalRule::getRule(StringValidatorRule::getRule()), true);
     ArgumentValidator::validate($effectiveDate, OptionalRule::getRule(HasMethodsValidatorRule::getRule('asDateAndTime')), true);
     ArgumentValidator::validate($expirationDate, OptionalRule::getRule(HasMethodsValidatorRule::getRule('asDateAndTime')), true);
     ArgumentValidator::validate($explicit, BooleanValidatorRule::getRule(), true);
     // ** end of parameter validation
     // make sure effective date is before expiration date
     if (isset($effectiveDate) && isset($expirationDate)) {
         if ($effectiveDate > $expirationDate) {
             $str = "The effective date must be before the expiration date.";
             throwError(new Error($str, "Authorization", true));
         }
     }
     $this->_id = $id;
     $this->_agentId = $agentId;
     $this->_functionId = $functionId;
     $this->_qualifierId = $qualifierId;
     if (isset($effectiveDate)) {
         $this->_effectiveDate = $effectiveDate;
     }
     if (isset($expirationDate)) {
         $this->_expirationDate = $expirationDate;
     }
     $this->_explicit = $explicit;
     $this->_cache = $cache;
 }
 /**
  * Sets the display name of this menu item.
  * @access public
  * @param string displayName The new display name.
  **/
 function setDisplayName($displayName)
 {
     // ** parameter validation
     ArgumentValidator::validate($displayName, StringValidatorRule::getRule(), true);
     // ** end of parameter validation
     $this->_displayName = $displayName;
 }
 /**
  * The constructor.
  * @param string displayName The display name of this menu item.
  * @param string url The url of this menu item.
  * @param boolean selected The selected state of this menu item.
  * @param integer index The index of this component. The index has no semantic meaning: 
  * you can think of the index as 'level' of the component. Alternatively, 
  * the index could serve as means of distinguishing between components with 
  * the same type. Most often one would use the index in conjunction with
  * the <code>getStylesForComponentType()</code> and 
  * <code>addStyleForComponentType()</code> methods.
  * @param string target The target window of this menu item.
  * @param string accessKey The access key (shortcut) of this menu item.
  * @param string toolTip The toolTip of this menu item.
  * @access public
  **/
 function MenuItemLinkWithAdditionalHtml($displayName, $url, $selected, $index, $target = null, $accessKey = null, $toolTip = null, $additionalHtml = '')
 {
     ArgumentValidator::validate($additionalHtml, StringValidatorRule::getRule());
     // ** end of parameter validation
     $this->_additionalHtml = $additionalHtml;
     $this->MenuItemLink($displayName, $url, $selected, $index, $target, $accessKey, $toolTip);
 }
 /**
  * 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));
         }
     }
 }
 /**
  * Constructor
  * @param string $label the unique label for this field.
  * @param string $name the field's display name
  * @param string $type The string name as registered with the {@link DataTypeManager} of the data type (ie, "string", "integer", "boolean", etc)
  * @param optional string $description a description for this field
  * @param optional boolean $mult flag specifying if multiple values are allowed
  * @param optional boolean $required flag specifying if we will disallow a database commit without at least one value for this field
  * @param optional boolean $active flag specifying if this field is to be used or no.
  */
 function SchemaField($label, $name, $type, $description = "", $mult = false, $required = false, $active = true)
 {
     ArgumentValidator::validate($mult, BooleanValidatorRule::getRule());
     ArgumentValidator::validate($type, StringValidatorRule::getRule());
     ArgumentValidator::validate($label, StringValidatorRule::getRule());
     ArgumentValidator::validate($name, StringValidatorRule::getRule());
     ArgumentValidator::validate($required, BooleanValidatorRule::getRule());
     ArgumentValidator::validate($active, BooleanValidatorRule::getRule());
     $this->_id = null;
     $this->_associated = false;
     $this->_mult = $mult;
     $this->_required = $required;
     $this->_description = $description;
     $this->_displayName = $name;
     $this->_type = $type;
     $this->_label = $label;
     $this->_active = $active;
     $this->_addToDB = false;
     $this->_delete = false;
     $this->_update = false;
     $this->_schema = null;
     $this->_idManager = Services::getService("Id");
     //		print "first time name: ".$this->_displayName."<br>";
     // let's do a quick check and make sure that this type is registered
     //		$typeMgr = Services::getService("DataTypeManager");
     //		if (!$typeMgr->typeRegistered($type)) {
     //			// throw an error
     //			throwError( new Error("Could not create new SchemaField for type '$type' because it doesn't
     //				seem to be a valid type. All types must be registered with a DataTypeManager first.","DataManager",true));
     //			return false;
     //		}
 }
 /**
  * Constructor
  * 
  * @param string $name
  * @return object
  * @access public
  * @since 3/1/06
  */
 function HarmoniReadableLog($name, $dbIndex)
 {
     ArgumentValidator::validate($name, StringValidatorRule::getRule());
     ArgumentValidator::validate($dbIndex, IntegerValidatorRule::getRule());
     $this->_name = $name;
     $this->_dbIndex = $dbIndex;
 }
 /**
  * Assign the configuration of this Manager. There are no valid configuration options for
  * this manager.
  *
  * @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)
 {
     $def = $configuration->getProperty('default_authority');
     // ** parameter validation
     ArgumentValidator::validate($def, StringValidatorRule::getRule(), true);
     // ** end of parameter validation
     $this->_defaultAuthority = $def;
 }
 /**
  * Adds one SQL string to this query.
  * @access public
  * @param string sql One SQL string,
  * @return void 
  */
 function addSQLQuery($sql)
 {
     // ** parameter validation
     $stringRule = StringValidatorRule::getRule();
     ArgumentValidator::validate($sql, $stringRule, true);
     // ** end of parameter validation
     $this->_sql[] = $sql;
 }
 /**
  * Adds a specific data type (identified by a string such as "integer") to our registry. Each data type has two classes associated with it: a {@link Primitive} and a {@link StorablePrimitive}. The former is used when setting/getting values, the latter used when talking with the database.
  * @param string $typeName The name (such as "integer" or "boolean") of this new data type.
  * @param string $primitiveClass The name of the {@link Primitive} class.
  * @param string $storablePrimitiveClass The name of the {@link StorablePrimitive} class.
  * @param string $conversionMethod
  * @access public
  * @return void
  */
 function addDataType($typeName, $primitiveClass, $storablePrimitiveClass, $conversionMethod)
 {
     ArgumentValidator::validate($conversionMethod, StringValidatorRule::getRule());
     $this->_registeredTypes[$typeName] = array("primitive" => $primitiveClass, "storable" => $storablePrimitiveClass, "ConversionMethod" => $conversionMethod);
     if (!in_array(strtolower($storablePrimitiveClass), $this->_primitiveClassMapping)) {
         $this->_primitiveClassMapping[] = strtolower($storablePrimitiveClass);
     }
 }
 /**
  * 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'));
 }
 /**
  * Constructor
  * 
  * @param string $id
  * @param string $displayName
  * @param string $description
  * @param array $choices
  * @return null
  * @access public
  * @since 5/9/08
  */
 public function __construct($id, $displayName, $description, array $choices)
 {
     ArgumentValidator::validate($id, NonzeroLengthStringValidatorRule::getRule());
     ArgumentValidator::validate($displayName, NonzeroLengthStringValidatorRule::getRule());
     ArgumentValidator::validate($description, StringValidatorRule::getRule());
     $this->id = $id;
     $this->displayName = $displayName;
     $this->description = $description;
     $this->choices = $choices;
 }
 /**
  * Sets the passed value to be selected in the list.
  * @param string $value
  * @access public
  * @return void
  */
 function setValue($value)
 {
     ArgumentValidator::validate($value, StringValidatorRule::getRule());
     foreach ($this->_optionValues as $optKey => $optVal) {
         $child = $this->getChild(strval($optKey));
         if ($optVal == $value) {
             $child->setChecked(true);
         }
     }
 }
 /**
  * Answer the RootSiteComponent for the site
  * 
  * @param string $id
  * @return object SiteNavBlockSiteComponent
  * @access public
  * @since 4/3/06
  */
 function getRootSiteComponent($id = null)
 {
     if (!isset($this->_rootSiteComponent)) {
         ArgumentValidator::validate($id, StringValidatorRule::getRule());
         $currentElement = $this->_document->getElementByID($id, false);
         $this->activateDefaultsDown($currentElement);
         $this->_rootSiteComponent = $this->traverseUpToRootSiteComponent($currentElement);
     }
     return $this->_rootSiteComponent;
 }
Exemple #16
0
 /**
  * Constructor.
  *
  * @param string $id The id of this Node.
  */
 function TreeNode($id)
 {
     // ** parameter validation
     $stringRule = StringValidatorRule::getRule();
     ArgumentValidator::validate($id, $stringRule, true);
     // ** end of parameter validation
     $this->_id = $id;
     $this->_parents = array();
     $this->_children = array();
 }
 /**
  * Constructor.
  *
  * @param object ID	  $id	The Id of this Node.
  * @param string $displayName The displayName of the Node.
  * @param integer $depth The depth of the Node.
  * @access public
  */
 function __construct(Id $id, $displayName, $depth)
 {
     // Check the arguments
     ArgumentValidator::validate($displayName, StringValidatorRule::getRule());
     ArgumentValidator::validate($depth, IntegerValidatorRule::getRule());
     // set the private variables
     $this->_id = $id;
     $this->_displayName = $displayName;
     $this->_depth = $depth;
 }
 /**
  * Constructor.
  * 
  * @param string $idString
  * @param object Properties $configuration
  * @return object
  * @access public
  * @since 2/24/06
  */
 function LDAPGroup($idString, $type, $configuration, $authNMethod)
 {
     ArgumentValidator::validate($idString, StringValidatorRule::getRule(), true);
     ArgumentValidator::validate($type, ExtendsValidatorRule::getRule("Type"), true);
     ArgumentValidator::validate($configuration, ExtendsValidatorRule::getRule("Properties"), true);
     ArgumentValidator::validate($authNMethod, ExtendsValidatorRule::getRule("LDAPAuthNMethod"), true);
     $this->_type = $type;
     $this->_idString = $idString;
     $this->_configuration = $configuration;
     $this->_authNMethod = $authNMethod;
 }
 /**
  * The constructor.
  * @param ref object $configuration A {@link Properties} Properties with configuration for connection.
  * @access public
  * @return void 
  **/
 function LDAPConnector($configuration)
 {
     $this->_configuration = $configuration;
     // Validate the configuration options we use:
     ArgumentValidator::validate($this->_configuration->getProperty('LDAPHost'), FieldRequiredValidatorRule::getRule());
     ArgumentValidator::validate($this->_configuration->getProperty('LDAPPort'), OptionalRule::getRule(NumericValidatorRule::getRule()));
     ArgumentValidator::validate($this->_configuration->getProperty('UserBaseDN'), FieldRequiredValidatorRule::getRule());
     ArgumentValidator::validate($this->_configuration->getProperty('ClassesBaseDN'), FieldRequiredValidatorRule::getRule());
     ArgumentValidator::validate($this->_configuration->getProperty('GroupBaseDN'), FieldRequiredValidatorRule::getRule());
     ArgumentValidator::validate($this->_configuration->getProperty('bindDN'), OptionalRule::getRule(StringValidatorRule::getRule()));
     ArgumentValidator::validate($this->_configuration->getProperty('bindDNPassword'), OptionalRule::getRule(StringValidatorRule::getRule()));
 }
 /**
  * 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 = '';
 }
Exemple #21
0
 /**
  * adds a new $rule to $key, which if fails when validated throws $error
  * @param string $key the key to associate the rule with
  * @param ref object ValidatorRule $rule the ValidatorRule object to be added
  * @param optional string $message the error to throw if the validation fails
  * @access public
  * @return void 
  **/
 function addRule($key, $rule, $message = null, $type = '')
 {
     ArgumentValidator::validate($rule, ExtendsValidatorRule::getRule("ValidatorRuleInterface"));
     ArgumentValidator::validate($key, StringValidatorRule::getRule());
     if ($message !== null) {
         ArgumentValidator::validate($message, StringValidatorRule::getRule(), true);
     }
     if (!isset($this->_rules[$key])) {
         $this->_rules[$key] = array();
     }
     $this->_rules[$key][] = array($rule, $message, $type);
 }
 /**
  * Constructor
  * 
  * @param object SeguePluginsAPI $pluginInstance
  * @param string $versionId
  * @param object DateAndTime $timestamp
  * @param object Id $agentId
  * @param int $number
  * @param string $comment
  * @return void
  * @access public
  * @since 1/7/08
  */
 public function __construct(SeguePluginsAPI $pluginInstance, $versionId, DateAndTime $timestamp, Id $agentId, $number, $comment)
 {
     ArgumentValidator::validate($versionId, NonZeroLengthStringValidatorRule::getRule());
     ArgumentValidator::validate($number, IntegerValidatorRule::getRule());
     ArgumentValidator::validate($comment, StringValidatorRule::getRule());
     $this->pluginInstance = $pluginInstance;
     $this->versionId = $versionId;
     $this->timestamp = $timestamp;
     $this->agentId = $agentId;
     $this->number = $number;
     $this->comment = $comment;
 }
Exemple #23
0
 /**
  * Answer a new MediaAsset that wraps the Asset identified with the passed Ids.
  * 
  * @param string $repositoryId May be null of an empty string.
  * @param string $assetId
  * @return object MediaAsset
  * @access public
  * @since 4/27/07
  * @static
  */
 public static function withIdStrings($repositoryId, $assetId, $recordId)
 {
     ArgumentValidator::validate($repositoryId, OptionalRule::getRule(StringValidatorRule::getRule()));
     ArgumentValidator::validate($assetId, NonZeroLengthStringValidatorRule::getRule());
     ArgumentValidator::validate($recordId, NonZeroLengthStringValidatorRule::getRule());
     $idManager = Services::getService("Id");
     if (!$repositoryId) {
         $repositoryId = 'edu.middlebury.segue.sites_repository';
     }
     $mediaFile = MediaFile::withIds($idManager->getId($repositoryId), $idManager->getId($assetId), $idManager->getId($recordId));
     return $mediaFile;
 }
 /**
  * The constructor.
  * @access public
  * @param string content This is an arbitrary string that will be printed,
  * whenever the user calls the <code>render()</code> method. The parameter
  * is required.
  * @param integer index The index of this component. The index has no semantic meaning: 
  * you can think of the index as 'level' of the component. Alternatively, 
  * the index could serve as means of distinguishing between components with 
  * the same type. Most often one would use the index in conjunction with
  * the <code>getStylesForComponentType()</code> and 
  * <code>addStyleForComponentType()</code> methods.
  * @param optional object StyleCollections styles,... Zero, one, or more StyleCollection 
  * objects that will be added to the newly created Component. Warning, this will
  * result in copying the objects instead of referencing them as using
  * <code>addStyle()</code> would do.
  **/
 function UnstyledBlock($content, $index = 1)
 {
     // ** parameter validation
     ArgumentValidator::validate($content, StringValidatorRule::getRule(), true);
     // ** end of parameter validation
     $this->Component($content, BLANK, $index);
     // if there are style collections to add
     if (func_num_args() > 2) {
         for ($i = 2; $i < func_num_args(); $i++) {
             $this->addStyle(func_get_arg($i));
         }
     }
 }
 /**
  * Constructor. Creates a HarmoniId with id = $id or a new unique id if $id is NULL.
  * @param string $id The desired id. If NULL, a new unique id is used.
  *
  */
 function HarmoniTestId($id = NULL)
 {
     if ($id != NULL) {
         // use this id
         ArgumentValidator::validate($id, StringValidatorRule::getRule());
         $this->_id = $id;
     } else {
         // get a new unique id
         // for testing purposes, we are just going to store a counter for the session.
         // this won't work once we start saving things to persistable storage.
         $this->_id = "harmoni." . $_SESSION[harmoniid];
         $_SESSION[harmoniid]++;
     }
 }
 /**
  * Stores the configuration. Calls the parent configuration first,
  * then does additional operations.
  * 
  * @param object Properties $configuration
  * @return object
  * @access public
  * @since 3/24/05
  */
 function assignConfiguration(Properties $configuration)
 {
     parent::assignConfiguration($configuration);
     // Validate the configuration options we use:
     ArgumentValidator::validate($this->_configuration->getProperty('properties_fields'), ArrayValidatorRuleWithRule::getRule(StringValidatorRule::getRule()));
     ArgumentValidator::validate($this->_configuration->getProperty('database_id'), IntegerValidatorRule::getRule());
     ArgumentValidator::validate($this->_configuration->getProperty('authentication_table'), StringValidatorRule::getRule());
     ArgumentValidator::validate($this->_configuration->getProperty('username_field'), StringValidatorRule::getRule());
     ArgumentValidator::validate($this->_configuration->getProperty('password_field'), StringValidatorRule::getRule());
     ArgumentValidator::validate($this->_configuration->getProperty('allow_token_addition'), OptionalRule::getRule(BooleanValidatorRule::getRule()));
     ArgumentValidator::validate($this->_configuration->getProperty('allow_token_deletion'), OptionalRule::getRule(BooleanValidatorRule::getRule()));
     ArgumentValidator::validate($this->_configuration->getProperty('allow_token_updates'), OptionalRule::getRule(BooleanValidatorRule::getRule()));
     ArgumentValidator::validate($this->_configuration->getProperty('allow_property_updates'), OptionalRule::getRule(BooleanValidatorRule::getRule()));
 }
 /**
  * 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();
 }
 /**
  *    Tests different types of validations.
  */
 function test_All_Sorts_Of_Values()
 {
     // test a plain string
     $this->assertTrue(ArgumentValidator::validate("Hello!", StringValidatorRule::getRule(), true));
     // test numeric values
     $this->assertTrue(ArgumentValidator::validate("23.21E10", NumericValidatorRule::getRule(), true));
     $this->assertTrue(ArgumentValidator::validate(23, NumericValidatorRule::getRule(), true));
     $this->assertTrue(ArgumentValidator::validate(23.21, NumericValidatorRule::getRule(), true));
     // test integer values
     $this->assertTrue(ArgumentValidator::validate(23, IntegerValidatorRule::getRule(), true));
     // test string values
     $this->assertTrue(ArgumentValidator::validate("23", StringValidatorRule::getRule(), true));
     // test email values
     $this->assertTrue(ArgumentValidator::validate("*****@*****.**", EmailValidatorRule::getRule(), true));
     $this->assertFalse(ArgumentValidator::validate("dradichk@middlebury", EmailValidatorRule::getRule(), false), "Gabe, fix this! Your EmailValidatorRule is faulty!");
     // test boolean values
     $this->assertTrue(ArgumentValidator::validate(true, BooleanValidatorRule::getRule(), true));
     $this->assertFalse(ArgumentValidator::validate("HOHO", BooleanValidatorRule::getRule(), false), "Gabe, fix this! Your BooleanValidatorRule is faulty!\nIn fact, I think you should just use is_bool() in your check() function.");
 }
Exemple #29
0
 /**
  * Answer a help link (HTML markup) for the topic specified.
  * 
  * @param string $topic
  * @return string
  * @access public
  * @since 12/4/07
  * @static
  */
 public static function link($topic = '')
 {
     ArgumentValidator::validate($topic, StringValidatorRule::getRule());
     $harmoni = Harmoni::instance();
     $harmoni->request->startNamespace(null);
     if (strlen($topic)) {
         $url = $harmoni->request->quickURL('help', 'browse_help', array('topic' => $topic));
     } else {
         $url = $harmoni->request->quickURL('help', 'browse_help');
     }
     $harmoni->request->endNamespace();
     ob_start();
     print "<a href='{$url}' ";
     print "onclick=\"";
     print "var url='{$url}'; ";
     print "url = url.urlDecodeAmpersands(); ";
     print "var helpWindow = window.open(url, 'help', 'width=700,height=600,scrollbars=yes,resizable=yes'); ";
     print "helpWindow.focus(); ";
     print "return false; ";
     print "\">" . _("help") . "</a>";
     return ob_get_clean();
 }
 /**
  * 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'];
 }