/** * Get all the Groups with the specified search criteria and search Type. * * This method is defined in v.2 of the OSIDs. * * @param mixed $searchCriteria * @param object Type $groupSearchType * @return object AgentIterator * @access public * @since 11/10/04 */ function getGroupsBySearch($searchCriteria) { ArgumentValidator::validate($searchCriteria, AlwaysTrueValidatorRule::getRule()); $agentManager = Services::getService("Agent"); $idManager = Services::getService("Id"); $everyoneId = $idManager->getId("edu.middlebury.agents.everyone"); $usersId = $idManager->getId("edu.middlebury.agents.users"); $allGroupsId = $idManager->getId("edu.middlebury.agents.all_groups"); $groupIds = array(); $groupIds[$everyoneId->getIdString()] = $everyoneId; $groupIds[$usersId->getIdString()] = $usersId; // :: Load Groups from the Hierarchy $allGroups = $this->_hierarchy->getNode($allGroupsId); $allGroupNodes = $allGroups->getChildren(); $childGroups = array(); while ($allGroupNodes->hasNext()) { $node = $allGroupNodes->next(); $nodeId = $node->getId(); $isRoot = TRUE; $parents = $node->getParents(); while ($parents->hasNext()) { $parent = $parents->next(); if (!$allGroupsId->isEqual($parent->getId())) { $isRoot = FALSE; break; } } if ($isRoot) { $groupIds[$nodeId->getIdString()] = $nodeId; } } // :: Build Group Objects // now create an array of the group objects to add to the iterator. $groups = array(); foreach ($groupIds as $groupId) { $groups[] = $agentManager->getGroup($groupId); } $allGroups = new MultiIteratorIterator(); $allGroups->addIterator(new HarmoniIterator($groups)); // :: Add External Groups $authNMethodManager = Services::getService("AuthNMethodManager"); $types = $authNMethodManager->getAuthNTypes(); while ($types->hasNext()) { $type = $types->next(); $authNMethod = $authNMethodManager->getAuthNMethodForType($type); if ($authNMethod->supportsDirectory()) { $allGroups->addIterator($authNMethod->getRootGroups()); } } // :: Return our iterator return $allGroups; }
/** * the constructor * * @access public * @return void **/ function ArrayValidatorRule() { $this->_rule = AlwaysTrueValidatorRule::getRule(); }