Source for file agent_search.act.php

Documentation is available at agent_search.act.php

  1. <?php
  2.  
  3. /**
  4. * @package polyphony.coursemanagement
  5. *
  6. * @copyright Copyright &copy; 2006, Middlebury College
  7. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  8. *
  9. * @version $Id: agent_search.act.php,v 1.5 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. class agent_SearchAction
  17. extends MainWindowAction
  18. {
  19. /**
  20. * Check Authorizations
  21. *
  22. * @return boolean
  23. * @access public
  24. * @since 4/26/05
  25. */
  26. function isAuthorizedToExecute () {
  27. // Check for authorization
  28. $authZManager = Services::getService("AuthZ");
  29. $idManager = Services::getService("IdManager");
  30. if ($authZManager->isUserAuthorized(
  31. $idManager->getId("edu.middlebury.authorization.view"),
  32. $idManager->getId("edu.middlebury.coursemanagement")))
  33. {
  34. return TRUE;
  35. } else {
  36. return FALSE;
  37. }
  38. }
  39. /**
  40. * Return the heading text for this action, or an empty string.
  41. *
  42. * @return string
  43. * @access public
  44. * @since 4/26/05
  45. */
  46. function getHeadingText () {
  47. return dgettext("polyphony", "Browse Agents and Groups");
  48. }
  49. /**
  50. * Build the content for this action
  51. *
  52. * @return void
  53. * @access public
  54. * @since 4/26/05
  55. */
  56. function buildContent () {
  57. $defaultTextDomain = textdomain("polyphony");
  58. $actionRows =$this->getActionRows();
  59. $pageRows = new Container(new YLayout(), OTHER, 1);
  60. $harmoni = Harmoni::instance();
  61. $harmoni->request->startNamespace("polyphony-agents");
  62.  
  63. $agentManager = Services::getService("Agent");
  64. $idManager = Services::getService("Id");
  65. $cm = Services::getService("CourseManagement");
  66. $everyoneId =$idManager->getId("edu.middlebury.agents.everyone");
  67. $usersId =$idManager->getId("edu.middlebury.agents.users");
  68. /*********************************************************
  69. * the agent search form
  70. *********************************************************/
  71. // Users header
  72. $actionRows->add(new Heading(_("Users"), 2), "100%", null, LEFT, CENTER);
  73. ob_start();
  74. $self = $harmoni->request->quickURL();
  75. $lastCriteria = $harmoni->request->get("search_criteria");
  76. $search_criteria_name = RequestContext::name("search_criteria");
  77. $search_type_name = RequestContext::name("search_type");
  78. print _("Search For Users").": ";
  79. print "<form action='$self' method='post'>
  80. <div>
  81. <input type='text' name='$search_criteria_name' value='$lastCriteria' />";
  82.  
  83. print "\n\t<input type='submit' value='"._("Search")."' />";
  84. print "\n\t<a href='".$harmoni->request->quickURL()."'>";
  85. print "<input type='button' value='"._("Clear")."' /></a>";
  86. print "\n</div>\n</form>";
  87. $actionRows->add(new Block(ob_get_contents(), STANDARD_BLOCK), "100%", null, LEFT, CENTER);
  88. ob_end_clean();
  89. /*********************************************************
  90. * the agent search results
  91. *********************************************************/
  92. ob_start();
  93.  
  94. if ($search_criteria = $harmoni->request->get('search_criteria')) {
  95. //$typeParts = explode("::", @html_entity_decode($search_type, ENT_COMPAT, 'UTF-8'));
  96. $searchType = new HarmoniType("Agent & Group Search", "edu.middlebury.harmoni", "TokenSearch");
  97. //$searchType = new HarmoniType("Agent & Group Search", "edu.middlebury.harmoni", "WildcardSearch");
  98. $string= "*".$search_criteria."*";
  99. $agents =$agentManager->getAgentsBySearch($string, $searchType);
  100. print "search: " . $search_criteria;
  101.  
  102. while ($agents->hasNext()) {
  103. $agent =$agents->next();
  104. $id =$agent->getId();
  105.  
  106.  
  107. $harmoni->history->markReturnURL("polyphony/agents/edit_agent_details");
  108. print "\n<p align='center'><a href='".$harmoni->request->quickURL("agents","edit_agent_details", array("agentId"=>$id->getIdString()))."'>";
  109. print "\n".$agent->getDisplayName()."</a>";
  110. print "\n - <a href=\"Javascript:alert('"._("Id:").'\n\t'.addslashes($id->getIdString())."')\">Id</a></p>";
  111. }
  112. print "\n</div>";
  113. $actionRows->add(new Block(ob_get_contents(), STANDARD_BLOCK), "100%", null, LEFT, CENTER);
  114. ob_end_clean();
  115. }
  116. }
  117. }

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