ILIAS  release_7 Revision v7.30-3-g800a261c036
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 }
global $DIC
Definition: goto.php:24

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

239 {
240 global $DIC;
241
242 if (count($commandParts) > 1) {
243 if (isset($config[$commandParts[0]])) {
244 $DIC->tabs()->activateTab($commandParts[0]);
245
246 if (isset($config[$commandParts[0]]['subtabs'][$commandParts[1]])) {
247 $DIC->tabs()->activateSubTab($commandParts[1]);
248 }
249 }
250 } elseif (count($commandParts) == 1) {
251 $DIC->tabs()->activateTab($commandParts[0]);
252 }
253 }
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 177 of file class.ilChatroomTabGUIFactory.php.

178 {
179 global $DIC;
180
181 require_once 'Modules/Chatroom/classes/class.ilChatroom.php';
182 foreach ($config as $id => $tabDefinition) {
183 if (!$inRoom && !$DIC->rbac()->system()->checkAccess($tabDefinition['permission'], $this->gui->getRefId())) {
184 continue;
185 } elseif ($inRoom && !ilChatroom::checkUserPermissions($tabDefinition['permission'], $this->gui->getRefId(), false)) {
186 continue;
187 } elseif (isset($tabDefinition['enabled']) && !$tabDefinition['enabled']) {
188 continue;
189 }
190
191 $tabs->addTab($id, $this->getLabel($tabDefinition, $id), $tabDefinition['link']);
192
193 if ($command[0] == $id && isset($tabDefinition['subtabs']) &&
194 is_array($tabDefinition['subtabs'])
195 ) {
196 foreach ($tabDefinition['subtabs'] as $subid => $subTabDefinition) {
197 if (!$inRoom && !$DIC->rbac()->system()->checkAccess($tabDefinition['permission'], $this->gui->getRefId())) {
198 continue;
199 } elseif ($inRoom && !ilChatroom::checkUserPermissions($subTabDefinition['permission'], $this->gui->getRefId())) {
200 continue;
201 } elseif (isset($subTabDefinition['enabled']) && !$subTabDefinition['enabled']) {
202 continue;
203 }
204 $tabs->addSubTab(
205 $subid,
206 $this->getLabel($subTabDefinition, $subid),
207 $subTabDefinition['link']
208 );
209 }
210 }
211 }
212 }
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 164 of file class.ilChatroomTabGUIFactory.php.

165 {
166 return strtolower(preg_replace('/(.*?)-(.*?)/', '$1_$2', $value));
167 }

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:52

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 )
94 ),
95 'smiley' => array(
96 'lng' => 'smiley',
97 'link' => $DIC->ctrl()->getLinkTargetByClass('ilObjChatroomAdminGUI', 'smiley'),
98 'permission' => 'read'
99 )
100 );
101 $DIC->ctrl()->setParameterByClass('ilObjChatroomGUI', 'ref_id', $public_room_ref);
102
103 $config['settings'] = array(
104 'lng' => 'public_chat_settings',
105 'link' => $DIC->ctrl()->getLinkTargetByClass('ilObjChatroomGUI', 'settings-general'),
106 'permission' => 'read',
107 'subtabs' => array(
108 'settings' => array(
109 'lng' => 'settings',
110 'link' => $DIC->ctrl()->getLinkTarget($this->gui, 'settings-general'),
111 'permission' => 'read'
112 ),
113 'ban' => array(
114 'lng' => 'bans',
115 'link' => $DIC->ctrl()->getLinkTargetByClass('ilObjChatroomGUI', 'ban-show'),
116 'permission' => 'read'
117 )
118 )
119 );
120
121 $DIC->ctrl()->setParameterByClass('ilPermissionGUI', 'ref_id', $public_room_ref);
122 $config['perm'] = array(
123 'lng' => 'public_chat_permissions',
124 'link' => $DIC->ctrl()->getLinkTargetByClass('ilPermissionGUI', 'perm'),
125 'permission' => 'read',
126 );
127 $DIC->ctrl()->clearParametersByClass('ilPermissionGUI');
128
129 $DIC->ctrl()->setParameterByClass('ilPermissionGUI', 'ref_id', $admin_ref);
130 $config['perm_settings'] = array(
131 'lng' => 'perm_settings',
132 'link' => $DIC->ctrl()->getLinkTargetByClass('ilpermissiongui', 'perm'),
133 'permission' => 'edit_permission',
134 );
135 $DIC->ctrl()->clearParametersByClass('ilPermissionGUI');
136
137 $commandParts = explode('_', $command, 2);
138 if ($command == 'ban_show') {
139 $commandParts[0] = 'settings';
140 $commandParts[1] = 'ban';
141 } elseif ($command == 'settings_general') {
142 $commandParts[0] = 'settings';
143 $commandParts[1] = 'settings';
144 } elseif ($command == 'view_saveclientsettings') {
145 $commandParts[0] = 'view';
146 $commandParts[1] = 'clientsettings';
147 } elseif ($DIC->ctrl()->getCmdClass() == 'ilpermissiongui' && $_REQUEST['ref_id'] == $public_room_ref) {
148 $commandParts[0] = 'perm';
149 $DIC->ctrl()->setParameterByClass('ilPermissionGUI', 'ref_id', $public_room_ref);
150 } elseif ($DIC->ctrl()->getCmdClass() == 'ilpermissiongui' && $_REQUEST['ref_id'] == $admin_ref) {
151 $commandParts[0] = 'perm_settings';
152 $DIC->ctrl()->setParameterByClass('ilPermissionGUI', 'ref_id', $admin_ref);
153 }
154
155 $this->buildTabs($DIC->tabs(), $config, $commandParts, false);
156 $this->activateTab($commandParts, $config);
157 }
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 223 of file class.ilChatroomTabGUIFactory.php.

224 {
225 if (isset($tabDefinition['lng'])) {
226 return $this->lng->txt($tabDefinition['lng']);
227 } else {
228 return $this->lng->txt($id);
229 }
230 }

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

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