Source for file clear_authorizations.act.php

Documentation is available at clear_authorizations.act.php

  1. <?php
  2.  
  3. /**
  4. *
  5. * @package polyphony.agents
  6. *
  7. * @copyright Copyright &copy; 2005, Middlebury College
  8. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  9. *
  10. * @version $Id: clear_authorizations.act.php,v 1.3 2007/09/19 14:04:53 adamfranco Exp $
  11. */
  12.  
  13. require_once(HARMONI."/GUIManager/Layouts/YLayout.class.php");
  14. require_once(HARMONI."/GUIManager/Components/Heading.class.php");
  15.  
  16. require_once(POLYPHONY."/main/library/AbstractActions/MainWindowAction.class.php");
  17.  
  18.  
  19. /**
  20. * This action clears all authorizations for the passed user(s).
  21. *
  22. * @since 11/10/04
  23. *
  24. * @package polyphony.agents
  25. *
  26. * @copyright Copyright &copy; 2005, Middlebury College
  27. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  28. *
  29. * @version $Id: clear_authorizations.act.php,v 1.3 2007/09/19 14:04:53 adamfranco Exp $
  30. */
  31. class clear_authorizationsAction
  32. extends MainWindowAction
  33. {
  34. /**
  35. * Check Authorizations
  36. *
  37. * @return boolean
  38. * @access public
  39. * @since 4/26/05
  40. */
  41. function isAuthorizedToExecute () {
  42. // Check for authorization
  43. $authZManager = Services::getService("AuthZ");
  44. $idManager = Services::getService("IdManager");
  45. return $authZManager->isUserAuthorized(
  46. $idManager->getId("edu.middlebury.authorization.modify_authorizations"),
  47. $idManager->getId("edu.middlebury.authorization.root"));
  48. }
  49.  
  50. /**
  51. * Return the heading text for this action, or an empty string.
  52. *
  53. * @return string
  54. * @access public
  55. * @since 4/26/05
  56. */
  57. function getHeadingText () {
  58. return dgettext("polyphony", "Clear Authorizations");
  59. }
  60.  
  61. /**
  62. * Build the content for this action
  63. *
  64. * @return void
  65. * @access public
  66. * @since 4/26/05
  67. */
  68. function buildContent () {
  69. $harmoni = Harmoni::instance();
  70. $harmoni->request->startNamespace("polyphony-authorizations");
  71. // Our
  72. $actionRows =$this->getActionRows();
  73. // pass our search variables through to new URLs
  74. $harmoni->request->passthrough("agents");
  75.  
  76. if (!$harmoni->request->get("agents")) $harmoni->history->goBack("polyphony/agents/clear_authorizations");
  77. $agents = unserialize($harmoni->request->get("agents"));
  78. if (count($agents) == 0) $harmoni->history->goBack("polyphony/agents/clear_authorizations");
  79. // now, if we have a confirm, go ahead and delete the agents and get back to where we came from
  80. if ($harmoni->request->get("confirm")) {
  81. $authZ = Services::getService("AuthZ");
  82. $idManager = Services::getService("Id");
  83. // clear all authorizations for the users selected
  84. foreach ($agents as $agentIdString) {
  85. $authorizations =$authZ->getAllExplicitAZsForAgent($idManager->getId($agentIdString), false);
  86. while($authorizations->hasNext()) {
  87. $authorization =$authorizations->next();
  88. $authZ->deleteAuthorization($authorization);
  89. }
  90. }
  91. // and done
  92. $harmoni->history->goBack("polyphony/agents/clear_authorizations");
  93. exit(0);
  94. }
  95.  
  96. ob_start();
  97. $confirmUrl =$harmoni->request->mkURL();
  98. $confirmUrl->setValue("confirm","1");
  99. if (count($agents) == 1) {
  100. $string = _("Are you sure you wish to clear all authorizations for the agent selected?");
  101. } else {
  102. $string = sprintf(_("Are you sure you wish to clear all authorizations for the %s agents selected?"), count($agents));
  103. }
  104. print $string;
  105.  
  106. print "\n<div align='right'><a href='".$harmoni->history->getReturnURL("polyphony/authorizations/clear_authorizations")."'>&lt;&lt; "._("Go Back")."</a>\n<a href='".$confirmUrl->write()."'>Confirm &gt;&gt;</a></div>\n";
  107.  
  108. $actionRows->add(new Block(ob_get_contents(), 4));
  109. ob_end_clean();
  110.  
  111.  
  112. $harmoni->request->endNamespace();
  113.  
  114. /*********************************************************
  115. * Return the main layout.
  116. *********************************************************/
  117. return $actionRows;
  118. }
  119.  
  120.  
  121. }

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