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

Class ilChatroomTabGUIFactory. More...

+ Collaboration diagram for ilChatroomTabGUIFactory:

Public Member Functions

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

Static Public Member Functions

static convertUnderscoreCaseToLowerCamelCaseConversion ($value, $upper_case_first=false)
 Convert a value given in underscore case conversion to lower camel case conversion (e.g. More...
 
static convertLowerCamelCaseToUnderscoreCaseConversion ($value)
 Convert a value given in lower camel case conversion to underscore case conversion (e.g. More...
 

Private Member Functions

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

Private Attributes

 $gui
 
 $lng
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilChatroomTabGUIFactory::__construct ( ilObjectGUI  $gui)
Parameters
ilObjectGUI$gui

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

27 {
28 global $DIC;
29
30 $this->gui = $gui;
31 $this->lng = $DIC->language();
32 }
$DIC
Definition: xapitoken.php:46

References $DIC, and $gui.

Member Function Documentation

◆ activateTab()

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

Activates tab or subtab if existing.

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

Parameters
array$commandParts

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

247 {
248 global $DIC;
249
250 if (count($commandParts) > 1) {
251 if (isset($config[$commandParts[0]])) {
252 $DIC->tabs()->activateTab($commandParts[0]);
253
254 if (isset($config[$commandParts[0]]['subtabs'][$commandParts[1]])) {
255 $DIC->tabs()->activateSubTab($commandParts[1]);
256 }
257 }
258 } elseif (count($commandParts) == 1) {
259 $DIC->tabs()->activateTab($commandParts[0]);
260 }
261 }
if(!array_key_exists('PATH_INFO', $_SERVER)) $config
Definition: metadata.php:68

References $config, and $DIC.

Referenced by getAdminTabsForCommand(), and getTabsForCommand().

+ Here is the caller graph for this function:

◆ buildTabs()

ilChatroomTabGUIFactory::buildTabs ( ilTabsGUI  $tabs,
  $config,
  $command,
  $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 185 of file class.ilChatroomTabGUIFactory.php.

186 {
187 global $DIC;
188
189 require_once 'Modules/Chatroom/classes/class.ilChatroom.php';
190 foreach ($config as $id => $tabDefinition) {
191 if (!$inRoom && !$DIC->rbac()->system()->checkAccess($tabDefinition['permission'], $this->gui->getRefId())) {
192 continue;
193 } elseif ($inRoom && !ilChatroom::checkUserPermissions($tabDefinition['permission'], $this->gui->getRefId(), false)) {
194 continue;
195 } elseif (isset($tabDefinition['enabled']) && !$tabDefinition['enabled']) {
196 continue;
197 }
198
199 $tabs->addTab($id, $this->getLabel($tabDefinition, $id), $tabDefinition['link']);
200
201 if ($command[0] == $id && isset($tabDefinition['subtabs']) &&
202 is_array($tabDefinition['subtabs'])
203 ) {
204 foreach ($tabDefinition['subtabs'] as $subid => $subTabDefinition) {
205 if (!$inRoom && !$DIC->rbac()->system()->checkAccess($tabDefinition['permission'], $this->gui->getRefId())) {
206 continue;
207 } elseif ($inRoom && !ilChatroom::checkUserPermissions($subTabDefinition['permission'], $this->gui->getRefId())) {
208 continue;
209 } elseif (isset($subTabDefinition['enabled']) && !$subTabDefinition['enabled']) {
210 continue;
211 }
212 $tabs->addSubTab(
213 $subid,
214 $this->getLabel($subTabDefinition, $subid),
215 $subTabDefinition['link']
216 );
217 }
218 }
219 }
220 }
getLabel($tabDefinition, $id)
Returns label for tab by $tabDefinition or $id.
static checkUserPermissions($permissions, $ref_id, $send_info=true)
Checks user permissions by given array and ref_id.
addTab($a_id, $a_text, $a_link, $a_frame="")
Add a Tab.
addSubTab($a_id, $a_text, $a_link, $a_frame="")
Add a Subtab.

References $config, $DIC, 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 (   $value)
static

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 172 of file class.ilChatroomTabGUIFactory.php.

173 {
174 return strtolower(preg_replace('/(.*?)-(.*?)/', '$1_$2', $value));
175 }

Referenced by getAdminTabsForCommand(), and getTabsForCommand().

+ Here is the caller graph for this function:

◆ convertUnderscoreCaseToLowerCamelCaseConversion()

static ilChatroomTabGUIFactory::convertUnderscoreCaseToLowerCamelCaseConversion (   $value,
  $upper_case_first = false 
)
static

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

my_class to MyClass)

Parameters
string$valueValue in underscore case conversion
boolean$upper_case_firstIf TRUE first character in upper case, lower case if FALSE
Returns
string The value in lower camel case conversion

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

41 {
42 $tokens = (array) explode('_', $value);
43 $value = '';
44
45 foreach ($tokens as $token) {
46 $value .= ucfirst($token);
47 }
48
49 if ($upper_case_first === false) {
50 $value = strtolower(substr($value, 0, 1)) . substr($value, 1);
51 }
52
53 return $value;
54 }
$token
Definition: xapitoken.php:57

References $token.

◆ getAdminTabsForCommand()

ilChatroomTabGUIFactory::getAdminTabsForCommand (   $command)

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

Parameters
string$command

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

62 {
63 global $DIC;
64
65 $command = $this->convertLowerCamelCaseToUnderscoreCaseConversion($command);
66 $stopCommands = array('create');
67
68 if (in_array($command, $stopCommands)) {
69 return;
70 }
71
72 $settings = new ilSetting('chatroom');
73 $public_room_ref = $settings->get('public_room_ref');
74
75 $objIds = ilObject::_getObjectsByType('chta');
76 $firstObjId = current(array_keys($objIds));
77 $refIds = ilObject::_getAllReferences($firstObjId);
78 $admin_ref = current($refIds);
79
80 $DIC->ctrl()->setParameterByClass('ilObjChatroomAdminGUI', 'ref_id', $admin_ref);
81
82 $config = array(
83 'view' => array(
84 'lng' => 'settings',
85 'link' => $DIC->ctrl()->getLinkTargetByClass('ilObjChatroomAdminGUI', 'view-clientsettings'),
86 'permission' => 'read',
87 'subtabs' => array(
88 'clientsettings' => array(
89 'lng' => 'client_settings',
90 'link' => $DIC->ctrl()->getLinkTargetByClass('ilObjChatroomAdminGUI', 'view-clientsettings'),
91 'permission' => 'read'
92 ),
93 'serversettings' => array(
94 'lng' => 'server_settings',
95 'link' => $DIC->ctrl()->getLinkTargetByClass('ilObjChatroomAdminGUI', 'view-serversettings'),
96 'permission' => 'read'
97 )
98 )
99 ),
100 'smiley' => array(
101 'lng' => 'smiley',
102 'link' => $DIC->ctrl()->getLinkTargetByClass('ilObjChatroomAdminGUI', 'smiley'),
103 'permission' => 'read'
104 )
105 );
106 $DIC->ctrl()->setParameterByClass('ilObjChatroomGUI', 'ref_id', $public_room_ref);
107
108 $config['settings'] = array(
109 'lng' => 'public_chat_settings',
110 'link' => $DIC->ctrl()->getLinkTargetByClass('ilObjChatroomGUI', 'settings-general'),
111 'permission' => 'read',
112 'subtabs' => array(
113 'settings' => array(
114 'lng' => 'settings',
115 'link' => $DIC->ctrl()->getLinkTarget($this->gui, 'settings-general'),
116 'permission' => 'read'
117 ),
118 'ban' => array(
119 'lng' => 'bans',
120 'link' => $DIC->ctrl()->getLinkTargetByClass('ilObjChatroomGUI', 'ban-show'),
121 'permission' => 'read'
122 )
123 )
124 );
125
126 $DIC->ctrl()->setParameterByClass('ilPermissionGUI', 'ref_id', $public_room_ref);
127 $config['perm'] = array(
128 'lng' => 'public_chat_permissions',
129 'link' => $DIC->ctrl()->getLinkTargetByClass('ilPermissionGUI', 'perm'),
130 'permission' => 'read',
131 );
132 $DIC->ctrl()->clearParametersByClass('ilPermissionGUI');
133
134 $DIC->ctrl()->setParameterByClass('ilPermissionGUI', 'ref_id', $admin_ref);
135 $config['perm_settings'] = array(
136 'lng' => 'perm_settings',
137 'link' => $DIC->ctrl()->getLinkTargetByClass('ilpermissiongui', 'perm'),
138 'permission' => 'edit_permission',
139 );
140 $DIC->ctrl()->clearParametersByClass('ilPermissionGUI');
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_savesettings') {
150 $commandParts[0] = 'view';
151 $commandParts[1] = 'serversettings';
152 } elseif ($command == 'view_saveclientsettings') {
153 $commandParts[0] = 'view';
154 $commandParts[1] = 'clientsettings';
155 } elseif ($DIC->ctrl()->getCmdClass() == 'ilpermissiongui' && $_REQUEST['ref_id'] == $public_room_ref) {
156 $commandParts[0] = 'perm';
157 $DIC->ctrl()->setParameterByClass('ilPermissionGUI', 'ref_id', $public_room_ref);
158 } elseif ($DIC->ctrl()->getCmdClass() == 'ilpermissiongui' && $_REQUEST['ref_id'] == $admin_ref) {
159 $commandParts[0] = 'perm_settings';
160 $DIC->ctrl()->setParameterByClass('ilPermissionGUI', 'ref_id', $admin_ref);
161 }
162
163 $this->buildTabs($DIC->tabs(), $config, $commandParts, false);
164 $this->activateTab($commandParts, $config);
165 }
buildTabs(ilTabsGUI $tabs, $config, $command, $inRoom=true)
Builds tabs and subtabs using given $tabs, $config and $command parameters.
activateTab(array $commandParts, $config)
Activates tab or subtab if existing.
static convertLowerCamelCaseToUnderscoreCaseConversion($value)
Convert a value given in lower camel case conversion to underscore case conversion (e....
static _getObjectsByType($a_obj_type="", $a_owner="")
Get objects by type.
static _getAllReferences($a_id)
get all reference ids of object
ILIAS Setting Class.

References $config, $DIC, ilObject\_getAllReferences(), ilObject\_getObjectsByType(), activateTab(), buildTabs(), and convertLowerCamelCaseToUnderscoreCaseConversion().

+ Here is the call graph for this function:

◆ getLabel()

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

Returns label for tab by $tabDefinition or $id.

Parameters
array$tabDefinition
string$id
Returns
string
Todo:
: $tabDefinition sollte doch stets ein array und $id stets ein string sein, oder? Dann sollte man auch hier typehinten. (array $tabDefinition, string $id)

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

232 {
233 if (isset($tabDefinition['lng'])) {
234 return $this->lng->txt($tabDefinition['lng']);
235 } else {
236 return $this->lng->txt($id);
237 }
238 }

Referenced by buildTabs().

+ Here is the caller graph for this function:

◆ getTabsForCommand()

ilChatroomTabGUIFactory::getTabsForCommand (   $command)

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

Parameters
string$command

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

269 {
270 global $DIC;
271
272 $command = $this->convertLowerCamelCaseToUnderscoreCaseConversion($command);
273 $stopCommands = array('create');
274
275 if (in_array($command, $stopCommands)) {
276 return;
277 }
278
279 require_once 'Modules/Chatroom/classes/class.ilChatroom.php';
280 $room = ilChatroom::byObjectId($this->gui->object->getId());
281
282 $config = array(
283 'view' => array(
284 'lng' => 'view',
285 'link' => $DIC->ctrl()->getLinkTarget($this->gui, 'view'),
286 'permission' => 'read'
287 ),
288 'history' => array(
289 'lng' => 'history',
290 'link' => $DIC->ctrl()->getLinkTarget($this->gui, 'history-byday'),
291 'permission' => 'read',
292 'enabled' => $room ? $room->getSetting('enable_history') : false,
293 'subtabs' => array(
294 'byday' => array(
295 'lng' => 'history_by_day',
296 'link' => $DIC->ctrl()->getLinkTarget($this->gui, 'history-byday'),
297 'permission' => 'read'
298 ),
299 'bysession' => array(
300 'lng' => 'history_by_session',
301 'link' => $DIC->ctrl()->getLinkTarget($this->gui, 'history-bysession'),
302 'permission' => 'read'
303 )
304 )
305 ),
306 'info' => array(
307 'lng' => 'info_short',
308 'link' => $DIC->ctrl()->getLinkTargetByClass(array(get_class($this->gui), 'ilinfoscreengui'), 'info'),
309 'permission' => 'read'
310 ),
311 'settings' => array(
312 'lng' => 'settings',
313 'link' => $DIC->ctrl()->getLinkTarget($this->gui, 'settings-general'),
314 'permission' => 'write',
315 'subtabs' => array(
316 'general' => array(
317 'lng' => 'settings_general',
318 'link' => $DIC->ctrl()->getLinkTarget($this->gui, 'settings-general'),
319 'permission' => 'write'
320 )
321 )
322 ),
323 'ban' => array(
324 'lng' => 'bans',
325 'link' => $DIC->ctrl()->getLinkTarget($this->gui, 'ban-show'),
326 'permission' => 'moderate',
327 'subtabs' => array(
328 'show' => array(
329 'lng' => 'bans_table',
330 'link' => $DIC->ctrl()->getLinkTarget($this->gui, 'ban-show'),
331 'permission' => 'moderate'
332 )
333 )
334 ),
335 'export' => array(
336 'lng' => 'export',
337 'link' => $DIC->ctrl()->getLinkTargetByClass('ilexportgui', ''),
338 'permission' => 'write'
339 ),
340 'perm' => array(
341 'lng' => 'permissions',
342 'link' => $DIC->ctrl()->getLinkTargetByClass('ilpermissiongui', 'perm'),
343 'permission' => 'edit_permission'
344 )
345 );
346
347 $commandParts = explode('_', $command, 2);
348
349 if ($DIC->ctrl()->getCmdClass() == 'ilpermissiongui') {
350 $commandParts[0] = 'perm';
351 }
352
353 $this->buildTabs($DIC->tabs(), $config, $commandParts);
354 $this->activateTab($commandParts, $config);
355 }
static byObjectId($object_id)
Returns ilChatroom object by given $object_id.

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

+ Here is the call graph for this function:

Field Documentation

◆ $gui

ilChatroomTabGUIFactory::$gui
private

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

Referenced by __construct().

◆ $lng

ilChatroomTabGUIFactory::$lng
private

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


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