Source for file Term.class.php

Documentation is available at Term.class.php

  1. <?php
  2.  
  3. require_once(OKI2."/osid/coursemanagement/Term.php");
  4. /**
  5. * Term includes an unique Id assigned by the implementation, a display name, a
  6. * termType, and a schedule.
  7. *
  8. * <p>
  9. * OSID Version: 2.0
  10. * </p>
  11. *
  12. * @package harmoni.osid_v2.coursemanagement
  13. *
  14. * @copyright Copyright &copy; 2005, Middlebury College
  15. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  16. *
  17. * @version $Id: Term.class.php,v 1.17 2007/09/04 20:25:39 adamfranco Exp $
  18. */
  19. class HarmoniTerm
  20. extends Term
  21. {
  22. /**
  23. * @variable object $_id the unique id for this term.
  24. * @access private
  25. * @variable object $_table the term table.
  26. * @access private
  27. ***/
  28. var $_id;
  29. var $_table;
  30. /**
  31. * The constructor.
  32. *
  33. * @param object Id $id
  34. *
  35. * @access public
  36. * @return void
  37. */
  38. function HarmoniTerm($id)
  39. {
  40. $this->_id =$id;
  41. $this->_table = 'cm_term';
  42. }
  43. /**
  44. * Update the display name for this Term.
  45. *
  46. * @param string $displayName
  47. *
  48. * @throws object CourseManagementException An exception
  49. * with one of the following messages defined in
  50. * org.osid.coursemanagement.CourseManagementException may be
  51. * thrown: {@link }
  52. * org.osid.coursemanagement.CourseManagementException#OPERATION_FAILED
  53. * OPERATION_FAILED}, {@link }
  54. * org.osid.coursemanagement.CourseManagementException#PERMISSION_DENIED
  55. * PERMISSION_DENIED}, {@link }
  56. * org.osid.coursemanagement.CourseManagementException#CONFIGURATION_ERROR
  57. * CONFIGURATION_ERROR}, {@link }
  58. * org.osid.coursemanagement.CourseManagementException#UNIMPLEMENTED
  59. * UNIMPLEMENTED}, {@link }
  60. * org.osid.coursemanagement.CourseManagementException#NULL_ARGUMENT
  61. * NULL_ARGUMENT}
  62. *
  63. * @access public
  64. */
  65. function updateDisplayName ( $displayName ) {
  66. $this->_setField('name',$displayName);
  67. }
  68.  
  69. /**
  70. * Get the display name for this Term.
  71. *
  72. * @return string
  73. *
  74. * @throws object CourseManagementException An exception
  75. * with one of the following messages defined in
  76. * org.osid.coursemanagement.CourseManagementException may be
  77. * thrown: {@link }
  78. * org.osid.coursemanagement.CourseManagementException#OPERATION_FAILED
  79. * OPERATION_FAILED}, {@link }
  80. * org.osid.coursemanagement.CourseManagementException#PERMISSION_DENIED
  81. * PERMISSION_DENIED}, {@link }
  82. * org.osid.coursemanagement.CourseManagementException#CONFIGURATION_ERROR
  83. * CONFIGURATION_ERROR}, {@link }
  84. * org.osid.coursemanagement.CourseManagementException#UNIMPLEMENTED
  85. * UNIMPLEMENTED}
  86. *
  87. * @access public
  88. */
  89. function getDisplayName () {
  90. return $this->_getField('name');
  91. }
  92.  
  93. /**
  94. * Get the unique Id for this Term.
  95. *
  96. * @return object Id
  97. *
  98. * @throws object CourseManagementException An exception
  99. * with one of the following messages defined in
  100. * org.osid.coursemanagement.CourseManagementException may be
  101. * thrown: {@link }
  102. * org.osid.coursemanagement.CourseManagementException#OPERATION_FAILED
  103. * OPERATION_FAILED}, {@link }
  104. * org.osid.coursemanagement.CourseManagementException#PERMISSION_DENIED
  105. * PERMISSION_DENIED}, {@link }
  106. * org.osid.coursemanagement.CourseManagementException#CONFIGURATION_ERROR
  107. * CONFIGURATION_ERROR}, {@link }
  108. * org.osid.coursemanagement.CourseManagementException#UNIMPLEMENTED
  109. * UNIMPLEMENTED}
  110. *
  111. * @access public
  112. */
  113. function getId () {
  114. return $this->_id;
  115. }
  116.  
  117. /**
  118. * Get the Type for this Term. This Type is meaningful to the
  119. * implementation and applications and is not specified by the OSID.
  120. *
  121. * @return object Type
  122. *
  123. * @throws object CourseManagementException An exception
  124. * with one of the following messages defined in
  125. * org.osid.coursemanagement.CourseManagementException may be
  126. * thrown: {@link }
  127. * org.osid.coursemanagement.CourseManagementException#OPERATION_FAILED
  128. * OPERATION_FAILED}, {@link }
  129. * org.osid.coursemanagement.CourseManagementException#PERMISSION_DENIED
  130. * PERMISSION_DENIED}, {@link }
  131. * org.osid.coursemanagement.CourseManagementException#CONFIGURATION_ERROR
  132. * CONFIGURATION_ERROR}, {@link }
  133. * org.osid.coursemanagement.CourseManagementException#UNIMPLEMENTED
  134. * UNIMPLEMENTED}
  135. *
  136. * @access public
  137. */
  138. function getType () {
  139. return $this->_getType('term');
  140. }
  141.  
  142. /**
  143. * Get the Schedule for this Term. Schedules are defined in scheduling
  144. * OSID. ScheduleItems are returned in chronological order by increasing
  145. * start date.
  146. *
  147. * @return object ScheduleItemIterator
  148. *
  149. * @throws object CourseManagementException An exception
  150. * with one of the following messages defined in
  151. * org.osid.coursemanagement.CourseManagementException may be
  152. * thrown: {@link }
  153. * org.osid.coursemanagement.CourseManagementException#OPERATION_FAILED
  154. * OPERATION_FAILED}, {@link }
  155. * org.osid.coursemanagement.CourseManagementException#PERMISSION_DENIED
  156. * PERMISSION_DENIED}, {@link }
  157. * org.osid.coursemanagement.CourseManagementException#CONFIGURATION_ERROR
  158. * CONFIGURATION_ERROR}, {@link }
  159. * org.osid.coursemanagement.CourseManagementException#UNIMPLEMENTED
  160. * UNIMPLEMENTED}
  161. *
  162. * @access public
  163. */
  164. function getSchedule () {
  165.  
  166. $dbManager = Services::getService("DatabaseManager");
  167. $query= new SelectQuery;
  168. $query->addTable('cm_schedule');
  169. $query->addColumn('fk_sc_item');
  170. $query->addWhere("fk_id='".addslashes($this->_id->getIdString())."'");
  171. //$query->addOrderBy
  172. $res=$dbManager->query($query);
  173. $array=array();
  174. $sm = Services::getService("SchedulingManager");
  175. $idManager = Services::getService("IdManager");
  176. while($res->hasMoreRows()){
  177. $row = $res->getCurrentRow();
  178. $res->advanceRow();
  179. $id =$idManager->getId($row['fk_sc_item']);
  180. $si = $sm->getScheduleItem($id);
  181. $start = $si->getStart();
  182. $array[$start] =$si;
  183. }
  184. ksort($array);
  185. $ret = new HarmoniScheduleItemIterator($array);
  186.  
  187. return $ret;
  188. }
  189. function _typeToIndex($typename, $type)
  190. {
  191. $cm=Services::getService("CourseManagement");
  192. return $cm->_typeToIndex($typename, $type);
  193. }
  194. function _getTypes($typename)
  195. {
  196. $cm=Services::getService("CourseManagement");
  197. return $cm->_getTypes($typename);
  198. }
  199. function _getField($key)
  200. {
  201. $cm=Services::getService("CourseManagement");
  202. return $cm->_getField($this->_id,$this->_table,$key);
  203. }
  204. function _getType($typename){
  205. $cm=Services::getService("CourseManagement");
  206. return $cm->_getType($this->_id,$this->_table,$typename);
  207. }
  208. function _setField($key, $value)
  209. {
  210. $cm=Services::getService("CourseManagement");
  211. return $cm->_setField($this->_id,$this->_table,$key, $value);
  212. }
  213. }
  214.  
  215. ?>

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