ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
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

readonly ilLanguage $lng
 
readonly ilRbacSystem $rbacSystem
 
readonly GlobalHttpState $http
 
readonly 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.

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

References $DIC.

Referenced by getAdminTabsForCommand(), and getTabsForCommand().

247  : void
248  {
249  global $DIC;
250 
251  if (count($commandParts) > 1) {
252  if (isset($config[$commandParts[0]])) {
253  $DIC->tabs()->activateTab($commandParts[0]);
254  $this->activated_tab = $commandParts[0];
255 
256  if (isset($config[$commandParts[0]]['subtabs'][$commandParts[1]])) {
257  $DIC->tabs()->activateSubTab($commandParts[1]);
258  $this->activated_sub_tab = $commandParts[1];
259  }
260  }
261  } elseif (count($commandParts) === 1) {
262  $DIC->tabs()->activateTab($commandParts[0]);
263  $this->activated_tab = $commandParts[0];
264  }
265  }
global $DIC
Definition: shib_login.php:26
+ 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.

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

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

Referenced by getAdminTabsForCommand(), and getTabsForCommand().

177  : void
178  {
179  foreach ($config as $id => $tabDefinition) {
180  if (!$inRoom && !$this->rbacSystem->checkAccess($tabDefinition['permission'], $this->gui->getRefId())) {
181  continue;
182  }
183 
184  if (
185  $inRoom &&
186  !ilChatroom::checkUserPermissions($tabDefinition['permission'], $this->gui->getRefId(), false)
187  ) {
188  continue;
189  }
190 
191  if (isset($tabDefinition['enabled']) && !$tabDefinition['enabled']) {
192  continue;
193  }
194 
195  $tabs->addTab($id, $this->getLabel($tabDefinition, $id), $tabDefinition['link']);
196 
197  if (
198  $command[0] === $id && isset($tabDefinition['subtabs']) &&
199  is_array($tabDefinition['subtabs'])
200  ) {
201  foreach ($tabDefinition['subtabs'] as $subid => $subTabDefinition) {
202  if (
203  !$inRoom &&
204  $this->rbacSystem->checkAccess($tabDefinition['permission'], $this->gui->getRefId())
205  ) {
206  continue;
207  }
208 
209  if (
210  $inRoom &&
211  !ilChatroom::checkUserPermissions($subTabDefinition['permission'], $this->gui->getRefId())
212  ) {
213  continue;
214  }
215 
216  if (isset($subTabDefinition['enabled']) && !$subTabDefinition['enabled']) {
217  continue;
218  }
219 
220  $tabs->addSubTab(
221  $subid,
222  $this->getLabel($subTabDefinition, $subid),
223  $subTabDefinition['link']
224  );
225  }
226  }
227  }
228  }
static checkUserPermissions($permissions, int $ref_id, bool $send_info=true)
Checks user permissions by given array and ref_id.
addSubTab(string $a_id, string $a_text, string $a_link, string $a_frame="")
getLabel(array $tabDefinition, string $id)
Returns label for tab by $tabDefinition or $id.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
addTab(string $a_id, string $a_text, string $a_link, string $a_frame="")
Add a Tab.
+ 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 168 of file class.ilChatroomTabGUIFactory.php.

168  : string
169  {
170  return strtolower(preg_replace('/(.*?)-(.*?)/', '$1_$2', $value));
171  }

◆ getActivatedSubTab()

ilChatroomTabGUIFactory::getActivatedSubTab ( )

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

References $activated_sub_tab.

272  : ?string
273  {
275  }

◆ getActivatedTab()

ilChatroomTabGUIFactory::getActivatedTab ( )

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

References $activated_tab.

267  : ?string
268  {
269  return $this->activated_tab;
270  }

◆ getAdminTabsForCommand()

ilChatroomTabGUIFactory::getAdminTabsForCommand ( string  $command)

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

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

References $DIC, ilObject\_getAllReferences(), ilObject\_getObjectsByType(), activateTab(), buildTabs(), ILIAS\FileDelivery\http(), ILIAS\Repository\int(), and ILIAS\Repository\refinery().

