Source for file add_delete_group.act.php

Documentation is available at add_delete_group.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: add_delete_group.act.php,v 1.15 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: add_delete_group.act.php,v 1.15 2007/09/19 14:04:52 adamfranco Exp $
  33. */
  34. class add_delete_groupAction
  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. if ($authZManager->isUserAuthorized(
  49. $idManager->getId("edu.middlebury.authorization.view"),
  50. $idManager->getId("edu.middlebury.authorization.root")))
  51. {
  52. return TRUE;
  53. } else {
  54.  
  55. return FALSE;
  56. }
  57. }
  58.  
  59. /**
  60. * Return the heading text for this action, or an empty string.
  61. *
  62. * @return string
  63. * @access public
  64. * @since 4/26/05
  65. */
  66. function getHeadingText () {
  67. return dgettext("polyphony", "Add and Delete Groups");
  68. }
  69.  
  70. /**
  71. * Build the content for this action
  72. *
  73. * @return void
  74. * @access public
  75. * @since 4/26/05
  76. */
  77. function buildContent () {
  78. $harmoni = Harmoni::instance();
  79. $harmoni->request->startNamespace("polyphony-agents");
  80. $harmoni->history->markReturnURL("polyphony/agents/delete_group", $harmoni->request->mkURLWithPassthrough());
  81.  
  82. // Our
  83. $actionRows =$this->getActionRows();
  84.  
  85. $agentManager = Services::getService("Agent");
  86.  
  87. // pass our search variables through to new URLs
  88. $harmoni->request->passthrough();
  89.  
  90. /*********************************************************
  91. * Deleting a Group
  92. *********************************************************/
  93.  
  94. // 'Delete a Group' header
  95. /* $deleteHeader = new Heading(_("Delete a Group"), 3);
  96. $actionRows->add($deleteHeader, "100%", null, null, LEFT, CENTER);
  97. */
  98.  
  99. ob_start();
  100. $addURL = $harmoni->request->quickURL("agents","add_group");
  101. $harmoni->history->markReturnURL("polyphony/agents/add_group", $harmoni->request->mkURLWithPassthrough());
  102. print sprintf(_("On this page you may delete existing groups with the interface below, or %s."), "<input type='button' value='"._("Add a New Group")."' onclick='javascript: window.location = \"$addURL\"'/>");
  103. $actionRows->add(new Block(ob_get_contents(), 4));
  104. ob_end_clean();
  105.  
  106. // Loop through all of the Root Groups
  107. $groups =$agentManager->getGroupsBySearch($null = null, new Type("Agent & Group Search", "edu.middlebury.harmoni", "RootGroups"));
  108. while ($groups->hasNext()) {
  109. $group =$groups->next();
  110. $groupId =$group->getId();
  111. // Create a layout for this group using the GroupPrinter
  112. ob_start();
  113.  
  114. GroupPrinter::printGroup($group, $harmoni,
  115. 2,
  116. "add_delete_groupAction::printGroup",
  117. "add_delete_groupAction::printMember");
  118. $groupLayout = new Block(ob_get_contents(), 4);
  119. ob_end_clean();
  120. $actionRows->add($groupLayout, "100%", null, LEFT, CENTER);
  121. }
  122.  
  123. $harmoni->request->endNamespace();
  124.  
  125. /*********************************************************
  126. * Return the main layout.
  127. *********************************************************/
  128. return $actionRows;
  129. }
  130.  
  131.  
  132.  
  133. /*******************************************************
  134. * Functions used for the GroupPrinter
  135. *********************************************************/
  136.  
  137. /**
  138. * Callback function for printing a group
  139. *
  140. * @param object Group $group
  141. * @return void
  142. * @access public
  143. * @ignore
  144. */
  145. function printGroup($group) {
  146. $id =$group->getId();
  147. $groupType =$group->getType();
  148.  
  149. $harmoni = Harmoni::instance();
  150. $toggleURL = $harmoni->request->quickURL("agents","delete_group",
  151. array("groupId"=>$id->getIdString()));
  152.  
  153. print "\n<input type='button' value='"._('delete')."' ";
  154. print " onclick=\"javascript:window.location='".$toggleURL."'\" />";
  155. print "\n<a title='".$groupType->getAuthority()." :: ".$groupType->getDomain()." :: ".$groupType->getKeyword()." - ".$groupType->getDescription()."'>";
  156. print "\n<span style='text-decoration: underline; font-weight: bold;'>".$id->getIdString()." - ".$group->getDisplayName()."</span></a>";
  157. }
  158.  
  159. /**
  160. * Callback function for printing an agent
  161. *
  162. * @param object Agent $member
  163. * @return void
  164. * @access public
  165. * @ignore
  166. */
  167. function printMember($member) {
  168. $id =$member->getId();
  169. $memberType =$member->getType();
  170. print "\n<a title='".$memberType->getDomain()." :: ".$memberType->getAuthority()." :: ".$memberType->getKeyword()." - ".$memberType->getDescription()."'>";
  171. print "\n<span style='text-decoration: underline;'>".$id->getIdString()." - ".$member->getDisplayName()."</span>";
  172.  
  173. // print out the properties of the Agent
  174. print "\n<em>";
  175. $propertiesIterator =$member->getProperties();
  176. while($propertiesIterator->hasNext()) {
  177. $properties =$propertiesIterator->next();
  178. $propertiesType =$properties->getType();
  179. print "\n\t(<a title='".$propertiesType->getDomain()." :: ".$propertiesType->getAuthority()." :: ".$propertiesType->getKeyword()." - ".$propertiesType->getDescription()."'>";
  180.  
  181. $keys =$properties->getKeys();
  182. $i = 0;
  183. while ($keys->hasNext()) {
  184. $key =$keys->next();
  185. print "\n\t\t".(($i)?", ":"").$key.": ".$properties->getProperty($key);
  186. $i++;
  187. }
  188.  
  189. print "\n\t</a>)";
  190. }
  191. print "\n</em>";
  192. }
  193. }

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