Source for file HarmoniAuthorizationManager.class.php

Documentation is available at HarmoniAuthorizationManager.class.php

  1. <?php
  2.  
  3. require_once(OKI2."/osid/authorization/AuthorizationManager.php");
  4. require_once(HARMONI.'oki2/authorization/AuthorizationCache.class.php');
  5. require_once(HARMONI.'oki2/authorization/HarmoniFunction.class.php');
  6. require_once(HARMONI.'oki2/authorization/HarmoniAuthorization.class.php');
  7. require_once(HARMONI.'oki2/authorization/HarmoniAuthorizationIterator.class.php');
  8. require_once(HARMONI.'oki2/authorization/HarmoniQualifier.class.php');
  9. require_once(HARMONI.'oki2/authorization/IsAuthorizedCache.class.php');
  10. require_once(HARMONI.'oki2/shared/HarmoniIdIterator.class.php');
  11.  
  12. /**
  13. * AuthorizationManager allows an application to create Authorizations, get
  14. * Authorizations given selection criterias, ask questions of Authorization
  15. * such as what agentId can do a Function in a Qualifier context, etc.
  16. *
  17. * <p>
  18. * The primary objects in Authorization are Authorization, Function, agentId,
  19. * and Qualifier. There are also Function and Qualifier types that are
  20. * understood by the implementation.
  21. * </p>
  22. *
  23. * <p>
  24. * Ids in Authorization are externally defined and their uniqueness is enforced
  25. * by the implementation.
  26. * </p>
  27. *
  28. * <p>
  29. * There are two methods to create Authorizations. One method uses agentId,
  30. * Function, and Qualifier. The other adds effective date and expiration
  31. * date. For the method without the dates, the effective date is today and
  32. * there is no expiration date.
  33. * </p>
  34. *
  35. * <p>
  36. * All implementations of OsidManager (manager) provide methods for accessing
  37. * and manipulating the various objects defined in the OSID package. A manager
  38. * defines an implementation of an OSID. All other OSID objects come either
  39. * directly or indirectly from the manager. New instances of the OSID objects
  40. * are created either directly or indirectly by the manager. Because the OSID
  41. * objects are defined using interfaces, create methods must be used instead
  42. * of the new operator to create instances of the OSID objects. Create methods
  43. * are used both to instantiate and persist OSID objects. Using the
  44. * OsidManager class to define an OSID's implementation allows the application
  45. * to change OSID implementations by changing the OsidManager package name
  46. * used to load an implementation. Applications developed using managers
  47. * permit OSID implementation substitution without changing the application
  48. * source code. As with all managers, use the OsidLoader to load an
  49. * implementation of this interface.
  50. * </p>
  51. *
  52. * <p></p>
  53. *
  54. * <p>
  55. * OSID Version: 2.0
  56. * </p>
  57. *
  58. * @package harmoni.osid_v2.authorization
  59. *
  60. * @copyright Copyright &copy; 2005, Middlebury College
  61. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  62. *
  63. * @version $Id: HarmoniAuthorizationManager.class.php,v 1.39 2007/09/04 20:25:38 adamfranco Exp $
  64. */
  65. class HarmoniAuthorizationManager
  66. extends AuthorizationManager
  67. {
  68. /**
  69. * The AuthorizationCache object.
  70. * @var object _cache
  71. * @access private
  72. */
  73. var $_cache;
  74. var $_groupAncestorsCache;
  75. /**
  76. * Constructor
  77. * manager.
  78. * @access public
  79. */
  80. function HarmoniAuthorizationManager() {
  81. $this->_groupAncestorsCache = array();
  82. }
  83. /**
  84. * Assign the configuration of this Manager. Valid configuration options are as
  85. * follows:
  86. * database_index integer
  87. * database_name string
  88. *
  89. * @param object Properties $configuration (original type: java.util.Properties)
  90. *
  91. * @throws object OsidException An exception with one of the following
  92. * messages defined in org.osid.OsidException: {@link }
  93. * org.osid.OsidException#OPERATION_FAILED OPERATION_FAILED},
  94. * {@link org.osid.OsidException#PERMISSION_DENIED}
  95. * PERMISSION_DENIED}, {@link }
  96. * org.osid.OsidException#CONFIGURATION_ERROR
  97. * CONFIGURATION_ERROR}, {@link }
  98. * org.osid.OsidException#UNIMPLEMENTED UNIMPLEMENTED}, {@link }
  99. * org.osid.OsidException#NULL_ARGUMENT NULL_ARGUMENT}
  100. *
  101. * @access public
  102. */
  103. function assignConfiguration ( $configuration ) {
  104. $this->_configuration =$configuration;
  105. $dbIndex =$configuration->getProperty('database_index');
  106. $authzDB =$configuration->getProperty('database_name');
  107. // ** parameter validation
  108. ArgumentValidator::validate($dbIndex, IntegerValidatorRule::getRule(), true);
  109. ArgumentValidator::validate($authzDB, StringValidatorRule::getRule(), true);
  110. // ** end of parameter validation
  111. $this->_cache = new AuthorizationCache($dbIndex, $authzDB);
  112. }
  113.  
  114. /**
  115. * Return context of this OsidManager.
  116. *
  117. * @return object OsidContext
  118. *
  119. * @throws object OsidException
  120. *
  121. * @access public
  122. */
  123. function getOsidContext () {
  124. return $this->_osidContext;
  125. }
  126.  
  127. /**
  128. * Assign the context of this OsidManager.
  129. *
  130. * @param object OsidContext $context
  131. *
  132. * @throws object OsidException An exception with one of the following
  133. * messages defined in org.osid.OsidException: {@link }
  134. * org.osid.OsidException#NULL_ARGUMENT NULL_ARGUMENT}
  135. *
  136. * @access public
  137. */
  138. function assignOsidContext ( $context ) {
  139. $this->_osidContext =$context;
  140. }
  141.  
  142. /**
  143. * Creates a new Authorization for an Agent performing a Function with a
  144. * Qualifier.
  145. *
  146. * @param object Id $agentId
  147. * @param object Id $functionId
  148. * @param object Id $qualifierId
  149. * @param int $effectiveDate
  150. * @param int $expirationDate
  151. *
  152. * @return object Authorization
  153. *
  154. * @throws object AuthorizationException An exception with
  155. * one of the following messages defined in
  156. * org.osid.authorization.AuthorizationException may be thrown:
  157. * {@link }
  158. * org.osid.authorization.AuthorizationException#OPERATION_FAILED
  159. * OPERATION_FAILED}, {@link }
  160. * org.osid.authorization.AuthorizationException#PERMISSION_DENIED
  161. * PERMISSION_DENIED}, {@link }
  162. * org.osid.authorization.AuthorizationException#CONFIGURATION_ERROR
  163. * CONFIGURATION_ERROR}, {@link }
  164. * org.osid.authorization.AuthorizationException#UNIMPLEMENTED
  165. * UNIMPLEMENTED}, {@link }
  166. * org.osid.authorization.AuthorizationException#NULL_ARGUMENT
  167. * NULL_ARGUMENT}, {@link }
  168. * org.osid.authorization.AuthorizationException#UNKNOWN_ID
  169. * UNKNOWN_ID}, {@link }
  170. * org.osid.authorization.AuthorizationException#EFFECTIVE_PRECEDE_EXPIRATION}
  171. *
  172. * @access public
  173. */
  174. function createDatedAuthorization ( $agentId, $functionId, $qualifierId, $effectiveDate, $expirationDate ) {
  175. $authorization =$this->_cache->createAuthorization($agentId, $functionId, $qualifierId, $effectiveDate, $expirationDate);
  176. IsAuthorizedCache::dirtyNode($qualifierId);
  177. return $authorization;
  178. }
  179.  
  180. /**
  181. * Creates a new Authorization for a Agent performing a Function with a
  182. * Qualifier. Uses current date/time as the effectiveDate and doesn't set
  183. * an expiration date.
  184. *
  185. * @param object Id $agentId
  186. * @param object Id $functionId
  187. * @param object Id $qualifierId
  188. *
  189. * @return object Authorization
  190. *
  191. * @throws object AuthorizationException An exception with
  192. * one of the following messages defined in
  193. * org.osid.authorization.AuthorizationException may be thrown:
  194. * {@link }
  195. * org.osid.authorization.AuthorizationException#OPERATION_FAILED
  196. * OPERATION_FAILED}, {@link }
  197. * org.osid.authorization.AuthorizationException#PERMISSION_DENIED
  198. * PERMISSION_DENIED}, {@link }
  199. * org.osid.authorization.AuthorizationException#CONFIGURATION_ERROR
  200. * CONFIGURATION_ERROR}, {@link }
  201. * org.osid.authorization.AuthorizationException#UNIMPLEMENTED
  202. * UNIMPLEMENTED}, {@link }
  203. * org.osid.authorization.AuthorizationException#NULL_ARGUMENT
  204. * NULL_ARGUMENT}, {@link }
  205. * org.osid.authorization.AuthorizationException#UNKNOWN_ID
  206. * UNKNOWN_ID}
  207. *
  208. * @access public
  209. */
  210. function createAuthorization ( $agentId, $functionId, $qualifierId ) {
  211. $authorization =$this->_cache->createAuthorization($agentId, $functionId, $qualifierId);
  212. IsAuthorizedCache::dirtyNode($qualifierId);
  213. return $authorization;
  214. }
  215.  
  216. /**
  217. * Ids in Authorization are externally defined and their uniqueness is
  218. * enforced by the implementation.
  219. *
  220. * @param object Id $functionId
  221. * @param string $displayName
  222. * @param string $description
  223. * @param object Type $functionType
  224. * @param object Id $qualifierHierarchyId
  225. *
  226. * @return object Function
  227. *
  228. * @throws object AuthorizationException An exception with
  229. * one of the following messages defined in
  230. * org.osid.authorization.AuthorizationException may be thrown:
  231. * {@link }
  232. * org.osid.authorization.AuthorizationException#OPERATION_FAILED
  233. * OPERATION_FAILED}, {@link }
  234. * org.osid.authorization.AuthorizationException#PERMISSION_DENIED
  235. * PERMISSION_DENIED}, {@link }
  236. * org.osid.authorization.AuthorizationException#CONFIGURATION_ERROR
  237. * CONFIGURATION_ERROR}, {@link }
  238. * org.osid.authorization.AuthorizationException#UNIMPLEMENTED
  239. * UNIMPLEMENTED}, {@link }
  240. * org.osid.authorization.AuthorizationException#NULL_ARGUMENT
  241. * NULL_ARGUMENT}, {@link }
  242. * org.osid.authorization.AuthorizationException#UNKNOWN_ID
  243. * UNKNOWN_ID}
  244. *
  245. * @access public
  246. */
  247. function createFunction ( $functionId, $displayName, $description, $functionType, $qualifierHierarchyId ) {
  248. $function =$this->_cache->createFunction($functionId, $displayName, $description, $functionType, $qualifierHierarchyId);
  249. return $function;
  250. }
  251.  
  252. /**
  253. * Creates a new Qualifier in the Authorization Service that has no parent.
  254. * This is different from making a new instance of a Qualifier object
  255. * locally as the Qualifier will be inserted into the Authorization
  256. * Service.
  257. *
  258. * @param object Id $qualifierId
  259. * @param string $displayName
  260. * @param string $description
  261. * @param object Type $qualifierType
  262. * @param object Id $qualifierHierarchyId
  263. *
  264. * @return object Qualifier
  265. *
  266. * @throws object AuthorizationException An exception with
  267. * one of the following messages defined in
  268. * org.osid.authorization.AuthorizationException may be thrown:
  269. * {@link }
  270. * org.osid.authorization.AuthorizationException#OPERATION_FAILED
  271. * OPERATION_FAILED}, {@link }
  272. * org.osid.authorization.AuthorizationException#PERMISSION_DENIED
  273. * PERMISSION_DENIED}, {@link }
  274. * org.osid.authorization.AuthorizationException#CONFIGURATION_ERROR
  275. * CONFIGURATION_ERROR}, {@link }
  276. * org.osid.authorization.AuthorizationException#UNIMPLEMENTED
  277. * UNIMPLEMENTED}, {@link }
  278. * org.osid.authorization.AuthorizationException#NULL_ARGUMENT
  279. * NULL_ARGUMENT}, {@link }
  280. * org.osid.authorization.AuthorizationException#UNKNOWN_ID
  281. * UNKNOWN_ID}, {@link }
  282. * org.osid.authorization.AuthorizationException#UNKNOWN_TYPE
  283. * UNKNOWN_TYPE}
  284. *
  285. * @access public
  286. */
  287. function createRootQualifier ( $qualifierId, $displayName, $description, $qualifierType, $qualifierHierarchyId ) {
  288. $qualifier =$this->_cache->createRootQualifier($qualifierId, $displayName, $description, $qualifierType, $qualifierHierarchyId);
  289. return $qualifier;
  290. }
  291.  
  292. /**
  293. * Ids in Authorization are externally defined and their uniqueness is
  294. * enforced by the implementation. Creates a new Qualifier in the
  295. * Authorization Service. This is different than making a new instance of
  296. * a Qualifier object locally as the Qualifier will be inserted into the
  297. * Authorization Service.
  298. *
  299. * @param object Id $qualifierId
  300. * @param string $displayName
  301. * @param string $description
  302. * @param object Type $qualifierType
  303. * @param object Id $parentId
  304. *
  305. * @return object Qualifier
  306. *
  307. * @throws object AuthorizationException An exception with
  308. * one of the following messages defined in
  309. * org.osid.authorization.AuthorizationException may be thrown:
  310. * {@link }
  311. * org.osid.authorization.AuthorizationException#OPERATION_FAILED
  312. * OPERATION_FAILED}, {@link }
  313. * org.osid.authorization.AuthorizationException#PERMISSION_DENIED
  314. * PERMISSION_DENIED}, {@link }
  315. * org.osid.authorization.AuthorizationException#CONFIGURATION_ERROR
  316. * CONFIGURATION_ERROR}, {@link }
  317. * org.osid.authorization.AuthorizationException#UNIMPLEMENTED
  318. * UNIMPLEMENTED}, {@link }
  319. * org.osid.authorization.AuthorizationException#NULL_ARGUMENT
  320. * NULL_ARGUMENT}, {@link }
  321. * org.osid.authorization.AuthorizationException#UNKNOWN_ID
  322. * UNKNOWN_ID}, {@link }
  323. * org.osid.authorization.AuthorizationException#UNKNOWN_TYPE
  324. * UNKNOWN_TYPE}
  325. *
  326. * @access public
  327. */
  328. function createQualifier ( $qualifierId, $displayName, $description, $qualifierType, $parentId ) {
  329. $qualifier =$this->_cache->createQualifier($qualifierId, $displayName, $description, $qualifierType, $parentId);
  330. return $qualifier;
  331. }
  332.  
  333. /**
  334. * Deletes an existing Authorization.
  335. *
  336. * @param object Authorization $authorization
  337. *
  338. * @throws object AuthorizationException An exception with
  339. * one of the following messages defined in
  340. * org.osid.authorization.AuthorizationException may be thrown:
  341. * {@link }
  342. * org.osid.authorization.AuthorizationException#OPERATION_FAILED
  343. * OPERATION_FAILED}, {@link }
  344. * org.osid.authorization.AuthorizationException#PERMISSION_DENIED
  345. * PERMISSION_DENIED}, {@link }
  346. * org.osid.authorization.AuthorizationException#CONFIGURATION_ERROR
  347. * CONFIGURATION_ERROR}, {@link }
  348. * org.osid.authorization.AuthorizationException#UNIMPLEMENTED
  349. * UNIMPLEMENTED}, {@link }
  350. * org.osid.authorization.AuthorizationException#NULL_ARGUMENT
  351. * NULL_ARGUMENT}, {@link }
  352. * org.osid.authorization.AuthorizationException#UNKNOWN_ID
  353. * UNKNOWN_ID}
  354. *
  355. * @access public
  356. */
  357. function deleteAuthorization ( $authorization ) {
  358. ArgumentValidator::validate($authorization, ExtendsValidatorRule::getRule("Authorization"), true);
  359. $qualifier =$authorization->getQualifier();
  360. $qualifierId =$qualifier->getId();
  361. $this->_cache->deleteAuthorization($authorization);
  362. IsAuthorizedCache::dirtyNode($qualifierId);
  363. }
  364.  
  365. /**
  366. * Delete a Function by Id.
  367. *
  368. * @param object Id $functionId
  369. *
  370. * @throws object AuthorizationException An exception with
  371. * one of the following messages defined in
  372. * org.osid.authorization.AuthorizationException may be thrown:
  373. * {@link }
  374. * org.osid.authorization.AuthorizationException#OPERATION_FAILED
  375. * OPERATION_FAILED}, {@link }
  376. * org.osid.authorization.AuthorizationException#PERMISSION_DENIED
  377. * PERMISSION_DENIED}, {@link }
  378. * org.osid.authorization.AuthorizationException#CONFIGURATION_ERROR
  379. * CONFIGURATION_ERROR}, {@link }
  380. * org.osid.authorization.AuthorizationException#UNIMPLEMENTED
  381. * UNIMPLEMENTED}, {@link }
  382. * org.osid.authorization.AuthorizationException#NULL_ARGUMENT
  383. * NULL_ARGUMENT}, {@link }
  384. * org.osid.authorization.AuthorizationException#UNKNOWN_ID
  385. * UNKNOWN_ID}
  386. *
  387. * @access public
  388. */
  389. function deleteFunction ( $functionId ) {
  390. $this->_cache->deleteFunction($functionId);
  391. }
  392.  
  393. /**
  394. * Delete a Qualifier by Id. The last root Qualifier cannot be deleted.
  395. *
  396. * @param object Id $qualifierId
  397. *
  398. * @throws object AuthorizationException An exception with
  399. * one of the following messages defined in
  400. * org.osid.authorization.AuthorizationException may be thrown:
  401. * {@link }
  402. * org.osid.authorization.AuthorizationException#OPERATION_FAILED
  403. * OPERATION_FAILED}, {@link }
  404. * org.osid.authorization.AuthorizationException#PERMISSION_DENIED
  405. * PERMISSION_DENIED}, {@link }
  406. * org.osid.authorization.AuthorizationException#CONFIGURATION_ERROR
  407. * CONFIGURATION_ERROR}, {@link }
  408. * org.osid.authorization.AuthorizationException#UNIMPLEMENTED
  409. * UNIMPLEMENTED}, {@link }
  410. * org.osid.authorization.AuthorizationException#NULL_ARGUMENT
  411. * NULL_ARGUMENT}, {@link }
  412. * org.osid.authorization.AuthorizationException#UNKNOWN_ID
  413. * UNKNOWN_ID}, {@link }
  414. * org.osid.authorization.AuthorizationException#CANNOT_DELETE_LAST_ROOT_QUALIFIER
  415. * CANNOT_DELETE_LAST_ROOT_QUALIFIER}
  416. *
  417. * @access public
  418. */
  419. function deleteQualifier ( $qualifierId ) {
  420. $this->_cache->deleteQualifier($qualifierId);
  421. }
  422.  
  423. /**
  424. * Given an agentId, functionId, and qualifierId returns true if the Agent
  425. * is authorized now to perform the Function with the Qualifier.
  426. *
  427. * @param object Id $agentId
  428. * @param object Id $functionId
  429. * @param object Id $qualifierId
  430. *
  431. * @return boolean
  432. *
  433. * @throws object AuthorizationException An exception with
  434. * one of the following messages defined in
  435. * org.osid.authorization.AuthorizationException may be thrown:
  436. * {@link }
  437. * org.osid.authorization.AuthorizationException#OPERATION_FAILED
  438. * OPERATION_FAILED}, {@link }
  439. * org.osid.authorization.AuthorizationException#PERMISSION_DENIED
  440. * PERMISSION_DENIED}, {@link }
  441. * org.osid.authorization.AuthorizationException#CONFIGURATION_ERROR
  442. * CONFIGURATION_ERROR}, {@link }
  443. * org.osid.authorization.AuthorizationException#UNIMPLEMENTED
  444. * UNIMPLEMENTED}, {@link }
  445. * org.osid.authorization.AuthorizationException#NULL_ARGUMENT
  446. * NULL_ARGUMENT}, {@link }
  447. * org.osid.authorization.AuthorizationException#UNKNOWN_ID
  448. * UNKNOWN_ID}
  449. *
  450. * @access public
  451. */
  452. function isAuthorized ( $agentId, $functionId, $qualifierId ) {
  453. // $authorizations =$this->getAllAZs($agentId, $functionId, $qualifierId, true);
  454. // return ($authorizations->hasNext());
  455. $isAuthorizedCache = IsAuthorizedCache::instance();
  456. return $isAuthorizedCache->isAuthorized($agentId, $functionId, $qualifierId);
  457. }
  458.  
  459. /**
  460. * Given a functionId and qualifierId returns true if the user is
  461. * authorized now to perform the Function with the Qualifier.
  462. *
  463. * @param object Id $functionId
  464. * @param object Id $qualifierId
  465. *
  466. * @return boolean
  467. *
  468. * @throws object AuthorizationException An exception with
  469. * one of the following messages defined in
  470. * org.osid.authorization.AuthorizationException may be thrown:
  471. * {@link }
  472. * org.osid.authorization.AuthorizationException#OPERATION_FAILED
  473. * OPERATION_FAILED}, {@link }
  474. * org.osid.authorization.AuthorizationException#PERMISSION_DENIED
  475. * PERMISSION_DENIED}, {@link }
  476. * org.osid.authorization.AuthorizationException#CONFIGURATION_ERROR
  477. * CONFIGURATION_ERROR}, {@link }
  478. * org.osid.authorization.AuthorizationException#UNIMPLEMENTED
  479. * UNIMPLEMENTED}, {@link }
  480. * org.osid.authorization.AuthorizationException#NULL_ARGUMENT
  481. * NULL_ARGUMENT}, {@link }
  482. * org.osid.authorization.AuthorizationException#UNKNOWN_ID
  483. * UNKNOWN_ID}
  484. *
  485. * @access public
  486. */
  487. function isUserAuthorized ( $functionId, $qualifierId ) {
  488. // $authorizations =$this->getAllUserAZs($functionId, $qualifierId, true);
  489. // return ($authorizations->hasNext());
  490. $isAuthorizedCache = IsAuthorizedCache::instance();
  491. return $isAuthorizedCache->isUserAuthorized($functionId, $qualifierId);
  492. }
  493. /**
  494. * Given an agentId, functionId, and qualifierId returns true if the Agent
  495. * is authorized now to perform the Function with the Qualifier or one of
  496. * the decendents of the qualifier.
  497. *
  498. * This method is used in determining when to provide UI links deep into a
  499. * hierarchy, as well as in determining when to display UI components that
  500. * only apply if an agent has a particular authorization on any element in
  501. * a subtree.
  502. *
  503. * WARNING: NOT IN OSID
  504. *
  505. * @param object Id $agentId
  506. * @param object Id $functionId
  507. * @param object Id $qualifierId
  508. * @return boolean
  509. * @access public
  510. * @since 2/27/07
  511. */
  512. function isAuthorizedBelow ( $agentId, $functionId, $qualifierId ) {
  513. $isAuthorizedCache = IsAuthorizedCache::instance();
  514. // First check if the authorization exists for the qualifier. If so,
  515. // it will by definition cascade to the descendents.
  516. if ($isAuthorizedCache->isAuthorized($agentId, $functionId, $qualifierId)) {
  517. return true;
  518. }
  519. // Check to see if the authorization is set on any descendents
  520. else {
  521. $descendents =$this->getQualifierDescendants($qualifierId);
  522. while ($descendents->hasNext()) {
  523. $descendent =$descendents->next();
  524. if ($this->isAuthorizedBelow($agentId, $functionId, $descendent->getId()))
  525. return true;
  526. }
  527. return false;
  528. }
  529. }
  530. /**
  531. * Given an agentId, functionId, and qualifierId returns true if the Agent
  532. * is authorized now to perform the Function with the Qualifier or one of
  533. * the decendents of the qualifier.
  534. *
  535. * This method is used in determining when to provide UI links deep into a
  536. * hierarchy, as well as in determining when to display UI components that
  537. * only apply if an agent has a particular authorization on any element in
  538. * a subtree.
  539. *
  540. * WARNING: NOT IN OSID
  541. *
  542. * @param object Id $agentId
  543. * @param object Id $functionId
  544. * @param object Id $qualifierId
  545. * @return boolean
  546. * @access public
  547. * @since 2/27/07
  548. */
  549. function isUserAuthorizedBelow ( $functionId, $qualifierId ) {
  550. $isAuthorizedCache = IsAuthorizedCache::instance();
  551. // First check if the authorization exists for the qualifier. If so,
  552. // it will by definition cascade to the descendents.
  553. if ($isAuthorizedCache->isUserAuthorized($functionId, $qualifierId)) {
  554. return true;
  555. }
  556. // Check to see if the authorization is set on any descendents
  557. else {
  558. $descendents =$this->getQualifierDescendants($qualifierId);
  559. while ($descendents->hasNext()) {
  560. $descendent =$descendents->next();
  561. if ($this->isUserAuthorizedBelow($functionId, $descendent->getId()))
  562. return true;
  563. }
  564. return false;
  565. }
  566. }
  567. /**
  568. * Get all the FunctionTypes supported by the Authorization implementation.
  569. *
  570. * @return object TypeIterator
  571. *
  572. * @throws object AuthorizationException An exception with
  573. * one of the following messages defined in
  574. * org.osid.authorization.AuthorizationException may be thrown:
  575. * {@link }
  576. * org.osid.authorization.AuthorizationException#OPERATION_FAILED
  577. * OPERATION_FAILED}, {@link }
  578. * org.osid.authorization.AuthorizationException#PERMISSION_DENIED
  579. * PERMISSION_DENIED}, {@link }
  580. * org.osid.authorization.AuthorizationException#CONFIGURATION_ERROR
  581. * CONFIGURATION_ERROR}, {@link }
  582. * org.osid.authorization.AuthorizationException#UNIMPLEMENTED
  583. * UNIMPLEMENTED}
  584. *
  585. * @access public
  586. */
  587. function getFunctionTypes () {
  588. return $this->_cache->getFunctionTypes();
  589. }
  590.  
  591. /**
  592. * Get all the Functions of the specified Type.
  593. *
  594. * @param object Type $functionType
  595. *
  596. * @return object FunctionIterator
  597. *
  598. * @throws object AuthorizationException An exception with
  599. * one of the following messages defined in
  600. * org.osid.authorization.AuthorizationException may be thrown:
  601. * {@link }
  602. * org.osid.authorization.AuthorizationException#OPERATION_FAILED
  603. * OPERATION_FAILED}, {@link }
  604. * org.osid.authorization.AuthorizationException#PERMISSION_DENIED
  605. * PERMISSION_DENIED}, {@link }
  606. * org.osid.authorization.AuthorizationException#CONFIGURATION_ERROR
  607. * CONFIGURATION_ERROR}, {@link }
  608. * org.osid.authorization.AuthorizationException#UNIMPLEMENTED
  609. * UNIMPLEMENTED}, {@link }
  610. * org.osid.authorization.AuthorizationException#NULL_ARGUMENT
  611. * NULL_ARGUMENT}, {@link }
  612. * org.osid.authorization.AuthorizationException#UNKNOWN_TYPE
  613. * UNKNOWN_TYPE}
  614. *
  615. * @access public
  616. */
  617. function getFunctions ( $functionType ) {
  618. return $this->_cache->getFunctions($functionType);
  619. }
  620.  
  621. /**
  622. *
  623. *
  624. * @param object Id $functionId
  625. *
  626. * @return object Function
  627. *
  628. * @throws object AuthorizationException An exception with
  629. * one of the following messages defined in
  630. * org.osid.authorization.AuthorizationException may be thrown:
  631. * {@link }
  632. * org.osid.authorization.AuthorizationException#OPERATION_FAILED
  633. * OPERATION_FAILED}, {@link }
  634. * org.osid.authorization.AuthorizationException#PERMISSION_DENIED
  635. * PERMISSION_DENIED}, {@link }
  636. * org.osid.authorization.AuthorizationException#CONFIGURATION_ERROR
  637. * CONFIGURATION_ERROR}, {@link }
  638. * org.osid.authorization.AuthorizationException#UNIMPLEMENTED
  639. * UNIMPLEMENTED}, {@link }
  640. * org.osid.authorization.AuthorizationException#NULL_ARGUMENT
  641. * NULL_ARGUMENT}, {@link }
  642. * org.osid.authorization.AuthorizationException#UNKNOWN_ID
  643. * UNKNOWN_ID}
  644. *
  645. * @access public
  646. */
  647. function getFunction ( $functionId ) {
  648. // ** parameter validation
  649. ArgumentValidator::validate($functionId, ExtendsValidatorRule::getRule("Id"), true);
  650. // ** end of parameter validation
  651. $idValue = $functionId->getIdString();
  652. $result =$this->_cache->getFunction($idValue);
  653. return $result;
  654. }
  655.  
  656. /**
  657. * Return true if the agentId exists in the Authorization Service; false
  658. * otherwise. This is not asking if there are any Authorizations that
  659. * reference this agentId. This is not asking if the agentId is known to
  660. * the Agent OSID.
  661. *
  662. * @param object Id $agentId
  663. *
  664. * @return boolean
  665. *
  666. * @throws object AuthorizationException An exception with
  667. * one of the following messages defined in
  668. * org.osid.authorization.AuthorizationException may be thrown:
  669. * {@link }
  670. * org.osid.authorization.AuthorizationException#OPERATION_FAILED
  671. * OPERATION_FAILED}, {@link }
  672. * org.osid.authorization.AuthorizationException#PERMISSION_DENIED
  673. * PERMISSION_DENIED}, {@link }
  674. * org.osid.authorization.AuthorizationException#CONFIGURATION_ERROR
  675. * CONFIGURATION_ERROR}, {@link }
  676. * org.osid.authorization.AuthorizationException#UNIMPLEMENTED
  677. * UNIMPLEMENTED}, {@link }
  678. * org.osid.authorization.AuthorizationException#NULL_ARGUMENT
  679. * NULL_ARGUMENT}, {@link }
  680. * org.osid.authorization.AuthorizationException#UNKNOWN_ID
  681. * UNKNOWN_ID}
  682. *
  683. * @access public
  684. */
  685. function agentExists ( $agentId ) {
  686. die(UNIMPLEMENTED);
  687. }
  688.  
  689. /**
  690. * Get all the QualifierTypes supported by the Authorization
  691. * implementation.
  692. *
  693. * @return object TypeIterator
  694. *
  695. * @throws object AuthorizationException An exception with
  696. * one of the following messages defined in
  697. * org.osid.authorization.AuthorizationException may be thrown:
  698. * {@link }
  699. * org.osid.authorization.AuthorizationException#OPERATION_FAILED
  700. * OPERATION_FAILED}, {@link }
  701. * org.osid.authorization.AuthorizationException#PERMISSION_DENIED
  702. * PERMISSION_DENIED}, {@link }
  703. * org.osid.authorization.AuthorizationException#CONFIGURATION_ERROR
  704. * CONFIGURATION_ERROR}, {@link }
  705. * org.osid.authorization.AuthorizationException#UNIMPLEMENTED
  706. * UNIMPLEMENTED}
  707. *
  708. * @access public
  709. */
  710. function getQualifierTypes () {
  711. $hierarchyManager = Services::getService("Hierarchy");
  712. $hierarchies =$hierarchyManager->getHierarchies();
  713. $types = array();
  714. while ($hierarchies->hasNext()) {
  715. $hierarchy =$hierarchies->next();
  716. $nodeTypes =$hierarchy->getNodeTypes();
  717. while ($nodeTypes->hasNext()) {
  718. $type =$nodeTypes->next();
  719. $typeString = $type->getDomain()
  720. ."::".$type->getAuthority()
  721. ."::".$type->getKeyword();
  722. if (!$types[$typeString])
  723. $types[$typeString] =$type;
  724. }
  725. }
  726. $i = new HarmoniIterator($types);
  727. return $i;
  728. }
  729.  
  730. /**
  731. * Given a hierarchyId, returns the Qualifiers at the root of the specified
  732. * Hierarchy.
  733. *
  734. * @param object Id $qualifierHierarchyId
  735. *
  736. * @return object QualifierIterator
  737. *
  738. * @throws object AuthorizationException An exception with
  739. * one of the following messages defined in
  740. * org.osid.authorization.AuthorizationException may be thrown:
  741. * {@link }
  742. * org.osid.authorization.AuthorizationException#OPERATION_FAILED
  743. * OPERATION_FAILED}, {@link }
  744. * org.osid.authorization.AuthorizationException#PERMISSION_DENIED
  745. * PERMISSION_DENIED}, {@link }
  746. * org.osid.authorization.AuthorizationException#CONFIGURATION_ERROR
  747. * CONFIGURATION_ERROR}, {@link }
  748. * org.osid.authorization.AuthorizationException#UNIMPLEMENTED
  749. * UNIMPLEMENTED}, {@link }
  750. * org.osid.authorization.AuthorizationException#NULL_ARGUMENT
  751. * NULL_ARGUMENT}, {@link }
  752. * org.osid.authorization.AuthorizationException#UNKNOWN_TYPE
  753. * UNKNOWN_TYPE}
  754. *
  755. * @access public
  756. */
  757. function getRootQualifiers ( $qualifierHierarchyId ) {
  758. return $this->_cache->getRootQualifiers($qualifierHierarchyId);
  759. }
  760.  
  761. /**
  762. * Given an existing qualifierId returns the Ids of its child Qualifiers.
  763. *
  764. * @param object Id $qualifierId
  765. *
  766. * @return object QualifierIterator
  767. *
  768. * @throws object AuthorizationException An exception with
  769. * one of the following messages defined in
  770. * org.osid.authorization.AuthorizationException may be thrown:
  771. * {@link }
  772. * org.osid.authorization.AuthorizationException#OPERATION_FAILED
  773. * OPERATION_FAILED}, {@link }
  774. * org.osid.authorization.AuthorizationException#PERMISSION_DENIED
  775. * PERMISSION_DENIED}, {@link }
  776. * org.osid.authorization.AuthorizationException#CONFIGURATION_ERROR
  777. * CONFIGURATION_ERROR}, {@link }
  778. * org.osid.authorization.AuthorizationException#UNIMPLEMENTED
  779. * UNIMPLEMENTED}, {@link }
  780. * org.osid.authorization.AuthorizationException#NULL_ARGUMENT
  781. * NULL_ARGUMENT}, {@link }
  782. * org.osid.authorization.AuthorizationException#UNKNOWN_ID
  783. * UNKNOWN_ID}
  784. *
  785. * @access public
  786. */
  787. function getQualifierChildren ( $qualifierId ) {
  788. // get the qualifier
  789. $qualifier =$this->getQualifier($qualifierId);
  790. return $qualifier->getChildren();
  791. }
  792.  
  793. /**
  794. * Given an existing qualifierId returns the Ids of all descendants
  795. * including its child Qualifiers.
  796. *
  797. * @param object Id $qualifierId
  798. *
  799. * @return object QualifierIterator
  800. *
  801. * @throws object AuthorizationException An exception with
  802. * one of the following messages defined in
  803. * org.osid.authorization.AuthorizationException may be thrown:
  804. * {@link }
  805. * org.osid.authorization.AuthorizationException#OPERATION_FAILED
  806. * OPERATION_FAILED}, {@link }
  807. * org.osid.authorization.AuthorizationException#PERMISSION_DENIED
  808. * PERMISSION_DENIED}, {@link }
  809. * org.osid.authorization.AuthorizationException#CONFIGURATION_ERROR
  810. * CONFIGURATION_ERROR}, {@link }
  811. * org.osid.authorization.AuthorizationException#UNIMPLEMENTED
  812. * UNIMPLEMENTED}, {@link }
  813. * org.osid.authorization.AuthorizationException#NULL_ARGUMENT
  814. * NULL_ARGUMENT}, {@link }
  815. * org.osid.authorization.AuthorizationException#UNKNOWN_ID
  816. * UNKNOWN_ID}
  817. *
  818. * @access public
  819. */
  820. function getQualifierDescendants ( $qualifierId ) {
  821. // ** parameter validation
  822. ArgumentValidator::validate($qualifierId, ExtendsValidatorRule::getRule("Id"), true);
  823. // ** end of parameter validation
  824. $result =$this->_cache->getQualifierDescendants($qualifierId);
  825. return $result;
  826. }
  827.  
  828. /**
  829. *
  830. *
  831. * @param object Id $qualifierId
  832. *
  833. * @return object Qualifier
  834. *
  835. * @throws object AuthorizationException An exception with
  836. * one of the following messages defined in
  837. * org.osid.authorization.AuthorizationException may be thrown:
  838. * {@link }
  839. * org.osid.authorization.AuthorizationException#OPERATION_FAILED
  840. * OPERATION_FAILED}, {@link }
  841. * org.osid.authorization.AuthorizationException#PERMISSION_DENIED
  842. * PERMISSION_DENIED}, {@link }
  843. * org.osid.authorization.AuthorizationException#CONFIGURATION_ERROR
  844. * CONFIGURATION_ERROR}, {@link }
  845. * org.osid.authorization.AuthorizationException#UNIMPLEMENTED
  846. * UNIMPLEMENTED}, {@link }
  847. * org.osid.authorization.AuthorizationException#NULL_ARGUMENT
  848. * NULL_ARGUMENT}, {@link }
  849. * org.osid.authorization.AuthorizationException#UNKNOWN_ID
  850. * UNKNOWN_ID}
  851. *
  852. * @access public
  853. */
  854. function getQualifier ( $qualifierId ) {
  855. // ** parameter validation
  856. ArgumentValidator::validate($qualifierId, ExtendsValidatorRule::getRule("Id"), true);
  857. // ** end of parameter validation
  858. $result =$this->_cache->getQualifier($qualifierId);
  859. return $result;
  860. }
  861.  
  862. /**
  863. * Given a functionId and a qualifierId returns the Ids of all Agents
  864. * allowed to do the Function with the Qualifier. A null qualifierId is
  865. * treated as a wildcard.
  866. *
  867. * @param object Id $functionId
  868. * @param object Id $qualifierId
  869. *
  870. * @return object IdIterator
  871. *
  872. * @throws object AuthorizationException An exception with
  873. * one of the following messages defined in
  874. * org.osid.authorization.AuthorizationException may be thrown:
  875. * {@link }
  876. * org.osid.authorization.AuthorizationException#OPERATION_FAILED
  877. * OPERATION_FAILED}, {@link }
  878. * org.osid.authorization.AuthorizationException#PERMISSION_DENIED
  879. * PERMISSION_DENIED}, {@link }
  880. * org.osid.authorization.AuthorizationException#CONFIGURATION_ERROR
  881. * CONFIGURATION_ERROR}, {@link }
  882. * org.osid.authorization.AuthorizationException#UNIMPLEMENTED
  883. * UNIMPLEMENTED}, {@link }
  884. * org.osid.authorization.AuthorizationException#NULL_ARGUMENT
  885. * NULL_ARGUMENT}, {@link }
  886. * org.osid.authorization.AuthorizationException#UNKNOWN_ID
  887. * UNKNOWN_ID}
  888. *
  889. * @access public
  890. */
  891. function getWhoCanDo ( $functionId, $qualifierId ) {
  892. // ** parameter validation
  893. ArgumentValidator::validate($functionId, ExtendsValidatorRule::getRule("Id"), true);
  894. ArgumentValidator::validate($qualifierId, OptionalRule::getRule(ExtendsValidatorRule::getRule("Id")), true);
  895. // Removed as of version 2 of the OSID
  896. // ArgumentValidator::validate($isActiveNow, BooleanValidatorRule::getRule(), true);
  897. // ** end of parameter validation
  898. $authorizations =$this->getAllAZs($null = null, $functionId, $qualifierId, true);
  899. $agentIds = array();
  900. while ($authorizations->hasNext()) {
  901. $authorization =$authorizations->next();
  902. $agentId =$authorization->getAgentId();
  903. if (!isset($agentIds[$agentId->getIdString()]))
  904. $agentIds[$agentId->getIdString()] =$agentId;
  905. }
  906. $i = new HarmoniIdIterator($agentIds);
  907. return $i;
  908. }
  909.  
  910. /**
  911. * Given a functionId and qualifierId (one must be non-null) returns the
  912. * matching user Authorizations. Explicit Authorizations can be
  913. * modified.. Any null argument will be treated as a wildcard.
  914. *
  915. * @param object Id $functionId
  916. * @param object Id $qualifierId
  917. * @param boolean $isActiveNowOnly
  918. *
  919. * @return object AuthorizationIterator
  920. *
  921. * @throws object AuthorizationException An exception with
  922. * one of the following messages defined in
  923. * org.osid.authorization.AuthorizationException may be thrown:
  924. * {@link }
  925. * org.osid.authorization.AuthorizationException#OPERATION_FAILED
  926. * OPERATION_FAILED}, {@link }
  927. * org.osid.authorization.AuthorizationException#PERMISSION_DENIED
  928. * PERMISSION_DENIED}, {@link }
  929. * org.osid.authorization.AuthorizationException#CONFIGURATION_ERROR
  930. * CONFIGURATION_ERROR}, {@link }
  931. * org.osid.authorization.AuthorizationException#UNIMPLEMENTED
  932. * UNIMPLEMENTED}, {@link }
  933. * org.osid.authorization.AuthorizationException#NULL_ARGUMENT
  934. * NULL_ARGUMENT}, {@link }
  935. * org.osid.authorization.AuthorizationException#UNKNOWN_ID
  936. * UNKNOWN_ID}
  937. *
  938. * @access public
  939. */
  940. function getExplicitUserAZs ( $functionId, $qualifierId, $isActiveNowOnly ) {
  941. // ** parameter validation
  942. ArgumentValidator::validate($functionId, ExtendsValidatorRule::getRule("Id"), true);
  943. ArgumentValidator::validate($qualifierId, ExtendsValidatorRule::getRule("Id"), true);
  944. ArgumentValidator::validate($isActiveNowOnly, BooleanValidatorRule::getRule(), true);
  945. // ** end of parameter validation
  946. $userIds =$this->_getUserIds();
  947. $authorizations = array();
  948. foreach (array_keys($userIds) as $key) {
  949. $userId =$userIds[$key];
  950. $userAZs =$this->_cache->getAZs(
  951. $userId->getIdString(), // aid
  952. $functionId->getIdString(), // fid
  953. $qualifierId->getIdString(), // qid
  954. null, // ftype
  955. true, // returnExplicitOnly
  956. false, // searchUp
  957. $isActiveNowOnly);
  958. $authorizations = array_merge($authorizations, $userAZs);
  959. }
  960. $i = new HarmoniAuthorizationIterator($authorizations);
  961. return $i;
  962. }
  963.  
  964. /**
  965. * Given a FunctionType and qualifierId returns the matching user
  966. * Authorizations. The Authorizations must be for Functions within the
  967. * given FunctionType. Explicit Authorizations can be modified. Any null
  968. * argument will be treated as a wildcard.
  969. *
  970. * @param object Type $functionType
  971. * @param object Id $qualifierId
  972. * @param boolean $isActiveNowOnly
  973. *
  974. * @return object AuthorizationIterator
  975. *
  976. * @throws object AuthorizationException An exception with
  977. * one of the following messages defined in
  978. * org.osid.authorization.AuthorizationException may be thrown:
  979. * {@link }
  980. * org.osid.authorization.AuthorizationException#OPERATION_FAILED
  981. * OPERATION_FAILED}, {@link }
  982. * org.osid.authorization.AuthorizationException#PERMISSION_DENIED
  983. * PERMISSION_DENIED}, {@link }
  984. * org.osid.authorization.AuthorizationException#CONFIGURATION_ERROR
  985. * CONFIGURATION_ERROR}, {@link }
  986. * org.osid.authorization.AuthorizationException#UNIMPLEMENTED
  987. * UNIMPLEMENTED}, {@link }
  988. * org.osid.authorization.AuthorizationException#NULL_ARGUMENT
  989. * NULL_ARGUMENT}, {@link }
  990. * org.osid.authorization.AuthorizationException#UNKNOWN_ID
  991. * UNKNOWN_ID}, {@link }
  992. * org.osid.authorization.AuthorizationException#UNKNOWN_TYPE
  993. * UNKNOWN_TYPE}
  994. *
  995. * @access public
  996. */
  997. function getExplicitUserAZsByFuncType ( $functionType, $qualifierId, $isActiveNowOnly ) {
  998. // ** parameter validation
  999. ArgumentValidator::validate($functionType, ExtendsValidatorRule::getRule("Type"), true);
  1000. ArgumentValidator::validate($qualifierId, ExtendsValidatorRule::getRule("Id"), true);
  1001. ArgumentValidator::validate($isActiveNowOnly, BooleanValidatorRule::getRule(), true);
  1002. // ** end of parameter validation
  1003. $userIds =$this->_getUserIds();
  1004. $authorizations = array();
  1005. foreach (array_keys($userIds) as $key) {
  1006. $userId =$userIds[$key];
  1007. $userAZs =$this->_cache->getAZs(
  1008. $userId->getIdString(), // aid
  1009. null, // fid
  1010. $qualifierId->getIdString(), // qid
  1011. $functionType, // ftype
  1012. true, // returnExplicitOnly
  1013. false, // searchUp
  1014. $isActiveNowOnly); // isActiveNowOnly
  1015. $authorizations = array_merge($authorizations, $userAZs);
  1016. }
  1017. $i = new HarmoniAuthorizationIterator($authorizations);
  1018. return $i;
  1019. }
  1020.  
  1021. /**
  1022. * Given a functionId and a qualifierId returns all Authorizations that
  1023. * would allow the user to do the Function with the Qualifier. This method
  1024. * differs from the simple form of getAuthorizations in that this method
  1025. * looks for any Authorization that permits doing the Function with the
  1026. * Qualifier even if the Authorization's Qualifier happens to be a parent
  1027. * of this Qualifier argument.
  1028. *
  1029. * @param object Id $functionId
  1030. * @param object Id $qualifierId
  1031. * @param boolean $isActiveNowOnly
  1032. *
  1033. * @return object AuthorizationIterator
  1034. *
  1035. * @throws object AuthorizationException An exception with
  1036. * one of the following messages defined in
  1037. * org.osid.authorization.AuthorizationException may be thrown:
  1038. * {@link }
  1039. * org.osid.authorization.AuthorizationException#OPERATION_FAILED
  1040. * OPERATION_FAILED}, {@link }
  1041. * org.osid.authorization.AuthorizationException#PERMISSION_DENIED
  1042. * PERMISSION_DENIED}, {@link }
  1043. * org.osid.authorization.AuthorizationException#CONFIGURATION_ERROR
  1044. * CONFIGURATION_ERROR}, {@link }
  1045. * org.osid.authorization.AuthorizationException#UNIMPLEMENTED
  1046. * UNIMPLEMENTED}, {@link }
  1047. * org.osid.authorization.AuthorizationException#NULL_ARGUMENT
  1048. * NULL_ARGUMENT}, {@link }
  1049. * org.osid.authorization.AuthorizationException#UNKNOWN_ID
  1050. * UNKNOWN_ID}
  1051. *
  1052. * @access public
  1053. */
  1054. function getAllUserAZs ( $functionId, $qualifierId, $isActiveNowOnly ) {
  1055. // ** parameter validation
  1056. ArgumentValidator::validate($functionId, ExtendsValidatorRule::getRule("Id"), true);
  1057. ArgumentValidator::validate($qualifierId, ExtendsValidatorRule::getRule("Id"), true);
  1058. ArgumentValidator::validate($isActiveNowOnly, BooleanValidatorRule::getRule(), true);
  1059. // ** end of parameter validation
  1060. $userIds =$this->_getUserIds();
  1061. $authorizations = array();
  1062. foreach (array_keys($userIds) as $key) {
  1063. $userId =$userIds[$key];
  1064. $userAZs =$this->_cache->getAZs(
  1065. $userId->getIdString(), // aid
  1066. $functionId->getIdString(), // fid
  1067. $qualifierId->getIdString(), // qid
  1068. null, // ftype
  1069. false, // returnExplicitOnly
  1070. true, // searchUp
  1071. $isActiveNowOnly, // isActiveOnly
  1072. $this->_getContainingGroupIdStrings($userId));
  1073. $authorizations = array_merge($authorizations, $userAZs);
  1074. }
  1075. $i = new HarmoniAuthorizationIterator($authorizations);
  1076. return $i;
  1077. }
  1078. /**
  1079. * Given a FunctionType and a qualifierId returns all Authorizations that
  1080. * would allow the user to do Functions in the FunctionType with the
  1081. * Qualifier. This method differs from getAuthorizations in that this
  1082. * method looks for any Authorization that permits doing the Function with
  1083. * the Qualifier even if the Authorization's Qualifier happens to be a
  1084. * parent of the Qualifier argument.
  1085. *
  1086. * @param object Type $functionType
  1087. * @param object Id $qualifierId
  1088. * @param boolean $isActiveNowOnly
  1089. *
  1090. * @return object AuthorizationIterator
  1091. *
  1092. * @throws object AuthorizationException An exception with
  1093. * one of the following messages defined in
  1094. * org.osid.authorization.AuthorizationException may be thrown:
  1095. * {@link }
  1096. * org.osid.authorization.AuthorizationException#OPERATION_FAILED
  1097. * OPERATION_FAILED}, {@link }
  1098. * org.osid.authorization.AuthorizationException#PERMISSION_DENIED
  1099. * PERMISSION_DENIED}, {@link }
  1100. * org.osid.authorization.AuthorizationException#CONFIGURATION_ERROR
  1101. * CONFIGURATION_ERROR}, {@link }
  1102. * org.osid.authorization.AuthorizationException#UNIMPLEMENTED
  1103. * UNIMPLEMENTED}, {@link }
  1104. * org.osid.authorization.AuthorizationException#NULL_ARGUMENT
  1105. * NULL_ARGUMENT}, {@link }
  1106. * org.osid.authorization.AuthorizationException#UNKNOWN_ID
  1107. * UNKNOWN_ID}, {@link }
  1108. * org.osid.authorization.AuthorizationException#UNKNOWN_TYPE
  1109. * UNKNOWN_TYPE}
  1110. *
  1111. * @access public
  1112. */
  1113. function getAllUserAZsByFuncType ( $functionType, $qualifierId, $isActiveNowOnly ) {
  1114. // ** parameter validation
  1115. ArgumentValidator::validate($functionType, ExtendsValidatorRule::getRule("Type"), true);
  1116. ArgumentValidator::validate($qualifierId, ExtendsValidatorRule::getRule("Id"), true);
  1117. ArgumentValidator::validate($isActiveNowOnly, BooleanValidatorRule::getRule(), true);
  1118. // ** end of parameter validation
  1119. $userIds =$this->_getUserIds();
  1120. $authorizations = array();
  1121. foreach (array_keys($userIds) as $key) {
  1122. $userId =$userIds[$key];
  1123. $userAZs =$this->_cache->getAZs(
  1124. $userId->getIdString(), // aid
  1125. null, // fid
  1126. $qualifierId->getIdString(), // qid
  1127. $functionType, // ftype
  1128. false, // returnExplicitOnly
  1129. true, // searchUp
  1130. $isActiveNowOnly, // isActiveNowOnly
  1131. $this->_getContainingGroupIdStrings($userId));
  1132. $authorizations = array_merge($authorizations, $userAZs);
  1133. }
  1134. $i = new HarmoniAuthorizationIterator($authorizations);
  1135. return $i;
  1136. }
  1137.  
  1138. /**
  1139. * Given a agentId, a functionId, and a qualifierId (at least one of these
  1140. * must be non-null) returns the matching Authorizations. Explicit
  1141. * Authorizations can be modified. Any null argument will be treated as a
  1142. * wildcard.
  1143. *
  1144. * @param object Id $agentId
  1145. * @param object Id $functionId
  1146. * @param object Id $qualifierId
  1147. * @param boolean $isActiveNowOnly
  1148. *
  1149. * @return object AuthorizationIterator
  1150. *
  1151. * @throws object AuthorizationException An exception with
  1152. * one of the following messages defined in
  1153. * org.osid.authorization.AuthorizationException may be thrown:
  1154. * {@link }
  1155. * org.osid.authorization.AuthorizationException#OPERATION_FAILED
  1156. * OPERATION_FAILED}, {@link }
  1157. * org.osid.authorization.AuthorizationException#PERMISSION_DENIED
  1158. * PERMISSION_DENIED}, {@link }
  1159. * org.osid.authorization.AuthorizationException#CONFIGURATION_ERROR
  1160. * CONFIGURATION_ERROR}, {@link }
  1161. * org.osid.authorization.AuthorizationException#UNIMPLEMENTED
  1162. * UNIMPLEMENTED}, {@link }
  1163. * org.osid.authorization.AuthorizationException#NULL_ARGUMENT
  1164. * NULL_ARGUMENT}, {@link }
  1165. * org.osid.authorization.AuthorizationException#UNKNOWN_ID
  1166. * UNKNOWN_ID}
  1167. *
  1168. * @access public
  1169. */
  1170. function getExplicitAZs ( $agentId, $functionId, $qualifierId, $isActiveNowOnly ) {
  1171. // ** parameter validation
  1172. ArgumentValidator::validate($agentId, ExtendsValidatorRule::getRule("Id"), true);
  1173. ArgumentValidator::validate($functionId, ExtendsValidatorRule::getRule("Id"), true);
  1174. ArgumentValidator::validate($qualifierId, ExtendsValidatorRule::getRule("Id"), true);
  1175. ArgumentValidator::validate($isActiveNowOnly, BooleanValidatorRule::getRule(), true);
  1176. // ** end of parameter validation
  1177. $authorizations =$this->_cache->getAZs(
  1178. $agentId->getIdString(), // aid
  1179. $functionId->getIdString(), // fid
  1180. $qualifierId->getIdString(), // qid
  1181. null, // ftype
  1182. true, // returnExplicitOnly
  1183. false, // searchUp
  1184. $isActiveNowOnly); // isActiveNowOnly
  1185. $i = new HarmoniAuthorizationIterator($authorizations);
  1186. return $i;
  1187. }
  1188.  
  1189. /**
  1190. * Given a agentId, a FunctionType, and a qualifierId (either agentId or
  1191. * qualifierId must be non-null) returns the matching Authorizations. The
  1192. * Authorizations must be for Functions within the given FunctionType.
  1193. * Explicit Authorizations can be modified. Any null argument will be
  1194. * treated as a wildcard.
  1195. *
  1196. * @param object Id $agentId
  1197. * @param object Type $functionType
  1198. * @param object Id $qualifierId
  1199. * @param boolean $isActiveNowOnly
  1200. *
  1201. * @return object AuthorizationIterator
  1202. *
  1203. * @throws object AuthorizationException An exception with
  1204. * one of the following messages defined in
  1205. * org.osid.authorization.AuthorizationException may be thrown:
  1206. * {@link }
  1207. * org.osid.authorization.AuthorizationException#OPERATION_FAILED
  1208. * OPERATION_FAILED}, {@link }
  1209. * org.osid.authorization.AuthorizationException#PERMISSION_DENIED
  1210. * PERMISSION_DENIED}, {@link }
  1211. * org.osid.authorization.AuthorizationException#CONFIGURATION_ERROR
  1212. * CONFIGURATION_ERROR}, {@link }
  1213. * org.osid.authorization.AuthorizationException#UNIMPLEMENTED
  1214. * UNIMPLEMENTED}, {@link }
  1215. * org.osid.authorization.AuthorizationException#NULL_ARGUMENT
  1216. * NULL_ARGUMENT}, {@link }
  1217. * org.osid.authorization.AuthorizationException#UNKNOWN_ID
  1218. * UNKNOWN_ID}, {@link }
  1219. * org.osid.authorization.AuthorizationException#UNKNOWN_TYPE
  1220. * UNKNOWN_TYPE}
  1221. *
  1222. * @access public
  1223. */
  1224. function getExplicitAZsByFuncType ( $agentId, $functionType, $qualifierId, $isActiveNowOnly ) {
  1225. // ** parameter validation
  1226. ArgumentValidator::validate($agentId, ExtendsValidatorRule::getRule("Id"), true);
  1227. ArgumentValidator::validate($functionType, ExtendsValidatorRule::getRule("Type"), true);
  1228. ArgumentValidator::validate($qualifierId, ExtendsValidatorRule::getRule("Id"), true);
  1229. ArgumentValidator::validate($isActiveNowOnly, BooleanValidatorRule::getRule(), true);
  1230. // ** end of parameter validation
  1231. $authorizations =$this->_cache->getAZs(
  1232. $agentId->getIdString(), // aid
  1233. null, // fid
  1234. $qualifierId->getIdString(), // qid
  1235. $functionType, // ftype
  1236. true, // returnExplicitOnly
  1237. false, // searchUp
  1238. $isActiveNowOnly); // isActiveNowOnly
  1239. $iter = new HarmoniAuthorizationIterator($authorizations);
  1240. return $iter;
  1241. }
  1242. /**
  1243. * WARNING: NOT IN OSID!
  1244. *
  1245. * Returns a list of all explicit authorizations for a given user across all functions and qualifiers.
  1246. * @param ref object $agentId The agent's ID.
  1247. * @param boolean $isActiveNowOnly Include only active authorizations.
  1248. *
  1249. * @return ref object Iterator
  1250. ***/
  1251. function getAllExplicitAZsForAgent($agentId, $isActiveNowOnly)
  1252. {
  1253. // ** parameter validation
  1254. ArgumentValidator::validate($agentId, ExtendsValidatorRule::getRule("Id"), true);
  1255. ArgumentValidator::validate($isActiveNowOnly, BooleanValidatorRule::getRule(), true);
  1256. // ** end
  1257. $authorizations =$this->_cache->getAZs(
  1258. $agentId->getIdString(), // aid
  1259. null, // fid
  1260. null, // qid
  1261. null, // ftype
  1262. true, // returnExplicitOnly
  1263. false, // searchUp
  1264. $isActiveNowOnly); // isActiveNowOnly
  1265. $iter = new HarmoniAuthorizationIterator($authorizations);
  1266. return $iter;
  1267. }
  1268.  
  1269. /**
  1270. * Given a functionId and a qualifierId returns all Authorizations that
  1271. * would allow agents to do the Function with the Qualifier. This method
  1272. * differs from the simple form of getAuthorizations in that this method
  1273. * looks for any Authorization that permits doing the Function with the
  1274. * Qualifier even if the Authorization's Qualifier happens to be a parent
  1275. * of this Qualifier argument.
  1276. *
  1277. * @param object Id $agentId
  1278. * @param object Id $functionId
  1279. * @param object Id $qualifierId
  1280. * @param boolean $isActiveNowOnly
  1281. *
  1282. * @return object AuthorizationIterator
  1283. *
  1284. * @throws object AuthorizationException An exception with
  1285. * one of the following messages defined in
  1286. * org.osid.authorization.AuthorizationException may be thrown:
  1287. * {@link }
  1288. * org.osid.authorization.AuthorizationException#OPERATION_FAILED
  1289. * OPERATION_FAILED}, {@link }
  1290. * org.osid.authorization.AuthorizationException#PERMISSION_DENIED
  1291. * PERMISSION_DENIED}, {@link }
  1292. * org.osid.authorization.AuthorizationException#CONFIGURATION_ERROR
  1293. * CONFIGURATION_ERROR}, {@link }
  1294. * org.osid.authorization.AuthorizationException#UNIMPLEMENTED
  1295. * UNIMPLEMENTED}, {@link }
  1296. * org.osid.authorization.AuthorizationException#NULL_ARGUMENT
  1297. * NULL_ARGUMENT}, {@link }
  1298. * org.osid.authorization.AuthorizationException#UNKNOWN_ID
  1299. * UNKNOWN_ID}
  1300. *
  1301. * @access public
  1302. */
  1303. function getAllAZs ( $agentId, $functionId, $qualifierId, $isActiveNowOnly ) {
  1304. // ** parameter validation
  1305. ArgumentValidator::validate($agentId, OptionalRule::getRule(ExtendsValidatorRule::getRule("Id")), true);
  1306. ArgumentValidator::validate($functionId, OptionalRule::getRule(ExtendsValidatorRule::getRule("Id")), true);
  1307. ArgumentValidator::validate($qualifierId, OptionalRule::getRule(ExtendsValidatorRule::getRule("Id")), true);
  1308. ArgumentValidator::validate($isActiveNowOnly, BooleanValidatorRule::getRule(), true);
  1309. // ** end of parameter validation
  1310. if (is_null($agentId)) {
  1311. $agentIdString = null;
  1312. $containingGroups = array();
  1313. } else {
  1314. $agentIdString = $agentId->getIdString();
  1315. $containingGroups = $this->_getContainingGroupIdStrings($agentId);
  1316. }
  1317. if (is_null($functionId))
  1318. $functionIdString = null;
  1319. else
  1320. $functionIdString = $functionId->getIdString();
  1321. if (is_null($qualifierId))
  1322. $qualifierIdString = null;
  1323. else
  1324. $qualifierIdString = $qualifierId->getIdString();
  1325. // printpre("a: $agentIdString \nf: $functionIdString \nq: $qualifierIdString");
  1326. // printpre($containingGroups);
  1327. // throwError(new Error("failed"));
  1328. // We need to check all of the groups that may contain $aId as well as
  1329. // aId itsself.
  1330. $authorizations =$this->_cache->getAZs(
  1331. $agentIdString, // aid
  1332. $functionIdString, // fid
  1333. $qualifierIdString, // qid
  1334. null, // ftype
  1335. false, // returnExplicitOnly
  1336. true, // searchUp
  1337. $isActiveNowOnly, // isActiveNowOnly
  1338. $containingGroups);
  1339. $i = new HarmoniAuthorizationIterator($authorizations);
  1340. return $i;
  1341. }
  1342.  
  1343. /**
  1344. * Given a FunctionType and a qualifierId returns all Authorizations that
  1345. * would allow Agents to do Functions in the FunctionType with the
  1346. * Qualifier. This method differs from getAuthorizations in that this
  1347. * method looks for any Authorization that permits doing the Function with
  1348. * the Qualifier even if the Authorization's Qualifier happens to be a
  1349. * parent of the Qualifier argument.
  1350. *
  1351. * @param object Id $agentId
  1352. * @param object Type $functionType
  1353. * @param object Id $qualifierId
  1354. * @param boolean $isActiveNowOnly
  1355. *
  1356. * @return object AuthorizationIterator
  1357. *
  1358. * @throws object AuthorizationException An exception with
  1359. * one of the following messages defined in
  1360. * org.osid.authorization.AuthorizationException may be thrown:
  1361. * {@link }
  1362. * org.osid.authorization.AuthorizationException#OPERATION_FAILED
  1363. * OPERATION_FAILED}, {@link }
  1364. * org.osid.authorization.AuthorizationException#PERMISSION_DENIED
  1365. * PERMISSION_DENIED}, {@link }
  1366. * org.osid.authorization.AuthorizationException#CONFIGURATION_ERROR
  1367. * CONFIGURATION_ERROR}, {@link }
  1368. * org.osid.authorization.AuthorizationException#UNIMPLEMENTED
  1369. * UNIMPLEMENTED}, {@link }
  1370. * org.osid.authorization.AuthorizationException#NULL_ARGUMENT
  1371. * NULL_ARGUMENT}, {@link }
  1372. * org.osid.authorization.AuthorizationException#UNKNOWN_ID
  1373. * UNKNOWN_ID}, {@link }
  1374. * org.osid.authorization.AuthorizationException#UNKNOWN_TYPE
  1375. * UNKNOWN_TYPE}
  1376. *
  1377. * @access public
  1378. */
  1379. function getAllAZsByFuncType ( $agentId, $functionType, $qualifierId, $isActiveNowOnly ) {
  1380. // ** parameter validation
  1381. ArgumentValidator::validate($agentId, ExtendsValidatorRule::getRule("Id"), true);
  1382. ArgumentValidator::validate($functionType, ExtendsValidatorRule::getRule("Type"), true);
  1383. ArgumentValidator::validate($qualifierId, ExtendsValidatorRule::getRule("Id"), true);
  1384. ArgumentValidator::validate($isActiveNowOnly, BooleanValidatorRule::getRule(), true);
  1385. // ** end of parameter validation
  1386. $authorizations =$this->_cache->getAZs(
  1387. $agentId->getIdString(), // aid
  1388. null, // fid
  1389. $qualifierId->getIdString(), // qid
  1390. $functionType, // ftype
  1391. false, // returnExplicitOnly
  1392. true, // searchUp
  1393. $isActiveNowOnly, // isActiveNowOnly
  1394. $this->_getContainingGroupIdStrings($agentId));
  1395. $i = new HarmoniAuthorizationIterator($authorizations);
  1396. return $i;
  1397. }
  1398. /**
  1399. * Given an implicit returns the matching explicit user Authorizations.
  1400. * Explicit Authorizations can be modified. A null argument will be
  1401. * treated as a wildcard.
  1402. *
  1403. * @param object Authorization $implicitAuthorization
  1404. *
  1405. * @return object AuthorizationIterator
  1406. *
  1407. * @throws object AuthorizationException An exception with
  1408. * one of the following messages defined in
  1409. * org.osid.authorization.AuthorizationException may be thrown:
  1410. * {@link }
  1411. * org.osid.authorization.AuthorizationException#OPERATION_FAILED
  1412. * OPERATION_FAILED}, {@link }
  1413. * org.osid.authorization.AuthorizationException#PERMISSION_DENIED
  1414. * PERMISSION_DENIED}, {@link }
  1415. * org.osid.authorization.AuthorizationException#CONFIGURATION_ERROR
  1416. * CONFIGURATION_ERROR}, {@link }
  1417. * org.osid.authorization.AuthorizationException#UNIMPLEMENTED
  1418. * UNIMPLEMENTED}, {@link }
  1419. * org.osid.authorization.AuthorizationException#NULL_ARGUMENT
  1420. * NULL_ARGUMENT}, {@link }
  1421. * org.osid.authorization.AuthorizationException#UNKNOWN_ID
  1422. * UNKNOWN_ID}, {@link }
  1423. * org.osid.authorization.AuthorizationException#UNKNOWN_TYPE
  1424. * UNKNOWN_TYPE}
  1425. *
  1426. * @access public
  1427. */
  1428. function getExplicitUserAZsForImplicitAZ ($implicitAuthorization ) {
  1429. // ** parameter validation
  1430. ArgumentValidator::validate($implicitAuthorization, ExtendsValidatorRule::getRule("Authorization"), true);
  1431. // ** end of parameter validation
  1432. if ($implicitAuthorization->isExplicit()) {
  1433. // "The Authorization must be implicit."
  1434. throwError(new Error(AuthorizationExeption::OPERATION_FAILED(), "AuthorizationManager", true));
  1435. }
  1436. $agentId =$implicitAuthorization->getAgentId();
  1437. $function =$implicitAuthorization->getFunction();
  1438. $functionId =$function->getId();
  1439. $qualifier =$implicitAuthorization->getQualifier();
  1440. $qualifierId =$qualifier->getId();
  1441. $authorizations =$this->_cache->getAZs(
  1442. $agentId->getIdString(), // aid
  1443. $functionId->getIdString(), // fid
  1444. $qualifierId->getIdString(), // qid
  1445. null, // ftype
  1446. true, // returnExplicitOnly
  1447. true, // searchUp
  1448. $implicitAuthorization->isActiveNow(),
  1449. $this->_getContainingGroupIdStrings($agentId)); // isActiveNow
  1450. // Make sure that we are only returning explicit AZs for implicit
  1451. // AZs, not other explicit AZs at this node. This means, only return
  1452. // AZs where the agentId or the qualifier Id are different from those
  1453. // of the implicit AZ
  1454. $explicitForImplicit = array();
  1455. foreach(array_keys($authorizations) as $key) {
  1456. $az =$authorizations[$key];
  1457. $aId =$az->getAgentId();
  1458. $q =$az->getQualifier();
  1459. $qId =$q->getId();
  1460. if ($agentId->isEqual($aId) && $qualifierId->isEqual($qId))
  1461. continue;
  1462. else
  1463. $explicitForImplicit[] =$az;
  1464. }
  1465. $i = new HarmoniAuthorizationIterator($explicitForImplicit);
  1466. return $i;
  1467. }
  1468. /**
  1469. * Returns the Qualifier Hierarchies supported by the Authorization
  1470. * implementation. Qualifier Hierarchies are referenced by Id and may be
  1471. * known and managed through the Hierarchy OSID.
  1472. *
  1473. * @return object IdIterator
  1474. *
  1475. * @throws object AuthorizationException An exception with
  1476. * one of the following messages defined in
  1477. * org.osid.authorization.AuthorizationException may be thrown:
  1478. * {@link }
  1479. * org.osid.authorization.AuthorizationException#OPERATION_FAILED
  1480. * OPERATION_FAILED}, {@link }
  1481. * org.osid.authorization.AuthorizationException#PERMISSION_DENIED
  1482. * PERMISSION_DENIED}, {@link }
  1483. * org.osid.authorization.AuthorizationException#CONFIGURATION_ERROR
  1484. * CONFIGURATION_ERROR}, {@link }
  1485. * org.osid.authorization.AuthorizationException#UNIMPLEMENTED
  1486. * UNIMPLEMENTED}
  1487. *
  1488. * @access public
  1489. */
  1490. function getQualifierHierarchies () {
  1491. $hierarchyManager = Services::getService("Hierarchy");
  1492. $hierarchies =$hierarchyManager->getHierarchies();
  1493. $array = array();
  1494. while ($hierarchies->hasNext()) {
  1495. $hierarchy =$hierarchies->next();
  1496. $array[] =$hierarchy->getId();
  1497. }
  1498. $i = new HarmoniIterator($array);
  1499. return $i;
  1500. }
  1501. /**
  1502. * This method indicates whether this implementation supports
  1503. * AuthorizationManager methods: createFunction, deleteFunction. Function
  1504. * methods: updateDescription, updateDisplayName.
  1505. *
  1506. * @return boolean
  1507. *
  1508. * @throws object AuthorizationException An exception with
  1509. * one of the following messages defined in
  1510. * org.osid.authorization.AuthorizationException may be thrown:
  1511. * {@link }
  1512. * org.osid.authorization.AuthorizationException#OPERATION_FAILED
  1513. * OPERATION_FAILED}, {@link }
  1514. * org.osid.authorization.AuthorizationException#PERMISSION_DENIED
  1515. * PERMISSION_DENIED}, {@link }
  1516. * org.osid.authorization.AuthorizationException#CONFIGURATION_ERROR
  1517. * CONFIGURATION_ERROR}, {@link }
  1518. * org.osid.authorization.AuthorizationException#UNIMPLEMENTED
  1519. * UNIMPLEMENTED}
  1520. *
  1521. * @access public
  1522. */
  1523. function supportsDesign () {
  1524. return TRUE;
  1525. }
  1526.  
  1527. /**
  1528. * This method indicates whether this implementation supports
  1529. * AuthorizationManager methods: createAuthorization,
  1530. * createDatedAuthorization, createQualifier, createRootQualifier,
  1531. * deleteAuthorization, deleteQualifier, getFunctionTypes, getQualifier,
  1532. * getQualifierChildren, getQualifierDescendents, getQualifierHierarchies,
  1533. * getQualifierTypes, getRootQualifiers, getWhoCanDo. Function methods:
  1534. * getDescription, getDisplayName, getFunctionType, getId,
  1535. * getQualifierHierarchy. Qualifier methods: addParent, changeParent,
  1536. * getChildren, getDescription, getDisplayName, isParent, getId,
  1537. * getParents, getQualifierType, isChildOf, isDescendentOf, removeParent,
  1538. * updateDescription, updateDisplayName.
  1539. *
  1540. * @return boolean
  1541. *
  1542. * @throws object AuthorizationException An exception with
  1543. * one of the following messages defined in
  1544. * org.osid.authorization.AuthorizationException may be thrown:
  1545. * {@link }
  1546. * org.osid.authorization.AuthorizationException#OPERATION_FAILED
  1547. * OPERATION_FAILED}, {@link }
  1548. * org.osid.authorization.AuthorizationException#PERMISSION_DENIED
  1549. * PERMISSION_DENIED}, {@link }
  1550. * org.osid.authorization.AuthorizationException#CONFIGURATION_ERROR
  1551. * CONFIGURATION_ERROR}, {@link }
  1552. * org.osid.authorization.AuthorizationException#UNIMPLEMENTED
  1553. * UNIMPLEMENTED}
  1554. *
  1555. * @access public
  1556. */
  1557. function supportsMaintenance () {
  1558. return TRUE;
  1559. }
  1560. /**
  1561. * Get an array of the string Ids of the groups that contain the particular
  1562. * Id.
  1563. *
  1564. * @param object Id $agentOrGroupId
  1565. * @return array
  1566. * @access private
  1567. * @since 11/29/04
  1568. */
  1569. function _getContainingGroupIdStrings ( $agentOrGroupId ) {
  1570. $agentOrGroupIdString = $agentOrGroupId->getIdString();
  1571. // Check our cache first and only do the search if we don't have
  1572. // the ancestors yet.
  1573. if (!isset($this->_groupAncestorsCache[$agentOrGroupIdString])
  1574. || !is_array($this->_groupAncestorsCache[$agentOrGroupIdString]))
  1575. {
  1576. $groupIds = array();
  1577. $agentManager = Services::getService("Agent");
  1578. $ancestorSearchType = new HarmoniType("Agent & Group Search",
  1579. "edu.middlebury.harmoni","AncestorGroups");
  1580. $containingGroups =$agentManager->getGroupsBySearch(
  1581. $agentOrGroupId, $ancestorSearchType);
  1582. while ($containingGroups->hasNext()) {
  1583. $group =$containingGroups->next();
  1584. $groupId =$group->getId();
  1585. $groupIds[] = $groupId->getIdString();
  1586. }
  1587. $this->_groupAncestorsCache[$agentOrGroupIdString] = $groupIds;
  1588. }
  1589. return $this->_groupAncestorsCache[$agentOrGroupIdString];
  1590. }
  1591.  
  1592. /**
  1593. * Get the Ids of the current user. The user may be authenticated in multiple
  1594. * ways which each have a different Id.
  1595. *
  1596. * @return array
  1597. * @access private
  1598. * @since 3/16/05
  1599. */
  1600. function _getUserIds () {
  1601. $authentication = Services::getService("AuthN");
  1602. $authNTypes =$authentication->getAuthenticationTypes();
  1603. $ids = array();
  1604. $isAuthenticated = FALSE;
  1605. while ($authNTypes->hasNext()) {
  1606. $authNType =$authNTypes->next();
  1607. if ($authentication->isUserAuthenticated($authNType)) {
  1608. $ids[] =$authentication->getUserId($authNType);
  1609. $isAuthenticated = TRUE;
  1610. }
  1611. }
  1612. // Otherwise return the "anonymous user"
  1613. if (!$isAuthenticated) {
  1614. $idManager = Services::getService("Id");
  1615. $ids[] =$idManager->getId("edu.middlebury.agents.anonymous");
  1616. }
  1617. return $ids;
  1618. }
  1619. }
  1620.  
  1621.  
  1622. ?>

Documentation generated on Wed, 19 Sep 2007 10:23:50 -0400 by phpDocumentor 1.3.0RC3