Source for file edit_section_details.act.php

Documentation is available at edit_section_details.act.php

  1. <?php
  2.  
  3. /**
  4. * This action is the central page for viewing and modifying course section information.
  5. *
  6. * @package polyphony.coursemanagement
  7. *
  8. *
  9. * @since 7/28/06
  10. *
  11. * @copyright Copyright &copy; 2006, Middlebury College
  12. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  13. *
  14. * @version $Id: edit_section_details.act.php,v 1.21 2007/09/19 14:04:54 adamfranco Exp $
  15. */
  16.  
  17. require_once(POLYPHONY."/main/library/AbstractActions/MainWindowAction.class.php");
  18. require_once(HARMONI."GUIManager/Components/Blank.class.php");
  19.  
  20. class edit_section_detailsAction
  21. extends MainWindowAction
  22. {
  23. /**
  24. * Check Authorizations
  25. *
  26. * @return boolean
  27. * @access public
  28. * @since 4/26/05
  29. */
  30. function isAuthorizedToExecute () {
  31. // Check for authorization
  32. $authZManager = Services::getService("AuthZ");
  33. $idManager = Services::getService("IdManager");
  34. $harmoni = Harmoni::instance();
  35.  
  36. $harmoni->request->startNamespace("polyphony-agents");
  37. $sectionIdString = $harmoni->request->get("courseId");
  38.  
  39. $harmoni->request->endNamespace();
  40.  
  41. if ($authZManager->isUserAuthorized(
  42. $idManager->getId("edu.middlebury.authorization.modify"),
  43. $idManager->getId($sectionIdString)))
  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. $harmoni = Harmoni::instance();
  59. $harmoni->request->startNamespace("polyphony-agents");
  60. $harmoni->request->passthrough("courseId");
  61. $sectionIdString = $harmoni->request->get("courseId");
  62. $idManager = Services::getService("Id");
  63. $sectionId =$idManager->getId($sectionIdString);
  64. $cm = Services::getService("CourseManagement");
  65. $section =$cm->getCourseSection($sectionId);
  66. return dgettext("polyphony", $section->getDisplayName());
  67. }
  68.  
  69. /**
  70. * Build the content for this action
  71. *
  72. * @return void
  73. * @access public
  74. * @since 4/26/05
  75. */
  76. function buildContent () {
  77. $defaultTextDomain = textdomain("polyphony");
  78. $idManager = Services::getService("Id");
  79.  
  80. $actionRows =$this->getActionRows();
  81. $pageRows = new Container(new YLayout(), OTHER, 1);
  82. $harmoni = Harmoni::instance();
  83.  
  84. $harmoni->request->startNamespace("polyphony-agents");
  85. $harmoni->request->passthrough("courseId");
  86. $sectionIdString = $harmoni->request->get("courseId");
  87. $furtherAction = $harmoni->request->get("furtherAction");
  88.  
  89. $sectionId =$idManager->getId($sectionIdString);
  90. $cm = Services::getService("CourseManagement");
  91. $section =$cm->getCourseSection($sectionId);
  92.  
  93. ob_start();
  94.  
  95. print "<div style='margin-left: 15px'>";
  96.  
  97. if (!$furtherAction) $furtherAction = "edit_section_detailsAction::viewSectionDetails";
  98.  
  99. $actionFunctions = array(
  100. "edit_section_detailsAction::viewSectionDetails",
  101. "edit_section_detailsAction::editSectionDetails",
  102. "edit_section_detailsAction::confirmDeleteSection",
  103. "edit_section_detailsAction::deleteSection",
  104. );
  105.  
  106.  
  107. if($furtherAction && in_array($furtherAction, $actionFunctions)){
  108. eval($furtherAction.'($section);');
  109. }else{
  110. print "No such action '".$furtherAction."'";
  111. }
  112.  
  113. print "</div>";
  114.  
  115. // Layout
  116. $actionRows->add(new Block(ob_get_contents(), 2),"100%", null, CENTER, TOP);
  117. ob_end_clean();
  118. $harmoni->request->forget("courseId");
  119. $harmoni->request->endNamespace();
  120.  
  121. textdomain($defaultTextDomain);
  122. }
  123.  
  124. /***************************FUNCTIONS***************************************/
  125.  
  126.  
  127. /**
  128. * shows the details of the offering's properties and gives menu of actions
  129. *
  130. * @param object Agent $agent
  131. * @return void
  132. * @access public
  133. * @since 7/19/05
  134. */
  135. function viewSectionDetails($section){
  136.  
  137.  
  138.  
  139.  
  140. $sectionId =$section->getId();
  141.  
  142.  
  143. //display offering info
  144.  
  145. print "\n<table><tr><td>";
  146.  
  147. print "\n<h2>".$section->getDisplayName()."</h2>";
  148.  
  149. print "</td><td>";
  150.  
  151.  
  152.  
  153.  
  154. //actions menu
  155. $harmoni = Harmoni::instance();
  156. $url =$harmoni->request->mkURL();
  157.  
  158. $courseId =$section->getId();
  159. $courseIdString = $courseId->getIdString();
  160. print "<ul>";
  161. $link1 = $harmoni->request->quickURL("coursemanagement", "edit_section_details",
  162. array("courseId"=>$courseIdString, "furtherAction"=>"edit_section_detailsAction::editSectionDetails"));
  163. print "<li><a href='".$link1."'>Edit section</a></li>";
  164. $link2 = $harmoni->request->quickURL("coursemanagement", "edit_section_details",
  165. array("courseId"=>$courseIdString, "furtherAction"=>"edit_section_detailsAction::deleteSection"));
  166. print "<li><a href='".$link2."'>Delete section</a></li>";
  167. $harmoni->history->markReturnURL("polyphony/coursemanagement/edit_section_details");
  168. $link1 = $harmoni->request->quickURL("coursemanagement", "edit_section_roster",
  169. array("courseId"=>$courseIdString));
  170. print "<li><a href='$link1'>Edit roster</a></li>";
  171.  
  172. print "</ul>";
  173. print "\n</td></tr></table>";
  174.  
  175.  
  176. print "\n<h4>Members</h4>";
  177.  
  178.  
  179.  
  180.  
  181. $enrollmentRecordIterator =$section->getRoster();
  182.  
  183. $am = Services::getService("AgentManager");
  184.  
  185.  
  186.  
  187. print "<table cellpadding='20'>";
  188. print "\t<tr>";
  189. $column = 0;
  190. if (!$enrollmentRecordIterator->hasNextEnrollmentRecord()) {
  191. print "<td></td>";
  192. } else {
  193. while ($enrollmentRecordIterator->hasNextEnrollmentRecord()) {
  194. if ($column == 4) {
  195. $column = 0;
  196. print "\n\t</tr><tr>";
  197. }
  198. $column++;
  199. $er =$enrollmentRecordIterator->nextEnrollmentRecord();
  200. $id =$er->getStudent();
  201. $member =$am->getAgent($id);
  202.  
  203. $harmoni = Harmoni::instance();
  204.  
  205. $harmoni->history->markReturnURL("polyphony/agents/edit_agent_details");
  206.  
  207. print "\n<td><a href='".$harmoni->request->quickURL("agents", "edit_agent_details",
  208. array("agentId"=>$id->getIdString()))."'>";
  209. print "\n".$member->getDisplayName()."</a>";
  210. print "\n - <a href=\"Javascript:alert('"._("Id:").'\n\t'.addslashes($id->getIdString())."')\">Id</a>
  211. </td>";
  212. }
  213. }
  214.  
  215. print "</tr></table>";
  216.  
  217.  
  218. }
  219.  
  220.  
  221.  
  222.  
  223. /*
  224. * offers a confirmation screen for deleting an entire offering
  225. */
  226.  
  227. function confirmDeleteSection($section){
  228. $harmoni = Harmoni::instance();
  229. $url =$harmoni->request->mkURL();
  230. print "Do you really want to delete ".$section->getDisplayName()."?<br />";
  231. print "<form action='".$url->write("furtherAction","edit_offering_detailsAction::deleteSection")."' method='post'><input type='submit' value='Delete' /></form><input type='button' value='Cancel' onclick='history.back()' />";
  232. return;
  233. }
  234.  
  235. /*
  236. * Handles the actual deletion of a section
  237. */
  238. function deleteSection($section){
  239. //$cm = Services::getService("CourseManagement");
  240. $idManager = Services::getService("Id");
  241. $offering =$section->getCourseOffering();
  242. $offering->deleteCourseSection($section->getId());
  243. $offeringId =$offering->getId();
  244. $offeringIdString = $offeringId->getIdString();
  245.  
  246. $harmoni = Harmoni::instance();
  247. print "Section deleted.<br />";
  248. $link = $harmoni->request->quickURL("coursemanagement", "edit_offering_details",
  249. array("courseId"=>$offeringIdString));
  250. print "<a href='".$link."'>Go Back</a>";
  251.  
  252. return;
  253. }
  254. }

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