Exemple #1
0
 /**
  * Constructor
  * @param mixed $schema Either a {@link Schema} object or a string ID of the schema to use.
  * @param optional boolean $verControl If set to TRUE this DMRecord will use version-control.
  * @param optional int $fetchMode USED INTERNALLY
  */
 function DMRecord($schema, $verControl = false, $fetchMode = RECORD_FULL)
 {
     ArgumentValidator::validate($verControl, BooleanValidatorRule::getRule());
     //		ArgumentValidator::validate($schema, ExtendsValidatorRule::getRule("Schema"));
     if (is_object($schema)) {
         $schemaID = $schema->getID();
     } else {
         $schemaID = $schema;
     }
     // it's a string (we hope)
     $schemaManager = Services::getService("SchemaManager");
     $schema = $schemaManager->getSchemaByID($schemaID);
     $schema->load();
     $this->_schema = $schema;
     $this->_fields = array();
     $this->_versionControlled = $verControl;
     $this->_fetchMode = $fetchMode;
     $this->_fetchedValueIDs = array();
     $this->_creationDate = DateAndTime::now();
     $this->_myID = null;
     $this->_delete = false;
     // set up the individual fields
     foreach ($schema->getAllIDs(true) as $label) {
         $def = $schema->getField($label);
         $this->_fields[$label] = new RecordField($def, $this);
         unset($def);
     }
     $this->_idManager = Services::getService("Id");
 }
 /**
  * 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()));
 }
 /**
  *    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.");
 }
 /**
 * Assign the configuration of this Manager. Valid configuration options are as
 * follows:
 *
 *	thumbnail_format		string	(ex: 'image/jpeg')
 *
 *	use_gd					boolean
 I
 *	gd_formats				array of strings	(ex: array('image/jpeg', 'image/png'))
 *							An empty array indicates any/all supported formats.
 *
 *	use_imagemagick			boolean
 *
 *	imagemagick_path		string	(ex: 'usr/bin' OR '/usr/X11R6/bin')
 *
 *	imagemagick_temp_dir	string	(ex: '/tmp')
 *
 *	imagemagick_formats		array of strings	(ex: array('image/jpeg', 'image/png'))
 *							An empty array indicates any/all supported formats.
 * 
 * @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('thumbnail_format'), StringValidatorRule::getRule());
     ArgumentValidator::validate($configuration->getProperty('use_gd'), BooleanValidatorRule::getRule());
     ArgumentValidator::validate($configuration->getProperty('gd_formats'), ArrayValidatorRuleWithRule::getRule(StringValidatorRule::getRule()));
     ArgumentValidator::validate($configuration->getProperty('use_imagemagick'), BooleanValidatorRule::getRule());
     ArgumentValidator::validate($configuration->getProperty('imagemagick_path'), StringValidatorRule::getRule());
     ArgumentValidator::validate($configuration->getProperty('imagemagick_temp_dir'), StringValidatorRule::getRule());
     ArgumentValidator::validate($configuration->getProperty('imagemagick_formats'), ArrayValidatorRuleWithRule::getRule(StringValidatorRule::getRule()));
     $this->_thumbnailFormat = $configuration->getProperty('thumbnail_format');
     $this->_useGD = $configuration->getProperty('use_gd');
     $this->_gdFormats = $configuration->getProperty('gd_formats');
     $this->_useImageMagick = $configuration->getProperty('use_imagemagick');
     $this->_ImageMagickPath = $configuration->getProperty('imagemagick_path');
     $this->_ImageMagickTempDir = $configuration->getProperty('imagemagick_temp_dir');
     $this->_ImageMagickFormats = $configuration->getProperty('imagemagick_formats');
     if ($this->_useGD) {
         $this->_gdProcessor = new GDProcessor($configuration->getProperty('thumbnail_format'));
     }
     if ($this->_useImageMagick) {
         $this->_ImageMagickProcessor = new ImageMagickProcessor($configuration->getProperty('thumbnail_format'), $this->_ImageMagickPath, $this->_ImageMagickTempDir);
     }
 }
 /**
  * Constructor -- sets up the allowed fields for this kind of {@link DataContainer}
  * 
  * @see DataContainer
  * @access public 
  * @return void 
  */
 function HarmoniConfig()
 {
     // initialize the data container
     $this->init();
     // add the fields we want to allow
     $message = "HarmoniConfig - the option 'defaultAction' must be set to a string value!";
     $type = "Harmoni";
     $this->add("defaultAction", StringValidatorRule::getRule(), $message, $type);
     $this->add("defaultAction", FieldRequiredValidatorRule::getRule(), $message, $type);
     unset($message, $type);
     $message = "HarmoniConfig - the option 'defaultModule' must be set to a string value!";
     $type = "Harmoni";
     $this->add("defaultModule", StringValidatorRule::getRule(), $message, $type);
     $this->add("defaultModule", FieldRequiredValidatorRule::getRule(), $message, $type);
     $message = "HarmoniConfig - if specified, the option 'defaultParams' must be set to a an array of string values!";
     $this->add("defaultParams", OptionalRule::getRule(ArrayValidatorRuleWithRule::getRule(StringValidatorRule::getRule())), $message, $type);
     $this->add("programTitle", StringValidatorRule::getRule(), $message, $type);
     $this->add("sessionName", FieldRequiredValidatorRule::getRule());
     $this->set("sessionName", "Harmoni");
     $this->add("sessionUseCookies", BooleanValidatorRule::getRule());
     $this->set("sessionUseCookies", true);
     $this->add("sessionUseOnlyCookies", BooleanValidatorRule::getRule());
     $this->set("sessionUseOnlyCookies", true);
     $this->add("sessionCookiePath", FieldRequiredValidatorRule::getRule());
     $this->set("sessionCookiePath", "/");
     $this->add("sessionCookieDomain", StringValidatorRule::getRule(), "HarmoniConfig - You must set the 'sessionDomain' to the DNS domain you would like your session cookie sent to! (eg, '.mydomain.com')", "Harmoni");
     $this->set("sessionCookieDomain", "");
     // default
     // An array of module.action in which session ids are allowed to be passed in the
     // url
     $this->add("sessionInUrlActions", OptionalRule::getRule(ArrayValidatorRuleWithRule::getRule(StringValidatorRule::getRule())), $message, $type);
     $this->add("sessionCookiesSecure", BooleanValidatorRule::getRule());
     $this->set("sessionCookiesSecure", false);
     $this->add("sessionCookiesHttpOnly", BooleanValidatorRule::getRule());
     $this->set("sessionCookiesHttpOnly", true);
 }
 /**
  * Return <code>true</code> if the Member or Group is in the Group,
  * optionally including subgroups, <code>false</code> otherwise.
  * 
  * @param object Agent $memberOrGroup
  * @param boolean $searchSubgroups
  *	
  * @return boolean
  * 
  * @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}
  * 
  * @access public
  */
 function contains(Agent $memberOrGroup, $searchSubgroups)
 {
     ArgumentValidator::validate($searchSubgroups, BooleanValidatorRule::getRule(), true);
     // ** end of parameter validation
     $id = $memberOrGroup->getId();
     $children = $this->getMembers($searchSubgroups);
     while ($children->hasNext()) {
         if ($id->isEqual($children->next()->getId())) {
             return true;
         }
     }
     $children = $this->getGroups($searchSubgroups);
     while ($children->hasNext()) {
         if ($id->isEqual($children->next()->getId())) {
             return true;
         }
     }
     return FALSE;
 }
 /**
  * Assign the configuration of this Manager. Valid configuration options are as
  * follows:
  *	hierarchy_id				string
  *	root_id						string
  *	course_management_id		string
  *	canonical_courses_id		string
  *	course_groups_id			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');
     $courseManagementId = $configuration->getProperty('course_management_id');
     $terms = $configuration->getProperty('terms_to_add');
     $makeTerms = $configuration->getProperty('whether_to_add_terms');
     $authority = $configuration->getProperty('authority');
     // ** parameter validation
     ArgumentValidator::validate($hierarchyId, StringValidatorRule::getRule(), true);
     ArgumentValidator::validate($courseManagementId, StringValidatorRule::getRule(), true);
     ArgumentValidator::validate($makeTerms, BooleanValidatorRule::getRule(), true);
     ArgumentValidator::validate($authority, StringValidatorRule::getRule(), true);
     // ** end of parameter validation
     //convert to ids
     $idManager = Services::getService("Id");
     $hierarchyId = $idManager->getId($hierarchyId);
     $canonicalCoursesId = $idManager->getId($courseManagementId . ".canonicalcourses");
     $courseGroupsId = $idManager->getId($courseManagementId . ".coursegroups");
     $courseManagementId = $idManager->getId($courseManagementId);
     $hierarchyManager = Services::getService("Hierarchy");
     $this->_hierarchy = $hierarchyManager->getHierarchy($hierarchyId);
     $this->_courseManagementRootId = $courseManagementId;
     $this->_canonicalCoursesId = $canonicalCoursesId;
     $this->_courseGroupsId = $courseGroupsId;
     //terms
     if ($makeTerms) {
         if (!isset($_SESSION['terms_have_been_taken_care_of'])) {
             /*********************************************************
              * Check for existing data in the database
              *********************************************************/
             $dbManager = Services::getService("DatabaseManager");
             $query = new SelectQuery();
             $query->addTable('cm_term');
             $query->addColumn('id');
             $res = $dbManager->query($query);
             //create terms only if the term table is empty
             if (!$res->hasMoreRows()) {
                 $sm = Services::getService("Scheduling");
                 foreach ($terms as $array) {
                     $name = $array['name'];
                     $start = $array['start']->asUnixTimeStamp() * 1000;
                     $end = $array['end']->asUnixTimeStamp() * 1000 - 1;
                     $type = new Type("ScheduleItemStatusType", $authority, "Autogenerated Term");
                     $schedule[0] = $sm->v3_createScheduleItem($name . " range", "The start and end of the " . $name . " Term", $type, $start, $end, null);
                     $term = $this->createTerm($array['type'], $schedule);
                     $term->updateDisplayName($name);
                 }
                 $_SESSION['table_setup_complete'] = TRUE;
             }
         }
     }
 }
 /**
  * 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;
 }
 /**
  * Given a FunctionType and a qualifierId returns all Authorizations that
  * would allow Agents to do Functions in the FunctionType with the
  * Qualifier. This method differs from getAuthorizations in that this
  * method looks for any Authorization that permits doing the Function with
  * the Qualifier even if the Authorization's Qualifier happens to be a
  * parent of the Qualifier argument.
  * 
  * @param object Id $agentId
  * @param object Type $functionType
  * @param object Id $qualifierId
  * @param boolean $isActiveNowOnly
  *	
  * @return object AuthorizationIterator
  * 
  * @throws object AuthorizationException An exception with
  *		   one of the following messages defined in
  *		   org.osid.authorization.AuthorizationException may be thrown:
  *		   {@link
  *		   org.osid.authorization.AuthorizationException#OPERATION_FAILED
  *		   OPERATION_FAILED}, {@link
  *		   org.osid.authorization.AuthorizationException#PERMISSION_DENIED
  *		   PERMISSION_DENIED}, {@link
  *		   org.osid.authorization.AuthorizationException#CONFIGURATION_ERROR
  *		   CONFIGURATION_ERROR}, {@link
  *		   org.osid.authorization.AuthorizationException#UNIMPLEMENTED
  *		   UNIMPLEMENTED}, {@link
  *		   org.osid.authorization.AuthorizationException#NULL_ARGUMENT
  *		   NULL_ARGUMENT}, {@link
  *		   org.osid.authorization.AuthorizationException#UNKNOWN_ID
  *		   UNKNOWN_ID}, {@link
  *		   org.osid.authorization.AuthorizationException#UNKNOWN_TYPE
  *		   UNKNOWN_TYPE}
  * 
  * @access public
  */
 function getAllAZsByFuncType(Id $agentId, Type $functionType, Id $qualifierId, $isActiveNowOnly)
 {
     // ** parameter validation
     ArgumentValidator::validate($isActiveNowOnly, BooleanValidatorRule::getRule(), true);
     // ** end of parameter validation
     $authorizations = $this->_cache->getAZs($agentId->getIdString(), null, $qualifierId->getIdString(), $functionType, false, $isActiveNowOnly, $this->_getContainingGroupIdStrings($agentId));
     $i = new AuthZ2_AuthorizationIterator($authorizations);
     return $i;
 }
 /**
  * Sets the selected state of this menu item.
  * @access public
  * @param boolean selected <code>TRUE</code> means selected; <code>FALSE</code>
  * is unselected.
  **/
 function setSelected($selected)
 {
     // ** parameter validation
     ArgumentValidator::validate($selected, BooleanValidatorRule::getRule(), true);
     // ** end of parameter validation
     $this->_selected = $selected;
     $type = $selected ? MENU_ITEM_LINK_SELECTED : MENU_ITEM_LINK_UNSELECTED;
     $this->_type = $type;
 }
