Source for file getWhoCanDo.act.php

Documentation is available at getWhoCanDo.act.php

  1. <?php
  2. /**
  3. * @since 11/29/06
  4. * @package polyphony.authorization
  5. *
  6. * @copyright Copyright &copy; 2005, Middlebury College
  7. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  8. *
  9. * @version $Id: getWhoCanDo.act.php,v 1.5 2007/09/19 14:04:53 adamfranco Exp $
  10. */
  11.  
  12. require_once(dirname(__FILE__).'/AuthZXmlAction.class.php');
  13.  
  14. /**
  15. * Answer who has authorization to view a given qualifier
  16. *
  17. * @since 11/29/06
  18. * @package polyphony.authorization
  19. *
  20. * @copyright Copyright &copy; 2005, Middlebury College
  21. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  22. *
  23. * @version $Id: getWhoCanDo.act.php,v 1.5 2007/09/19 14:04:53 adamfranco Exp $
  24. */
  25. class getWhoCanDoAction
  26. extends AuthZXmlAction
  27. {
  28. /**
  29. * Check Authorizations
  30. *
  31. * @return boolean
  32. * @access public
  33. * @since 4/26/05
  34. */
  35. function isAuthorizedToExecute () {
  36. // Check that the user can access this collection
  37. $authZ = Services::getService("AuthZ");
  38.  
  39. $idManager = Services::getService("Id");
  40. if (!$this->getQualifierId())
  41. return false;
  42. return $authZ->isUserAuthorized(
  43. $idManager->getId("edu.middlebury.authorization.view_authorizations"),
  44. $this->getQualifierId());
  45. }
  46. /**
  47. * Execute the action
  48. *
  49. * @return void
  50. * @access public
  51. * @since 11/29/06
  52. */
  53. function buildContent () {
  54. $authZ = Services::getService("AuthZ");
  55. $agentMan = Services::getService("Agent");
  56. $agentIds =$authZ->getWhoCanDo($this->getFunctionId(), $this->getQualifierId());
  57. $this->start();
  58. while ($agentIds->hasNext()) {
  59. $agentId =$agentIds->next();
  60. if ($agent =$agentMan->getAgentOrGroup($agentId)) {
  61. print "\n\t<agent id=\"".$agentId->getIdString()."\"";
  62. print " displayName=\"".$agent->getDisplayName()."\"";
  63. print " agentOrGroup=\"".((method_exists($agent, 'getMembers'))?"group":"agent")."\"";
  64. print ">";
  65. // Get the AZs for the agent
  66. $azs =$authZ->getAllAZs($agentId, $null = null, $this->getQualifierId(), true);
  67. while ($azs->hasNext()) {
  68. $az =$azs->next();
  69. print "\n\t\t<authorization>";
  70. $function =$az->getFunction();
  71. $functionId =$function->getId();
  72. print "\n\t\t\t<function id=\"".$functionId->getIdString()."\" ";
  73. print "referenceName=\"".$function->getReferenceName()."\">";
  74. print "\n\t\t\t\t<description>".$function->getDescription()."</description>";
  75. $functionType =$function->getFunctionType();
  76. print "\n\t\t\t\t<type>";
  77. print "\n\t\t\t\t\t<domain>".$functionType->getDomain()."</domain>";
  78. print "\n\t\t\t\t\t<authority>".$functionType->getAuthority()."</authority>";
  79. print "\n\t\t\t\t\t<keyword>".$functionType->getKeyword()."</keyword>";
  80. print "\n\t\t\t\t\t<description>".$functionType->getDescription()."</description>";
  81. print "\n\t\t\t\t</type>";
  82. print "\n\t\t\t</function>";
  83. print "\n\t\t</authorization>";
  84. }
  85. print "\n\t</agent>";
  86. }
  87. }
  88. $this->end();
  89. }
  90. }
  91.  
  92. ?>

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