Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00034 class ilTimingPlaned
00035 {
00036 var $ilErr;
00037 var $ilDB;
00038 var $lng;
00039
00040 function ilTimingPlaned($item_id,$a_usr_id)
00041 {
00042 global $ilErr,$ilDB,$lng,$tree;
00043
00044 $this->ilErr =& $ilErr;
00045 $this->db =& $ilDB;
00046 $this->lng =& $lng;
00047
00048 $this->item_id = $item_id;
00049 $this->user_id = $a_usr_id;
00050
00051 $this->__read();
00052 }
00053
00054 function getUserId()
00055 {
00056 return $this->user_id;
00057 }
00058 function getItemId()
00059 {
00060 return $this->item_id;
00061 }
00062
00063 function getPlanedStartingTime()
00064 {
00065 return $this->start;
00066 }
00067 function setPlanedStartingTime($a_time)
00068 {
00069 $this->start = $a_time;
00070 }
00071 function getPlanedEndingTime()
00072 {
00073 return $this->end;
00074 }
00075 function setPlanedEndingTime($a_end)
00076 {
00077 $this->end = $a_end;
00078 }
00079
00080 function validate()
00081 {
00082 include_once 'Modules/Course/classes/class.ilCourseItems.php';
00083 $item_data = ilCourseItems::_getItem($this->getItemId());
00084
00085 if($this->getPlanedEndingTime() > $item_data['latest_end'])
00086 {
00087 return false;
00088 }
00089 return true;
00090 }
00091
00092 function update()
00093 {
00094 ilTimingPlaned::_delete($this->getItemId(),$this->getUserId());
00095 $this->create();
00096 return true;
00097 }
00098
00099 function create()
00100 {
00101 global $ilDB;
00102
00103 $query = "INSERT INTO crs_timings_planed ".
00104 "SET item_id = ".$ilDB->quote($this->getItemId()).", ".
00105 "usr_id = ".$ilDB->quote($this->getUserId()).", ".
00106 "planed_start = ".$ilDB->quote($this->getPlanedStartingTime()).", ".
00107 "planed_end = ".$ilDB->quote($this->getPlanedEndingTime())." ";
00108 $this->db->query($query);
00109 }
00110
00111 function delete()
00112 {
00113 return ilTimingPlaned::_delete($this->getItemId(),$this->getUserId());
00114 }
00115
00116 function _delete($a_item_id,$a_usr_id)
00117 {
00118 global $ilDB;
00119
00120 $query = "DELETE FROM crs_timings_planed ".
00121 "WHERE item_id = ".$ilDB->quote($a_item_id)." ".
00122 "AND usr_id = ".$ilDB->quote($a_usr_id)." ";
00123 $ilDB->query($query);
00124 }
00125
00126
00127 function _getPlanedTimings($a_usr_id,$a_item_id)
00128 {
00129 global $ilDB;
00130
00131 $query = "SELECT * FROM crs_timings_planed ".
00132 "WHERE item_id = ".$ilDB->quote($a_item_id)." ".
00133 "AND usr_id = ".$a_usr_id." ";
00134 $res = $ilDB->query($query);
00135 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00136 {
00137 $data['planed_start'] = $row->planed_start;
00138 $data['planed_end'] = $row->planed_end;
00139 }
00140 return $data ? $data : array();
00141 }
00142
00143
00144 function _getPlanedTimingsByItem($a_item_id)
00145 {
00146 global $ilDB;
00147
00148 $query = "SELECT * FROM crs_timings_planed ".
00149 "WHERE item_id = ".$ilDB->quote($a_item_id)." ";
00150 $res = $ilDB->query($query);
00151 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00152 {
00153 $data[$row->usr_id]['start'] = $row->planed_start;
00154 $data[$row->usr_id]['end'] = $row->planed_end;
00155 }
00156 return $data ? $data : array();
00157 }
00158
00159 function _deleteByItem($a_item_id)
00160 {
00161 global $ilDB;
00162
00163 $query = "DELETE FROM crs_timings_planed ".
00164 "WHERE item_id = ".$ilDB->quote($a_item_id)." ";
00165 $ilDB->query($query);
00166 }
00167
00168 function _deleteByUser($a_usr_id)
00169 {
00170 global $ilDB;
00171
00172 $query = "DELETE FROM crs_timings_planed ".
00173 "WHERE usr_id = ".$ilDB->quote($a_usr_id)." ";
00174 $ilDB->query($query);
00175 }
00176
00177 function __read()
00178 {
00179 global $ilDB;
00180
00181 $query = "SELECT * FROM crs_timings_planed ".
00182 "WHERE item_id = ".$ilDB->quote($this->getItemId())." ".
00183 "AND usr_id = ".$ilDB->quote($this->getUserId())." ";
00184 $res = $this->db->query($query);
00185 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00186 {
00187 $this->setPlanedStartingTime($row->planed_start);
00188 $this->setPlanedEndingTime($row->planed_end);
00189 }
00190 return true;
00191 }
00192 }
00193 ?>