Exemple #11
0
 /**
  * Traverses the tree and returns all the nodes in an array. The traversal
  * is a depth-first pre-order traversal starting from the specified node.
  * @access public
  * @param ref object node The node to start traversal from.
  * @param boolean down If <code>true</code>, this argument specifies that the traversal will
  * go down the children; if <code>false</code> then it will go up the parents.
  * @param integer levels Specifies how many levels of nodes remain to be fetched. This
  * will be recursively decremented and at 0 the recursion will stop. If this is negative
  * then the recursion will go on until the last level is processed.
  * @return ref array An array of all nodes in the tree visited in a pre-order
  * manner. The keys of the array correspond to the nodes' ids.
  * Each element of the array is another array of two elements, the first
  * being the node itself, and the second being the depth of the node relative
  * to the starting node. Descendants are assigned increasingly positive levels; 
  * ancestors increasingly negative levels. 
  */
 function traverse($node, $down, $levels)
 {
     // ** parameter validation
     $extendsRule = ExtendsValidatorRule::getRule("TreeNodeInterface");
     ArgumentValidator::validate($node, $extendsRule, true);
     ArgumentValidator::validate($down, BooleanValidatorRule::getRule(), true);
     ArgumentValidator::validate($levels, IntegerValidatorRule::getRule(), true);
     // ** end of parameter validation
     if (!$this->nodeExists($node->getId())) {
         $str = "Attempted to traverse from a node that does not exist in the tree.";
         throwError(new Error($str, "Hierarchy", true));
     }
     $cacheKey = $this->getCacheKey($node, $down, $levels);
     if (!isset($this->_traversalCache[$cacheKey])) {
         $this->_traversalCache[$cacheKey] = array();
         $this->_traverse($this->_traversalCache[$cacheKey], $node, $down, $levels, $levels);
     }
     return $this->_traversalCache[$cacheKey];
 }
 /**
  * Sets if this field is allowed to have multiple values.
  * @param bool $mult
  * @return void
  * @access public
  */
 function setMultFlag($mult)
 {
     ArgumentValidator::validate($mult, BooleanValidatorRule::getRule());
     $this->_mult = $mult;
 }
 /**
  * Auxilliary private function that returns Authorizations according to a
  * criteria. Null values are interpreted as wildmarks. Warning: $returnExplicitOnly = false
  * will increase the running time significantly - USE SPARINGLY!
  * @access public
  * @param string aId The string id of an agent.
  * @param string fId The string id of a function.
  * @param string qId The string id of a qualifier. This parameter can not be null
  * and used as a wildmark.
  * @param object fType The type of a function.
  * @param boolean returnExplicitOnly If True, only explicit Authorizations
  *		will be returned.
  * @param boolean searchUp If true, the ancester nodes of the qualifier will
  *		be checked as well
  * @param boolean isActiveNow If True, only active Authorizations will be returned.
  * @return ref object An AuthorizationIterator.
  **/
 function getAZs($aId, $fId, $qId, $fType, $returnExplicitOnly, $searchUp, $isActiveNow, $groupIds = array())
 {
     // 		printpre (func_get_args());
     // ** parameter validation
     $rule = StringValidatorRule::getRule();
     ArgumentValidator::validate($groupIds, ArrayValidatorRuleWithRule::getRule(OptionalRule::getRule($rule)), true);
     ArgumentValidator::validate($aId, OptionalRule::getRule($rule), true);
     ArgumentValidator::validate($fId, OptionalRule::getRule($rule), true);
     ArgumentValidator::validate($qId, OptionalRule::getRule($rule), true);
     ArgumentValidator::validate($fType, OptionalRule::getRule(ExtendsValidatorRule::getRule("Type")), true);
     ArgumentValidator::validate($returnExplicitOnly, BooleanValidatorRule::getRule(), true);
     ArgumentValidator::validate($isActiveNow, BooleanValidatorRule::getRule(), true);
     // ** end of parameter validation
     $idManager = Services::getService("Id");
     // the parameter that influences the result most is $returnExplicitOnly
     // 1) If $returnExplicitOnly is TRUE, then we only need to check for Authorizations
     // that have been explicitly created, i.e. no need to look for inherited
     // authorizations
     // 2) If $returnExplicitOnly is FALSE, then we need to include inherited Authorizations
     // as well.
     // this array will store the ids of all qualifiers to be checked for authorizations
     $qualifiers = array();
     // check all ancestors of given qualifier
     $hierarchyManager = Services::getService("Hierarchy");
     if (isset($qId)) {
         $qualifierId = $idManager->getId($qId);
         $node = $hierarchyManager->getNode($qualifierId);
         $hierarchy = $hierarchyManager->getHierarchyForNode($node);
         if ($searchUp) {
             // these are the ancestor nodes
             $nodes = $hierarchy->traverse($qualifierId, Hierarchy::TRAVERSE_MODE_DEPTH_FIRST, Hierarchy::TRAVERSE_DIRECTION_UP, Hierarchy::TRAVERSE_LEVELS_ALL);
             // now get the id of each node and store in array
             while ($nodes->hasNext()) {
                 $info = $nodes->next();
                 $id = $info->getNodeId();
                 $qualifiers[] = $id->getIdString();
             }
         } else {
             $qualifiers = array($qId);
         }
     }
     //		print_r($qualifiers);
     // setup the query
     $dbHandler = Services::getService("DatabaseManager");
     $query = new SelectQuery();
     $query->addColumn("authorization_id", "id");
     $query->addColumn("fk_agent", "aid");
     $query->addColumn("fk_function", "fid");
     $query->addColumn("fk_qualifier", "qid");
     $query->addColumn("authorization_effective_date", "eff_date");
     $query->addColumn("authorization_expiration_date", "exp_date");
     $query->addTable("az_authorization");
     // now include criteria
     // the qualifiers criteria
     if (isset($qualifiers) && count($qualifiers)) {
         $query->addWhereIn('az_authorization.fk_qualifier', $qualifiers);
     }
     // Agents/Groups
     if (isset($aId)) {
         $agentIds = array($aId);
     } else {
         $agentIds = array();
     }
     $allAgentIds = array_merge($agentIds, $groupIds);
     // the agent criteria
     if (count($allAgentIds)) {
         $query->addWhereIn('az_authorization.fk_agent', $allAgentIds);
     }
     // the function criteria
     if (isset($fId)) {
         $joinc = "az_authorization.fk_function = az_function.function_id";
         $query->addTable("az_function", INNER_JOIN, $joinc);
         $query->addWhereEqual("az_authorization.fk_function", $fId);
     }
     // the function type criteria
     if (isset($fType)) {
         // do not join with az_function if we did already
         if (!isset($fId)) {
             $joinc = "az_authorization.fk_function = az_function.function_id";
             $query->addTable("az_function", INNER_JOIN, $joinc);
         }
         // now join with type
         $joinc = "az_function.fk_type = type.type_id";
         $query->addTable("type", INNER_JOIN, $joinc);
         $query->addWhereEqual("type.type_domain", $fType->getDomain());
         $query->addWhereEqual("type.type_authority", $fType->getAuthority());
         $query->addWhereEqual("type.type_keyword", $fType->getKeyword());
     }
     // the isActiveNow criteria
     if ($isActiveNow) {
         $where = "(authorization_effective_date IS NULL OR (NOW() >= authorization_effective_date))";
         $query->addWhere($where);
         $where = "(authorization_expiration_date IS NULL OR (NOW() < authorization_expiration_date))";
         $query->addWhere($where);
     }
     $query->addOrderBy("authorization_id");
     //		echo "<pre>\n";
     //		echo MySQL_SQLGenerator::generateSQLQuery($query);
     //		echo "</pre>\n";
     $queryResult = $dbHandler->query($query, $this->_dbIndex);
     // this array will store the authorizations that will be returned
     $authorizations = array();
     // we only want to create one implicitAZ for a given Agent/Function/Qualifier
     // combo, so maintain a list of already created ones to skip
     $createdImplicitAZs = array();
     $i = 0;
     // process all rows and create the explicit authorizations
     while ($queryResult->hasMoreRows()) {
         $row = $queryResult->getCurrentRow();
         // 			printpre($row);
         $idValue = $row['id'];
         $id = $idManager->getId($idValue);
         if (isset($this->_authorizations[$idValue])) {
             $authorization = $this->_authorizations[$idValue];
         } else {
             $agentId = $idManager->getId($row['aid']);
             $functionId = $idManager->getId($row['fid']);
             $explicitQualifierId = $idManager->getId($row['qid']);
             $effectiveDate = $dbHandler->fromDBDate($row['eff_date'], $this->_dbIndex);
             $expirationDate = $dbHandler->fromDBDate($row['exp_date'], $this->_dbIndex);
             // create the explicit authorization (each explicit authorization
             // has a corresponding row in the authorization db table)
             $authorization = new HarmoniAuthorization($idValue, $agentId, $functionId, $explicitQualifierId, true, $this, $effectiveDate, $expirationDate);
             $this->_authorizations[$idValue] = $authorization;
         }
         // Explicit AZ for ancestor qualifiers and groups should have
         // corresponding implicit AZs
         // in decendents, but not appear in their AZs directly.
         // Therefore, only add the explicit AZ if it is for the requested
         // qualifier and agent if we are fetching more than just the explicitAZs.
         if ($row['qid'] == $qId && $row['aid'] == $aId || $returnExplicitOnly) {
             $authorizations[] = $authorization;
         }
         // now create the implicit authorizations
         // the implicit authorizations will be created for all nodes
         // on the hierarchy path(s) between the node with the explicit authorization
         // and the node on which getAZs() was called.
         // If the row's qualifier and agent are what we asked for however,
         // then the AZ is explicit and doesn't need an implicit AZ as well.
         if ((!$returnExplicitOnly || $searchUp) && ($row['qid'] != $qId || $aId && $row['aid'] != $aId)) {
             // 				printpre("Building Implicit AZs...");
             // 				var_dump($returnExplicitOnly);
             // 				var_dump($searchUp);
             // if this is an AZ that is implicit because of a group instead
             // of because of the hierarchy, create it.
             if ($row['qid'] == $qId && $row['aid'] != $aId) {
                 // 					printpre("In first clause (AuthorizationCache)");
                 $qualifierId = $idManager->getId($qId);
                 // If we are getting implicit AZs for a given agent, make sure
                 // that the implicit AZ has their Id.
                 if ($aId) {
                     $agentId = $idManager->getId($aId);
                 } else {
                     $agentId = $authorization->getAgentId();
                 }
                 $function = $authorization->getFunction();
                 $functionId = $function->getId();
                 $effectiveDate = $authorization->getEffectiveDate();
                 $expirationDate = $authorization->getExpirationDate();
                 $implicit = new HarmoniAuthorization(null, $agentId, $functionId, $qualifierId, false, $this, $effectiveDate, $expirationDate);
                 $azHash = $agentId->getIdString() . "::" . $functionId->getIdString() . "::" . $qualifierId->getIdString();
                 if (!in_array($azHash, $createdImplicitAZs)) {
                     $authorizations[] = $implicit;
                     $createdImplicitAZs[] = $azHash;
                 }
             } else {
                 if (!$returnExplicitOnly && $qId) {
                     // 					printpre("In second clause (AuthorizationCache)");
                     // If we are getting implicit AZs for a given agent, make sure
                     // that the implicit AZ has their Id.
                     if ($aId) {
                         $agentId = $idManager->getId($aId);
                     } else {
                         $agentId = $authorization->getAgentId();
                     }
                     $function = $authorization->getFunction();
                     $functionId = $function->getId();
                     $effectiveDate = $authorization->getEffectiveDate();
                     $expirationDate = $authorization->getExpirationDate();
                     $implicitQualifierId = $idManager->getId($qId);
                     $implicit = new HarmoniAuthorization(null, $agentId, $functionId, $implicitQualifierId, false, $this, $effectiveDate, $expirationDate);
                     $azHash = $agentId->getIdString() . "::" . $functionId->getIdString() . "::" . $implicitQualifierId->getIdString();
                     if (!in_array($azHash, $createdImplicitAZs)) {
                         $authorizations[] = $implicit;
                         $createdImplicitAZs[] = $azHash;
                     }
                 } else {
                     if (!$returnExplicitOnly) {
                         printpre($row);
                         printpre("In third clause (AuthorizationCache)");
                         $explicitQualifier = $authorization->getQualifier();
                         $explicitQualifierId = $explicitQualifier->getId();
                         // If we are getting implicit AZs for a given agent, make sure
                         // that the implicit AZ has their Id.
                         if ($aId) {
                             $agentId = $idManager->getId($aId);
                         } else {
                             $agentId = $authorization->getAgentId();
                         }
                         $function = $authorization->getFunction();
                         $functionId = $function->getId();
                         $effectiveDate = $authorization->getEffectiveDate();
                         $expirationDate = $authorization->getExpirationDate();
                         // this is set 2
                         $authZManager = Services::getService("AuthZ");
                         $hierarchies = $authZManager->getQualifierHierarchies();
                         while ($hierarchies->hasNext()) {
                             $hierarchyId = $hierarchies->next();
                             $hierarchy = $hierarchyManager->getHierarchy($hierarchyId);
                             $timer = new Timer();
                             $timer->start();
                             $nodes = $hierarchy->traverse($explicitQualifierId, Hierarchy::TRAVERSE_MODE_DEPTH_FIRST, Hierarchy::TRAVERSE_DIRECTION_DOWN, Hierarchy::TRAVERSE_LEVELS_ALL);
                             $timer->end();
                             printf("LoadAZTime: %1.6f <br/>", $timer->printTime());
                             // now get the id of each node and store in array
                             $set2 = array();
                             // skip the first node
                             $nodes->next();
                             while ($nodes->hasNext()) {
                                 $info = $nodes->next();
                                 $nodeId = $info->getNodeId();
                                 $implicit = new HarmoniAuthorization(null, $agentId, $functionId, $nodeId, false, $this, $effectiveDate, $expirationDate);
                                 $azHash = $agentId->getIdString() . "::" . $functionId->getIdString() . "::" . $nodeId->getIdString();
                                 // 							printpre($azHash);
                                 // Weird bugs were happening, with $createdImplicitAZs
                                 // but I can't figure out what is going on.
                                 if (!in_array($azHash, $createdImplicitAZs)) {
                                     $authorizations[] = $implicit;
                                     // 								$createdImplicitAZs[] = $azHash;
                                 }
                             }
                         }
                     }
                 }
             }
         }
         $queryResult->advanceRow();
     }
     $queryResult->free();
     return $authorizations;
 }
 /**
  * Duplicate a RecordStructure, optionally duplicating the records as well,
  * also optionally deleting the records in the original RecordStructure.
  *
  * Use this method to convert from data stored in a 'global' RecordStructure
  * such as DublinCore into a 'local' version of the RecordStructure Core in which the
  * user has the option of customizing fields.
  *
  * As well, this method can be used to convert a RecordStructure and associated
  * Records to a local version if the RecordStructure was accidentally created
  * as a 'global' one.
  *
  * WARNING: NOT IN OSID
  * 
  * @param object Id $recordStructureId The id of the RecordStructure to duplicate
  * @param boolean $copyRecords 	If true, existing records will be duplicated
  *								under the new RecordStructure.
  * @param optional object $id An optional id for the new RecordStructure
  * @param optional boolean $isGlobal If true the new RecordStructure will be made a global one.
  * @param optional object $statusStars A status indicator to use if passed.
  * @return void
  * @access public
  * @since 6/7/06
  */
 function duplicateRecordStructure(Id $recordStructureId, $copyRecords = FALSE, $id = null, $isGlobal = FALSE, $statusStars = null)
 {
     ArgumentValidator::validate($recordStructureId, ExtendsValidatorRule::getRule("Id"));
     ArgumentValidator::validate($copyRecords, BooleanValidatorRule::getRule());
     ArgumentValidator::validate($id, OptionalRule::getRule(ExtendsValidatorRule::getRule("Id")));
     ArgumentValidator::validate($isGlobal, BooleanValidatorRule::getRule());
     $oldRecStruct = $this->getRecordStructure($recordStructureId);
     $newRecStruct = $this->createRecordStructure($oldRecStruct->getDisplayName() . _(" Copy"), $oldRecStruct->getDescription(), $oldRecStruct->getFormat(), $oldRecStruct->getSchema(), $id, $isGlobal);
     $mapping = array();
     $oldPartStructs = $oldRecStruct->getPartStructures();
     while ($oldPartStructs->hasNext()) {
         $oldPartStruct = $oldPartStructs->next();
         $newPartStruct = $newRecStruct->createPartStructure($oldPartStruct->getDisplayName(), $oldPartStruct->getDescription(), $oldPartStruct->getType(), $oldPartStruct->isMandatory(), $oldPartStruct->isRepeatable(), $oldPartStruct->isPopulatedByRepository());
         // Mapping
         $oldPartStructId = $oldPartStruct->getId();
         $mapping[$oldPartStructId->getIdString()] = $newPartStruct->getId();
     }
     unset($oldPartStruct, $newPartStruct);
     if ($copyRecords) {
         $assets = $this->getAssets();
         if (!is_null($statusStars)) {
             $statusStars->initializeStatistics($assets->count());
         }
         while ($assets->hasNext()) {
             $asset = $assets->next();
             $oldRecords = $asset->getRecordsByRecordStructure($oldRecStruct->getId());
             while ($oldRecords->hasNext()) {
                 $oldRecord = $oldRecords->next();
                 // Create the new Record
                 $newRecord = $asset->createRecord($newRecStruct->getId());
                 $oldParts = $oldRecord->getParts();
                 while ($oldParts->hasNext()) {
                     $oldPart = $oldParts->next();
                     $oldPartStruct = $oldPart->getPartStructure();
                     $oldPartStructId = $oldPartStruct->getId();
                     $newPart = $newRecord->createPart($mapping[$oldPartStructId->getIdString()], $oldPart->getValue());
                 }
             }
             if (!is_null($statusStars)) {
                 $statusStars->updateStatistics();
             }
         }
     }
     return $newRecStruct;
 }
 /**
  * Create an PartStructure in this RecordStructure. This is not part of the Repository OSID at 
  * the time of this writing, but is needed for dynamically created 
  * RecordStructures/PartStructures.
  *
  * @param string $displayName	The DisplayName of the new RecordStructure.
  * @param string $description	The Description of the new RecordStructure.
  * @param object Type $type		One of the InfoTypes supported by this implementation.
  *								E.g. string, shortstring, blob, datetime, integer, float,
  *								
  * @param boolean $isMandatory	True if the PartStructure is Mandatory.
  * @param boolean $isRepeatable True if the PartStructure is Repeatable.
  * @param boolean $isPopulatedByDR	True if the PartStructure is PopulatedBy the DR.
  * @param optional object $id			An optional {@link HarmoniId} object for this part structure.
  *
  * @return object PartStructure The newly created PartStructure.
  */
 function createPartStructure($displayName, $description, Type $partType, $isMandatory, $isRepeatable, $isPopulatedByRepository, $theid = null)
 {
     ArgumentValidator::validate($displayName, StringValidatorRule::getRule());
     ArgumentValidator::validate($description, StringValidatorRule::getRule());
     ArgumentValidator::validate($partType, ExtendsValidatorRule::getRule("Type"));
     ArgumentValidator::validate($isMandatory, BooleanValidatorRule::getRule());
     ArgumentValidator::validate($isRepeatable, BooleanValidatorRule::getRule());
     ArgumentValidator::validate($isPopulatedByRepository, BooleanValidatorRule::getRule());
     if ($theid == null) {
         $idManager = Services::getService("Id");
         $id = $idManager->createId();
         $label = $id->getIdString();
     } else {
         // check if this ID follows our Schema's ID
         $id = $theid;
         if (strpos($id->getIdString(), $this->_schema->getID()) != 0) {
             throwError(new Error("Could not create PartStructure -- the passed ID does not conform to the Schema's internal ID: " . $this->_schema->getID(), "Repository", true));
         }
         $label = str_replace($this->_schema->getID() . ".", "", $id->getIdString());
     }
     $fieldDef = new SchemaField($label, $displayName, $partType->getKeyword(), $description, $isRepeatable, $isMandatory);
     $schema = $this->_schema->deepCopy();
     $schema->addField($fieldDef);
     $sm = Services::getService("SchemaManager");
     $sm->synchronize($schema);
     $this->_schema = $sm->getSchemaByID($this->_schema->getID());
     $idString = $this->_schema->getFieldIDFromLabel($label);
     $this->_createdParts[$idString] = new HarmoniPartStructure($this->manager, $this, $fieldDef, $this->_repositoryId);
     return $this->_createdParts[$idString];
 }
 /**
  * Performs a depth-first pre-order traversal. It either returns the previously cached nodes 
  * or fetches them from the database and then caches them (depending on whtether
  * they had been already cached).
  * @access public
  * @param object id The id of the node where to start traversal from.
  * @param boolean down If <code>true</code>, this argument specifies that the traversal will
  * go down the children; if <code>false</code> then it will go up the parents.
  * @param integer levels Specifies how many levels of nodes to traverse. If this is negative
  * then the traversal will go on until the last level is processed.
  * @return ref array An array of all nodes in the tree visited in a pre-order
  * manner.
  **/
 function traverse($id, $down, $levels)
 {
     // ** parameter validation
     ArgumentValidator::validate($id, ExtendsValidatorRule::getRule("Id"), true);
     ArgumentValidator::validate($down, BooleanValidatorRule::getRule(), true);
     ArgumentValidator::validate($levels, IntegerValidatorRule::getRule(), true);
     // ** end of parameter validation
     // get the id value
     $idValue = $id->getIdString();
     // see if the nodes have already been cached, if so
     // there is no need to access the database, but if not,
     // then hell yeah, we gotta access the database.
     // the manner of traversing if completely different
     // for the 2 directions: therefore, execution splits here
     // BIG NOTE: It seems that efficient caching mechanisms with
     // partial fetching of the hierarchy (i.e. traversing with levels > 1)
     // is not feasible. Thus, this method will only take advantage of the cache
     // when traversing all the way down (levels < 0) or when getting the children
     // 1) GOING DOWN
     if ($down) {
         // if not cached, fetch from DB and cache!
         if (!$this->_isCachedDown($idValue, $levels)) {
             $this->_traverseDown($idValue, $levels);
         }
     } else {
         // if not cached, fetch from DB and cache!
         if (!$this->_isCachedUp($idValue, $levels)) {
             $this->_traverseUpAncestory($idValue, $levels);
         }
         // 				$this->_traverseUp($idValue, $levels);
     }
     // now that all nodes are cached, return them
     $treeNode = $this->_tree->getNode($idValue);
     $treeNodes = $this->_tree->traverse($treeNode, $down, $levels);
     $result = array();
     foreach (array_keys($treeNodes) as $i => $key) {
         $node = $this->_cache[$key][0];
         // If the node was deleted, but the cache still has a key for it,
         // continue.
         if (!is_object($node)) {
             continue;
             //				throwError(new Error("Missing node object", "Hierarchy Cache"));
         }
         $nodeId = $node->getId();
         if (!isset($this->_infoCache[$nodeId->getIdString()])) {
             $this->_infoCache[$nodeId->getIdString()] = new AuthZ2_TraversalInfo($nodeId, $node->getDisplayName(), $treeNodes[$key][1]);
         }
         $result[] = $this->_infoCache[$nodeId->getIdString()];
     }
     $iterator = new AuthZ2_TraversalInfoIterator($result);
     return $iterator;
 }
