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
00034 class ilObjRemoteCourse extends ilObject
00035 {
00036 const ACTIVATION_OFFLINE = 0;
00037 const ACTIVATION_UNLIMITED = 1;
00038 const ACTIVATION_LIMITED = 2;
00039
00040 protected $availability_type;
00041 protected $end;
00042 protected $start;
00043 protected $local_information;
00044
00051 public function __construct($a_id = 0,$a_call_by_reference = true)
00052 {
00053 global $ilDB;
00054
00055 $this->type = "rcrs";
00056 $this->ilObject($a_id,$a_call_by_reference);
00057 $this->db = $ilDB;
00058 }
00059
00068 public static function _lookupOnline($a_obj_id)
00069 {
00070 global $ilDB;
00071
00072 $query = "SELECT * FROM remote_course_settings ".
00073 "WHERE obj_id = ".$ilDB->quote($a_obj_id)." ";
00074 $res = $ilDB->query($query);
00075 $row = $res->fetchRow(DB_FETCHMODE_OBJECT);
00076 switch($row->availability_type)
00077 {
00078 case self::ACTIVATION_UNLIMITED:
00079 return true;
00080
00081 case self::ACTIVATION_OFFLINE:
00082 return false;
00083
00084 case self::ACTIVATION_LIMITED:
00085 return time() > $row->start && time < $row->end;
00086
00087 default:
00088 return false;
00089 }
00090
00091 return false;
00092 }
00093
00100 public function getLocalInformation()
00101 {
00102 return $this->local_information;
00103 }
00104
00112 public function setLocalInformation($a_info)
00113 {
00114 $this->local_information = $a_info;
00115 }
00116
00124 public function setAvailabilityType($a_type)
00125 {
00126 $this->availability_type = $a_type;
00127 }
00128
00135 public function getAvailabilityType()
00136 {
00137 return $this->availability_type;
00138 }
00139
00147 public function setStartingTime($a_time)
00148 {
00149 $this->start = $a_time;
00150 }
00151
00159 public function getStartingTime()
00160 {
00161 return $this->start;
00162 }
00163
00171 public function setEndingTime($a_time)
00172 {
00173 $this->end = $a_time;
00174 }
00175
00183 public function getEndingTime()
00184 {
00185 return $this->end;
00186 }
00187
00195 public function update()
00196 {
00197 global $ilDB;
00198
00199 if (!parent::update())
00200 {
00201 return false;
00202 }
00203
00204 $query = "REPLACE INTO remote_course_settings ".
00205 "SET availability_type = ".$this->db->quote($this->getAvailabilityType()).", ".
00206 "start = ".$this->db->quote($this->getStartingTime()).", ".
00207 "end = ".$this->db->quote($this->getEndingTime()).", ".
00208 "local_information = ".$this->db->quote($this->getLocalInformation()).", ".
00209 "obj_id = ".$this->db->quote($this->getId())." ";
00210 $this->db->query($query);
00211 return true;
00212 }
00213
00220 public function delete()
00221 {
00222 if(!parent::delete())
00223 {
00224 return false;
00225 }
00226
00227
00228
00229 return true;
00230 }
00231
00239 public function read($a_force_db = false)
00240 {
00241 parent::read($a_force_db);
00242
00243 $query = "SELECT * FROM remote_course_settings ".
00244 "WHERE obj_id = ".$this->db->quote($this->getId())." ";
00245 $res = $this->db->query($query);
00246 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00247 {
00248 $this->setLocalInformation($row->local_information);
00249 $this->setAvailabilityType($row->availability_type);
00250 $this->setStartingTime($row->start);
00251 $this->setEndingTime($row->end);
00252 }
00253 }
00254 }
00255 ?>