54  : void
55  {
56  global $DIC;
57 
58  $command = self::convertLowerCamelCaseToUnderscoreCaseConversion($command);
59  $stopCommands = ['create'];
60 
61  if (in_array($command, $stopCommands, true)) {
62  return;
63  }
64 
65  $settings = new ilSetting('chatroom');
66  $public_room_ref = (int) $settings->get('public_room_ref', '0');
67 
68  $objIds = ilObject::_getObjectsByType('chta');
69  $firstObjId = (int) current(array_keys($objIds));
70  $refIds = ilObject::_getAllReferences($firstObjId);
71  $admin_ref = (int) current($refIds);
72 
73  $DIC->ctrl()->setParameterByClass(ilObjChatroomAdminGUI::class, 'ref_id', $admin_ref);
74 
75  $config = [
76  'view' => [
77  'lng' => 'settings',
78  'link' => $DIC->ctrl()->getLinkTargetByClass(ilObjChatroomAdminGUI::class, 'view-clientsettings'),
79  'permission' => 'read',
80  'subtabs' => [
81  'clientsettings' => [
82  'lng' => 'client_settings',
83  'link' => $DIC->ctrl()->getLinkTargetByClass(
84  ilObjChatroomAdminGUI::class,
85  'view-clientsettings'
86  ),
87  'permission' => 'read'
88  ]
89  ]
90  ],
91  ];
92  $DIC->ctrl()->setParameterByClass(ilObjChatroomGUI::class, 'ref_id', $public_room_ref);
93 
94  $config['settings'] = [
95  'lng' => 'public_chat_settings',
96  'link' => $DIC->ctrl()->getLinkTargetByClass(ilObjChatroomGUI::class, 'settings-general'),
97  'permission' => 'read',
98  'subtabs' => [
99  'settings' => [
100  'lng' => 'settings',
101  'link' => $DIC->ctrl()->getLinkTarget($this->gui, 'settings-general'),
102  'permission' => 'read'
103  ],
104  'ban' => [
105  'lng' => 'bans',
106  'link' => $DIC->ctrl()->getLinkTargetByClass(ilObjChatroomGUI::class, 'ban-show'),
107  'permission' => 'read'
108  ]
109  ]
110  ];
111 
112  $DIC->ctrl()->setParameterByClass(ilPermissionGUI::class, 'ref_id', $public_room_ref);
113  $config['perm'] = [
114  'lng' => 'public_chat_permissions',
115  'link' => $DIC->ctrl()->getLinkTargetByClass(ilPermissionGUI::class, 'perm'),
116  'permission' => 'read',
117  ];
118  $DIC->ctrl()->clearParametersByClass(ilPermissionGUI::class);
119 
120  $DIC->ctrl()->setParameterByClass(ilPermissionGUI::class, 'ref_id', $admin_ref);
121  $config['perm_settings'] = [
122  'lng' => 'perm_settings',
123  'link' => $DIC->ctrl()->getLinkTargetByClass(ilPermissionGUI::class, 'perm'),
124  'permission' => 'edit_permission',
125  ];
126  $DIC->ctrl()->clearParametersByClass(ilPermissionGUI::class);
127 
128  $is_in_permission_gui = (
129  strtolower($DIC->ctrl()->getCmdClass() ?? '') === strtolower(ilPermissionGUI::class) ||
130  strtolower($DIC->ctrl()->getCmdClass() ?? '') === strtolower(ilObjectPermissionStatusGUI::class)
131  );
132 
133  $commandParts = explode('_', $command, 2);
134  if ($command === 'ban_show') {
135  $commandParts[0] = 'settings';
136  $commandParts[1] = 'ban';
137  } elseif ($command === 'settings_general') {
138  $commandParts[0] = 'settings';
139  $commandParts[1] = 'settings';
140  } elseif ($command === 'view_saveclientsettings') {
141  $commandParts[0] = 'view';
142  $commandParts[1] = 'clientsettings';
143  } elseif (
144  $is_in_permission_gui &&
145  $this->http->wrapper()->query()->has('ref_id') &&
146  $this->http->wrapper()->query()->retrieve('ref_id', $this->refinery->kindlyTo()->int()) === $public_room_ref
147  ) {
148  $commandParts[0] = 'perm';
149  $DIC->ctrl()->setParameterByClass(ilPermissionGUI::class, 'ref_id', $public_room_ref);
150  } elseif (
151  $is_in_permission_gui &&
152  $this->http->wrapper()->query()->has('ref_id') &&
153  $this->http->wrapper()->query()->retrieve('ref_id', $this->refinery->kindlyTo()->int()) === $admin_ref
154  ) {
155  $commandParts[0] = 'perm_settings';
156  $DIC->ctrl()->setParameterByClass(ilPermissionGUI::class, 'ref_id', $admin_ref);
157  }
158 
159  $this->buildTabs($DIC->tabs(), $config, $commandParts, false);
160  $this->activateTab($commandParts, $config);
161  }
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
static http()
Fetches the global http state from ILIAS.
global $DIC
Definition: shib_login.php:26
+ Here is the call graph for this function:

