ILIAS  release_8 Revision v8.24
ilChatroomTabGUIFactory Class Reference

Class ilChatroomTabGUIFactory. More...

+ Collaboration diagram for ilChatroomTabGUIFactory:

Public Member Functions

 getAdminTabsForCommand (string $command)
 Builds $config and $commandparts arrays to assign them as parameters when calling $this->buildTabs and $this->activateTab. More...
 
 getActivatedTab ()
 
 getActivatedSubTab ()
 
 getTabsForCommand (string $command)
 Builds $config and $commandparts arrays to assign them as parameters when calling $this->buildTabs and $this->activateTab. More...
 

Private Member Functions

 buildTabs (ilTabsGUI $tabs, array $config, array $command, bool $inRoom=true)
 Builds tabs and subtabs using given $tabs, $config and $command parameters. More...
 
 getLabel (array $tabDefinition, string $id)
 Returns label for tab by $tabDefinition or $id. More...
 
 activateTab (array $commandParts, array $config)
 Activates tab or subtab if existing. More...
 

Static Private Member Functions

static convertLowerCamelCaseToUnderscoreCaseConversion (string $value)
 Convert a value given in lower camel case conversion to underscore case conversion (e.g. More...
 

Private Attributes

ilObjectGUI $gui
 
ilLanguage $lng
 
ilRbacSystem $rbacSystem
 
GlobalHttpState $http
 
Refinery $refinery
 
string $activated_tab = null
 
string $activated_sub_tab = null
 

Detailed Description

Member Function Documentation

◆ activateTab()

ilChatroomTabGUIFactory::activateTab ( array  $commandParts,
array  $config 
)
private

Activates tab or subtab if existing.

Calls $ilTabs->activateTab() or $ilTabs->activateSubTab() method to set current tab active.

Parameters
array$commandParts
array$config

Definition at line 265 of file class.ilChatroomTabGUIFactory.php.

265 : void
266 {
267 global $DIC;
268
269 if (count($commandParts) > 1) {
270 if (isset($config[$commandParts[0]])) {
271 $DIC->tabs()->activateTab($commandParts[0]);
272 $this->activated_tab = $commandParts[0];
273
274 if (isset($config[$commandParts[0]]['subtabs'][$commandParts[1]])) {
275 $DIC->tabs()->activateSubTab($commandParts[1]);
276 $this->activated_sub_tab = $commandParts[1];
277 }
278 }
279 } elseif (count($commandParts) === 1) {
280 $DIC->tabs()->activateTab($commandParts[0]);
281 $this->activated_tab = $commandParts[0];
282 }
283 }
global $DIC
Definition: feed.php:28
if(!array_key_exists('PATH_INFO', $_SERVER)) $config
Definition: metadata.php:85

References $config, and $DIC.

Referenced by getAdminTabsForCommand(), and getTabsForCommand().

+ Here is the caller graph for this function:

◆ buildTabs()

ilChatroomTabGUIFactory::buildTabs ( ilTabsGUI  $tabs,
array  $config,
array  $command,
bool  $inRoom = true 
)
private

Builds tabs and subtabs using given $tabs, $config and $command parameters.

Parameters
ilTabsGUI$tabs
array$config
array$command
bool$inRoom

Definition at line 190 of file class.ilChatroomTabGUIFactory.php.

190 : void
191 {
192 foreach ($config as $id => $tabDefinition) {
193 if (!$inRoom && !$this->rbacSystem->checkAccess($tabDefinition['permission'], $this->gui->getRefId())) {
194 continue;
195 }
196
197 if (
198 $inRoom &&
199 !ilChatroom::checkUserPermissions($tabDefinition['permission'], $this->gui->getRefId(), false)
200 ) {
201 continue;
202 }
203
204 if (isset($tabDefinition['enabled']) && !$tabDefinition['enabled']) {
205 continue;
206 }
207
208 $tabs->addTab($id, $this->getLabel($tabDefinition, $id), $tabDefinition['link']);
209
210 if (
211 $command[0] === $id && isset($tabDefinition['subtabs']) &&
212 is_array($tabDefinition['subtabs'])
213 ) {
214 foreach ($tabDefinition['subtabs'] as $subid => $subTabDefinition) {
215 if (
216 !$inRoom &&
217 $this->rbacSystem->checkAccess($tabDefinition['permission'], $this->gui->getRefId())
218 ) {
219 continue;
220 }
221
222 if (
223 $inRoom &&
224 !ilChatroom::checkUserPermissions($subTabDefinition['permission'], $this->gui->getRefId())
225 ) {
226 continue;
227 }
228
229 if (isset($subTabDefinition['enabled']) && !$subTabDefinition['enabled']) {
230 continue;
231 }
232
233 $tabs->addSubTab(
234 $subid,
235 $this->getLabel($subTabDefinition, $subid),
236 $subTabDefinition['link']
237 );
238 }
239 }
240 }
241 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
getLabel(array $tabDefinition, string $id)
Returns label for tab by $tabDefinition or $id.
static checkUserPermissions($permissions, int $ref_id, bool $send_info=true)
Checks user permissions by given array and ref_id.
addTab(string $a_id, string $a_text, string $a_link, string $a_frame="")
Add a Tab.
addSubTab(string $a_id, string $a_text, string $a_link, string $a_frame="")

References $config, $id, ilTabsGUI\addSubTab(), ilTabsGUI\addTab(), ilChatroom\checkUserPermissions(), and getLabel().

Referenced by getAdminTabsForCommand(), and getTabsForCommand().

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

◆ convertLowerCamelCaseToUnderscoreCaseConversion()

static ilChatroomTabGUIFactory::convertLowerCamelCaseToUnderscoreCaseConversion ( string  $value)
staticprivate

Convert a value given in lower camel case conversion to underscore case conversion (e.g.

MyClass to my_class)

Parameters
string$valueValue in lower camel case conversion
Returns
string The value in underscore case conversion

Definition at line 177 of file class.ilChatroomTabGUIFactory.php.

177 : string
178 {
179 return strtolower(preg_replace('/(.*?)-(.*?)/', '$1_$2', $value));
180 }

Referenced by getAdminTabsForCommand(), and getTabsForCommand().

+ Here is the caller graph for this function:

◆ getActivatedSubTab()

ilChatroomTabGUIFactory::getActivatedSubTab ( )

Definition at line 290 of file class.ilChatroomTabGUIFactory.php.

290 : ?string
291 {
293 }

References $activated_sub_tab.

◆ getActivatedTab()

ilChatroomTabGUIFactory::getActivatedTab ( )

Definition at line 285 of file class.ilChatroomTabGUIFactory.php.

285 : ?string
286 {
288 }

References $activated_tab.

◆ getAdminTabsForCommand()

ilChatroomTabGUIFactory::getAdminTabsForCommand ( string  $command)

Builds $config and $commandparts arrays to assign them as parameters when calling $this->buildTabs and $this->activateTab.

Parameters
string$command

Definition at line 58 of file class.ilChatroomTabGUIFactory.php.

58 : void
59 {
60 global $DIC;
61
63 $stopCommands = ['create'];
64
65 if (in_array($command, $stopCommands, true)) {
66 return;
67 }
68
69 $settings = new ilSetting('chatroom');
70 $public_room_ref = (int) $settings->get('public_room_ref', '0');
71
72 $objIds = ilObject::_getObjectsByType('chta');
73 $firstObjId = (int) current(array_keys($objIds));
74 $refIds = ilObject::_getAllReferences($firstObjId);
75 $admin_ref = (int) current($refIds);
76
77 $DIC->ctrl()->setParameterByClass(ilObjChatroomAdminGUI::class, 'ref_id', $admin_ref);
78
79 $config = [
80 'view' => [
81 'lng' => 'settings',
82 'link' => $DIC->ctrl()->getLinkTargetByClass(ilObjChatroomAdminGUI::class, 'view-clientsettings'),
83 'permission' => 'read',
84 'subtabs' => [
85 'clientsettings' => [
86 'lng' => 'client_settings',
87 'link' => $DIC->ctrl()->getLinkTargetByClass(
88 ilObjChatroomAdminGUI::class,
89 'view-clientsettings'
90 ),
91 'permission' => 'read'
92 ]
93 ]
94 ],
95 'smiley' => [
96 'lng' => 'smiley',
97 'link' => $DIC->ctrl()->getLinkTargetByClass(ilObjChatroomAdminGUI::class, 'smiley'),
98 'permission' => 'read'
99 ]
100 ];
101 $DIC->ctrl()->setParameterByClass(ilObjChatroomGUI::class, 'ref_id', $public_room_ref);
102
103 $config['settings'] = [
104 'lng' => 'public_chat_settings',
105 'link' => $DIC->ctrl()->getLinkTargetByClass(ilObjChatroomGUI::class, 'settings-general'),
106 'permission' => 'read',
107 'subtabs' => [
108 'settings' => [
109 'lng' => 'settings',
110 'link' => $DIC->ctrl()->getLinkTarget($this->gui, 'settings-general'),
111 'permission' => 'read'
112 ],
113 'ban' => [
114 'lng' => 'bans',
115 'link' => $DIC->ctrl()->getLinkTargetByClass(ilObjChatroomGUI::class, 'ban-show'),
116 'permission' => 'read'
117 ]
118 ]
119 ];
120
121 $DIC->ctrl()->setParameterByClass(ilPermissionGUI::class, 'ref_id', $public_room_ref);
122 $config['perm'] = [
123 'lng' => 'public_chat_permissions',
124 'link' => $DIC->ctrl()->getLinkTargetByClass(ilPermissionGUI::class, 'perm'),
125 'permission' => 'read',
126 ];
127 $DIC->ctrl()->clearParametersByClass(ilPermissionGUI::class);
128
129 $DIC->ctrl()->setParameterByClass(ilPermissionGUI::class, 'ref_id', $admin_ref);
130 $config['perm_settings'] = [
131 'lng' => 'perm_settings',
132 'link' => $DIC->ctrl()->getLinkTargetByClass(ilPermissionGUI::class, 'perm'),
133 'permission' => 'edit_permission',
134 ];
135 $DIC->ctrl()->clearParametersByClass(ilPermissionGUI::class);
136
137 $is_in_permission_gui = (
138 strtolower($DIC->ctrl()->getCmdClass()) === strtolower(ilPermissionGUI::class) ||
139 strtolower($DIC->ctrl()->getCmdClass()) === strtolower(ilObjectPermissionStatusGUI::class)
140 );
141
142 $commandParts = explode('_', $command, 2);
143 if ($command === 'ban_show') {
144 $commandParts[0] = 'settings';
145 $commandParts[1] = 'ban';
146 } elseif ($command === 'settings_general') {
147 $commandParts[0] = 'settings';
148 $commandParts[1] = 'settings';
149 } elseif ($command === 'view_saveclientsettings') {
150 $commandParts[0] = 'view';
151 $commandParts[1] = 'clientsettings';
152 } elseif (
153 $is_in_permission_gui &&
154 $this->http->wrapper()->query()->has('ref_id') &&
155 $this->http->wrapper()->query()->retrieve('ref_id', $this->refinery->kindlyTo()->int()) === $public_room_ref
156 ) {
157 $commandParts[0] = 'perm';
158 $DIC->ctrl()->setParameterByClass(ilPermissionGUI::class, 'ref_id', $public_room_ref);
159 } elseif (
160 $is_in_permission_gui &&
161 $this->http->wrapper()->query()->has('ref_id') &&
162 $this->http->wrapper()->query()->retrieve('ref_id', $this->refinery->kindlyTo()->int()) === $admin_ref
163 ) {
164 $commandParts[0] = 'perm_settings';
165 $DIC->ctrl()->setParameterByClass(ilPermissionGUI::class, 'ref_id', $admin_ref);
166 }
167
168 $this->buildTabs($DIC->tabs(), $config, $commandParts, false);
169 $this->activateTab($commandParts, $config);
170 }
static convertLowerCamelCaseToUnderscoreCaseConversion(string $value)
Convert a value given in lower camel case conversion to underscore case conversion (e....
buildTabs(ilTabsGUI $tabs, array $config, array $command, bool $inRoom=true)
Builds tabs and subtabs using given $tabs, $config and $command parameters.
activateTab(array $commandParts, array $config)
Activates tab or subtab if existing.
static _getObjectsByType(string $obj_type="", int $owner=null)
static _getAllReferences(int $id)
get all reference ids for object ID
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.
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200

References $config, $DIC, ILIAS\LTI\ToolProvider\$settings, ilObject\_getAllReferences(), ilObject\_getObjectsByType(), activateTab(), buildTabs(), convertLowerCamelCaseToUnderscoreCaseConversion(), ILIAS\FileDelivery\http(), and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ getLabel()

ilChatroomTabGUIFactory::getLabel ( array  $tabDefinition,
string  $id 
)
private

Returns label for tab by $tabDefinition or $id.

Parameters
array$tabDefinition
string$id
Returns
string

Definition at line 249 of file class.ilChatroomTabGUIFactory.php.

249 : string
250 {
251 if (isset($tabDefinition['lng'])) {
252 return $this->lng->txt($tabDefinition['lng']);
253 }
254
255 return $this->lng->txt($id);
256 }

References ILIAS\Repository\lng().

Referenced by buildTabs().

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

◆ getTabsForCommand()

ilChatroomTabGUIFactory::getTabsForCommand ( string  $command)

Builds $config and $commandparts arrays to assign them as parameters when calling $this->buildTabs and $this->activateTab.

Parameters
string$command

Definition at line 300 of file class.ilChatroomTabGUIFactory.php.

300 : void
301 {
302 global $DIC;
303
305 $stopCommands = ['create'];
306
307 if (in_array($command, $stopCommands, true)) {
308 return;
309 }
310
311 $room = ilChatroom::byObjectId($this->gui->getObject()->getId());
312
313 $config = [
314 'view' => [
315 'lng' => 'view',
316 'link' => $DIC->ctrl()->getLinkTarget($this->gui, 'view'),
317 'permission' => 'read'
318 ],
319 'history' => [
320 'lng' => 'history',
321 'link' => $DIC->ctrl()->getLinkTarget($this->gui, 'history-byday'),
322 'permission' => 'read',
323 'enabled' => $room ? $room->getSetting('enable_history') : false,
324 'subtabs' => [
325 'byday' => [
326 'lng' => 'history_by_day',
327 'link' => $DIC->ctrl()->getLinkTarget($this->gui, 'history-byday'),
328 'permission' => 'read'
329 ],
330 'bysession' => [
331 'lng' => 'history_by_session',
332 'link' => $DIC->ctrl()->getLinkTarget($this->gui, 'history-bysession'),
333 'permission' => 'read'
334 ]
335 ]
336 ],
337 'info' => [
338 'lng' => 'info_short',
339 'link' => $DIC->ctrl()->getLinkTargetByClass([get_class($this->gui), ilInfoScreenGUI::class], 'info'),
340 'permission' => 'read'
341 ],
342 'settings' => [
343 'lng' => 'settings',
344 'link' => $DIC->ctrl()->getLinkTarget($this->gui, 'settings-general'),
345 'permission' => 'write',
346 'subtabs' => [
347 'general' => [
348 'lng' => 'settings_general',
349 'link' => $DIC->ctrl()->getLinkTarget($this->gui, 'settings-general'),
350 'permission' => 'write'
351 ]
352 ]
353 ],
354 'ban' => [
355 'lng' => 'bans',
356 'link' => $DIC->ctrl()->getLinkTarget($this->gui, 'ban-show'),
357 'permission' => 'moderate',
358 'subtabs' => [
359 'show' => [
360 'lng' => 'bans_table',
361 'link' => $DIC->ctrl()->getLinkTarget($this->gui, 'ban-show'),
362 'permission' => 'moderate'
363 ]
364 ]
365 ],
366 'export' => [
367 'lng' => 'export',
368 'link' => $DIC->ctrl()->getLinkTargetByClass(ilExportGUI::class, ''),
369 'permission' => 'write'
370 ],
371 'perm' => [
372 'lng' => 'permissions',
373 'link' => $DIC->ctrl()->getLinkTargetByClass(ilPermissionGUI::class, 'perm'),
374 'permission' => 'edit_permission'
375 ]
376 ];
377
378 $commandParts = explode('_', $command, 2);
379 if (strtolower($DIC->ctrl()->getCmdClass()) === strtolower(ilPermissionGUI::class)) {
380 $commandParts[0] = 'perm';
381 }
382
383 $this->buildTabs($DIC->tabs(), $config, $commandParts);
384 $this->activateTab($commandParts, $config);
385 }
static byObjectId(int $object_id)

References $config, $DIC, activateTab(), buildTabs(), ilChatroom\byObjectId(), and convertLowerCamelCaseToUnderscoreCaseConversion().

+ Here is the call graph for this function:

Field Documentation

◆ $activated_sub_tab

string ilChatroomTabGUIFactory::$activated_sub_tab = null
private

Definition at line 39 of file class.ilChatroomTabGUIFactory.php.

Referenced by getActivatedSubTab().

◆ $activated_tab

string ilChatroomTabGUIFactory::$activated_tab = null
private

Definition at line 38 of file class.ilChatroomTabGUIFactory.php.

Referenced by getActivatedTab().

◆ $gui

ilObjectGUI ilChatroomTabGUIFactory::$gui
private

Definition at line 33 of file class.ilChatroomTabGUIFactory.php.

◆ $http

GlobalHttpState ilChatroomTabGUIFactory::$http
private

Definition at line 36 of file class.ilChatroomTabGUIFactory.php.

◆ $lng

ilLanguage ilChatroomTabGUIFactory::$lng
private

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

◆ $rbacSystem

ilRbacSystem ilChatroomTabGUIFactory::$rbacSystem
private

Definition at line 35 of file class.ilChatroomTabGUIFactory.php.

◆ $refinery

Refinery ilChatroomTabGUIFactory::$refinery
private

Definition at line 37 of file class.ilChatroomTabGUIFactory.php.


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