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 ilTimingAccepted
00037 {
00038 var $ilErr;
00039 var $ilDB;
00040 var $lng;
00041
00042 function ilTimingAccepted($crs_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->crs_id = $crs_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 getCourseId()
00061 {
00062 return $this->crs_id;
00063 }
00064 function accept($a_status)
00065 {
00066 $this->accepted = $a_status;
00067 }
00068 function isAccepted()
00069 {
00070 return $this->accepted ? true : false;
00071 }
00072 function setRemark($a_remark)
00073 {
00074 $this->remark = $a_remark;
00075 }
00076 function getRemark()
00077 {
00078 return $this->remark;
00079 }
00080 function setVisible($a_visible)
00081 {
00082 $this->visible = $a_visible;
00083 }
00084 function isVisible()
00085 {
00086 return $this->visible ? true : false;
00087 }
00088
00089 function update()
00090 {
00091 ilTimingAccepted::_delete($this->getCourseId(),$this->getUserId());
00092 $this->create();
00093 return true;
00094 }
00095
00096 function create()
00097 {
00098 $query = "INSERT INTO crs_timings_usr_accept ".
00099 "SET crs_id = '".$this->getCourseId()."', ".
00100 "usr_id = '".$this->getUserId()."', ".
00101 "visible = '".(int) $this->isVisible()."', ".
00102 "accept = '".(int) $this->isAccepted()."', ".
00103 "remark = '".ilUtil::prepareDBString($this->getRemark())."'";
00104 $this->db->query($query);
00105 }
00106
00107 function delete()
00108 {
00109 return ilTimingAccepted::_delete($this->getCourseId(),$this->getUserId());
00110 }
00111
00112 function _delete($a_crs_id,$a_usr_id)
00113 {
00114 global $ilDB;
00115
00116 $query = "DELETE FROM crs_timings_usr_accept ".
00117 "WHERE crs_id = '".$a_crs_id."' ".
00118 "AND usr_id = '".$a_usr_id."'";
00119 $ilDB->query($query);
00120 }
00121
00122 function _deleteByCourse($a_crs_id)
00123 {
00124 global $ilDB;
00125
00126 $query = "DELETE FROM crs_timings_usr_accept ".
00127 "WHERE crs_id = '".$a_crs_id."'";
00128 $ilDB->query($query);
00129 }
00130
00131 function _deleteByUser($a_usr_id)
00132 {
00133 global $ilDB;
00134
00135 $query = "DELETE FROM crs_timings_usr_accept ".
00136 "WHERE usr_id = '".$a_usr_id."'";
00137 $ilDB->query($query);
00138 }
00139
00140 function __read()
00141 {
00142 $query = "SELECT * FROM crs_timings_usr_accept ".
00143 "WHERE crs_id = '".$this->getCourseId()."' ".
00144 "AND usr_id = '".$this->getUserId()."'";
00145 $res = $this->db->query($query);
00146 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00147 {
00148 $this->setVisible($row->visible);
00149 $this->setRemark($row->remark);
00150 $this->accept($row->accept);
00151 }
00152 return true;
00153 }
00154 }
00155 ?>