Source for file HarmoniScheduleItem.class.php

Documentation is available at HarmoniScheduleItem.class.php

  1. <?php
  2. require_once(OKI2."/osid/scheduling/ScheduleItem.php");
  3.  
  4.  
  5. /**
  6. * ScheduleItem contains a set of AgentCommitments (e.g. calendar events) as
  7. * well as the creator of the ScheduleItem and some date information.
  8. *
  9. * <p>
  10. * OSID Version: 2.0
  11. * </p>
  12. *
  13. * <p>
  14. * Licensed under the {@link org.osid.SidImplementationLicenseMIT MIT}
  15. * O.K.I&#46; OSID Definition License}.
  16. * </p>
  17. *
  18. * @package org.osid.scheduling
  19. */
  20. class HarmoniScheduleItem
  21. extends ScheduleItem
  22. {
  23. /**
  24. * @variable object $_id the unique id for this ScheduleItem.
  25. * @access private
  26. * @variable object $_table the ScheduleItem table.
  27. * @access private
  28. ***/
  29. var $_id;
  30. var $_table;
  31. /**
  32. * The constructor.
  33. *
  34. * @param object Id $id
  35. *
  36. * @access public
  37. * @return void
  38. */
  39. function HarmoniScheduleItem($id)
  40. {
  41. $this->_id =$id;
  42. $this->_table = 'sc_item';
  43. }
  44. /**
  45. * Update the DisplayName of this ScheduleItem.
  46. *
  47. * @param string $displayName
  48. *
  49. * @throws object SchedulingException An exception with one of
  50. * the following messages defined in
  51. * org.osid.scheduling.SchedulingException may be thrown: {@link }
  52. * org.osid.scheduling.SchedulingException#OPERATION_FAILED
  53. * OPERATION_FAILED}, {@link }
  54. * org.osid.scheduling.SchedulingException#PERMISSION_DENIED
  55. * PERMISSION_DENIED}, {@link }
  56. * org.osid.scheduling.SchedulingException#CONFIGURATION_ERROR
  57. * CONFIGURATION_ERROR}, {@link }
  58. * org.osid.scheduling.SchedulingException#UNIMPLEMENTED
  59. * UNIMPLEMENTED}, {@link }
  60. * org.osid.scheduling.SchedulingException#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 description of this ScheduleItem.
  71. *
  72. * @param string $description
  73. *
  74. * @throws object SchedulingException An exception with one of
  75. * the following messages defined in
  76. * org.osid.scheduling.SchedulingException may be thrown: {@link }
  77. * org.osid.scheduling.SchedulingException#OPERATION_FAILED
  78. * OPERATION_FAILED}, {@link }
  79. * org.osid.scheduling.SchedulingException#PERMISSION_DENIED
  80. * PERMISSION_DENIED}, {@link }
  81. * org.osid.scheduling.SchedulingException#CONFIGURATION_ERROR
  82. * CONFIGURATION_ERROR}, {@link }
  83. * org.osid.scheduling.SchedulingException#UNIMPLEMENTED
  84. * UNIMPLEMENTED}, {@link }
  85. * org.osid.scheduling.SchedulingException#NULL_ARGUMENT
  86. * NULL_ARGUMENT}
  87. *
  88. * @access public
  89. */
  90. function updateDescription ( $description ) {
  91. $this->_setField('description', $description);
  92. }
  93.  
  94. /**
  95. * Update the Start for this ScheduleItem.
  96. *
  97. * @param int $start
  98. *
  99. * @throws object SchedulingException An exception with one of
  100. * the following messages defined in
  101. * org.osid.scheduling.SchedulingException may be thrown: {@link }
  102. * org.osid.scheduling.SchedulingException#OPERATION_FAILED
  103. * OPERATION_FAILED}, {@link }
  104. * org.osid.scheduling.SchedulingException#PERMISSION_DENIED
  105. * PERMISSION_DENIED}, {@link }
  106. * org.osid.scheduling.SchedulingException#CONFIGURATION_ERROR
  107. * CONFIGURATION_ERROR}, {@link }
  108. * org.osid.scheduling.SchedulingException#UNIMPLEMENTED
  109. * UNIMPLEMENTED}, {@link }
  110. * org.osid.scheduling.SchedulingException#NULL_ARGUMENT
  111. * NULL_ARGUMENT}
  112. *
  113. * @access public
  114. */
  115. function updateStart ( $start ) {
  116. $this->_setField('start_date', $start);
  117. }
  118.  
  119. /**
  120. * Update the End for this ScheduleItem.
  121. *
  122. * @param int $end
  123. *
  124. * @throws object SchedulingException An exception with one of
  125. * the following messages defined in
  126. * org.osid.scheduling.SchedulingException may be thrown: {@link }
  127. * org.osid.scheduling.SchedulingException#OPERATION_FAILED
  128. * OPERATION_FAILED}, {@link }
  129. * org.osid.scheduling.SchedulingException#PERMISSION_DENIED
  130. * PERMISSION_DENIED}, {@link }
  131. * org.osid.scheduling.SchedulingException#CONFIGURATION_ERROR
  132. * CONFIGURATION_ERROR}, {@link }
  133. * org.osid.scheduling.SchedulingException#UNIMPLEMENTED
  134. * UNIMPLEMENTED}, {@link }
  135. * org.osid.scheduling.SchedulingException#NULL_ARGUMENT
  136. * NULL_ARGUMENT}
  137. *
  138. * @access public
  139. */
  140. function updateEnd ( $end ) {
  141. $this->_setField('end_date', $end);
  142. }
  143.  
  144. /**
  145. * Update the Status Type for this ScheduleItem.
  146. *
  147. * @param object Type $status
  148. *
  149. * @throws object SchedulingException An exception with one of
  150. * the following messages defined in
  151. * org.osid.scheduling.SchedulingException may be thrown: {@link }
  152. * org.osid.scheduling.SchedulingException#OPERATION_FAILED
  153. * OPERATION_FAILED}, {@link }
  154. * org.osid.scheduling.SchedulingException#PERMISSION_DENIED
  155. * PERMISSION_DENIED}, {@link }
  156. * org.osid.scheduling.SchedulingException#CONFIGURATION_ERROR
  157. * CONFIGURATION_ERROR}, {@link }
  158. * org.osid.scheduling.SchedulingException#UNIMPLEMENTED
  159. * UNIMPLEMENTED}, {@link }
  160. * org.osid.scheduling.SchedulingException#NULL_ARGUMENT
  161. * NULL_ARGUMENT}, {@link }
  162. * org.osid.scheduling.SchedulingException#UNKNOWN_TYPE
  163. * UNKNOWN_TYPE}
  164. *
  165. * @access public
  166. */
  167. function updateStatus ( $status ) {
  168. $index = $this->_typeToIndex('item_stat',$status);
  169. $this->_setField('fk_sc_item_stat_type', $index);
  170. }
  171.  
  172. /**
  173. * Get the unique Id for this ScheduleItem. The unique Id is set when the
  174. * ScheduleItem is created.
  175. *
  176. * @return object Id
  177. *
  178. * @throws object SchedulingException An exception with one of
  179. * the following messages defined in
  180. * org.osid.scheduling.SchedulingException may be thrown: {@link }
  181. * org.osid.scheduling.SchedulingException#OPERATION_FAILED
  182. * OPERATION_FAILED}, {@link }
  183. * org.osid.scheduling.SchedulingException#PERMISSION_DENIED
  184. * PERMISSION_DENIED}, {@link }
  185. * org.osid.scheduling.SchedulingException#CONFIGURATION_ERROR
  186. * CONFIGURATION_ERROR}, {@link }
  187. * org.osid.scheduling.SchedulingException#UNIMPLEMENTED
  188. * UNIMPLEMENTED}
  189. *
  190. * @access public
  191. */
  192. function getId () {
  193. return $this->_id;
  194. }
  195.  
  196. /**
  197. * Get the DisplayName of this ScheduleItem.
  198. *
  199. * @return string
  200. *
  201. * @throws object SchedulingException An exception with one of
  202. * the following messages defined in
  203. * org.osid.scheduling.SchedulingException may be thrown: {@link }
  204. * org.osid.scheduling.SchedulingException#OPERATION_FAILED
  205. * OPERATION_FAILED}, {@link }
  206. * org.osid.scheduling.SchedulingException#PERMISSION_DENIED
  207. * PERMISSION_DENIED}, {@link }
  208. * org.osid.scheduling.SchedulingException#CONFIGURATION_ERROR
  209. * CONFIGURATION_ERROR}, {@link }
  210. * org.osid.scheduling.SchedulingException#UNIMPLEMENTED
  211. * UNIMPLEMENTED}
  212. *
  213. * @access public
  214. */
  215. function getDisplayName () {
  216. return $this->_getField('name');
  217. }
  218.  
  219. /**
  220. * Get the description of this ScheduleItem.
  221. *
  222. * @return string
  223. *
  224. * @throws object SchedulingException An exception with one of
  225. * the following messages defined in
  226. * org.osid.scheduling.SchedulingException may be thrown: {@link }
  227. * org.osid.scheduling.SchedulingException#OPERATION_FAILED
  228. * OPERATION_FAILED}, {@link }
  229. * org.osid.scheduling.SchedulingException#PERMISSION_DENIED
  230. * PERMISSION_DENIED}, {@link }
  231. * org.osid.scheduling.SchedulingException#CONFIGURATION_ERROR
  232. * CONFIGURATION_ERROR}, {@link }
  233. * org.osid.scheduling.SchedulingException#UNIMPLEMENTED
  234. * UNIMPLEMENTED}
  235. *
  236. * @access public
  237. */
  238. function getDescription () {
  239. return $this->_getField('description');
  240. }
  241.  
  242. /**
  243. * Get the unique Id of the Agent that created this ScheduleItem.
  244. *
  245. *
  246. * @return object Id
  247. *
  248. * @throws object SchedulingException An exception with one of
  249. * the following messages defined in
  250. * org.osid.scheduling.SchedulingException may be thrown: {@link }
  251. * org.osid.scheduling.SchedulingException#OPERATION_FAILED
  252. * OPERATION_FAILED}, {@link }
  253. * org.osid.scheduling.SchedulingException#PERMISSION_DENIED
  254. * PERMISSION_DENIED}, {@link }
  255. * org.osid.scheduling.SchedulingException#CONFIGURATION_ERROR
  256. * CONFIGURATION_ERROR}, {@link }
  257. * org.osid.scheduling.SchedulingException#UNIMPLEMENTED
  258. * UNIMPLEMENTED}
  259. *
  260. * @access public
  261. */
  262. function getCreator () {
  263. $idManager = Services::getServices("Id");
  264. $creatorIdString =$this->_getField('fk_creator_id');
  265. //not created by anyone in particular
  266. if($creatorIdString ===""){
  267. return null;
  268. }
  269. return $idManager->getId($creatorIdString);
  270. }
  271.  
  272. /**
  273. * Get the Start for this ScheduleItem.
  274. *
  275. * @return int
  276. *
  277. * @throws object SchedulingException An exception with one of
  278. * the following messages defined in
  279. * org.osid.scheduling.SchedulingException may be thrown: {@link }
  280. * org.osid.scheduling.SchedulingException#OPERATION_FAILED
  281. * OPERATION_FAILED}, {@link }
  282. * org.osid.scheduling.SchedulingException#PERMISSION_DENIED
  283. * PERMISSION_DENIED}, {@link }
  284. * org.osid.scheduling.SchedulingException#CONFIGURATION_ERROR
  285. * CONFIGURATION_ERROR}, {@link }
  286. * org.osid.scheduling.SchedulingException#UNIMPLEMENTED
  287. * UNIMPLEMENTED}
  288. *
  289. * @access public
  290. */
  291. function getStart () {
  292. return $this->_getField('start_date');
  293. }
  294.  
  295. /**
  296. * Get the End for this ScheduleItem.
  297. *
  298. * @return int
  299. *
  300. * @throws object SchedulingException An exception with one of
  301. * the following messages defined in
  302. * org.osid.scheduling.SchedulingException may be thrown: {@link }
  303. * org.osid.scheduling.SchedulingException#OPERATION_FAILED
  304. * OPERATION_FAILED}, {@link }
  305. * org.osid.scheduling.SchedulingException#PERMISSION_DENIED
  306. * PERMISSION_DENIED}, {@link }
  307. * org.osid.scheduling.SchedulingException#CONFIGURATION_ERROR
  308. * CONFIGURATION_ERROR}, {@link }
  309. * org.osid.scheduling.SchedulingException#UNIMPLEMENTED
  310. * UNIMPLEMENTED}
  311. *
  312. * @access public
  313. */
  314. function getEnd () {
  315. return $this->_getField('end_date');
  316. }
  317.  
  318. /**
  319. * Get the Status Type for this ScheduleItem.
  320. *
  321. * @return object Type
  322. *
  323. * @throws object SchedulingException An exception with one of
  324. * the following messages defined in
  325. * org.osid.scheduling.SchedulingException may be thrown: {@link }
  326. * org.osid.scheduling.SchedulingException#OPERATION_FAILED
  327. * OPERATION_FAILED}, {@link }
  328. * org.osid.scheduling.SchedulingException#PERMISSION_DENIED
  329. * PERMISSION_DENIED}, {@link }
  330. * org.osid.scheduling.SchedulingException#CONFIGURATION_ERROR
  331. * CONFIGURATION_ERROR}, {@link }
  332. * org.osid.scheduling.SchedulingException#UNIMPLEMENTED
  333. * UNIMPLEMENTED}
  334. *
  335. * @access public
  336. */
  337. function getStatus () {
  338. return $this->_getType('item_stat');
  339. }
  340.  
  341. /**
  342. * Get the Master Identifier for this ScheduleItem. A Master Identifier is
  343. * a key, rule, or function that can be used to associated more than one
  344. * ScheduleItem together. An example can be recurring items where each
  345. * recurring item has the same Master Identifier.
  346. *
  347. * @return string
  348. *
  349. * @throws object SchedulingException An exception with one of
  350. * the following messages defined in
  351. * org.osid.scheduling.SchedulingException may be thrown: {@link }
  352. * org.osid.scheduling.SchedulingException#OPERATION_FAILED
  353. * OPERATION_FAILED}, {@link }
  354. * org.osid.scheduling.SchedulingException#PERMISSION_DENIED
  355. * PERMISSION_DENIED}, {@link }
  356. * org.osid.scheduling.SchedulingException#CONFIGURATION_ERROR
  357. * CONFIGURATION_ERROR}, {@link }
  358. * org.osid.scheduling.SchedulingException#UNIMPLEMENTED
  359. * UNIMPLEMENTED}
  360. *
  361. * @access public
  362. */
  363. function getMasterIdentifier () {
  364. return $this->_getField('master_id');
  365. }
  366.  
  367. /**
  368. * Get all the Property Types for ScheduleItem.
  369. *
  370. * @return object TypeIterator
  371. *
  372. * @throws object SchedulingException An exception with one of
  373. * the following messages defined in
  374. * org.osid.scheduling.SchedulingException may be thrown: {@link }
  375. * org.osid.scheduling.SchedulingException#OPERATION_FAILED
  376. * OPERATION_FAILED}, {@link }
  377. * org.osid.scheduling.SchedulingException#PERMISSION_DENIED
  378. * PERMISSION_DENIED}, {@link }
  379. * org.osid.scheduling.SchedulingException#CONFIGURATION_ERROR
  380. * CONFIGURATION_ERROR}, {@link }
  381. * org.osid.scheduling.SchedulingException#UNIMPLEMENTED
  382. * UNIMPLEMENTED}
  383. *
  384. * @access public
  385. */
  386. function getPropertyTypes () {
  387. $type =$this->getStatus();
  388. $propertiesType = new Type("PropertiesType", $type->getAuthority(), "properties");
  389. $array = array($propertiesType);
  390. $typeIterator = new HarmoniTypeIterator($array);
  391. return $typeIterator;
  392. }
  393.  
  394. /**
  395. * Get all the Agent commitments for this ScheduleItem.
  396. *
  397. * @return object AgentCommitmentIterator
  398. *
  399. * @throws object SchedulingException An exception with one of
  400. * the following messages defined in
  401. * org.osid.scheduling.SchedulingException may be thrown: {@link }
  402. * org.osid.scheduling.SchedulingException#OPERATION_FAILED
  403. * OPERATION_FAILED}, {@link }
  404. * org.osid.scheduling.SchedulingException#PERMISSION_DENIED
  405. * PERMISSION_DENIED}, {@link }
  406. * org.osid.scheduling.SchedulingException#CONFIGURATION_ERROR
  407. * CONFIGURATION_ERROR}, {@link }
  408. * org.osid.scheduling.SchedulingException#UNIMPLEMENTED
  409. * UNIMPLEMENTED}
  410. *
  411. * @access public
  412. */
  413. function getAgentCommitments () {
  414. $dbHandler = Services::getService("DBHandler");
  415.  
  416. $array=array();
  417.  
  418.  
  419. $query= new SelectQuery;
  420. $query->addTable('sc_commit');
  421. $query->addColumn('id');
  422. $query->addWhere("fk_sc_item='".addslashes($this->_id->getIdString())."'");
  423.  
  424.  
  425. $res=$dbHandler->query($query);
  426. $idManager = Services::getService("Id");
  427. while($res->hasMoreRows()){
  428. $row = $res->getCurrentRow();
  429. $res->advanceRow();
  430. $array[] = new HarmoniAgentCommitment($idManager->getId($row['id']));
  431. }
  432. $ret = new HarmoniAgentCommitmentIterator($array);
  433. return $ret;
  434. }
  435.  
  436. /**
  437. *
  438. * Remove a previously added Agent commitment for this ScheduleItem.
  439. *
  440. * WARNING: NOT IN OSID -- Will likely be added in v3
  441. *
  442. * @param object Id $agentId
  443. *
  444. * @throws object SchedulingException An exception with one of
  445. * the following messages defined in
  446. * org.osid.scheduling.SchedulingException may be thrown: {@link }
  447. * org.osid.scheduling.SchedulingException#OPERATION_FAILED
  448. * OPERATION_FAILED}, {@link }
  449. * org.osid.scheduling.SchedulingException#PERMISSION_DENIED
  450. * PERMISSION_DENIED}, {@link }
  451. * org.osid.scheduling.SchedulingException#CONFIGURATION_ERROR
  452. * CONFIGURATION_ERROR}, {@link }
  453. * org.osid.scheduling.SchedulingException#UNIMPLEMENTED
  454. * UNIMPLEMENTED}, {@link }
  455. * org.osid.scheduling.SchedulingException#UNKNOWN_ID UNKNOWN_ID},
  456. * {@link org.osid.scheduling.SchedulingException#UNKNOWN_TYPE}
  457. * UNKNOWN_TYPE}
  458. *
  459. * @access public
  460. */
  461. function removeAgentCommitment ( $agentId) {
  462. $dbHandler = Services::getService("DBHandler");
  463. $query= new DeleteQuery;
  464. $query->setTable('sc_commit');
  465.  
  466. $query->addWhere("fk_sc_item='".addslashes($this->_id->getIdString())."'");
  467. $query->addWhere("fk_agent_id='".addslashes($agentId->getIdString())."'");
  468.  
  469. $res =$dbHandler->query($query);
  470. if($res->getNumberOfRows() == 0){
  471. print "<b>Warning!</b> Agent with Id [".$agentId->getIdString()."] is not added to ScheduleItem ".$this->getdisplayName()." [".$this->_id->getIdString()."] yet. Do not delete agents that are not added.";
  472. }
  473. }
  474. /**
  475. * Change a previously added Agent commitment for this ScheduleItem.
  476. *
  477. * @param object Id $agentId
  478. * @param object Type $agentStatus
  479. *
  480. * @throws object SchedulingException An exception with one of
  481. * the following messages defined in
  482. * org.osid.scheduling.SchedulingException may be thrown: {@link }
  483. * org.osid.scheduling.SchedulingException#OPERATION_FAILED
  484. * OPERATION_FAILED}, {@link }
  485. * org.osid.scheduling.SchedulingException#PERMISSION_DENIED
  486. * PERMISSION_DENIED}, {@link }
  487. * org.osid.scheduling.SchedulingException#CONFIGURATION_ERROR
  488. * CONFIGURATION_ERROR}, {@link }
  489. * org.osid.scheduling.SchedulingException#UNIMPLEMENTED
  490. * UNIMPLEMENTED}, {@link }
  491. * org.osid.scheduling.SchedulingException#UNKNOWN_ID UNKNOWN_ID},
  492. * {@link org.osid.scheduling.SchedulingException#UNKNOWN_TYPE}
  493. * UNKNOWN_TYPE}
  494. *
  495. * @access public
  496. */
  497. function changeAgentCommitment ( $agentId, $agentStatus ) {
  498. $typeIndex = $this->_typeToIndex('commit_stat',$agentStatus);
  499. $dbHandler = Services::getService("DBHandler");
  500. $query= new UpdateQuery;
  501. $query->setTable('sc_commit');
  502.  
  503. $query->addWhere("fk_sc_item='".addslashes($this->_id->getIdString())."'");
  504. $query->addWhere("fk_agent_id='".addslashes($agentId->getIdString())."'");
  505. $query->setColumns(array('fk_sc_commit_stat_type'));
  506. $query->setValues(array("'".addslashes($typeIndex)."'"));
  507.  
  508. $res =$dbHandler->query($query);
  509. if($res->getNumberOfRows()==0){
  510. print "<b>Warning!</b> Agent with Id [".$agentId->getIdString()."] is not added to ScheduleItem ".$this->getdisplayName()." [".$this->_id->getIdString()."] yet. Use addAgentCommitment() to add the Agent before changing it.";
  511. }else if($res->getNumberOfRows()>1){
  512. print "<b>Warning!</b> Agent with Id [".$agentId->getIdString()."] is added ".$res->getNumberOfRows()." times to ScheduleItem ".$this->getdisplayName()." [".$this->_id->getIdString()."] when only one is acceptable.";
  513. }
  514. }
  515.  
  516. /**
  517. * Add an Agent commitment to this ScheduleItem.
  518. *
  519. * @param object Id $agentId
  520. * @param object Type $agentStatus
  521. *
  522. * @throws object SchedulingException An exception with one of
  523. * the following messages defined in
  524. * org.osid.scheduling.SchedulingException may be thrown: {@link }
  525. * org.osid.scheduling.SchedulingException#OPERATION_FAILED
  526. * OPERATION_FAILED}, {@link }
  527. * org.osid.scheduling.SchedulingException#PERMISSION_DENIED
  528. * PERMISSION_DENIED}, {@link }
  529. * org.osid.scheduling.SchedulingException#CONFIGURATION_ERROR
  530. * CONFIGURATION_ERROR}, {@link }
  531. * org.osid.scheduling.SchedulingException#UNIMPLEMENTED
  532. * UNIMPLEMENTED}, {@link }
  533. * org.osid.scheduling.SchedulingException#UNKNOWN_ID UNKNOWN_ID},
  534. * {@link org.osid.scheduling.SchedulingException#UNKNOWN_TYPE}
  535. * UNKNOWN_TYPE}, {@link }
  536. * org.osid.shared.SharedException#ALREADY_ADDED ALREADY_ADDED}
  537. *
  538. * @access public
  539. */
  540. function addAgentCommitment ( $agentId, $agentStatus ) {
  541. $dbHandler = Services::getService("DBHandler");
  542. $query= new SelectQuery;
  543. $query->addTable('sc_commit');
  544. $query->addWhere("fk_sc_item='".addslashes($this->_id->getIdString())."'");
  545. $query->addWhere("fk_agent_id='".addslashes($agentId->getIdString())."'");
  546. $query->addColumn('id');//@TODO id is not really needed here--a count should probably be returned.
  547. $res=$dbHandler->query($query);
  548. if($res->getNumberOfRows()==0){
  549. $typeIndex = $this->_typeToIndex('commit_stat',$agentStatus);
  550. $query= new InsertQuery;
  551. $query->setTable('sc_commit');
  552. $values[]="'".addslashes($agentId->getIdString())."'";
  553. $values[]="'".addslashes($typeIndex)."'";
  554. $values[]="'".addslashes($this->_id->getIdString())."'";
  555. $query->setColumns(array('fk_agent_id','fk_sc_commit_stat_type','fk_sc_item'));
  556. $query->addRowOfValues($values);
  557. $query->setAutoIncrementColumn('id','id_sequence');
  558. $dbHandler->query($query);
  559. }else{
  560. print "<b>Warning!</b> Agent with id ".$agentId->getIdString()."is already added to ScheduleItem ".$this->getDisplayName().". Use changeAgentCommitment() to change the commitment status.";
  561. }
  562. }
  563.  
  564. /**
  565. * Get the Properties of this Type associated with this ScheduleItem.
  566. *
  567. * @param object Type $propertiesType
  568. *
  569. * @return object Properties
  570. *
  571. * @throws object SchedulingException An exception with one of
  572. * the following messages defined in
  573. * org.osid.scheduling.SchedulingException may be thrown: {@link }
  574. * org.osid.scheduling.SchedulingException#OPERATION_FAILED
  575. * OPERATION_FAILED}, {@link }
  576. * org.osid.scheduling.SchedulingException#PERMISSION_DENIED
  577. * PERMISSION_DENIED}, {@link }
  578. * org.osid.scheduling.SchedulingException#CONFIGURATION_ERROR
  579. * CONFIGURATION_ERROR}, {@link }
  580. * org.osid.scheduling.SchedulingException#UNIMPLEMENTED
  581. * UNIMPLEMENTED}, {@link }
  582. * org.osid.scheduling.SchedulingException#NULL_ARGUMENT
  583. * NULL_ARGUMENT}, {@link }
  584. * org.osid.scheduling.SchedulingException#UNKNOWN_TYPE
  585. * UNKNOWN_TYPE}
  586. *
  587. * @access public
  588. */
  589. function getPropertiesByType ( $propertiesType ) {
  590. $type =$this->getStatus();
  591. $propertiesType = new Type("PropertiesType", $type->getAuthority(), "properties");
  592. if($propertiesType->isEqualTo($propertiesType)){
  593. return $this->_getProperties();
  594. }
  595. return null;
  596. }
  597.  
  598. /**
  599. * Get the Properties associated with this ScheduleItem.
  600. *
  601. * @return object PropertiesIterator
  602. *
  603. * @throws object SchedulingException An exception with one of
  604. * the following messages defined in
  605. * org.osid.scheduling.SchedulingException may be thrown: {@link }
  606. * org.osid.scheduling.SchedulingException#OPERATION_FAILED
  607. * OPERATION_FAILED}, {@link }
  608. * org.osid.scheduling.SchedulingException#PERMISSION_DENIED
  609. * PERMISSION_DENIED}, {@link }
  610. * org.osid.scheduling.SchedulingException#CONFIGURATION_ERROR
  611. * CONFIGURATION_ERROR}, {@link }
  612. * org.osid.scheduling.SchedulingException#UNIMPLEMENTED
  613. * UNIMPLEMENTED}
  614. *
  615. * @access public
  616. */
  617. function getProperties () {
  618. $array = array($this->_getProperties());
  619. $ret = new HarmoniPropertiesIterator($array);
  620. return $ret;//return the iterator
  621. }
  622. function _getProperties(){
  623. $dbHandler = Services::getService("DBHandler");
  624. //get the record
  625. $query = new SelectQuery();
  626. $query->addTable('sc_item');
  627. $query->addColumn("*");
  628. $query->addWhere("id='".addslashes($this->_id->getIdString())."'");
  629. $res=$dbHandler->query($query);
  630. //make sure we can find that course
  631. if(!$res->hasMoreRows()){
  632. print "<b>Warning!</b> Can't get Properties of ScheduleItem with id ".$this->_id." since that id wasn't found in the database.";
  633. return null;
  634. }
  635. $row = $res->getCurrentRow();//grab (hopefully) the only row
  636. //make a type
  637. $type =$this->getStatus();
  638. $propertiesType = new Type("PropertiesType", $type->getAuthority(), "properties");
  639. //create a custom Properties object
  640. $idManager = Services::getService("Id");
  641. $property = new HarmoniProperties($propertiesType);
  642. $property->addProperty('display_name', $row['name']);
  643. $property->addProperty('description', $row['description']);
  644. $property->addProperty('id', $idManager->getId( $row['id']));
  645. $property->addProperty('start', $row['start_date']);
  646. $property->addProperty('end', $row['end_date']);
  647. $property->addProperty('master_identifier', $row['master_id']);
  648. $property->addProperty('status_type', $type);
  649.  
  650. $res->free();
  651. return $property;
  652. }
  653. // function getStatus () {
  654. // return $this->_getType('commit_stat');
  655. //}
  656. function _typeToIndex($typename, $type)
  657. {
  658. $sc=Services::getService("Scheduling");
  659. return $sc->_typeToIndex($typename, $type);
  660. }
  661. function _getTypes($typename)
  662. {
  663. $sc=Services::getService("Scheduling");
  664. return $sc->_getTypes($typename);
  665. }
  666. function _getField($key)
  667. {
  668. $sc=Services::getService("Scheduling");
  669. return $sc->_getField($this->_id,$this->_table,$key);
  670. }
  671. function _getType($typename){
  672. $sc=Services::getService("Scheduling");
  673. return $sc->_getType($this->_id,$this->_table,$typename);
  674. }
  675. function _setField($key, $value)
  676. {
  677. $sc=Services::getService("Scheduling");
  678. return $sc->_setField($this->_id,$this->_table,$key, $value);
  679. }
  680. }
  681.  
  682. ?>

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