ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilChatroomHistoryGUI Class Reference

Class ilChatroom Keeps methods to prepare and display the history task. More...

+ Inheritance diagram for ilChatroomHistoryGUI:
+ Collaboration diagram for ilChatroomHistoryGUI:

Public Member Functions

 __construct (ilChatroomObjectGUI $gui)
 {
Parameters
ilChatroomObjectGUI$gui
} More...
 
 byDayExport ()
 
 byDay ($export=false)
 Prepares and displays history period form by day. More...
 
 bySessionExport ()
 
 bySession ($export=false)
 Prepares and displays history period form by session. More...
 
 executeDefault ($method)
 {
Parameters
string$requestedMethod
Returns
mixed
} More...
 
- Public Member Functions inherited from ilChatroomGUIHandler
 __construct (ilChatroomObjectGUI $gui)
 
 execute ($method)
 Executes given $method if existing, otherwise executes executeDefault() method. More...
 
 executeDefault ($requestedMethod)
 
 redirectIfNoPermission ($permission)
 Checks for requested permissions and redirects if the permission check failed. More...
 
 isSuccessful ($response)
 Checks for success param in an json decoded response. More...
 
 sendResponse ($response)
 Sends a json encoded response and exits the php process. More...
 
 hasPermission ($permission)
 Checks for access with ilRbacSystem. More...
 

Private Member Functions

 showMessages ($messages, $durationForm, $export=false, $psessions=array(), $from, $to)
 Prepares history table and displays it. More...
 

Additional Inherited Members

- Protected Member Functions inherited from ilChatroomGUIHandler
 getRoomByObjectId ($objectId)
 
 exitIfNoRoomExists ($room)
 Checks if a ilChatroom exists. More...
 
 exitIfNoRoomPermission ($room, $subRoom, $chat_user)
 Check if user can moderate a chatroom. More...
 
 canModerate ($room, $subRoom, $user_id)
 Checks if the user has permission to moderate a ilChatroom. More...
 
 isMainRoom ($subRoomId)
 
- Protected Attributes inherited from ilChatroomGUIHandler
 $gui
 
 $ilUser
 
 $ilCtrl
 
 $ilLng
 
 $webDirectory
 
 $obj_service
 
 $upload
 
 $rbacsystem
 
 $mainTpl
 
 $ilias
 
 $navigationHistory
 
 $tree
 
 $tabs
 

Detailed Description

Class ilChatroom Keeps methods to prepare and display the history task.

Author
Jan Posselt jposs.nosp@m.elt@.nosp@m.datab.nosp@m.ay.d.nosp@m.e
Version
$Id$

Definition at line 11 of file class.ilChatroomHistoryGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilChatroomHistoryGUI::__construct ( ilChatroomObjectGUI  $gui)

{

Parameters
ilChatroomObjectGUI$gui
}

Reimplemented from ilChatroomGUIHandler.

Definition at line 16 of file class.ilChatroomHistoryGUI.php.