◆ getLabel()

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

Returns label for tab by $tabDefinition or $id.

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

References ILIAS\Repository\lng().

Referenced by buildTabs().

233  : string
234  {
235  if (isset($tabDefinition['lng'])) {
236  return $this->lng->txt($tabDefinition['lng']);
237  }
238 
239  return $this->lng->txt($id);
240  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ 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.

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

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

281  : void
282  {
283  global $DIC;
284 
285  $command = self::convertLowerCamelCaseToUnderscoreCaseConversion($command);
286  $stopCommands = ['create'];
287 
288  if (in_array($command, $stopCommands, true)) {
289  return;
290  }
291 
292  $room = ilChatroom::byObjectId($this->gui->getObject()->getId());
293 
294  $config = [
295  'view' => [
296  'lng' => 'obj_chtr',
297  'link' => $DIC->ctrl()->getLinkTarget($this->gui, 'view'),
298  'permission' => 'read'
299  ],
300  'history' => [
301  'lng' => 'history',
302  'link' => $DIC->ctrl()->getLinkTarget($this->gui, 'history-byday'),
303  'permission' => 'read',
304  'enabled' => $room ? $room->getSetting('enable_history') : false,
305  ],
306  'info' => [
307  'lng' => 'info_short',
308  'link' => $DIC->ctrl()->getLinkTargetByClass([$this->gui::class, ilInfoScreenGUI::class], 'showSummary'),
309  'permission' => 'read'
310  ],
311  'settings' => [
312  'lng' => 'settings',
313  'link' => $DIC->ctrl()->getLinkTarget($this->gui, 'settings-general'),
314  'permission' => 'write',
315  'subtabs' => [
316  'general' => [
317  'lng' => 'settings_general',
318  'link' => $DIC->ctrl()->getLinkTarget($this->gui, 'settings-general'),
319  'permission' => 'write'
320  ]
321  ]
322  ],
323  'ban' => [
324  'lng' => 'bans',
325  'link' => $DIC->ctrl()->getLinkTarget($this->gui, 'ban-show'),
326  'permission' => 'moderate',
327  'subtabs' => [
328  'show' => [
329  'lng' => 'bans_table',
330  'link' => $DIC->ctrl()->getLinkTarget($this->gui, 'ban-show'),
331  'permission' => 'moderate'
332  ]
333  ]
334  ],
335  'export' => [
336  'lng' => 'export',
337  'link' => $DIC->ctrl()->getLinkTargetByClass(ilExportGUI::class, ''),
338  'permission' => 'write'
339  ],
340  'perm' => [
341  'lng' => 'permissions',
342  'link' => $DIC->ctrl()->getLinkTargetByClass(ilPermissionGUI::class, 'perm'),
343  'permission' => 'edit_permission'
344  ]
345  ];
346 
347  $commandParts = explode('_', $command, 2);
348  if (strtolower($DIC->ctrl()->getCmdClass() ?? '') === strtolower(ilPermissionGUI::class)) {
349  $commandParts[0] = 'perm';
350  }
351  if (strtolower($DIC->ctrl()->getCmdClass() ?? '') === strtolower(ilInfoScreenGUI::class)) {
352  $commandParts[0] = 'info';
353  }
354 
355  $this->buildTabs($DIC->tabs(), $config, $commandParts);
356  $this->activateTab($commandParts, $config);
357  }
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.
global $DIC
Definition: shib_login.php:26
static byObjectId(int $object_id)
+ Here is the call graph for this function:

Field Documentation

◆ $activated_sub_tab

string ilChatroomTabGUIFactory::$activated_sub_tab = null
private

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

Referenced by getActivatedSubTab().

◆ $activated_tab

string ilChatroomTabGUIFactory::$activated_tab = null
private

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

Referenced by getActivatedTab().

◆ $http

readonly GlobalHttpState ilChatroomTabGUIFactory::$http
private

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

◆ $lng

readonly ilLanguage ilChatroomTabGUIFactory::$lng
private

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

◆ $rbacSystem

readonly ilRbacSystem ilChatroomTabGUIFactory::$rbacSystem
private

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

◆ $refinery

readonly Refinery ilChatroomTabGUIFactory::$refinery
private

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


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