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
00033 class ilChatRecord
00034 {
00035 var $ilias;
00036 var $lng;
00037
00038 var $error_msg;
00039
00040 var $ref_id = 0;
00041 var $moderator_id = 0;
00042 var $room_id = 0;
00043 var $record_id = 0;
00044
00045 var $data = array();
00046
00053 function ilChatRecord($a_id = 0)
00054 {
00055 global $ilias,$lng;
00056
00057 define(MAX_TIME,60*60*24);
00058
00059 $this->ilias =& $ilias;
00060 $this->lng =& $lng;
00061
00062 if ($a_id > 0)
00063 {
00064 $this->setRefId($a_id);
00065 }
00066 }
00067
00068
00069 function getErrorMessage()
00070 {
00071 return $this->error_msg;
00072 }
00073
00074 function setRoomId($a_id)
00075 {
00076 $this->room_id = $a_id;
00077 }
00078 function getRoomId()
00079 {
00080 return $this->room_id;
00081 }
00082
00083 function setRefId($a_id)
00084 {
00085 $this->ref_id = $a_id;
00086 }
00087 function getRefId()
00088 {
00089 return $this->ref_id;
00090 }
00091
00092 function setRecordId($a_id)
00093 {
00094 $this->record_id = $a_id;
00095 }
00096 function getRecordId()
00097 {
00098 return $this->record_id;
00099 }
00100
00101 function setModeratorId($a_id)
00102 {
00103 $this->moderator_id = $a_id;
00104 }
00105 function getModeratorId()
00106 {
00107 return $this->moderator_id;
00108 }
00109
00110 function setRecord($a_data)
00111 {
00112 $this->data = $a_data;
00113 }
00114 function getRecord($a_id = 0)
00115 {
00116 if ($a_id != 0)
00117 {
00118 $this->setRecordId($a_id);
00119 }
00120
00121 $query = "SELECT * FROM chat_records WHERE
00122 record_id = '" . addslashes($this->getRecordId()) . "'";
00123 $res = $this->ilias->db->query($query);
00124 if (DB::isError($res)) die("ilChatRecord::getRecord(): " . $res->getMessage() . "<br>SQL-Statement: ".$q);
00125
00126 $data = array();
00127 if ($res->numRows() > 0)
00128 {
00129 $data = $res->fetchRow(DB_FETCHMODE_ASSOC);
00130 }
00131 $this->setRecord($data);
00132 }
00133
00134 function setTitle($a_title)
00135 {
00136 $this->data["title"] = $a_title;
00137 }
00138 function getTitle()
00139 {
00140 return $this->data["title"];
00141 }
00142
00143 function setDescription($a_description)
00144 {
00145 $this->data["description"] = $a_description;
00146 }
00147 function getDescription()
00148 {
00149 return $this->data["description"];
00150 }
00151
00152 function startRecording($a_title = "")
00153 {
00154 $query = "INSERT INTO chat_records SET
00155 moderator_id = '" . $this->getModeratorId() . "',
00156 chat_id = '" . $this->getRefId() . "',
00157 room_id = '" . $this->getRoomId() . "',
00158 title = '" . addslashes($a_title) . "',
00159 start_time = '" . time() . "'";
00160 $res = $this->ilias->db->query($query);
00161 if (DB::isError($res)) die("ilChatRecord::startRecording(): " . $res->getMessage() . "<br>SQL-Statement: ".$q);
00162
00163 $query = "SELECT LAST_INSERT_ID()";
00164 $res = $this->ilias->db->query($query);
00165 if (DB::isError($res)) die("ilChatRecord::startRecording(): " . $res->getMessage() . "<br>SQL-Statement: ".$q);
00166
00167 if ($res->numRows() > 0)
00168 {
00169 $lastId = $res->fetchRow();
00170 $this->setRecordId($lastId[0]);
00171
00172 $this->getRecord();
00173 }
00174 }
00175
00176 function stopRecording()
00177 {
00178 $query = "UPDATE chat_records SET
00179 end_time = '" . time() . "' WHERE
00180 chat_id = '" . $this->getRefId() . "' AND
00181 room_id = '" . $this->getRoomId() . "'";
00182 $res = $this->ilias->db->query($query);
00183 if (DB::isError($res)) die("ilChatRecord::stopRecording(): " . $res->getMessage() . "<br>SQL-Statement: ".$q);
00184
00185 $this->setRecordId(0);
00186
00187 $data = array();
00188 $this->setRecord($data);
00189 }
00190
00191 function isRecording()
00192 {
00193 $query = "SELECT record_id FROM chat_records WHERE
00194 chat_id = '" . $this->getRefId() . "' AND
00195 room_id = '" . $this->getRoomId() . "' AND
00196 start_time > 0 AND
00197 end_time = 0";
00198 $res = $this->ilias->db->query($query);
00199 if (DB::isError($res)) die("ilChatRecord::isRecording(): " . $res->getMessage() . "<br>SQL-Statement: ".$q);
00200
00201 if ($res->numRows() > 0)
00202 {
00203 $id = $res->fetchRow(DB_FETCHMODE_ASSOC);
00204 $this->setRecordId($id["record_id"]);
00205
00206 $this->getRecord();
00207 return true;
00208 }
00209
00210 return false;
00211 }
00212
00213 }
00214 ?>