ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilChatroomTabFactory Class Reference

Class ilChatroomTabFactory. More...

+ Collaboration diagram for ilChatroomTabFactory:

Public Member Functions

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

Static Public Member Functions

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

Private Member Functions

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

Private Attributes

 $gui
 $lng
 $access

Detailed Description

Class ilChatroomTabFactory.

Author
Jan Posselt jposs.nosp@m.elt@.nosp@m.datab.nosp@m.ay.d.nosp@m.e
Version
$Id$

Definition at line 13 of file class.ilChatroomTabFactory.php.

Constructor & Destructor Documentation

ilChatroomTabFactory::__construct ( ilObjectGUI  $gui)

Constructor.

Sets $this->gui using given $gui. Sets $this->lng and $this->access

ilLanguage $lng ilAccessHandler $ilAccess

Parameters
ilObjectGUI$gui

Definition at line 30 of file class.ilChatroomTabFactory.php.

References $gui, and $lng.

{
global $lng, $ilAccess;
$this->gui = $gui;
$this->lng = $lng;
$this->access = $ilAccess;
}

Member Function Documentation

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

Activates tab or subtab if existing.

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

ilTabsGUI $ilTabs

Parameters
array$command
Todo:
: config muss auch immer ein array sein, oder?! typehint?

Definition at line 49 of file class.ilChatroomTabFactory.php.

References $config.

Referenced by getAdminTabsForCommand(), and getTabsForCommand().

{
global $ilTabs;
if( count( $commandParts ) > 1 )
{
if( isset( $config[$commandParts[0]] ) )
{
$ilTabs->activateTab( $commandParts[0] );
if( isset( $config[$commandParts[0]]['subtabs'][$commandParts[1]] ) )
{
$ilTabs->activateSubTab( $commandParts[1] );
}
}
}
else if( count($commandParts) == 1 /*&& isset( $config[$commandParts[0]] )*/ )
{
$ilTabs->activateTab( $commandParts[0] );
}
}

+ Here is the caller graph for this function:

ilChatroomTabFactory::buildTabs ( ilTabsGUI  $tabs,
  $config,
  $command 
)
private

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

Parameters
ilTabsGUI$tabs
array$config
array$command
Todo:
: soweit ich das sehe müssen sowohl $config, als auch $command grundsätzlich arrays sein, d.h. man könnte/sollte hier typehinten (ilTabsGUI $tabs, array $config, array $command) oder?!

Definition at line 305 of file class.ilChatroomTabFactory.php.

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

Referenced by getAdminTabsForCommand(), and getTabsForCommand().