17 {
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';
22 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References ilChatroomGUIHandler\$gui, and ILIAS\GlobalScreen\Provider\__construct().

+ Here is the call graph for this function:

Member Function Documentation

◆ byDay()

ilChatroomHistoryGUI::byDay (   $export = false)

Prepares and displays history period form by day.

Parameters
bool$export

Definition at line 34 of file class.ilChatroomHistoryGUI.php.

35 {
36 $room = ilChatroom::byObjectId($this->gui->object->getId());
37
38 $this->mainTpl->addJavaScript('./Services/Form/js/date_duration.js');
39
40 $scope = $room->getRoomId();
41
42 $chat_user = new ilChatroomUser($this->ilUser, $room);
43 $formFactory = new ilChatroomFormFactory();
44
45 $durationForm = $formFactory->getPeriodForm();
46 $durationForm->setTitle($this->ilLng->txt('history_byday_title'));
47 $durationForm->addCommandButton('history-byDayExport', $this->ilLng->txt('export'));
48 $durationForm->addCommandButton('history-byDay', $this->ilLng->txt('show'));
49 $durationForm->setFormAction($this->ilCtrl->getFormAction($this->gui), 'history-byDay');
50
51 $messages = array();
52 $psessions = array();
53 $submit_request = strtolower($_SERVER['REQUEST_METHOD']) == 'post';
54 $from = null;
55 $to = null;
56
57 if ($submit_request) {
58 if ($durationForm->checkInput()) {
59 $period = $durationForm->getItemByPostVar('timeperiod');
60
61 $messages = $room->getHistory(
62 $from = $period->getStart(),
63 $to = $period->getEnd(),
64 $chat_user->getUserId(),
65 isset($_REQUEST['scope']) ? $_REQUEST['scope'] : 0
66 );
67
68 $psessions = $room->getPrivateRoomSessions(
69 $from,
70 $to,
71 $chat_user->getUserId(),
72 $scope
73 );
74 } else {
75 $export = false;
76 }
77
78 $durationForm->setValuesByPost();
79 }
80
81 $this->showMessages($messages, $durationForm, $export, $psessions, $from, $to);
82 }
Class ilChatroomFormFactory.
showMessages($messages, $durationForm, $export=false, $psessions=array(), $from, $to)
Prepares history table and displays it.
Class ilChatroomUser.
static byObjectId($object_id)
Returns ilChatroom object by given $object_id.
This class provides processing control methods.
getFormAction( $a_gui_obj, $a_fallback_cmd="", $a_anchor="", $a_asynch=false, $xml_style=false)
Get form action url for gui class object.
$_SERVER['HTTP_HOST']
Definition: raiseError.php:10
$messages
Definition: xapiexit.php:5

References $_SERVER, $messages, ilChatroom\byObjectId(), ilCtrl\getFormAction(), and showMessages().

Referenced by byDayExport(), and executeDefault().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ byDayExport()

ilChatroomHistoryGUI::byDayExport ( )

Definition at line 24 of file class.ilChatroomHistoryGUI.php.

25 {
26 $this->tabs->activateSubTab('byday');
27 $this->byDay(true);
28 }
byDay($export=false)
Prepares and displays history period form by day.

References byDay().

+ Here is the call graph for this function:

◆ bySession()

ilChatroomHistoryGUI::bySession (   $export = false)

Prepares and displays history period form by session.

Parameters
bool$export

Definition at line 244 of file class.ilChatroomHistoryGUI.php.

245 {
246 $room = ilChatroom::byObjectId($this->gui->object->getId());
247
248 $scope = $room->getRoomId();
249
250 $chat_user = new ilChatroomUser($this->ilUser, $room);
251
252 $formFactory = new ilChatroomFormFactory();
253 $durationForm = $formFactory->getSessionForm($room->getSessions($chat_user));
254 $durationForm->setTitle($this->ilLng->txt('history_bysession_title'));
255 $durationForm->addCommandButton('history-bySessionExport', $this->ilLng->txt('export'));
256 $durationForm->addCommandButton('history-bySession', $this->ilLng->txt('show'));
257 $durationForm->setFormAction(
258 $this->ilCtrl->getFormAction($this->gui),
259 'history-bySession'
260 );
261
262 if (strtolower($_SERVER['REQUEST_METHOD']) == 'post') {
263 $durationForm->checkInput();
264 $postVals = explode(',', $_POST['session']);
265 $durationForm->setValuesByArray(array('session' => $_POST['session']));
266
267 $messages = $room->getHistory(
268 $from = new ilDateTime($postVals[0], IL_CAL_UNIX),
269 $to = new ilDateTime($postVals[1], IL_CAL_UNIX),
270 $chat_user->getUserId(),
271 isset($_REQUEST['scope']) ? $_REQUEST['scope'] : 0
272 );
273 } else {
274 $last_session = $room->getLastSession($chat_user);
275
276 if ($last_session) {
277 $from = new ilDateTime($last_session['connected'], IL_CAL_UNIX);
278 $to = new ilDateTime($last_session['disconnected'], IL_CAL_UNIX);
279 } else {
280 $from = null;
281 $to = null;
282 }
283
284 $messages = $room->getHistory(
285 $from,
286 $to,
287 $chat_user->getUserId(),
288 isset($_REQUEST['scope']) ? $_REQUEST['scope'] : 0
289 );
290 }
291
292 if ($from && $to) {
293 $psessions = $room->getPrivateRoomSessions(
294 $from,
295 $to,
296 $chat_user->getUserId(),
297 $scope
298 );
299 } else {
300 $from = new ilDateTime();
301 $to = new ilDateTime();
302 $psessions = array();
303 }
304
305 $psessions = $room->getPrivateRoomSessions(
306 $from,
307 $to,
308 $chat_user->getUserId(),
309 $scope
310 );
311
312 $this->showMessages($messages, $durationForm, $export, $psessions, $from, $to);
313 }
$_POST["username"]
const IL_CAL_UNIX
@classDescription Date and time handling

References $_POST, $_SERVER, $messages, ilChatroom\byObjectId(), ilCtrl\getFormAction(), IL_CAL_UNIX, and showMessages().

Referenced by bySessionExport().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ bySessionExport()

ilChatroomHistoryGUI::bySessionExport ( )

Definition at line 234 of file class.ilChatroomHistoryGUI.php.

235 {
236 $this->tabs->activateSubTab('bysession');
237 $this->bySession(true);
238 }
bySession($export=false)
Prepares and displays history period form by session.

References bySession().

+ Here is the call graph for this function:

◆ executeDefault()

ilChatroomHistoryGUI::executeDefault (   $method)

{

Parameters
string$requestedMethod
Returns
mixed
}

Reimplemented from ilChatroomGUIHandler.

Definition at line 318 of file class.ilChatroomHistoryGUI.php.

319 {
320 $this->byDay();
321 }

References byDay().

+ Here is the call graph for this function:

◆ showMessages()

ilChatroomHistoryGUI::showMessages (   $messages,
  $durationForm,
  $export = false,
  $psessions = array(),
  $from,
  $to 
)
private

Prepares history table and displays it.

Parameters
$messages
$durationForm
bool$export
array$psessions
$from
$to

Definition at line 93 of file class.ilChatroomHistoryGUI.php.

94 {
95 include_once 'Modules/Chatroom/classes/class.ilChatroom.php';
96
97 $this->redirectIfNoPermission('read');
98
99 $this->gui->switchToVisibleMode();
100
101 $this->mainTpl->addCSS('Modules/Chatroom/templates/default/style.css');
102
103 // should be able to grep templates
104 if ($export) {
105 $roomTpl = new ilGlobalTemplate('tpl.history_export.html', true, true, 'Modules/Chatroom');
106 } else {
107 $roomTpl = new ilTemplate('tpl.history.html', true, true, 'Modules/Chatroom');
108 }
109
110 $scopes = array();
111
112 if ($export) {
114 }
115
116 $time_format = $this->ilUser->getTimeFormat();
117
118 $prevDate = '';
119 $messagesShown = 0;
120 $lastDateTime = null;
121 foreach ($messages as $message) {
122 //$message['message']->content = json_decode($message['message']->content);
123
124 switch ($message['message']->type) {
125 case 'message':
126 if (($_REQUEST['scope'] && $message['message']->subRoomId == $_REQUEST['scope']) || (!$_REQUEST['scope'] && !$message['message']->subRoomId)) {
127 $date = new ilDate($message['timestamp'], IL_CAL_UNIX);
128 $dateTime = new ilDateTime($message['timestamp'], IL_CAL_UNIX);
129 $currentDate = ilDatePresentation::formatDate($dateTime);
130
131 $roomTpl->setCurrentBlock('MESSAGELINE');
132 $roomTpl->setVariable('MESSAGECONTENT', $message['message']->content); // oops... it is a message? ^^
133 $roomTpl->setVariable('MESSAGESENDER', $message['message']->from->username);
134 if (null == $lastDateTime ||
135 date('d', $lastDateTime->get(IL_CAL_UNIX)) != date('d', $dateTime->get(IL_CAL_UNIX)) ||
136 date('m', $lastDateTime->get(IL_CAL_UNIX)) != date('m', $dateTime->get(IL_CAL_UNIX)) ||
137 date('Y', $lastDateTime->get(IL_CAL_UNIX)) != date('Y', $dateTime->get(IL_CAL_UNIX))
138 ) {
139 $roomTpl->setVariable('MESSAGEDATE', ilDatePresentation::formatDate($date));
140 }
141
142 if ($prevDate != $currentDate) {
143 switch ($time_format) {
145 $date_string = $dateTime->get(IL_CAL_FKT_DATE, 'H:i', $this->ilUser->getTimeZone());
146 break;
148 $date_string = $dateTime->get(IL_CAL_FKT_DATE, 'g:ia', $this->ilUser->getTimeZone());
149 break;
150 }
151
152 $roomTpl->setVariable('MESSAGETIME', $date_string);
153 $prevDate = $currentDate;
154 }
155
156 $roomTpl->parseCurrentBlock();
157
158 $lastDateTime = $dateTime;
159
160 ++$messagesShown;
161 }
162 break;
163 }
164 }
165
166 foreach ($psessions as $session) {
167 $scopes[$session['proom_id']] = $session['title'];
168 }
169
170 if (isset($scopes[''])) {
171 unset($scopes['']);
172 }
173
174 if (!$messagesShown) {
175 //$roomTpl->touchBlock('NO_MESSAGES');
176 $roomTpl->setVariable('LBL_NO_MESSAGES', $this->ilLng->txt('no_messages'));
177 }
178
179 asort($scopes, SORT_STRING);
180
181 $scopes = array($this->ilLng->txt('main')) + $scopes;
182
183 if (count($scopes) > 1) {
184 $select = new ilSelectInputGUI($this->ilLng->txt('scope'), 'scope');
185 $select->setOptions($scopes);
186
187 if (isset($_REQUEST['scope'])) {
188 $select->setValue($_REQUEST['scope']);
189 }
190
191 $durationForm->addItem($select);
192 }
193
194 $room = ilChatroom::byObjectId($this->gui->object->getId());
195 //if ($room->getSetting('private_rooms_enabled')) {
196
197 $prevUseRelDates = ilDatePresentation::useRelativeDates();
199
200 if ($from instanceof ilDateTime && $to instanceof ilDateTime) {
201 $unixFrom = $from->getUnixTime();
202 $unixTo = $to->getUnixTime();
203
204 if ($unixFrom == $unixTo) {
205 $date = new ilDate($unixFrom, IL_CAL_UNIX);
206 $date_sub = ilDatePresentation::formatDate($date);
207 } else {
208 $date1 = new ilDate($unixFrom, IL_CAL_UNIX);
209 $date2 = new ilDate($unixTo, IL_CAL_UNIX);
210 $date_sub = ilDatePresentation::formatPeriod($date1, $date2);
211 }
213
214 $isPrivateRoom = (boolean) ((int) $_REQUEST['scope']);
215 if ($isPrivateRoom) {
216 $roomTpl->setVariable('ROOM_TITLE', sprintf($this->ilLng->txt('history_title_private_room'), $scopes[(int) $_REQUEST['scope']]) . ' (' . $date_sub . ')');
217 } else {
218 $roomTpl->setVariable('ROOM_TITLE', sprintf($this->ilLng->txt('history_title_general'), $this->gui->object->getTitle()) . ' (' . $date_sub . ')');
219 }
220 }
221
222 if ($export) {
223 header("Content-Type: text/html");
224 header("Content-Disposition: attachment; filename=\"" . urlencode($scopes[(int) $_REQUEST['scope']] . '.html') . "\"");
225 echo $roomTpl->get();
226 exit;
227 }
228
229 $roomTpl->setVariable('PERIOD_FORM', $durationForm->getHTML());
230
231 $this->mainTpl->setVariable('ADM_CONTENT', $roomTpl->get());
232 }
const IL_CAL_FKT_DATE
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, $include_seconds=false)
Format a date @access public.
static setUseRelativeDates($a_status)
set use relative dates
static useRelativeDates()
check if relative dates are used
static formatPeriod(ilDateTime $start, ilDateTime $end, $a_skip_starting_day=false)
Format a period of two date Shows: 14.
Class for single dates.
special template class to simplify handling of ITX/PEAR
This class represents a selection list property in a property form.
special template class to simplify handling of ITX/PEAR
exit
Definition: login.php:29
$session
$message
Definition: xapiexit.php:14

References $message, $messages, $session, ilChatroom\byObjectId(), exit, ilDatePresentation\formatDate(), ilDatePresentation\formatPeriod(), IL_CAL_FKT_DATE, IL_CAL_UNIX, ilChatroomGUIHandler\redirectIfNoPermission(), ilDatePresentation\setUseRelativeDates(), ilCalendarSettings\TIME_FORMAT_12, ilCalendarSettings\TIME_FORMAT_24, and ilDatePresentation\useRelativeDates().

Referenced by byDay(), and bySession().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

The documentation for this class was generated from the following file: