18 parent::__construct($gui);
19 require_once
'Modules/Chatroom/classes/class.ilChatroomFormFactory.php';
20 require_once
'Modules/Chatroom/classes/class.ilChatroom.php';
21 require_once
'Modules/Chatroom/classes/class.ilChatroomUser.php';
24 public function byDayExport()
31 $ilTabs->activateSubTab(
'byday');
39 public function byDay($export =
false)
51 $tpl->addJavaScript(
'./Services/Form/js/date_duration.js');
53 $scope = $room->getRoomId();
58 $durationForm = $formFactory->getPeriodForm();
59 $durationForm->setTitle($lng->txt(
'history_byday_title'));
60 $durationForm->addCommandButton(
'history-byDayExport', $lng->txt(
'export'));
61 $durationForm->addCommandButton(
'history-byDay', $lng->txt(
'show'));
62 $durationForm->setFormAction($ilCtrl->getFormAction($this->gui),
'history-byDay');
66 $submit_request = strtolower(
$_SERVER[
'REQUEST_METHOD']) ==
'post';
70 if ($submit_request) {
71 if ($durationForm->checkInput()) {
72 $period = $durationForm->getItemByPostVar(
'timeperiod');
75 $from = $period->getStart(),
76 $to = $period->getEnd(),
77 $chat_user->getUserId(),
78 isset($_REQUEST[
'scope']) ? $_REQUEST[
'scope'] : 0
81 $psessions = $room->getPrivateRoomSessions(
84 $chat_user->getUserId(),
91 $durationForm->setValuesByPost();
94 $this->showMessages(
$messages, $durationForm, $export, $psessions,
$from, $to);
106 private function showMessages(
$messages, $durationForm, $export =
false, $psessions =
array(),
$from, $to)
115 include_once
'Modules/Chatroom/classes/class.ilChatroom.php';
119 $this->gui->switchToVisibleMode();
121 $tpl->addCSS(
'Modules/Chatroom/templates/default/style.css');
125 $roomTpl =
new ilTemplate(
'tpl.history_export.html',
true,
true,
'Modules/Chatroom');
127 $roomTpl =
new ilTemplate(
'tpl.history.html',
true,
true,
'Modules/Chatroom');
137 $time_format = $ilUser->getTimeFormat();
141 $lastDateTime = null;
145 switch ($message[
'message']->type) {
147 if (($_REQUEST[
'scope'] && $message[
'message']->subRoomId == $_REQUEST[
'scope']) || (!$_REQUEST[
'scope'] && !$message[
'message']->subRoomId)) {
152 $roomTpl->setCurrentBlock(
'MESSAGELINE');
153 $roomTpl->setVariable(
'MESSAGECONTENT', $message[
'message']->content);
154 $roomTpl->setVariable(
'MESSAGESENDER', $message[
'message']->from->username);
155 if (null == $lastDateTime ||
163 if ($prevDate != $currentDate) {
164 switch ($time_format) {
166 $date_string = $dateTime->get(
IL_CAL_FKT_DATE,
'H:i', $ilUser->getTimeZone());
169 $date_string = $dateTime->get(
IL_CAL_FKT_DATE,
'g:ia', $ilUser->getTimeZone());
173 $roomTpl->setVariable(
'MESSAGETIME', $date_string);
174 $prevDate = $currentDate;
177 $roomTpl->parseCurrentBlock();
179 $lastDateTime = $dateTime;
188 $scopes[$session[
'proom_id']] = $session[
'title'];
191 if (isset($scopes[
''])) {
195 if (!$messagesShown) {
197 $roomTpl->setVariable(
'LBL_NO_MESSAGES', $lng->txt(
'no_messages'));
200 asort($scopes, SORT_STRING);
202 $scopes =
array($lng->txt(
'main')) + $scopes;
204 if (count($scopes) > 1) {
208 if (isset($_REQUEST[
'scope'])) {
209 $select->setValue($_REQUEST[
'scope']);
212 $durationForm->addItem($select);
222 $unixFrom =
$from->getUnixTime();
223 $unixTo = $to->getUnixTime();
225 if ($unixFrom == $unixTo) {
235 $isPrivateRoom = (boolean) ((
int) $_REQUEST[
'scope']);
236 if ($isPrivateRoom) {
237 $roomTpl->setVariable(
'ROOM_TITLE', sprintf($lng->txt(
'history_title_private_room'), $scopes[(int) $_REQUEST[
'scope']]) .
' (' . $date_sub .
')');
239 $roomTpl->setVariable(
'ROOM_TITLE', sprintf($lng->txt(
'history_title_general'), $this->gui->object->getTitle()) .
' (' . $date_sub .
')');
244 header(
"Content-Type: text/html");
245 header(
"Content-Disposition: attachment; filename=\"" . urlencode($scopes[(
int) $_REQUEST[
'scope']] .
'.html') .
"\"");
246 echo $roomTpl->get();
250 $roomTpl->setVariable(
'PERIOD_FORM', $durationForm->getHTML());
252 $tpl->setVariable(
'ADM_CONTENT', $roomTpl->get());
255 public function bySessionExport()
262 $ilTabs->activateSubTab(
'bysession');
263 $this->bySession(
true);
270 public function bySession($export =
false)
281 $scope = $room->getRoomId();
286 $durationForm = $formFactory->getSessionForm($room->getSessions($chat_user));
287 $durationForm->setTitle($lng->txt(
'history_bysession_title'));
288 $durationForm->addCommandButton(
'history-bySessionExport', $lng->txt(
'export'));
289 $durationForm->addCommandButton(
'history-bySession', $lng->txt(
'show'));
290 $durationForm->setFormAction(
291 $ilCtrl->getFormAction($this->gui),
295 if (strtolower(
$_SERVER[
'REQUEST_METHOD']) ==
'post') {
296 $durationForm->checkInput();
297 $postVals = explode(
',',
$_POST[
'session']);
298 $durationForm->setValuesByArray(
array(
'session' =>
$_POST[
'session']));
303 $chat_user->getUserId(),
304 isset($_REQUEST[
'scope']) ? $_REQUEST[
'scope'] : 0
307 $last_session = $room->getLastSession($chat_user);
320 $chat_user->getUserId(),
321 isset($_REQUEST[
'scope']) ? $_REQUEST[
'scope'] : 0
326 $psessions = $room->getPrivateRoomSessions(
329 $chat_user->getUserId(),
335 $psessions =
array();
338 $psessions = $room->getPrivateRoomSessions(
341 $chat_user->getUserId(),
345 $this->showMessages(
$messages, $durationForm, $export, $psessions,
$from, $to);
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
redirectIfNoPermission($permission)
Checks for requested permissions and redirects if the permission check failed.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false)
Format a date public.
static setUseRelativeDates($a_status)
set use relative dates
static useRelativeDates()
check if relative dates are used
catch(Exception $e) $message
Class ilChatroomGUIHandler.
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
special template class to simplify handling of ITX/PEAR
Add a drawing to the header
executeDefault($method)
{}
Create styles array
The data for the language used.
static formatPeriod(ilDateTime $start, ilDateTime $end, $a_skip_starting_day=false)
Format a period of two date Shows: 14.
__construct(ilChatroomObjectGUI $gui)
{}
Class ilChatroom Keeps methods to prepare and display the history task.
static byObjectId($object_id)
Returns ilChatroom object by given $object_id.