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 ilChatRecording
00034 {
00035 var $ilias;
00036 var $lng;
00037
00038 var $error_msg;
00039
00040 var $obj_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 ilChatRecording($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->setObjId($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 setObjId($a_id)
00084 {
00085 $this->obj_id = $a_id;
00086 }
00087 function getObjId()
00088 {
00089 return $this->obj_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 getStartTime()
00102 {
00103 return $this->data["start_time"];
00104 }
00105 function getEndTime()
00106 {
00107 return $this->data["end_time"];
00108 }
00109
00110 function setModeratorId($a_id)
00111 {
00112 $this->moderator_id = $a_id;
00113 }
00114 function getModeratorId()
00115 {
00116 return $this->moderator_id;
00117 }
00118
00119 function setRecord($a_data)
00120 {
00121 $this->data = $a_data;
00122 }
00123 function getRecord($a_id = 0)
00124 {
00125 if ($a_id != 0)
00126 {
00127 $this->setRecordId($a_id);
00128 }
00129
00130 $query = "SELECT * FROM chat_records WHERE
00131 record_id = '" . addslashes($this->getRecordId()) . "'";
00132 $res = $this->ilias->db->query($query);
00133 if (DB::isError($res)) die("ilChatRecording::getRecord(): " . $res->getMessage() . "<br>SQL-Statement: ".$q);
00134
00135 $data = array();
00136 $status = false;
00137 if ($res->numRows() > 0)
00138 {
00139 $data = $res->fetchRow(DB_FETCHMODE_ASSOC);
00140 $status = true;
00141 }
00142
00143 $this->setRecord($data);
00144 return $status;
00145 }
00146
00147 function setTitle($a_title)
00148 {
00149 $this->data["title"] = $a_title;
00150 }
00151 function getTitle()
00152 {
00153 return $this->data["title"];
00154 }
00155
00156 function setDescription($a_description)
00157 {
00158 $this->data["description"] = $a_description;
00159 }
00160 function getDescription()
00161 {
00162 return $this->data["description"];
00163 }
00164
00165 function startRecording($a_title = "")
00166 {
00167 $query = "INSERT INTO chat_records SET
00168 moderator_id = '" . $this->getModeratorId() . "',
00169 chat_id = '" . $this->getObjId() . "',
00170 room_id = '" . $this->getRoomId() . "',
00171 title = '" . (($a_title == "") ? "-N/A-" : addslashes($a_title)) . "',
00172 start_time = '" . time() . "'";
00173 $res = $this->ilias->db->query($query);
00174 if (DB::isError($res))
00175 die("ilChatRecording::startRecording(): " . $res->getMessage() . "<br>SQL-Statement: ".$q);
00176
00177 $query = "SELECT LAST_INSERT_ID()";
00178 $res = $this->ilias->db->query($query);
00179 if (DB::isError($res))
00180 die("ilChatRecording::startRecording(): " . $res->getMessage() . "<br>SQL-Statement: ".$q);
00181
00182 if ($res->numRows() > 0)
00183 {
00184 $lastId = $res->fetchRow();
00185 $this->setRecordId($lastId[0]);
00186
00187 $this->getRecord();
00188 }
00189 }
00190
00191 function stopRecording()
00192 {
00193 $query = "UPDATE chat_records SET
00194 end_time = '" . time() . "' WHERE
00195 chat_id = '" . $this->getObjId() . "' AND
00196 room_id = '" . $this->getRoomId() . "'";
00197 $res = $this->ilias->db->query($query);
00198 if (DB::isError($res)) die("ilChatRecording::stopRecording(): " . $res->getMessage() . "<br>SQL-Statement: ".$q);
00199
00200 $this->setRecordId(0);
00201
00202 $data = array();
00203 $this->setRecord($data);
00204 }
00205
00206 function isRecording()
00207 {
00208 $query = "SELECT record_id FROM chat_records WHERE
00209 chat_id = '" . $this->getObjId() . "' AND
00210 room_id = '" . $this->getRoomId() . "' AND
00211 start_time > 0 AND
00212 end_time = 0";
00213 $res = $this->ilias->db->query($query);
00214 if (DB::isError($res)) die("ilChatRecording::isRecording(): " . $res->getMessage() . "<br>SQL-Statement: ".$q);
00215
00216 if ($res->numRows() > 0)
00217 {
00218 $id = $res->fetchRow(DB_FETCHMODE_ASSOC);
00219 $this->setRecordId($id["record_id"]);
00220
00221 $this->getRecord();
00222 return true;
00223 }
00224
00225 return false;
00226 }
00227
00228 function getRecordings()
00229 {
00230 $query = "SELECT * FROM chat_records WHERE
00231 chat_id = '" . $this->getObjId() . "'";
00232 $res = $this->ilias->db->query($query);
00233 if (DB::isError($res)) die("ilChatRecording::getRecordings(): " . $res->getMessage() . "<br>SQL-Statement: ".$q);
00234
00235 if (($num = $res->numRows()) > 0)
00236 {
00237 for ($i = 0; $i < $num; $i++)
00238 {
00239 $data[] = $res->fetchRow(DB_FETCHMODE_ASSOC);
00240 }
00241 return $data;
00242 }
00243
00244 return false;
00245 }
00246
00247 function getModerator($a_id = 0)
00248 {
00249 if ($a_id == 0)
00250 {
00251 $a_id = $this->getModeratorId();
00252 }
00253
00254 return ilObjUser::_lookupLogin($a_id);
00255 }
00256
00257 function delete($a_id = 0)
00258 {
00259 if ($a_id == 0 ||
00260 $a_id == $this->getRecordId())
00261 {
00262 $a_id = $this->getRecordId();
00263 $this->setRecordId(0);
00264
00265 $data = array();
00266 $this->setRecord($data);
00267 }
00268
00269 $query = "DELETE FROM chat_records WHERE
00270 record_id = '" . $a_id . "'";
00271 $res = $this->ilias->db->query($query);
00272 if (DB::isError($res)) die("ilChatRecording::delete(): " . $res->getMessage() . "<br>SQL-Statement: ".$q);
00273
00274 $query = "DELETE FROM chat_record_data WHERE
00275 record_id = '" . $a_id . "'";
00276 $res = $this->ilias->db->query($query);
00277 if (DB::isError($res)) die("ilChatRecording::delete(): " . $res->getMessage() . "<br>SQL-Statement: ".$q);
00278 }
00279
00280 function exportMessages()
00281 {
00282 $query = "SELECT message FROM chat_record_data WHERE
00283 record_id = '" . $this->getRecordId() . "' ORDER BY
00284 msg_time ASC";
00285 $res = $this->ilias->db->query($query);
00286 if (DB::isError($res)) die("ilChatRecording::exportMessages(): " . $res->getMessage() . "<br>SQL-Statement: ".$q);
00287
00288 $html = "";
00289 if (($num = $res->numRows()) > 0)
00290 {
00291 $html = "";
00292 for ($i = 0; $i < $num; $i++)
00293 {
00294 $data = $res->fetchRow(DB_FETCHMODE_ASSOC);
00295 $html .= $data["message"] . "<br />\n";
00296 }
00297 }
00298
00299 return $html;
00300 }
00301
00302 }
00303 ?>