19declare(strict_types=1);
38 ?
string &$prev_date_time_presentation,
39 string $message_date_time_presentation,
44 if (
null === $prev_date_time ||
50 $prev_date_time = $message_date_time;
53 if ($prev_date_time_presentation !== $message_date_time_presentation) {
54 switch ($time_format) {
56 $date_string = $message_date_time->
get(
IL_CAL_FKT_DATE,
'H:i', $this->ilUser->getTimeZone());
60 $date_string = $message_date_time->
get(
IL_CAL_FKT_DATE,
'g:ia', $this->ilUser->getTimeZone());
64 $render_parts[
'MESSAGETIME'] = $date_string;
65 $prev_date_time_presentation = $message_date_time_presentation;
68 if ($render_parts !== []) {
69 $room_tpl->setCurrentBlock(
'datetime_line');
70 foreach ($render_parts as
$key => $value) {
71 $room_tpl->setVariable(
$key, $value);
73 $room_tpl->parseCurrentBlock();
79 $this->
tabs->activateSubTab(
'byday');
83 public function byDay(
bool $export =
false): void
86 $this->exitIfNoRoomExists($room);
88 $scope = $room->getRoomId();
93 $durationForm = $formFactory->getPeriodForm();
94 $durationForm->setTitle($this->ilLng->txt(
'history_byday_title'));
95 $durationForm->addCommandButton(
'history-byDayExport', $this->ilLng->txt(
'export'));
96 $durationForm->addCommandButton(
'history-byDay', $this->ilLng->txt(
'show'));
101 $submit_request = strtolower($this->
http->request()->getServerParams()[
'REQUEST_METHOD']) ===
'post';
105 if ($submit_request) {
106 if ($durationForm->checkInput()) {
107 $period = $durationForm->getItemByPostVar(
'timeperiod');
110 $from = $period->getStart(),
111 $to = $period->getEnd(),
112 $chat_user->getUserId(),
113 $this->getRequestValue(
'scope', $this->refinery->kindlyTo()->int(), 0)
116 $psessions = $room->getPrivateRoomSessions(
119 $chat_user->getUserId(),
126 $durationForm->setValuesByPost();
129 $this->showMessages(
$messages, $durationForm, $export, $psessions, $from, $to);
135 bool $export =
false,
136 array $psessions = [],
140 $this->redirectIfNoPermission(
'read');
142 $this->gui->switchToVisibleMode();
144 $this->mainTpl->addCss(
'Modules/Chatroom/templates/default/style.css');
148 $roomTpl =
new ilGlobalTemplate(
'tpl.history_export.html',
true,
true,
'Modules/Chatroom');
150 $roomTpl =
new ilTemplate(
'tpl.history.html',
true,
true,
'Modules/Chatroom');
154 $isScopeRequest = $this->hasRequestValue(
'scope');
155 $requestScope = $this->getRequestValue(
'scope', $this->
refinery->kindlyTo()->int(), 0);
161 $time_format = $this->ilUser->getTimeFormat();
164 $prev_date_time_presentation =
null;
165 $prev_date_time =
null;
167 switch (
$message[
'message']->type) {
173 (
int)
$message[
'message']->subRoomId === $requestScope
180 $this->renderDateTimeInformation(
185 $prev_date_time_presentation,
190 $roomTpl->setCurrentBlock(
'message_line');
191 $roomTpl->setVariable(
'MESSAGECONTENT',
$message[
'message']->content);
192 $roomTpl->setVariable(
'MESSAGESENDER',
$message[
'message']->from->username);
193 $roomTpl->parseCurrentBlock();
195 $roomTpl->setCurrentBlock(
'row');
196 $roomTpl->parseCurrentBlock();
212 if (!$messagesShown) {
213 $roomTpl->setVariable(
'LBL_NO_MESSAGES', $this->ilLng->txt(
'no_messages'));
224 if ($isScopeRequest) {
225 $select->setValue($requestScope);
228 $durationForm->
addItem($select);
235 $unixFrom = $from->getUnixTime();
236 $unixTo = $to->getUnixTime();
238 if ($unixFrom === $unixTo) {
248 $isPrivateRoom = $isScopeRequest;
249 if ($isPrivateRoom) {
250 $roomTpl->setVariable(
253 $this->ilLng->txt(
'history_title_private_room'),
255 ) .
' (' . $date_sub .
')'
258 $roomTpl->setVariable(
260 sprintf($this->ilLng->txt(
'history_title_general'), $this->gui->getObject()->getTitle()) .
' (' . $date_sub .
')'
273 $roomTpl->setVariable(
'PERIOD_FORM', $durationForm->
getHTML());
275 $this->mainTpl->setVariable(
'ADM_CONTENT', $roomTpl->get());
280 $this->
tabs->activateSubTab(
'bysession');
281 $this->bySession(
true);
287 $this->exitIfNoRoomExists($room);
289 $scope = $room->getRoomId();
294 $durationForm = $formFactory->getSessionForm($room->getSessions($chat_user));
295 $durationForm->
setTitle($this->ilLng->txt(
'history_bysession_title'));
296 $durationForm->
addCommandButton(
'history-bySessionExport', $this->ilLng->txt(
'export'));
297 $durationForm->
addCommandButton(
'history-bySession', $this->ilLng->txt(
'show'));
302 if (strtolower($this->
http->request()->getServerParams()[
'REQUEST_METHOD']) ===
'post') {
303 $session = $this->getRequestValue(
'session', $this->
refinery->kindlyTo()->string());
313 $chat_user->getUserId(),
314 $this->getRequestValue(
'scope', $this->refinery->kindlyTo()->int(), 0)
317 $last_session = $room->getLastSession($chat_user);
330 $chat_user->getUserId(),
331 $this->getRequestValue(
'scope', $this->refinery->kindlyTo()->int(), 0)
339 $psessions = $room->getPrivateRoomSessions(
342 $chat_user->getUserId(),
347 $this->showMessages(
$messages, $durationForm, $export, $psessions, $from, $to);
Class ilChatroomGUIHandler.
Class ilChatroom Keeps methods to prepare and display the history task.
renderDateTimeInformation( $room_tpl, ?ilDateTime &$prev_date_time, ilDateTime $message_date_time, ilDate $message_date, ?string &$prev_date_time_presentation, string $message_date_time_presentation, string $time_format)
byDay(bool $export=false)
showMessages(array $messages, ilPropertyFormGUI $durationForm, bool $export=false, array $psessions=[], ?ilDateTime $from=null, ?ilDateTime $to=null)
bySession(bool $export=false)
executeDefault(string $requestedMethod)
static byObjectId(int $object_id)
Class ilCtrl provides processing control methods.
getFormAction(object $a_gui_obj, string $a_fallback_cmd=null, string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
@inheritDoc
static formatPeriod(ilDateTime $start, ilDateTime $end, bool $a_skip_starting_day=false)
Format a period of two dates Shows: 14.
static useRelativeDates()
static setUseRelativeDates(bool $a_status)
set use relative dates
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
@classDescription Date and time handling
get(int $a_format, string $a_format_str='', string $a_tz='')
get formatted date
static getASCIIFilename(string $a_filename)
special template class to simplify handling of ITX/PEAR
special template class to simplify handling of ITX/PEAR
static deliverData(string $a_data, string $a_filename, string $mime="application/octet-stream")
static http()
Fetches the global http state from ILIAS.
$messages
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...