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
00036 class ilTimingPlaned
00037 {
00038 var $ilErr;
00039 var $ilDB;
00040 var $lng;
00041
00042 function ilTimingPlaned($item_id,$a_usr_id)
00043 {
00044 global $ilErr,$ilDB,$lng,$tree;
00045
00046 $this->ilErr =& $ilErr;
00047 $this->db =& $ilDB;
00048 $this->lng =& $lng;
00049
00050 $this->item_id = $item_id;
00051 $this->user_id = $a_usr_id;
00052
00053 $this->__read();
00054 }
00055
00056 function getUserId()
00057 {
00058 return $this->user_id;
00059 }
00060 function getItemId()
00061 {
00062 return $this->item_id;
00063 }
00064
00065 function getPlanedStartingTime()
00066 {
00067 return $this->start;
00068 }
00069 function setPlanedStartingTime($a_time)
00070 {
00071 $this->start = $a_time;
00072 }
00073 function getPlanedEndingTime()
00074 {
00075 return $this->end;
00076 }
00077 function setPlanedEndingTime($a_end)
00078 {
00079 $this->end = $a_end;
00080 }
00081
00082 function validate()
00083 {
00084 include_once 'course/classes/class.ilCourseItems.php';
00085 $item_data = ilCourseItems::_getItem($this->getItemId());
00086
00087 if($this->getPlanedEndingTime() > $item_data['latest_end'])
00088 {
00089 return false;
00090 }
00091 return true;
00092 }
00093
00094 function update()
00095 {
00096 ilTimingPlaned::_delete($this->getItemId(),$this->getUserId());
00097 $this->create();
00098 return true;
00099 }
00100
00101 function create()
00102 {
00103 $query = "INSERT INTO crs_timings_planed ".
00104 "SET item_id = '".$this->getItemId()."', ".
00105 "usr_id = '".$this->getUserId()."', ".
00106 "planed_start = '".(int) $this->getPlanedStartingTime()."', ".
00107 "planed_end = '".(int) $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 = '".$a_item_id."' ".
00122 "AND usr_id = '".$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 = '".$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 = '".$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 = '".$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 = '".$a_usr_id."'";
00174 $ilDB->query($query);
00175 }
00176
00177 function __read()
00178 {
00179 $query = "SELECT * FROM crs_timings_planed ".
00180 "WHERE item_id = '".$this->getItemId()."' ".
00181 "AND usr_id = '".$this->getUserId()."'";
00182 $res = $this->db->query($query);
00183 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00184 {
00185 $this->setPlanedStartingTime($row->planed_start);
00186 $this->setPlanedEndingTime($row->planed_end);
00187 }
00188 return true;
00189 }
00190 }
00191 ?>