Source for file edit_agents.act.php

Documentation is available at edit_agents.act.php

  1. <?php
  2.  
  3. /**
  4. * @package polyphony.agents
  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: edit_agents.act.php,v 1.4 2007/09/19 14:04:52 adamfranco Exp $
  10. */
  11.  
  12. require_once(POLYPHONY."/main/library/AbstractActions/MainWindowAction.class.php");
  13. require_once(HARMONI."GUIManager/Components/Blank.class.php");
  14.  
  15. /**
  16. * This action will allow for the modification of group Membership.
  17. *
  18. * @since 11/10/04
  19. *
  20. * @package polyphony.agents
  21. *
  22. * @copyright Copyright &copy; 2005, Middlebury College
  23. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  24. *
  25. * @version $Id: edit_agents.act.php,v 1.4 2007/09/19 14:04:52 adamfranco Exp $
  26. */
  27. class edit_agentsAction
  28. extends MainWindowAction
  29. {
  30. /**
  31. * Check Authorizations
  32. *
  33. * @return boolean
  34. * @access public
  35. * @since 4/26/05
  36. */
  37. function isAuthorizedToExecute () {
  38. // Check for authorization
  39. $authZManager = Services::getService("AuthZ");
  40. $idManager = Services::getService("IdManager");
  41. return $authZManager->isUserAuthorized(
  42. $idManager->getId("edu.middlebury.authorization.view"),
  43. $idManager->getId("edu.middlebury.authorization.root"));
  44. }
  45.  
  46.  
  47. /**
  48. * Return the "unauthorized" string to pring
  49. *
  50. * @return string
  51. * @access public
  52. * @since 4/26/05
  53. */
  54. function getUnauthorizedMessage () {
  55. return _("You are not authorized to browse agents.");
  56. }
  57.  
  58. /**
  59. * Build the content for this action
  60. *
  61. * @return void
  62. * @access public
  63. * @since 4/26/05
  64. */
  65. function buildContent () {
  66. $harmoni = Harmoni::instance();
  67.  
  68. $centerPane =$this->getActionRows();
  69. $cacheName = 'edit_agents_wizard';
  70.  
  71. // now, once we've run the content, we need to check if an action was chosen from the browser
  72. $wizard =$this->getWizard($cacheName);
  73.  
  74. if ($harmoni->request->get("reset")) {
  75. // get the agent browser component and reset it.
  76. $steps =$wizard->getChild("_steps");
  77. $step =$steps->getStep("namedescstep");
  78. $component =$step->getChild("agents");
  79. $component->reset();
  80. }
  81.  
  82. $this->runWizard ( $cacheName, $centerPane );
  83.  
  84. $wizard =$this->getWizard($cacheName);
  85. $values = $wizard->getAllValues();
  86. $browser =$values["namedescstep"]["agents"];
  87. if ($browser[0] != 'nop') {
  88. $selected = $browser[1];
  89. $param = serialize($selected);
  90. switch ($browser[0]) {
  91. case 'edit_properties':
  92. $url =$harmoni->request->mkURL("agents", "edit_properties");
  93. $harmoni->request->startNamespace("polyphony-agents");
  94. $url->setValue("agents", $param);
  95. $url->setValue("mult", "1");
  96. $harmoni->request->endNamespace();
  97. $harmoni->history->markReturnURL("polyphony/agents/edit_properties");
  98. $url->redirectBrowser();
  99. exit(0);
  100. break;
  101. case 'edit_authorizations':
  102. $harmoni->request->startNamespace("polyphony-authorizations");
  103. $url =$harmoni->request->mkURL("authorization", "edit_authorizations");
  104. $url->setValue("agents", $param);
  105. $url->setValue("mult", "1");
  106. $harmoni->history->markReturnURL("polyphony/authorization/edit_authorizations");
  107. $harmoni->request->endNamespace();
  108. $url->redirectBrowser();
  109. exit(0);
  110. break;
  111. case 'revoke_authorizations':
  112. $harmoni->request->startNamespace("polyphony-authorizations");
  113. $url =$harmoni->request->mkURL("authorization", "clear_authorizations");
  114. $url->setValue("agents", $param);
  115. $harmoni->history->markReturnURL("polyphony/agents/clear_authorizations");
  116. $harmoni->request->endNamespace();
  117. $url->redirectBrowser();
  118. exit(0);
  119. break;
  120. case 'create_group':
  121. $url =$harmoni->request->mkURL("agents", "add_group");
  122. $url->setValue("agents", $param);
  123. $harmoni->history->markReturnURL("polyphony/agents/add_group");
  124. $url->redirectBrowser();
  125. exit(0);
  126. break;
  127. case 'delete':
  128. $url =$harmoni->request->mkURL("agents", "delete");
  129. $url->setValue("agents", $param);
  130. $return =$harmoni->request->mkURL();
  131. $return->setValue("reset", "1");
  132. $harmoni->history->markReturnURL("polyphony/agents/delete", $return);
  133. $url->redirectBrowser();
  134. exit(0);
  135. break;
  136. }
  137. }
  138. }
  139.  
  140. /**
  141. * Return the heading text for this action, or an empty string.
  142. *
  143. * @return string
  144. * @access public
  145. * @since 4/26/05
  146. */
  147. function getHeadingText () {
  148. return _("Browse Agents");
  149. }
  150.  
  151. /**
  152. * Create a new Wizard for this action. Caching of this Wizard is handled by
  153. * {@link getWizard()} and does not need to be implemented here.
  154. *
  155. * @return object Wizard
  156. * @access public
  157. * @since 4/28/05
  158. */
  159. function createWizard () {
  160.  
  161. // Instantiate the wizard, then add our steps.
  162. $wizard = SimpleStepWizard::withDefaultLayout();
  163.  
  164. // :: Name and Description ::
  165. $step =$wizard->addStep("namedescstep", new WizardStep());
  166. $step->setDisplayName(_("Name &amp; Description"));
  167.  
  168. $browser =$step->addComponent("agents", new WAgentBrowser());
  169. $browser->addActionOption("edit_properties", _("Edit Properties"));
  170. $browser->addActionOption("edit_authorizations", _("Edit Authorizations"));
  171. $browser->addActionOption("revoke_authorizations", _("Clear All Authorizations"));
  172. $browser->addActionOption("create_group", _("Create Group..."));
  173. $browser->addActionOption("delete", _("Delete"));
  174. $step->setContent("[[agents]]");
  175. return $wizard;
  176.  
  177.  
  178. }
  179.  
  180. /**
  181. * Save our results. Tearing down and unsetting the Wizard is handled by
  182. * in {@link runWizard()} and does not need to be implemented here.
  183. *
  184. * @param string $cacheName
  185. * @return boolean TRUE if save was successful and tear-down/cleanup of the
  186. * Wizard should ensue.
  187. * @access public
  188. * @since 4/28/05
  189. */
  190. function saveWizard ( $cacheName ) {
  191. $wizard =$this->getWizard($cacheName);
  192.  
  193. if (!$wizard->validate()) return false;
  194.  
  195. // Make sure we have a valid Repository
  196. $idManager = Services::getService("Id");
  197.  
  198. $properties =$wizard->getAllValues();
  199.  
  200. }
  201.  
  202. /**
  203. * Return the URL that this action should return to when completed.
  204. *
  205. * @return string
  206. * @access public
  207. * @since 4/28/05
  208. */
  209. function getReturnUrl () {
  210. $harmoni = Harmoni::instance();
  211. return $harmoni->request->quickURL("admin", "main");
  212. }
  213.  
  214.  
  215. /*******************************************************
  216. * Functions used for the GroupPrinter
  217. *********************************************************/
  218.  
  219.  
  220. /**
  221. * Callback function for printing a group
  222. *
  223. * @param object Group $group
  224. * @return void
  225. * @access public
  226. * @ignore
  227. */
  228. function printGroup($group) {
  229. $idManager = Services::getService("Id");
  230. $everyoneId =$idManager->getId("edu.middlebury.agents.everyone");
  231. $usersId =$idManager->getId("edu.middlebury.agents.users");
  232.  
  233. $id =$group->getId();
  234. $groupType =$group->getType();
  235.  
  236. print "\n&nbsp; &nbsp; &nbsp;";
  237.  
  238. print "\n<a title='".htmlspecialchars($groupType->getAuthority()." :: ".$groupType->getDomain()." :: ".$groupType->getKeyword()." - ".$groupType->getDescription())."'>";
  239. print "\n<span style='text-decoration: underline; font-weight: bold;'>".$id->getIdString()." - ".htmlspecialchars($group->getDisplayName())."</span></a>";
  240.  
  241.  
  242. print "\n - <em>".htmlspecialchars($group->getDescription())."</em>";
  243.  
  244. // print out the properties of the Agent
  245. print "\n<em>";
  246. $propertiesIterator =$group->getProperties();
  247.  
  248. while($propertiesIterator->hasNext()) {
  249. $properties =$propertiesIterator->next();
  250. $propertiesType =$properties->getType();
  251. print "\n\t(<a title='".htmlspecialchars($propertiesType->getDomain()." :: ".$propertiesType->getAuthority()." :: ".$propertiesType->getKeyword()." - ".$propertiesType->getDescription())."'>";
  252.  
  253. $keys =$properties->getKeys();
  254. $i = 0;
  255.  
  256. while ($keys->hasNext()) {
  257. $key =$keys->next();
  258. print htmlspecialchars("\n\t\t".(($i)?", ":"").$key.": ".$properties->getProperty($key));
  259. $i++;
  260. }
  261.  
  262. print "\n\t</a>)";
  263. }
  264. print "\n</em>";
  265. }
  266.  
  267. /**
  268. * Callback function for printing an agent
  269. *
  270. * @param object Agent $member
  271. * @return void
  272. * @access public
  273. * @ignore
  274. */
  275. function printMember($member) {
  276. $harmoni = Harmoni::instance();
  277. $id =$member->getId();
  278.  
  279. $memberType =$member->getType();
  280. $harmoni->history->markReturnURL("polyphony/agents/edit_agent_details");
  281.  
  282. print "\n<a href='".$harmoni->request->quickURL("agents","edit_agent_details", array("agentId"=>$id->getIdString()))."' title='".htmlspecialchars($memberType->getDomain()." :: ".$memberType->getAuthority()." :: ".$memberType->getKeyword()." - ".$memberType->getDescription())."'>";
  283. print "\n<span style='text-decoration: none;'>".$id->getIdString()." - ".htmlspecialchars($member->getDisplayName())."</span></a>";
  284.  
  285. // print out the properties of the Agent
  286. print "\n<em>";
  287. $propertiesIterator = NULL;
  288. $propertiesIterator =$member->getProperties();
  289. while($propertiesIterator->hasNext()) {
  290. $properties = NULL;
  291. $properties =$propertiesIterator->next();
  292.  
  293. $propertiesType =$properties->getType();
  294. print "\n\t(<a title='".htmlspecialchars($propertiesType->getDomain()." :: ".$propertiesType->getAuthority()." :: ".$propertiesType->getKeyword()." - ".$propertiesType->getDescription())."'>";
  295.  
  296. $keys =$properties->getKeys();
  297. $i = 0;
  298. while ($keys->hasNext()) {
  299. $key =$keys->next();
  300. print htmlspecialchars("\n\t\t".(($i)?", ":"").$key.": ".$properties->getProperty($key));
  301. $i++;
  302. }
  303.  
  304. print "\n\t</a>)";
  305. }
  306. print "\n</em>";
  307. }
  308. }

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