19 declare(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 $date_string = match ($time_format) {
58 $this->ilUser->getTimeZone()
60 default => $message_date_time->
get(
IL_CAL_FKT_DATE,
'g:ia', $this->ilUser->getTimeZone()),
63 $render_parts[
'MESSAGETIME'] = $date_string;
64 $prev_date_time_presentation = $message_date_time_presentation;
67 if ($render_parts !== []) {
68 $room_tpl->setCurrentBlock(
'datetime_line');
69 foreach ($render_parts as
$key => $value) {
70 $room_tpl->setVariable(
$key, $value);
72 $room_tpl->parseCurrentBlock();
78 $this->
tabs->activateSubTab(
'byday');
82 public function byDay(
bool $export =
false): void
90 $durationForm = $formFactory->getPeriodForm();
91 $durationForm->setTitle($this->ilLng->txt(
'history_byday_title'));
92 $durationForm->addCommandButton(
'history-byDayExport', $this->ilLng->txt(
'export'));
93 $durationForm->addCommandButton(
'history-byDay', $this->ilLng->txt(
'show'));
94 $durationForm->setFormAction($this->
ilCtrl->getFormAction($this->gui,
'history-byDay'));
97 $submit_request = strtolower($this->
http->request()->getServerParams()[
'REQUEST_METHOD']) ===
'post';
101 if ($submit_request) {
102 if ($durationForm->checkInput()) {
103 $period = $durationForm->getItemByPostVar(
'timeperiod');
106 $from = $period->getStart(),
107 $to = $period->getEnd(),
108 $chat_user->getUserId()
114 $durationForm->setValuesByPost();
123 bool $export =
false,
129 $this->gui->switchToVisibleMode();
131 $this->mainTpl->addCss(
'Modules/Chatroom/templates/default/style.css');
135 $roomTpl =
new ilGlobalTemplate(
'tpl.history_export.html',
true,
true,
'Modules/Chatroom');
137 $roomTpl =
new ilTemplate(
'tpl.history.html',
true,
true,
'Modules/Chatroom');
144 $time_format = $this->ilUser->getTimeFormat();
146 $num_messages_shown = 0;
147 $prev_date_time_presentation = null;
148 $prev_date_time = null;
150 switch ($message[
'message']->type) {
161 $prev_date_time_presentation,
162 $message_date_time_presentation,
166 $roomTpl->setCurrentBlock(
'message_line');
167 $roomTpl->setVariable(
'MESSAGECONTENT', $message[
'message']->content);
168 $roomTpl->setVariable(
'MESSAGESENDER', $message[
'message']->
from->username);
169 $roomTpl->parseCurrentBlock();
171 $roomTpl->setCurrentBlock(
'row');
172 $roomTpl->parseCurrentBlock();
174 ++$num_messages_shown;
179 if (!$num_messages_shown) {
180 $roomTpl->setVariable(
'LBL_NO_MESSAGES', $this->ilLng->txt(
'no_messages'));
183 $scope = $this->ilLng->txt(
'main');
189 $unixFrom = $from->getUnixTime();
190 $unixTo = $to->getUnixTime();
192 if ($unixFrom === $unixTo) {
202 $roomTpl->setVariable(
204 sprintf($this->ilLng->txt(
'history_title_general'), $this->gui->getObject()->getTitle()) .
' (' . $date_sub .
')' 216 $roomTpl->setVariable(
'PERIOD_FORM', $durationForm->
getHTML());
218 $this->mainTpl->setVariable(
'ADM_CONTENT', $roomTpl->get());
223 $this->
tabs->activateSubTab(
'bysession');
232 $scope = $room->getRoomId();
237 $durationForm = $formFactory->getSessionForm($room->getSessions($chat_user));
238 $durationForm->setTitle($this->ilLng->txt(
'history_bysession_title'));
239 $durationForm->addCommandButton(
'history-bySessionExport', $this->ilLng->txt(
'export'));
240 $durationForm->addCommandButton(
'history-bySession', $this->ilLng->txt(
'show'));
241 $durationForm->setFormAction(
242 $this->
ilCtrl->getFormAction($this->gui,
'history-bySession')
245 if (strtolower($this->
http->request()->getServerParams()[
'REQUEST_METHOD']) ===
'post') {
247 $durationForm->checkInput();
248 $postVals = explode(
',', (
string) $session);
249 $durationForm->setValuesByArray([
250 'session' => $session
256 $chat_user->getUserId()
259 $last_session = $room->getLastSession($chat_user);
272 $chat_user->getUserId()
get(int $a_format, string $a_format_str='', string $a_tz='')
get formatted date
special template class to simplify handling of ITX/PEAR
redirectIfNoPermission($permission)
Checks for requested permissions and redirects if the permission check failed.
getRequestValue(string $key, Transformation $trafo, $default=null)
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
exitIfNoRoomExists(?ilChatroom $room)
Checks if a ilChatroom exists.
byDay(bool $export=false)
static deliverData(string $a_data, string $a_filename, string $mime="application/octet-stream")
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)
static useRelativeDates()
static getASCIIFilename(string $a_filename)
$messages
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static http()
Fetches the global http state from ILIAS.
Class ilChatroomGUIHandler.
showMessages(array $messages, ilPropertyFormGUI $durationForm, bool $export=false, ?ilDateTime $from=null, ?ilDateTime $to=null)
static formatPeriod(ilDateTime $start, ilDateTime $end, bool $a_skip_starting_day=false)
Format a period of two dates Shows: 14.
static byObjectId(int $object_id)
executeDefault(string $requestedMethod)
Class ilChatroom Keeps methods to prepare and display the history task.
bySession(bool $export=false)
static setUseRelativeDates(bool $a_status)
set use relative dates