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';
72 if($durationForm->checkInput())
74 $period = $durationForm->getItemByPostVar(
'timeperiod');
77 $from = $period->getStart(),
78 $to = $period->getEnd(),
79 $chat_user->getUserId(),
80 isset($_REQUEST[
'scope']) ? $_REQUEST[
'scope'] : 0
83 $psessions = $room->getPrivateRoomSessions(
86 $chat_user->getUserId(),
95 $durationForm->setValuesByPost();
98 $this->showMessages(
$messages, $durationForm, $export, $psessions, $from, $to);
110 private function showMessages(
$messages, $durationForm, $export =
false, $psessions =
array(), $from, $to)
119 include_once
'Modules/Chatroom/classes/class.ilChatroom.php';
123 $ilCtrl->setParameterByClass(
"ilrepositorygui",
"ref_id", ROOT_FOLDER_ID);
124 $ilCtrl->redirectByClass(
"ilrepositorygui",
"");
127 $this->gui->switchToVisibleMode();
129 $tpl->addCSS(
'Modules/Chatroom/templates/default/style.css');
134 $roomTpl =
new ilTemplate(
'tpl.history_export.html',
true,
true,
'Modules/Chatroom');
138 $roomTpl =
new ilTemplate(
'tpl.history.html',
true,
true,
'Modules/Chatroom');
149 $time_format = $ilUser->getTimeFormat();
153 $lastDateTime = null;
158 switch($message[
'message']->type)
161 if(($_REQUEST[
'scope'] && $message[
'message']->subRoomId == $_REQUEST[
'scope']) || (!$_REQUEST[
'scope'] && !$message[
'message']->subRoomId))
167 $roomTpl->setCurrentBlock(
'MESSAGELINE');
168 $roomTpl->setVariable(
'MESSAGECONTENT', $message[
'message']->content);
169 $roomTpl->setVariable(
'MESSAGESENDER', $message[
'message']->from->username);
170 if(null == $lastDateTime ||
179 if($prevDate != $currentDate)
184 $date_string = $dateTime->get(
IL_CAL_FKT_DATE,
'H:i', $ilUser->getTimeZone());
187 $date_string = $dateTime->get(
IL_CAL_FKT_DATE,
'g:ia', $ilUser->getTimeZone());
191 $roomTpl->setVariable(
'MESSAGETIME', $date_string);
192 $prevDate = $currentDate;
195 $roomTpl->parseCurrentBlock();
197 $lastDateTime = $dateTime;
205 foreach($psessions as $session)
207 $scopes[$session[
'proom_id']] = $session[
'title'];
210 if(isset($scopes[
'']))
218 $roomTpl->setVariable(
'LBL_NO_MESSAGES', $lng->txt(
'no_messages'));
221 asort($scopes, SORT_STRING);
223 $scopes =
array($lng->txt(
'main')) + $scopes;
225 if(count($scopes) > 1)
230 if(isset($_REQUEST[
'scope']))
232 $select->setValue($_REQUEST[
'scope']);
235 $durationForm->addItem($select);
246 $unixFrom = $from->getUnixTime();
247 $unixTo = $to->getUnixTime();
249 if($unixFrom == $unixTo)
262 $isPrivateRoom = (boolean)((
int)$_REQUEST[
'scope']);
265 $roomTpl->setVariable(
'ROOM_TITLE', sprintf($lng->txt(
'history_title_private_room'), $scopes[(int)$_REQUEST[
'scope']]) .
' (' . $date_sub .
')');
269 $roomTpl->setVariable(
'ROOM_TITLE', sprintf($lng->txt(
'history_title_general'), $this->gui->object->getTitle()) .
' (' . $date_sub .
')');
275 header(
"Content-Type: text/html");
276 header(
"Content-Disposition: attachment; filename=\"" . urlencode($scopes[(
int)$_REQUEST[
'scope']] .
'.html') .
"\"");
277 echo $roomTpl->get();
281 $roomTpl->setVariable(
'PERIOD_FORM', $durationForm->getHTML());
283 $tpl->setVariable(
'ADM_CONTENT', $roomTpl->get());
286 public function bySessionExport()
293 $ilTabs->activateSubTab(
'bysession');
294 $this->bySession(
true);
301 public function bySession($export =
false)
312 $scope = $room->getRoomId();
317 $durationForm = $formFactory->getSessionForm($room->getSessions($chat_user));
318 $durationForm->setTitle($lng->txt(
'history_bysession_title'));
319 $durationForm->addCommandButton(
'history-bySessionExport', $lng->txt(
'export'));
320 $durationForm->addCommandButton(
'history-bySession', $lng->txt(
'show'));
321 $durationForm->setFormAction(
322 $ilCtrl->getFormAction($this->gui),
'history-bySession' 325 if(strtolower(
$_SERVER[
'REQUEST_METHOD']) ==
'post')
327 $durationForm->checkInput();
328 $postVals = explode(
',',
$_POST[
'session']);
329 $durationForm->setValuesByArray(
array(
'session' =>
$_POST[
'session']));
334 $chat_user->getUserId(),
335 isset($_REQUEST[
'scope']) ? $_REQUEST[
'scope'] : 0
340 $last_session = $room->getLastSession($chat_user);
356 $chat_user->getUserId(),
357 isset($_REQUEST[
'scope']) ? $_REQUEST[
'scope'] : 0
363 $psessions = $room->getPrivateRoomSessions(
366 $chat_user->getUserId(),
374 $psessions =
array();
377 $psessions = $room->getPrivateRoomSessions(
380 $chat_user->getUserId(),
384 $this->showMessages(
$messages, $durationForm, $export, $psessions, $from, $to);
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
static formatPeriod(ilDateTime $start, ilDateTime $end)
Format a period of two date Shows: 14.
static setUseRelativeDates($a_status)
set use relative dates
static useRelativeDates()
check if relative dates are used
static checkUserPermissions($permissions, $ref_id, $send_info=true)
Checks user permissions by given array and ref_id.
Class ilChatroomGUIHandler.
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
special template class to simplify handling of ITX/PEAR
static formatDate(ilDateTime $date)
Format a date public.
Add a drawing to the header
executeDefault($method)
{}
Create styles array
The data for the language used.
__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.