Source for file delete.act.php

Documentation is available at delete.act.php

  1. <?php
  2.  
  3. /**
  4. * group_membership.act.php
  5. * This action will allow for the creation/deletion of groups
  6. * 11/29/04 Ryan Richards, some code from Adam Franco
  7. *
  8. * @package polyphony.agents
  9. *
  10. * @copyright Copyright &copy; 2005, Middlebury College
  11. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  12. *
  13. * @version $Id: delete.act.php,v 1.4 2007/09/19 14:04:52 adamfranco Exp $
  14. */
  15.  
  16. require_once(HARMONI."/GUIManager/Layouts/YLayout.class.php");
  17. require_once(HARMONI."/GUIManager/Components/Heading.class.php");
  18.  
  19. require_once(POLYPHONY."/main/library/AbstractActions/MainWindowAction.class.php");
  20.  
  21.  
  22. /**
  23. * This action will allow for the modification of group Membership.
  24. *
  25. * @since 11/10/04
  26. *
  27. * @package polyphony.agents
  28. *
  29. * @copyright Copyright &copy; 2005, Middlebury College
  30. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  31. *
  32. * @version $Id: delete.act.php,v 1.4 2007/09/19 14:04:52 adamfranco Exp $
  33. */
  34. class deleteAction
  35. extends MainWindowAction
  36. {
  37. /**
  38. * Check Authorizations
  39. *
  40. * @return boolean
  41. * @access public
  42. * @since 4/26/05
  43. */
  44. function isAuthorizedToExecute () {
  45. // Check for authorization
  46. $authZManager = Services::getService("AuthZ");
  47. $idManager = Services::getService("IdManager");
  48. return $authZManager->isUserAuthorized(
  49. $idManager->getId("edu.middlebury.authorization.delete_agent"),
  50. $idManager->getId("edu.middlebury.authorization.root"));
  51. }
  52.  
  53. /**
  54. * Return the heading text for this action, or an empty string.
  55. *
  56. * @return string
  57. * @access public
  58. * @since 4/26/05
  59. */
  60. function getHeadingText () {
  61. return dgettext("polyphony", "Delete Agent(s)");
  62. }
  63.  
  64. /**
  65. * Build the content for this action
  66. *
  67. * @return void
  68. * @access public
  69. * @since 4/26/05
  70. */
  71. function buildContent () {
  72. $harmoni = Harmoni::instance();
  73. // $harmoni->request->startNamespace("polyphony-agents");
  74. // Our
  75. $actionRows =$this->getActionRows();
  76. $agentManager = Services::getService("Agent");
  77.  
  78. // pass our search variables through to new URLs
  79. $harmoni->request->passthrough("agents");
  80.  
  81. if (!$harmoni->request->get("agents")) $harmoni->history->goBack("polyphony/agents/delete");
  82. $agents = unserialize($harmoni->request->get("agents"));
  83. if (count($agents) == 0) $harmoni->history->goBack("polyphony/agents/delete");
  84. // now, if we have a confirm, go ahead and delete the agents and get back to where we came from
  85. if ($harmoni->request->get("confirm")) {
  86. $agentManager = Services::getService("Agent");
  87. $tokenManager = Services::getService("AgentTokenMapping");
  88. $authNMethods = Services::getService("AuthNMethodManager");
  89. $idManager = Services::getService("Id");
  90. foreach ($agents as $idString) {
  91. print "deleting agent $idString... <br/>";
  92. $id =$idManager->getId($idString);
  93. $mappings =$tokenManager->getMappingsForAgentId($id);
  94. while($mappings->hasNext()) {
  95. $mapping =$mappings->next();
  96. print "handling mapping ... <br/>";
  97. $tokens =$mapping->getTokens();
  98. $authNTypes =$authNMethods->getAuthNTypes();
  99. while($authNTypes->hasNext()) {
  100. $authNType =$authNTypes->next();
  101. print "checking type: " . Type::typeToString($authNType) . "<br/>";
  102. $authNMethod =$authNMethods->getAuthNMethodForType($authNType);
  103. if ($authNMethod->supportsTokenDeletion() && $authNMethod->tokensExist($tokens)) {
  104. print "deleting tokens ... <br/>";
  105. $authNMethod->deleteTokens($tokens);
  106. }
  107. }
  108. $tokenManager->deleteMapping($mapping);
  109. }
  110. $agentManager->deleteAgent($id);
  111. }
  112. // and done
  113. $harmoni->history->goBack("polyphony/agents/delete");
  114. exit(0);
  115. }
  116.  
  117. ob_start();
  118. $confirmUrl =$harmoni->request->mkURL();
  119. $confirmUrl->setValue("confirm","1");
  120. if (count($agents) == 1) {
  121. $string = _("Are you sure you wish to delete the agent selected?");
  122. } else {
  123. $string = sprintf(_("Are you sure you wish to delete the %s agents selected?"), count($agents));
  124. }
  125. print $string;
  126.  
  127. print "\n<div align='right'><a href='".$harmoni->history->getReturnURL("polyphony/agents/delete")."'>&lt;&lt; "._("Go Back")."</a>\n<a href='".$confirmUrl->write()."'>Confirm &gt;&gt;</a></div>\n";
  128.  
  129. $actionRows->add(new Block(ob_get_contents(), 4));
  130. ob_end_clean();
  131.  
  132.  
  133. // $harmoni->request->endNamespace();
  134.  
  135. /*********************************************************
  136. * Return the main layout.
  137. *********************************************************/
  138. return $actionRows;
  139. }
  140.  
  141.  
  142. }

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