Exemple #17
0
 /**
  * Specifies whether distinct rows will be returned.
  * 
  * Use this method to specify whether the rows returned by the SELECT query
  * have to be distinct (i.e. only unique rows) or not. If the method is never 
  * called, then the default value is not distinct.
  * @param boolean $distinct If true, then only unique rows will be returned.
  * @access public
  */
 function setDistinct($distinct)
 {
     // ** parameter validation
     $booleanRule = BooleanValidatorRule::getRule();
     ArgumentValidator::validate($distinct, $booleanRule, true);
     // ** end of parameter validation
     $this->distinct($distinct);
 }
 /**
  * Set the status of showControls.
  * 
  * @param boolean $showControls
  * @return void
  * @access private
  * @since 2/22/06
  */
 private final function setShowControls($showControls)
 {
     ArgumentValidator::validate($showControls, BooleanValidatorRule::getRule());
     $this->_showControls = $showControls;
 }
 /**
  * Optional: Set the GUID and isPermaLink
  * 
  * @param string $guid
  * @param optional boolean $isPermaLink
  * @return void
  * @access public
  * @since 8/7/06
  */
 function setGUID($guid, $isPermaLink = true)
 {
     ArgumentValidator::validate($guid, StringValidatorRule::getRule());
     ArgumentValidator::validate($isPermaLink, BooleanValidatorRule::getRule());
     $this->_guid = $guid;
     $this->_isPermaLink = $isPermaLink;
 }
 /**
  * Create a Hierarchy.
  * 
  * @param string $displayName
  * @param object Type[] $nodeTypes
  * @param string $description
  * @param boolean $allowsMultipleParents
  * @param boolean $allowsRecursion
  * @param optional object Id $id WARNING: NOT IN OSID
  *	
  * @return object Hierarchy
  * 
  * @throws object HierarchyException An exception with one of
  *		   the following messages defined in
  *		   org.osid.hierarchy.HierarchyException may be thrown:	 {@link
  *		   org.osid.hierarchy.HierarchyException#OPERATION_FAILED
  *		   OPERATION_FAILED}, {@link
  *		   org.osid.hierarchy.HierarchyException#PERMISSION_DENIED
  *		   PERMISSION_DENIED}, {@link
  *		   org.osid.hierarchy.HierarchyException#CONFIGURATION_ERROR
  *		   CONFIGURATION_ERROR}, {@link
  *		   org.osid.hierarchy.HierarchyException#UNIMPLEMENTED
  *		   UNIMPLEMENTED}, {@link
  *		   org.osid.hierarchy.HierarchyException#NULL_ARGUMENT
  *		   NULL_ARGUMENT}, {@link
  *		   org.osid.hierarchy.HierarchyException#UNSUPPORTED_CREATION
  *		   UNSUPPORTED_CREATION}
  * 
  * @access public
  */
 function createHierarchy($displayName, array $nodeTypes, $description, $allowsMultipleParents, $allowsRecursion, Id $id = NULL)
 {
     // ** parameter validation
     ArgumentValidator::validate($description, StringValidatorRule::getRule(), true);
     ArgumentValidator::validate($displayName, StringValidatorRule::getRule(), true);
     ArgumentValidator::validate($allowsMultipleParents, BooleanValidatorRule::getRule(), true);
     ArgumentValidator::validate($allowsRecursion, BooleanValidatorRule::getRule(), true);
     ArgumentValidator::validate($id, OptionalRule::getRule(ExtendsValidatorRule::getRule("Id")), true);
     // ** end of parameter validation
     // check for supported hierarchies
     if ($allowsRecursion) {
         throw new OperationFailedException("Unsuported creation. Does not support recursion.");
     }
     $dbHandler = Services::getService("DatabaseManager");
     // Create an Id for the Hierarchy
     if (!is_object($id)) {
         $idManager = Services::getService("Id");
         $id = $idManager->createId();
     }
     $idValue = $id->getIdString();
     $query = new InsertQuery();
     $query->setTable("az2_hierarchy");
     $query->addValue("id", $idValue);
     $query->addValue("display_name", $displayName);
     $query->addValue("description", $description);
     $query->addValue("multiparent", $allowsMultipleParents ? '1' : '0');
     $queryResult = $dbHandler->query($query, $this->_dbIndex);
     // Create a new hierarchy and insert it into the database
     $cache = new AuthZ2_HierarchyCache($idValue, $allowsMultipleParents, $this->_dbIndex, isset($this->harmoni_db) ? $this->harmoni_db : null);
     $cache->setAuthorizationManager($this->getAuthorizationManager());
     $hierarchy = new AuthZ2_Hierarchy($id, $displayName, $description, $cache);
     // then cache it
     $this->_hierarchies[$idValue] = $hierarchy;
     return $hierarchy;
 }
 function test_rule_set_add_multiple()
 {
     $this->assertEqual($this->testRuleSet->count(), 0);
     // what the hell is this???
     // $error = 1;
     $error = new Error("UnitTest", "UnitTest", false);
     $rq = FieldRequiredValidatorRule::getRule();
     $email = EmailValidatorRule::getRule();
     $number = NumericValidatorRule::getRule();
     $this->testRuleSet->addRule("mystring", $rq, $error);
     $this->testRuleSet->addRule("mystring", $email, $error);
     $this->testRuleSet->addRule("boolean", BooleanValidatorRule::getRule(), $error);
     $this->testRuleSet->addRule("mynumber", $number, $error);
     $this->assertEqual($this->testRuleSet->count(), 3);
     $this->assertReference($this->testRuleSet->_rules["mystring"][0][0], $rq);
     $this->assertReference($this->testRuleSet->_rules["mystring"][1][0], $email);
     $this->assertReference($this->testRuleSet->_rules["mynumber"][0][0], $number);
     //			$this->assertEqual($this->testRuleSet->getKeys(), array("mystring","mynumber","boolean"));
 }
 /**
  * Auxilliary private function that returns Authorizations according to a
  * criteria. Null values are interpreted as wildmarks. Warning: $returnExplicitOnly = false
  * will increase the running time significantly - USE SPARINGLY!
  * @access public
  * @param string aId The string id of an agent.
  * @param string fId The string id of a function.
  * @param string qId The string id of a qualifier. This parameter can not be null
  * and used as a wildmark.
  * @param object fType The type of a function.
  * @param boolean returnExplicitOnly If True, only explicit Authorizations
  *		will be returned.
  * @param boolean isActiveNow If True, only active Authorizations will be returned.
  * @return array
  **/
 function getAZs($aId, $fId, $qId, $fType, $returnExplicitOnly, $isActiveNow, $groupIds = array())
 {
     // 		printpre (func_get_args());
     // ** parameter validation
     $rule = StringValidatorRule::getRule();
     ArgumentValidator::validate($groupIds, ArrayValidatorRuleWithRule::getRule(OptionalRule::getRule($rule)), true);
     ArgumentValidator::validate($aId, OptionalRule::getRule($rule), true);
     ArgumentValidator::validate($fId, OptionalRule::getRule($rule), true);
     ArgumentValidator::validate($qId, OptionalRule::getRule($rule), true);
     ArgumentValidator::validate($fType, OptionalRule::getRule(ExtendsValidatorRule::getRule("Type")), true);
     ArgumentValidator::validate($returnExplicitOnly, BooleanValidatorRule::getRule(), true);
     ArgumentValidator::validate($isActiveNow, BooleanValidatorRule::getRule(), true);
     // ** end of parameter validation
     $idManager = Services::getService("Id");
     // the parameter that influences the result most is $returnExplicitOnly
     // 1) If $returnExplicitOnly is TRUE, then we only need to check for Authorizations
     // that have been explicitly created, i.e. no need to look for inherited
     // authorizations
     // 2) If $returnExplicitOnly is FALSE, then we need to include inherited Authorizations
     // as well.
     // Agents/Groups
     if (isset($aId)) {
         $agentIds = array($aId);
     } else {
         $agentIds = array();
     }
     $allAgentIds = array_merge($agentIds, $groupIds);
     $explicitQueryResult = $this->getExplicitAZQueryResult($allAgentIds, $fId, $qId, $fType, $isActiveNow);
     if ($returnExplicitOnly) {
         return $this->getAuthorizationsFromQueryResult($explicitQueryResult, $aId, $qId, $returnExplicitOnly);
     } else {
         $implicitQueryResult = $this->getImplicitAZQueryResult($allAgentIds, $fId, $qId, $fType, $isActiveNow);
         return array_merge($this->getAuthorizationsFromQueryResult($explicitQueryResult, $aId, $qId, $returnExplicitOnly), $this->getAuthorizationsFromQueryResult($implicitQueryResult, $aId, $qId, $returnExplicitOnly));
     }
 }