19 declare(strict_types=1);
44 $this->
lng = $DIC->language();
45 $this->rbacSystem = $DIC->rbac()->system();
46 $this->
http = $DIC->http();
58 $command = self::convertLowerCamelCaseToUnderscoreCaseConversion($command);
59 $stopCommands = [
'create'];
61 if (in_array($command, $stopCommands,
true)) {
66 $public_room_ref = (
int) $settings->get(
'public_room_ref',
'0');
69 $firstObjId = (
int) current(array_keys($objIds));
71 $admin_ref = (
int) current($refIds);
73 $DIC->ctrl()->setParameterByClass(ilObjChatroomAdminGUI::class,
'ref_id', $admin_ref);
78 'link' => $DIC->ctrl()->getLinkTargetByClass(ilObjChatroomAdminGUI::class,
'view-clientsettings'),
79 'permission' =>
'read',
82 'lng' =>
'client_settings',
83 'link' => $DIC->ctrl()->getLinkTargetByClass(
84 ilObjChatroomAdminGUI::class,
87 'permission' =>
'read' 92 $DIC->ctrl()->setParameterByClass(ilObjChatroomGUI::class,
'ref_id', $public_room_ref);
94 $config[
'settings'] = [
95 'lng' =>
'public_chat_settings',
96 'link' => $DIC->ctrl()->getLinkTargetByClass(ilObjChatroomGUI::class,
'settings-general'),
97 'permission' =>
'read',
101 'link' => $DIC->ctrl()->getLinkTarget($this->gui,
'settings-general'),
102 'permission' =>
'read' 106 'link' => $DIC->ctrl()->getLinkTargetByClass(ilObjChatroomGUI::class,
'ban-show'),
107 'permission' =>
'read' 112 $DIC->ctrl()->setParameterByClass(ilPermissionGUI::class,
'ref_id', $public_room_ref);
114 'lng' =>
'public_chat_permissions',
115 'link' => $DIC->ctrl()->getLinkTargetByClass(ilPermissionGUI::class,
'perm'),
116 'permission' =>
'read',
118 $DIC->ctrl()->clearParametersByClass(ilPermissionGUI::class);
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',
126 $DIC->ctrl()->clearParametersByClass(ilPermissionGUI::class);
128 $is_in_permission_gui = (
129 strtolower($DIC->ctrl()->getCmdClass() ??
'') === strtolower(ilPermissionGUI::class) ||
130 strtolower($DIC->ctrl()->getCmdClass() ??
'') === strtolower(ilObjectPermissionStatusGUI::class)
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';
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
148 $commandParts[0] =
'perm';
149 $DIC->ctrl()->setParameterByClass(ilPermissionGUI::class,
'ref_id', $public_room_ref);
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
155 $commandParts[0] =
'perm_settings';
156 $DIC->ctrl()->setParameterByClass(ilPermissionGUI::class,
'ref_id', $admin_ref);
159 $this->
buildTabs($DIC->tabs(), $config, $commandParts,
false);
170 return strtolower(preg_replace(
'/(.*?)-(.*?)/',
'$1_$2', $value));
177 private function buildTabs(
ilTabsGUI $tabs, array $config, array $command,
bool $inRoom =
true): void
179 foreach ($config as
$id => $tabDefinition) {
180 if (!$inRoom && !$this->rbacSystem->checkAccess($tabDefinition[
'permission'], $this->gui->getRefId())) {
191 if (isset($tabDefinition[
'enabled']) && !$tabDefinition[
'enabled']) {
198 $command[0] ===
$id && isset($tabDefinition[
'subtabs']) &&
199 is_array($tabDefinition[
'subtabs'])
201 foreach ($tabDefinition[
'subtabs'] as $subid => $subTabDefinition) {
204 $this->rbacSystem->checkAccess($tabDefinition[
'permission'], $this->gui->getRefId())
216 if (isset($subTabDefinition[
'enabled']) && !$subTabDefinition[
'enabled']) {
222 $this->
getLabel($subTabDefinition, $subid),
223 $subTabDefinition[
'link']
233 private function getLabel(array $tabDefinition,
string $id): string
235 if (isset($tabDefinition[
'lng'])) {
236 return $this->
lng->txt($tabDefinition[
'lng']);
239 return $this->
lng->txt($id);
247 private function activateTab(array $commandParts, array $config): void
251 if (count($commandParts) > 1) {
252 if (isset($config[$commandParts[0]])) {
253 $DIC->tabs()->activateTab($commandParts[0]);
254 $this->activated_tab = $commandParts[0];
256 if (isset($config[$commandParts[0]][
'subtabs'][$commandParts[1]])) {
257 $DIC->tabs()->activateSubTab($commandParts[1]);
258 $this->activated_sub_tab = $commandParts[1];
261 } elseif (count($commandParts) === 1) {
262 $DIC->tabs()->activateTab($commandParts[0]);
263 $this->activated_tab = $commandParts[0];
285 $command = self::convertLowerCamelCaseToUnderscoreCaseConversion($command);
286 $stopCommands = [
'create'];
288 if (in_array($command, $stopCommands,
true)) {
297 'link' => $DIC->ctrl()->getLinkTarget($this->gui,
'view'),
298 'permission' =>
'read' 302 'link' => $DIC->ctrl()->getLinkTarget($this->gui,
'history-byday'),
303 'permission' =>
'read',
304 'enabled' => $room ? $room->getSetting(
'enable_history') :
false,
307 'lng' =>
'info_short',
308 'link' => $DIC->ctrl()->getLinkTargetByClass([$this->gui::class, ilInfoScreenGUI::class],
'showSummary'),
309 'permission' =>
'read' 313 'link' => $DIC->ctrl()->getLinkTarget($this->gui,
'settings-general'),
314 'permission' =>
'write',
317 'lng' =>
'settings_general',
318 'link' => $DIC->ctrl()->getLinkTarget($this->gui,
'settings-general'),
319 'permission' =>
'write' 325 'link' => $DIC->ctrl()->getLinkTarget($this->gui,
'ban-show'),
326 'permission' =>
'moderate',
329 'lng' =>
'bans_table',
330 'link' => $DIC->ctrl()->getLinkTarget($this->gui,
'ban-show'),
331 'permission' =>
'moderate' 337 'link' => $DIC->ctrl()->getLinkTargetByClass(ilExportGUI::class,
''),
338 'permission' =>
'write' 341 'lng' =>
'permissions',
342 'link' => $DIC->ctrl()->getLinkTargetByClass(ilPermissionGUI::class,
'perm'),
343 'permission' =>
'edit_permission' 347 $commandParts = explode(
'_', $command, 2);
348 if (strtolower($DIC->ctrl()->getCmdClass() ??
'') === strtolower(ilPermissionGUI::class)) {
349 $commandParts[0] =
'perm';
351 if (strtolower($DIC->ctrl()->getCmdClass() ??
'') === strtolower(ilInfoScreenGUI::class)) {
352 $commandParts[0] =
'info';
355 $this->
buildTabs($DIC->tabs(), $config, $commandParts);
static checkUserPermissions($permissions, int $ref_id, bool $send_info=true)
Checks user permissions by given array and ref_id.
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)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
readonly ilRbacSystem $rbacSystem
static convertLowerCamelCaseToUnderscoreCaseConversion(string $value)
Convert a value given in lower camel case conversion to underscore case conversion (e...
getAdminTabsForCommand(string $command)
Builds $config and $commandparts arrays to assign them as parameters when calling $this->buildTabs an...
string $activated_sub_tab
static _getAllReferences(int $id)
get all reference ids for object ID
readonly Refinery $refinery
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
addSubTab(string $a_id, string $a_text, string $a_link, string $a_frame="")
static http()
Fetches the global http state from ILIAS.
readonly GlobalHttpState $http
Class ilObjectGUI Basic methods of all Output classes.
Class ilChatroomTabGUIFactory.
getLabel(array $tabDefinition, string $id)
Returns label for tab by $tabDefinition or $id.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
__construct(Container $dic, ilPlugin $plugin)
static byObjectId(int $object_id)
getTabsForCommand(string $command)
Builds $config and $commandparts arrays to assign them as parameters when calling $this->buildTabs an...
addTab(string $a_id, string $a_text, string $a_link, string $a_frame="")
Add a Tab.