Source for file group_browse.act.php

Documentation is available at group_browse.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: group_browse.act.php,v 1.10 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: group_browse.act.php,v 1.10 2007/09/19 14:04:52 adamfranco Exp $
  26. */
  27. class group_browseAction
  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. if ($authZManager->isUserAuthorized(
  42. $idManager->getId("edu.middlebury.authorization.view"),
  43. $idManager->getId("edu.middlebury.authorization.root")))
  44. {
  45. return TRUE;
  46. } else {
  47. return FALSE;
  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", "Browse Agents and Groups");
  59. }
  60. /**
  61. * Build the content for this action
  62. *
  63. * @return void
  64. * @access public
  65. * @since 4/26/05
  66. */
  67. function buildContent () {
  68. $defaultTextDomain = textdomain("polyphony");
  69. $actionRows =$this->getActionRows();
  70. $pageRows = new Container(new YLayout(), OTHER, 1);
  71. $harmoni = Harmoni::instance();
  72. $harmoni->request->startNamespace("polyphony-agents");
  73.  
  74. $agentManager = Services::getService("Agent");
  75. $idManager = Services::getService("Id");
  76. $everyoneId =$idManager->getId("edu.middlebury.agents.everyone");
  77. $usersId =$idManager->getId("edu.middlebury.agents.users");
  78. /*********************************************************
  79. * the agent search form
  80. *********************************************************/
  81. // Users header
  82. $actionRows->add(new Heading(_("Users"), 2), "100%", null, LEFT, CENTER);
  83. ob_start();
  84. $self = $harmoni->request->quickURL();
  85. $lastCriteria = $harmoni->request->get("search_criteria");
  86. $search_criteria_name = RequestContext::name("search_criteria");
  87. $search_type_name = RequestContext::name("search_type");
  88. print _("Search For Users").": ";
  89. print <<<END
  90. <form action='$self' method='post'>
  91. <div>
  92. <input type='text' name='$search_criteria_name' value='$lastCriteria' />
  93. <br /><select name='$search_type_name'>
  94. END;
  95. $searchTypes =$agentManager->getAgentSearchTypes();
  96. while ($searchTypes->hasNext()) {
  97. $type =$searchTypes->next();
  98. $typeString = htmlspecialchars($type->getDomain()
  99. ."::".$type->getAuthority()
  100. ."::".$type->getKeyword());
  101. print "\n\t\t<option value='$typeString'";
  102. if ($harmoni->request->get("search_type") == $typeString)
  103. print " selected='selected'";
  104. print ">$typeString</option>";
  105. }
  106. print "\n\t</select>";
  107. print "\n\t<br /><input type='submit' value='"._("Search")."' />";
  108. print "\n\t<a href='".$harmoni->request->quickURL()."'>";
  109. print "<input type='button' value='"._("Clear")."' /></a>";
  110. print "\n</div>\n</form>";
  111. $actionRows->add(new Block(ob_get_contents(), STANDARD_BLOCK), "100%", null, LEFT, CENTER);
  112. ob_end_clean();
  113. /*********************************************************
  114. * the agent search results
  115. *********************************************************/
  116. ob_start();
  117. if (($search_criteria = $harmoni->request->get('search_criteria')) && ($search_type = $harmoni->request->get('search_type'))) {
  118. $typeParts = explode("::", @html_entity_decode($search_type, ENT_COMPAT, 'UTF-8'));
  119. $searchType = new HarmoniType($typeParts[0], $typeParts[1], $typeParts[2]);
  120. $agents =$agentManager->getAgentsBySearch($search_criteria, $searchType);
  121. print "search: " . $search_criteria;
  122. print <<<END
  123. <table>
  124. <tr>
  125. <td valign='top'>
  126. <div style='
  127. border: 1px solid #000;
  128. width: 15px;
  129. height: 15px;
  130. text-align: center;
  131. text-decoration: none;
  132. font-weight: bold;
  133. '>
  134. -
  135. </div>
  136. </td>
  137. <td>
  138. END;
  139. print "\n\t\t\t"._("Search Results");
  140. print <<<END
  141. </td>
  142. </tr>
  143. </table>
  144. <div style='
  145. margin-left: 13px;
  146. margin-right: 0px;
  147. margin-top:0px;
  148. padding-left: 10px;
  149. border-left: 1px solid #000;
  150. '>
  151. END;
  152. while ($agents->hasNext()) {
  153. $agent =$agents->next();
  154. group_browseAction::printMember($agent);
  155. print "<br />";
  156. }
  157. print "\n</div>";
  158. $pageRows->add(new Block(ob_get_contents(), STANDARD_BLOCK), "100%", null, LEFT, CENTER);
  159. ob_end_clean();
  160. }
  161. /*********************************************************
  162. * Groups
  163. *********************************************************/
  164. $pageRows->add(new Heading(_("Groups"), 2), "100%", null, LEFT, CENTER);
  165.  
  166. // Loop through all of the Root Groups
  167. $childGroupIds = array();
  168. $groups =$agentManager->getGroupsBySearch($null = null, new Type("Agent & Group Search", "edu.middlebury.harmoni", "RootGroups"));
  169.  
  170. while ($groups->hasNext()) {
  171. $group =$groups->next();
  172. $groupId =$group->getId();
  173. // Create a layout for this group using the GroupPrinter
  174. ob_start();
  175. GroupPrinter::printGroup($group, $harmoni,
  176. 2,
  177. "group_browseAction::printGroup",
  178. "group_browseAction::printMember");
  179. $groupLayout = new Block(ob_get_contents(), STANDARD_BLOCK);
  180. ob_end_clean();
  181. $pageRows->add($groupLayout, "100%", null, LEFT, CENTER);
  182. }
  183. // In order to preserve proper nesting on the HTML output, the checkboxes
  184. // are all in the pagerows layout instead of actionrows.
  185. $actionRows->add($pageRows, null, null,CENTER, CENTER);
  186. textdomain($defaultTextDomain);
  187. }
  188. /*******************************************************
  189. * Functions used for the GroupPrinter
  190. *********************************************************/
  191.  
  192. /**
  193. * Callback function for printing a group
  194. *
  195. * @param object Group $group
  196. * @return void
  197. * @access public
  198. * @ignore
  199. */
  200. function printGroup($group) {
  201. $idManager = Services::getService("Id");
  202. $everyoneId =$idManager->getId("edu.middlebury.agents.everyone");
  203. $usersId =$idManager->getId("edu.middlebury.agents.users");
  204. $id =$group->getId();
  205. $groupType =$group->getType();
  206. print "\n&nbsp; &nbsp; &nbsp;";
  207. print "\n<a title='".htmlspecialchars($groupType->getAuthority()." :: ".$groupType->getDomain()." :: ".$groupType->getKeyword()." - ".$groupType->getDescription())."'>";
  208. print "\n<span style='text-decoration: underline; font-weight: bold;'>".htmlspecialchars($group->getDisplayName())."</span></a>";
  209. print "\n - <a href=\"Javascript:alert('"._("Id:").'\n\t'.addslashes($id->getIdString())."')\">"._("Show Id")."</a>";
  210. print "\n - <em>".htmlspecialchars($group->getDescription())."</em>";
  211. // print out the properties of the Agent
  212. print "\n<em>";
  213. $propertiesIterator =$group->getProperties();
  214. while($propertiesIterator->hasNext()) {
  215. $properties =$propertiesIterator->next();
  216. $propertiesType =$properties->getType();
  217. print "\n\t(<a title='".htmlspecialchars($propertiesType->getDomain()." :: ".$propertiesType->getAuthority()." :: ".$propertiesType->getKeyword()." - ".$propertiesType->getDescription())."'>";
  218. $keys =$properties->getKeys();
  219. $i = 0;
  220. while ($keys->hasNext()) {
  221. $key =$keys->next();
  222. print htmlspecialchars("\n\t\t".(($i)?", ":"").$key.": ".$properties->getProperty($key));
  223. $i++;
  224. }
  225. print "\n\t</a>)";
  226. }
  227. print "\n</em>";
  228. }
  229. /**
  230. * Callback function for printing an agent
  231. *
  232. * @param object Agent $member
  233. * @return void
  234. * @access public
  235. * @ignore
  236. */
  237. function printMember($member) {
  238. $harmoni = Harmoni::instance();
  239. $id =$member->getId();
  240. $memberType =$member->getType();
  241. $harmoni->history->markReturnURL("polyphony/agents/edit_agent_details");
  242. 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())."'>";
  243. print "\n<span style='text-decoration: none;'>".htmlspecialchars($member->getDisplayName())."</span></a>";
  244. print "\n - <a href=\"Javascript:alert('"._("Id:").'\n\t'.addslashes($id->getIdString())."')\">"._("Show Id")."</a>";
  245. // print out the properties of the Agent
  246. print "\n<em>";
  247. $propertiesIterator = NULL;
  248. $propertiesIterator =$member->getProperties();
  249. while($propertiesIterator->hasNext()) {
  250. $properties = NULL;
  251. $properties =$propertiesIterator->next();
  252. $propertiesType =$properties->getType();
  253. print "\n\t(<a style='text-decoration: none; font-weight: normal;' title='".htmlspecialchars($propertiesType->getDomain()." :: ".$propertiesType->getAuthority()." :: ".$propertiesType->getKeyword()." - ".$propertiesType->getDescription())."'>";
  254. $keys =$properties->getKeys();
  255. $i = 0;
  256. while ($keys->hasNext()) {
  257. $key =$keys->next();
  258. print htmlspecialchars("\n\t\t".(($i)?", ":"").$key.": ".$properties->getProperty($key));
  259. $i++;
  260. }
  261. print "\n\t</a>)";
  262. }
  263. print "\n</em>";
  264. }
  265. }

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