{
require_once 'Modules/Chatroom/classes/class.ilChatroom.php';
foreach( $config as $id => $tabDefinition )
{
if( !ilChatroom::checkUserPermissions($tabDefinition['permission'], $this->gui->getRefId(), false)) {
//if( !$this->access->checkAccess( $tabDefinition['permission'], '', $this->gui->getRefId() ) ) {
continue;
}
else if (isset($tabDefinition['enabled']) && !$tabDefinition['enabled']) {
continue;
}
$tabs->addTab( $id, $this->getLabel( $tabDefinition, $id ), $tabDefinition['link'] );
if( $command[0] == $id && isset( $tabDefinition['subtabs'] ) &&
is_array( $tabDefinition['subtabs'] )
)
{
foreach( $tabDefinition['subtabs'] as $subid => $subTabDefinition )
{
if( !$this->access->checkAccess( $subTabDefinition['permission'], '', $this->gui->getRefId() ) ) {
continue;
}
else if (isset($subTabDefinition['enabled']) && !$subTabDefinition['enabled']) {
continue;
}
$tabs->addSubTab(
$subid, $this->getLabel( $subTabDefinition, $subid ),
$subTabDefinition['link']
);
}
}
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilChatroomTabFactory::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 367 of file class.ilChatroomTabFactory.php.

Referenced by getAdminTabsForCommand(), and getTabsForCommand().

{
//return strtolower(preg_replace('/([a-z])([A-Z])/', '$1_$2', $value));
return strtolower( preg_replace( '/(.*?)-(.*?)/', '$1_$2', $value ) );
}

+ Here is the caller graph for this function:

static ilChatroomTabFactory::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 381 of file class.ilChatroomTabFactory.php.

{
$tokens = (array)explode( '_', $value );
$value = '';
foreach( $tokens as $token )
{
$value .= ucfirst( $token );
}
if( $upper_case_first === FALSE )
{
$value = strtolower( $value, 0, 1 ) . substr( $value, 1 );
}
return $value;
}
ilChatroomTabFactory::getAdminTabsForCommand (   $command)

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

ilTabsGUI $ilTabs ilCtrl2 $ilCtrl

Parameters
string$command
Todo:
: $command muss eig. immer ein string sein, oder? Dann könnte man hier typehinten (string $command)

Definition at line 81 of file class.ilChatroomTabFactory.php.

References $_REQUEST, $command, $config, $data, $ilCtrl, $ilDB, $query, activateTab(), buildTabs(), and convertLowerCamelCaseToUnderscoreCaseConversion().

{
global $ilTabs, $ilCtrl, $ilDB;
$stopCommands = array('create');
if( in_array( $command, $stopCommands ) )
{
return;
}
$settings = new ilSetting('chatroom');
$public_room_ref = $settings->get('public_room_ref');
$query = 'SELECT ref_id FROM object_reference INNER JOIN object_data ON object_data.obj_id = object_reference.obj_id WHERE type = ' . $ilDB->quote('chta', 'text');
$rset = $ilDB->query($query);
$data = $ilDB->fetchAssoc($rset);
$admin_ref = $data['ref_id'];
$ilCtrl->setParameterByClass('ilObjChatroomAdminGUI', 'ref_id', $admin_ref);
$config = array(
'view' => array(
'lng' => 'settings',
'link' => $ilCtrl->getLinkTargetByClass('ilObjChatroomAdminGUI', 'view-clientsettings'),
'permission' => 'read',
'subtabs' => array(
'clientsettings' => array(
'lng' => 'client_settings',
'link' => $ilCtrl->getLinkTargetByClass( 'ilObjChatroomAdminGUI', 'view-clientsettings' ),
'permission' => 'read',
),
'serversettings' => array(
'lng' => 'server_settings',
'link' => $ilCtrl->getLinkTargetByClass( 'ilObjChatroomAdminGUI', 'view-serversettings' ),
'permission' => 'read',
),
),
),
'smiley' => array(
'lng' => 'smiley',
'link' => $ilCtrl->getLinkTargetByClass( 'ilObjChatroomAdminGUI', 'smiley' ),
'permission' => 'read'
),
);
$ilCtrl->setParameterByClass('ilObjChatroomGUI', 'ref_id', $public_room_ref);
$ilCtrl->setParameterByClass('ilPermissionGUI', 'ref_id', $public_room_ref);
$config['settings'] = array(
'lng' => 'public_chat_settings',
'link' => $ilCtrl->getLinkTargetByClass( 'ilObjChatroomGUI', 'settings-general' ),
'permission' => 'write',
'subtabs' => array(
'settings' => array(
'lng' => 'settings',
'link' => $ilCtrl->getLinkTarget( $this->gui, 'settings-general' ),
'permission' => 'write'
),
'ban' => array(
'lng' => 'bans',
'link' => $ilCtrl->getLinkTargetByClass( 'ilObjChatroomGUI', 'ban-show' ),
'permission' => 'moderate',
),
));
$config['perm'] = array(
'lng' => 'public_chat_permissions',
'link' => $ilCtrl->getLinkTargetByClass( 'ilpermissiongui', 'perm' ),
'permission' => 'write',
);
$ilCtrl->clearParametersByClass('ilPermissionGUI');
$ilCtrl->setParameterByClass('ilPermissionGUI', 'ref_id', $admin_ref);
$config['perm_settings'] = array(
'lng' => 'perm_settings',
'link' => $ilCtrl->getLinkTargetByClass( 'ilpermissiongui', 'perm' ),
'permission' => 'write',
);
$ilCtrl->clearParametersByClass('ilPermissionGUI');
$commandParts = explode( '_', $command, 2 );
if ($command == 'ban_show') {
$commandParts[0] = 'settings';
$commandParts[1] = 'ban';
}
else if ($command == 'settings_general') {
$commandParts[0] = 'settings';
$commandParts[1] = 'settings';
}
else if (in_array($command, array('perm', 'info', 'owner')) && $_REQUEST['ref_id'] == $public_room_ref) {
$commandParts[0] = 'perm';
}
else if (in_array($command, array('perm', 'info', 'owner')) && $_REQUEST['ref_id'] == $admin_ref) {
$commandParts[0] = 'perm_settings';
}
$this->buildTabs( $ilTabs, $config, $commandParts );
$this->activateTab( $commandParts, $config );
}

+ Here is the call graph for this function:

ilChatroomTabFactory::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 352 of file class.ilChatroomTabFactory.php.

Referenced by buildTabs().

{
if( isset( $tabDefinition['lng'] ) )
return $this->lng->txt( $tabDefinition['lng'] );
else
return $this->lng->txt( $id );
}

+ Here is the caller graph for this function:

ilChatroomTabFactory::getTabsForCommand (   $command)

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

ilTabsGUI $ilTabs ilCtrl2 $ilCtrl

Parameters
string$command
Todo:
: $command muss eig. immer ein string sein, oder? Dann könnte man hier typehinten (string $command)

Definition at line 198 of file class.ilChatroomTabFactory.php.

References $_REQUEST, $command, $config, $ilCtrl, activateTab(), buildTabs(), ilChatroom\byObjectId(), and convertLowerCamelCaseToUnderscoreCaseConversion().

{
global $ilTabs, $ilCtrl;
$stopCommands = array('create');
if( in_array( $command, $stopCommands ) )
{
return;
}
require_once 'Modules/Chatroom/classes/class.ilChatroom.php';
$room = ilChatroom::byObjectId( $this->gui->object->getId() );
$config = array(
'view' => array(
'lng' => 'view',
'link' => $ilCtrl->getLinkTarget( $this->gui, 'view' ),
'permission' => 'read'
),
'history' => array(
'lng' => 'history',
'link' => $ilCtrl->getLinkTarget( $this->gui, 'history-byday' ),
'permission' => 'read',
'enabled' => $room ? $room->getSetting('enable_history') : false,
'subtabs' => array(
'byday' => array(
'lng' => 'history_by_day',
'link' => $ilCtrl->getLinkTarget( $this->gui, 'history-byday' ),
'permission' => 'read',
),
'bysession' => array(
'lng' => 'history_by_session',
'link' => $ilCtrl->getLinkTarget( $this->gui, 'history-bysession' ),
'permission' => 'read',
)
),
),
'info' => array(
'lng' => 'info_short',
'link' => $ilCtrl->getLinkTargetByClass( array(get_class( $this->gui ), 'ilinfoscreengui'), 'info' ),
'permission' => 'read'
),
'settings' => array(
'lng' => 'settings',
'link' => $ilCtrl->getLinkTarget( $this->gui, 'settings-general' ),
'permission' => 'write',
'subtabs' => array(
'general' => array(
'lng' => 'settings_general',
'link' => $ilCtrl->getLinkTarget( $this->gui, 'settings-general' ),
'permission' => 'write',
)/*,
'privacy' => array(
'lng' => 'settings_privacy',
'link' => $ilCtrl->getLinkTarget( $this->gui, 'settings-privacy' ),
'permission' => 'write',
)*/
),
),
'ban' => array(
'lng' => 'bans',
'link' => $ilCtrl->getLinkTarget( $this->gui, 'ban-show' ),
'permission' => 'moderate',
'subtabs' => array(
'show' => array(
'lng' => 'bans_table',
'link' => $ilCtrl->getLinkTarget( $this->gui, 'ban-show' ),
'permission' => 'moderate',
),
/* 'add' => array(
'lng' => 'bans_add',
'link' => $ilCtrl->getLinkTarget($this->gui, 'ban-add'),
'permission' => 'moderate',
) */
),
),
'perm' => array(
'lng' => 'permissions',
'link' => $ilCtrl->getLinkTargetByClass( 'ilpermissiongui', 'perm' ),
'permission' => 'write',
)
);
$commandParts = explode( '_', $command, 2 );
if (in_array($command, array('perm', 'info', 'owner')) && strtolower($_REQUEST['cmdClass']) == 'ilpermissiongui') {
$commandParts[0] = 'perm';
}
$this->buildTabs( $ilTabs, $config, $commandParts );
$this->activateTab( $commandParts, $config );
}

+ Here is the call graph for this function:

Field Documentation

ilChatroomTabFactory::$access
private

Definition at line 18 of file class.ilChatroomTabFactory.php.

ilChatroomTabFactory::$gui
private

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

Referenced by __construct().

ilChatroomTabFactory::$lng
private

Definition at line 17 of file class.ilChatroomTabFactory.php.

Referenced by __construct().


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