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

Class ilChatroomViewTask. More...

+ Inheritance diagram for ilChatroomViewTask:
+ Collaboration diagram for ilChatroomViewTask:

Public Member Functions

 __construct (ilDBayObjectGUI $gui)
 Constructor.
 saveSettings ()
 Saves settings fetched from $_POST.
 saveClientSettings ()
 Saves client settings fetched from $_POST.
 serversettings (ilPropertyFormGUI $form=null)
 Prepares view form and displays it.
 executeDefault ($method)
 Calls this->view() method.
 clientsettings (ilPropertyFormGUI $form=null)
 forcePublicRoom ()
 createPublicRoom ()
 getServerStatus ()
 __construct (ilDBayObjectGUI $gui)
 Constructor.
 joinWithCustomName ()
 Joins user to chatroom with custom username, fetched from $_REQUEST['custom_username_text'] or by calling buld method.
 executeDefault ($method)
 Chatroom and Chatuser get prepared before $this->showRoom method is called.
 invitePD ()
 renderFileUploadForm ($roomTpl)
 Prepares Fileupload form and displays it.
 logout ()
 Performs logout.
 lostConnection ()
- Public Member Functions inherited from ilDBayTaskHandler
 execute ($method)
 Executes given $method if existing, otherwise executes executeDefault() method.

Protected Member Functions

 writeClientSettingsToFile ($settings)
 Writes client settings to client.properties file.
 getClientFileContent ($settings)
 Formats content for client settings file.
 writeDataToFile ($settings)
 Writes server settings to server.properties file.
 getFileContent ($settings)
 Builds and formats content tot write in server.properties file.
 checkDirectory ()
 Checks if external chatroom directory exists or can be created.
 checkPrivHosts ($ipnumbers)
 Checks if a valid IP number or a comma-separated string of valid IP numbers is given.
 renderRightUsersDock ($roomTpl)
 renderSendMessageBox ($roomTpl)

Private Member Functions

 showSoapWarningIfNeeded ()
 defaultActions ()
 cancelJoin ($message)
 Calls ilUtil::sendFailure method using given $message as parameter.
 showRoom (ilChatroom $room, ilChatroomUser $chat_user)
 Prepares and displays chatroom and connects user to it.
 showNameSelection (ilChatroomUser $chat_user)
 Prepares and displays name selection.
 setupTemplate ()
 Adds CSS and JavaScript files that should be included in the header.
 renderFontSettings ($roomTpl, $defaultSettings)
 Prepares given $roomTpl with font settings using given $defaultSettings among other things.

Private Attributes

 $gui
 $commonSettings

Detailed Description

Class ilChatroomViewTask.

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

Definition at line 14 of file class.ilChatroomViewTask.php.

Constructor & Destructor Documentation

ilChatroomViewTask::__construct ( ilDBayObjectGUI  $gui)

Constructor.

Sets $this->gui using given $gui

Parameters
ilDBayObjectGUI$gui

Reimplemented from ilDBayTaskHandler.

Definition at line 27 of file class.ilChatroomViewTask.php.

References $gui.

{
$this->gui = $gui;
$this->commonSettings = new ilSetting('common');
}
ilChatroomViewTask::__construct ( ilDBayObjectGUI  $gui)

Constructor.

Requires ilChatroom and ilChatroomUser. Sets $this->gui using given $gui.

Parameters
ilDBayObjectGUI$gui

Reimplemented from ilDBayTaskHandler.

Definition at line 25 of file class.ilChatroomViewTask.php.

References $gui.

{
$this->gui = $gui;
require_once 'Modules/Chatroom/classes/class.ilChatroom.php';
require_once 'Modules/Chatroom/classes/class.ilChatroomUser.php';
}

Member Function Documentation

ilChatroomViewTask::cancelJoin (   $message)
private

Calls ilUtil::sendFailure method using given $message as parameter.

Parameters
string$message

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

References ilUtil\sendFailure().

Referenced by showRoom().

{
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilChatroomViewTask::checkDirectory ( )
protected

Checks if external chatroom directory exists or can be created.

Definition at line 236 of file class.ilChatroomViewTask.php.

References $lng, ilUtil\getDataDir(), and ilUtil\makeDir().

Referenced by writeClientSettingsToFile(), and writeDataToFile().

{
global $lng;
$srv_prp_path = ilUtil::getDataDir().'/chatroom/';
if( !file_exists($srv_prp_path) )
{
if( !ilUtil::makeDir($srv_prp_path) )
{
throw new Exception('Directory cannot be created');
}
}
return $srv_prp_path;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilChatroomViewTask::checkPrivHosts (   $ipnumbers)
protected

Checks if a valid IP number or a comma-separated string of valid IP numbers is given.

Parameters
string$ipnumbers

Definition at line 260 of file class.ilChatroomViewTask.php.

Referenced by saveSettings().

{
$ipnumbers = preg_replace( "/[^0-9.,]+/", "", $ipnumbers );
$ips = explode( ',', $ipnumbers );
foreach( $ips as $ip )
{
$ip_parts = explode( '.', $ip );
if( !($ip_parts[0] <= 255 && $ip_parts[1] <= 255 && $ip_parts[2] <= 255 && $ip_parts[3] <= 255 &&
preg_match("!^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$!", $ip))
)
{
return false;
}
}
return true;
}

+ Here is the caller graph for this function:

ilChatroomViewTask::clientsettings ( ilPropertyFormGUI  $form = null)

Definition at line 344 of file class.ilChatroomViewTask.php.

References $data, $ilCtrl, $lng, $tpl, ilUtil\_getHttpPath(), ilChatroomServerConnector\checkServerConnection(), ilChatroom\checkUserPermissions(), defaultActions(), ilUtil\sendInfo(), and showSoapWarningIfNeeded().

Referenced by saveClientSettings(), and saveSettings().

{
global $ilUser, $tpl, $ilCtrl, $lng;
ilChatroom::checkUserPermissions( 'read', $this->gui->ref_id );
$this->defaultActions();
$this->gui->switchToVisibleMode();
require_once 'Modules/Chatroom/classes/class.ilChatroomAdmin.php';
$adminSettings = new ilChatroomAdmin( $this->gui->object->getId() );
if( $form === null )
{
require_once 'Modules/Chatroom/classes/class.ilChatroomFormFactory.php';
$factory = new ilChatroomFormFactory();
$form = $factory->getClientSettingsForm();
if (!$this->commonSettings->get('soap_user_administration')) {
$form->getItemByPostVar('chat_enabled')->setDisabled(!(boolean)$this->commonSettings->get('soap_user_administration'));
$form->getItemByPostVar('chat_enabled')->setChecked(0);
}
$data = (array)$adminSettings->loadClientSettings();
if(!$data['osd_intervall']) {
$data['osd_intervall'] = 60;
}
if( !$data )
{
$data = array();
}
if( !$data['url'] )
{
}
if( !$data['client'] )
{
$data['client'] = CLIENT_ID;
}
$data['password_retype'] = $data['password'];
}
require_once 'Modules/Chatroom/classes/class.ilChatroomServerConnector.php';
$serverSettings = (array)$adminSettings->loadGeneralSettings();
if ($serverSettings['port'] && $serverSettings['address'] && !(boolean)@ilChatroomServerConnector::checkServerConnection()) {
ilUtil::sendInfo($lng->txt('chat_cannot_connect_to_server'));
}
$form->setTitle( $lng->txt('general_settings_title') );
$form->addCommandButton( 'view-saveClientSettings', $lng->txt( 'save' ) );
//$form->addCommandButton( 'view-clientsettings', $lng->txt( 'cancel' ) );
$form->setFormAction( $ilCtrl->getFormAction( $this->gui, 'view-saveClientSettings' ) );
$settingsTpl = new ilTemplate('tpl.chatroom_serversettings.html', true, true, 'Modules/Chatroom');
$settingsTpl->setVariable('VAL_SERVERSETTINGS_FORM', $form->getHTML());
$settingsTpl->setVariable('LBL_SERVERSETTINGS_FURTHER_INFORMATION', sprintf($lng->txt('server_further_information'), ilUtil::_getHttpPath() . '/Modules/Chatroom/server/README.txt'));
$tpl->setVariable( 'ADM_CONTENT', $settingsTpl->get() );
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilChatroomViewTask::createPublicRoom ( )

Definition at line 448 of file class.ilChatroomViewTask.php.

References $lng, and ilUtil\sendSuccess().

Referenced by forcePublicRoom().

{
global $lng;
require_once 'Modules/Chatroom/classes/class.ilChatroomInstaller.php';
ilUtil::sendSuccess($lng->txt('public_chat_created'), true);
ilChatroomInstaller::createDefaultPublicRoom(true);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilChatroomViewTask::defaultActions ( )
private

Definition at line 415 of file class.ilChatroomViewTask.php.

References forcePublicRoom().

Referenced by clientsettings(), and serversettings().

{
$chatSettings = new ilSetting('chatroom');
if ($chatSettings->get('chat_enabled', false)) {
$this->forcePublicRoom();
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilChatroomViewTask::executeDefault (   $method)

Calls this->view() method.

Parameters
string$method

Reimplemented from ilDBayTaskHandler.

Definition at line 338 of file class.ilChatroomViewTask.php.

References $ilCtrl.

{
global $ilCtrl;
$ilCtrl->redirect($this->gui, 'view-clientsettings');
}
ilChatroomViewTask::executeDefault (   $method)

Chatroom and Chatuser get prepared before $this->showRoom method is called.

If custom usernames are allowed, $this->showNameSelection method is called if user isn't already registered in the Chatroom.

ilObjUser $ilUser ilLanguage $lng

Parameters
string$method

Reimplemented from ilDBayTaskHandler.

Definition at line 416 of file class.ilChatroomViewTask.php.

References $ilCtrl, $lng, ilChatroom\byObjectId(), ilChatroom\checkUserPermissions(), and exit.

{
global $ilUser, $lng, $ilCtrl;
include_once 'Modules/Chatroom/classes/class.ilChatroom.php';
ilChatroom::checkUserPermissions( 'read', $this->gui->ref_id );
$this->gui->switchToVisibleMode();
$this->setupTemplate();
$chatSettings = new ilSetting('chatroom');
if (!$chatSettings->get('chat_enabled')) {
$ilCtrl->redirect($this->gui, 'settings-general');
}
$room = ilChatroom::byObjectId($this->gui->object->getId());
if (!$room->getSetting('allow_anonymous') && $ilUser->getId() == ANONYMOUS_USER_ID) {
$this->cancelJoin($lng->txt('anonymous_not_allowed'));
return;
}
$chat_user = new ilChatroomUser($ilUser, $room);
if ($room->getSetting('allow_custom_usernames')) {
if ($room->isSubscribed($chat_user->getUserId())) {
$chat_user->setUsername($chat_user->getUsername());
$this->showRoom($room, $chat_user);
} else {
$this->showNameSelection($chat_user);
}
} else {
$chat_user->setUsername($ilUser->getLogin());
$this->showRoom($room, $chat_user);
}
}

+ Here is the call graph for this function:

ilChatroomViewTask::forcePublicRoom ( )

Definition at line 422 of file class.ilChatroomViewTask.php.

References $ref_id, ilObjChatroom\_getPublicRefId(), ilObject\_hasUntrashedReference(), ilObject\_lookupObjId(), createPublicRoom(), and ilObjectFactory\getInstanceByRefId().

Referenced by defaultActions().

{
if (!$ref_id) {
$this->createPublicRoom();
return;
}
if (!$instance) {
$this->createPublicRoom();
return;
}
if (!$obj_id) {
$this->createPublicRoom();
return;
}
$this->createPublicRoom();
return;
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilChatroomViewTask::getClientFileContent (   $settings)
protected

Formats content for client settings file.

Parameters
unknown_type$settings

Definition at line 173 of file class.ilChatroomViewTask.php.

Referenced by writeClientSettingsToFile().

{
$linebreak = "\n";
$content = 'hash = ' . $settings['hash'] . $linebreak;
$content .= 'name = ' . $settings['name'] . $linebreak;
$content .= 'url = ' . $settings['url'] . $linebreak;
$content .= 'user = ' . $settings['user'] . $linebreak;
$content .= 'password = ' . $settings['password'] . $linebreak;
$content .= 'client = ' . $settings['client'];
return $content;
}

+ Here is the caller graph for this function:

ilChatroomViewTask::getFileContent (   $settings)
protected

Builds and formats content tot write in server.properties file.

Parameters
array$settings

Definition at line 213 of file class.ilChatroomViewTask.php.

Referenced by writeDataToFile().

{
$linebreak = "\n";
$content = 'host = ' . $settings['address'] . $linebreak;
$content .= 'port = ' . $settings['port'] . $linebreak;
$content .= 'privileged_hosts = ' . $settings['priv_hosts'] . $linebreak;
$settings['protocol'] == 'https' ? $https = 1 : $https = 0;
$content .= 'https = ' . $https . $linebreak;
$content .= 'keystore = ' . $settings['keystore'] . $linebreak;
$content .= 'keypass = ' . $settings['keypass'] . $linebreak;
$content .= 'storepass = ' . $settings['storepass'];
return $content;
}

+ Here is the caller graph for this function:

ilChatroomViewTask::getServerStatus ( )

Definition at line 455 of file class.ilChatroomViewTask.php.

References ilChatroomServerConnector\checkServerConnection().

{
require_once 'Modules/Chatroom/classes/class.ilChatroomServerConnector.php';
echo array('server_alive' => (boolean)@ilChatroomServerConnector::checkServerConnection());
}

+ Here is the call graph for this function:

ilChatroomViewTask::invitePD ( )

Definition at line 455 of file class.ilChatroomViewTask.php.

References $_REQUEST, $_SESSION, $ilCtrl, $lng, $title, ilChatroom\byObjectId(), and exit.

{
global $ilUser,$ilCtrl,$lng;
$chatSettings = new ilSetting('chatroom');
if (!$chatSettings->get('chat_enabled')) {
$ilCtrl->redirect($this->gui, 'settings-general');
}
$room = ilChatroom::byObjectId($this->gui->object->getId());
$chat_user = new ilChatroomUser($ilUser, $room);
$user_id = $_REQUEST['usr_id'];
$connector = $this->gui->getConnector();
/*
if (!$room->isSubscribed($chat_user->getUserId()) && $room->connectUser($chat_user)) {
$connector->sendMessage(
$scope, $message = json_encode(
array(
'type' => 'connected',
'users' => array(
array(
'login' => $chat_user->getUsername(),
'id' => $user_id,
),
),
'timestamp' => time() * 1000
)
)
);
}
*/
$title = $room->getUniquePrivateRoomTitle($chat_user->getUsername());
$response = $connector->createPrivateRoom($room, $title, $chat_user);
$connector->inviteToPrivateRoom($room, $response->id, $ilUser, $user_id);
$room->sendInvitationNotification($this->gui, $ilUser->getId(), $user_id, $response->id);
$_REQUEST['sub'] = $response->id;
//ilUtil::sendInfo($lng->txt('user_invited'), true);
$_SESSION['show_invitation_message'] = $user_id;
$ilCtrl->setParameter($this->gui, 'sub', $response->id);
$ilCtrl->redirect($this->gui, 'view');
}

+ Here is the call graph for this function:

ilChatroomViewTask::joinWithCustomName ( )

Joins user to chatroom with custom username, fetched from $_REQUEST['custom_username_text'] or by calling buld method.

If sucessful, $this->showRoom method is called, otherwise $this->showNameSelection.

ilObjUser $ilUser ilLanguage $lng

Definition at line 382 of file class.ilChatroomViewTask.php.

References $_REQUEST, $lng, and ilChatroom\byObjectId().

{
global $ilUser, $lng;
$this->gui->switchToVisibleMode();
$this->setupTemplate();
$room = ilChatroom::byObjectId($this->gui->object->getId());
$chat_user = new ilChatroomUser($ilUser, $room);
if ($_REQUEST['custom_username_radio'] == 'custom_username') {
$username = $_REQUEST['custom_username_text'];
} elseif (method_exists($chat_user, 'build' . $_REQUEST['custom_username_radio'])) {
$username = $chat_user->{'build' . $_REQUEST['custom_username_radio']}();
} else {
$failure = true;
}
if (!$failure && trim($username) != '') {
$chat_user->setUsername($username);
$this->showRoom($room, $chat_user);
} else {
ilUtil::sendFailure($lng->txt('no_username_given'));
$this->showNameSelection($chat_user);
}
}

+ Here is the call graph for this function:

ilChatroomViewTask::logout ( )

Performs logout.

ilTree $tree

Todo:
logout user from room

Definition at line 623 of file class.ilChatroomViewTask.php.

References ilUtil\redirect().

{
//global $ilCtrl, $tree;
global $tree;
$pid = $tree->getParentId($this->gui->getRefId());
ilUtil::redirect('repository.php?ref_id=' . $pid);
}

+ Here is the call graph for this function:

ilChatroomViewTask::lostConnection ( )

Definition at line 634 of file class.ilChatroomViewTask.php.

References $ilCtrl, $lng, ilUtil\redirect(), and ilUtil\sendFailure().

{
global $lng, $ilCtrl;
ilUtil::sendFailure($lng->txt('lost_connection'), true);
$url = $ilCtrl->getLinkTargetByClass('ilinfoscreengui', 'info', false, false, false);
}

+ Here is the call graph for this function:

ilChatroomViewTask::renderFileUploadForm (   $roomTpl)

Prepares Fileupload form and displays it.

ilCtrl2 $ilCtrl

Parameters
string$roomTpl

Definition at line 604 of file class.ilChatroomViewTask.php.

References $ilCtrl.

{
return;
global $ilCtrl;
require_once 'Modules/Chatroom/classes/class.ilChatroomFormFactory.php';
$formFactory = new ilChatroomFormFactory();
$file_upload = $formFactory->getFileUploadForm();
//$file_upload->setFormAction( $ilCtrl->getFormAction($this->gui, 'UploadFile-uploadFile') );
$roomTpl->setVariable('FILE_UPLOAD', $file_upload->getHTML());
}
ilChatroomViewTask::renderFontSettings (   $roomTpl,
  $defaultSettings 
)
private

Prepares given $roomTpl with font settings using given $defaultSettings among other things.

ilLanguage $lng ilCtrl2 $ilCtrl

Parameters
ilTemplate$roomTpl
array$defaultSettings

Definition at line 512 of file class.ilChatroomViewTask.php.

References $ilCtrl, and $lng.

{
global $lng, $ilCtrl;
$font_family = array(
'sans' => 'Sans Serif',
'times' => 'Times',
'monospace' => 'Monospace',
);
$font_style = array(
'italic' => $lng->txt('italic'),
'bold' => $lng->txt('bold'),
'normal' => $lng->txt('normal'),
'underlined' => $lng->txt('underlined'),
);
$font_size = array(
'small' => $lng->txt('small'),
'normal' => $lng->txt('normal'),
'large' => $lng->txt('large')
);
$default_font_color = '#000000';
$default_font_family = (
isset($defaultSettings['font_family']) &&
isset($font_family[$defaultSettings['font_family']]) ?
$defaultSettings['font_family'] : 'sans'
);
$default_font_style = (
isset($defaultSettings['font_style']) &&
isset($font_family[$defaultSettings['font_style']]) ?
$defaultSettings['font_style'] : 'normal'
);
$default_font_size = (
isset($defaultSettings['font_size']) &&
isset($font_family[$defaultSettings['font_size']]) ?
$defaultSettings['font_size'] : 'normal'
);
$roomTpl->setVariable('VAL_FONTCOLOR', $default_font_color);
foreach ($font_family as $font => $label) {
$roomTpl->setCurrentBlock('chat_fontfamily');
$roomTpl->setVariable('VAL_FONTFAMILY', $font);
$roomTpl->setVariable('LBL_FONTFAMILY', $label);
$roomTpl->setVariable(
'SELECTED_FONTFAMILY', $font == $default_font_family ?
'selected="selected"' : ''
);
$roomTpl->parseCurrentBlock();
}
foreach ($font_style as $font => $label) {
$roomTpl->setCurrentBlock('chat_fontstyle');
$roomTpl->setVariable('VAL_FONTSTYLE', $font);
$roomTpl->setVariable('LBL_FONTSTYLE', $label);
$roomTpl->setVariable(
'SELECTED_FONTSTYLE', $font == $default_font_style ?
'selected="selected"' : ''
);
$roomTpl->parseCurrentBlock();
}
foreach ($font_size as $font => $label) {
$roomTpl->setCurrentBlock('chat_fontsize');
$roomTpl->setVariable('VAL_FONTSIZE', $font);
$roomTpl->setVariable('LBL_FONTSIZE', $label);
$roomTpl->setVariable(
'SELECTED_FONTSIZE', $font == $default_font_size ?
'selected="selected"' : ''
);
$roomTpl->parseCurrentBlock();
}
$roomTpl->setVariable('LBL_FONTCOLOR', $lng->txt('fontcolor'));
$roomTpl->setVariable('LBL_FONTFAMILY', $lng->txt('fontfamily'));
$roomTpl->setVariable('LBL_FONTSTYLE', $lng->txt('fontstyle'));
$roomTpl->setVariable('LBL_FONTSIZE', $lng->txt('fontsize'));
$logoutLink = $ilCtrl->getLinkTarget($this->gui, 'view-logout');
$roomTpl->setVariable('LOGOUT_LINK', $logoutLink);
}
ilChatroomViewTask::renderRightUsersDock (   $roomTpl)
protected

Definition at line 260 of file class.ilChatroomViewTask.php.

References $lng.

{
global $lng;
$roomTpl->setVariable('LBL_MAINROOM', $lng->txt('chat_mainroom'));
$roomTpl->setVariable('LBL_LEAVE_PRIVATE_ROOM', $lng->txt('leave_private_room'));
$roomTpl->setVariable('LBL_JOIN', $lng->txt('chat_join'));
$roomTpl->setVariable('LBL_DELETE_PRIVATE_ROOM', $lng->txt('delete_private_room'));
$roomTpl->setVariable('LBL_INVITE_TO_PRIVATE_ROOM', $lng->txt('invite_to_private_room'));
$roomTpl->setVariable('LBL_KICK', $lng->txt('chat_kick'));
$roomTpl->setVariable('LBL_BAN', $lng->txt('chat_ban'));
$roomTpl->setVariable('LBL_KICK_QUESTION', $lng->txt('kick_question'));
$roomTpl->setVariable('LBL_BAN_QUESTION', $lng->txt('ban_question'));
$roomTpl->setVariable('LBL_ADDRESS', $lng->txt('chat_address'));
$roomTpl->setVariable('LBL_WHISPER', $lng->txt('chat_whisper'));
$roomTpl->setVariable('LBL_CONNECT', $lng->txt('chat_connection_established'));
$roomTpl->setVariable('LBL_DISCONNECT', $lng->txt('chat_connection_disconnected'));
$roomTpl->setVariable('LBL_INVITE_USERS', $lng->txt('chat_invite_users'));
$roomTpl->setVariable('LBL_USER_TAB', $lng->txt('chat_right_box_user'));
$roomTpl->setVariable('LBL_PRIVATE_ROOM', $lng->txt('chat_private_room'));
$roomTpl->setVariable('LBL_CREATE_NEW_PRIVATE_ROOM', $lng->txt('chat_create_new_private_room'));
$roomTpl->setVariable('LBL_TO_MAINROOM', $lng->txt('chat_to_mainroom'));
$roomTpl->setVariable('LBL_CREATE_PRIVATE_ROOM', $lng->txt('chat_create_private_room_button'));
$roomTpl->setVariable('LBL_CREATE_PRIVATE_ROOM_TEXT', $lng->txt('create_private_room_text'));
$roomTpl->setVariable('LBL_WELCOME_TO_CHAT', $lng->txt('welcome_to_chat'));
$roomTpl->setVariable('LBL_USER_INVITED', $lng->txt('user_invited'));
$roomTpl->setVariable('LBL_USER_KICKED', $lng->txt('user_kicked'));
$roomTpl->setVariable('LBL_USER_INVITED_SELF', $lng->txt('user_invited_self'));
$roomTpl->setVariable('LBL_PRIVATE_ROOM_CLOSED', $lng->txt('private_room_closed'));
$roomTpl->setVariable('LBL_PRIVATE_ROOM_ENTERED', $lng->txt('private_room_entered'));
$roomTpl->setVariable('LBL_PRIVATE_ROOM_LEFT', $lng->txt('private_room_left'));
$roomTpl->setVariable('LBL_PRIVATE_ROOM_ENTERED_USER', $lng->txt('private_room_entered_user'));
$roomTpl->setVariable('LBL_KICKED_FROM_PRIVATE_ROOM', $lng->txt('kicked_from_private_room'));
$roomTpl->setVariable('LBL_OK', $lng->txt('ok'));
$roomTpl->setVariable('LBL_CANCEL', $lng->txt('cancel'));
$roomTpl->setVariable('LBL_WHISPER_TO', $lng->txt('whisper_to'));
$roomTpl->setVariable('LBL_SPEAK_TO', $lng->txt('speak_to'));
$roomTpl->setVariable('LBL_USER_IN_ROOM', $lng->txt('user_in_room'));
$roomTpl->setVariable('LBL_USER_IN_ILIAS', $lng->txt('user_in_ilias'));
$roomTpl->setVariable('LBL_HISTORY_CLEARED', $lng->txt('history_cleared'));
$roomTpl->setVariable('LBL_CLEAR_ROOM_HISTORY', $lng->txt('clear_room_history'));
$roomTpl->setVariable('LBL_CLEAR_ROOM_HISTORY_QUESTION', $lng->txt('clear_room_history_question'));
$roomTpl->setVariable('LBL_LAYOUT', $lng->txt('layout'));
$roomTpl->setVariable('LBL_SHOW_SETTINGS', $lng->txt('show_settings'));
$roomTpl->setVariable('LBL_HIDE_SETTINGS', $lng->txt('hide_settings'));
$roomTpl->setVariable('LBL_NO_FURTHER_USERS', $lng->txt('no_further_users'));
$roomTpl->setVariable('LBL_USERS', $lng->txt('users'));
$roomTpl->setVariable('LBL_END_WHISPER', $lng->txt('end_whisper'));
}
ilChatroomViewTask::renderSendMessageBox (   $roomTpl)
protected

Definition at line 313 of file class.ilChatroomViewTask.php.

References $lng.

{
global $lng;
$roomTpl->setVariable('LBL_MESSAGE', $lng->txt('chat_message'));
$roomTpl->setVariable('LBL_TOALL', $lng->txt('chat_message_to_all'));
$roomTpl->setVariable('LBL_OPTIONS', $lng->txt('chat_message_options'));
$roomTpl->setVariable('LBL_DISPLAY', $lng->txt('chat_message_display'));
$roomTpl->setVariable('LBL_SEND', $lng->txt('send'));
}
ilChatroomViewTask::saveClientSettings ( )

Saves client settings fetched from $_POST.

ilCtrl2 $ilCtrl ilLanguage $lng

Definition at line 98 of file class.ilChatroomViewTask.php.

References $_POST, $ilCtrl, $lng, clientsettings(), ilChatroomAdmin\saveClientSettings(), ilUtil\sendSuccess(), and writeClientSettingsToFile().

{
global $ilCtrl, $lng;
require_once 'Modules/Chatroom/classes/class.ilChatroomFormFactory.php';
$factory = new ilChatroomFormFactory();
$form = $factory->getClientSettingsForm();
if( !$form->checkInput() )
{
$form->setValuesByPost();
return $this->clientsettings( $form );
}
$settings = array(
//'hash' => $_POST['hash'],
'hash' => $_POST['name'],
'name' => $_POST['name'],
'url' => $_POST['url'],
'user' => $_POST['user'],
'password' => $_POST['password'],
'client' => CLIENT_ID,
'enable_osd' => (boolean)$_POST['enable_osd'],
'osd_intervall' => (int)$_POST['osd_intervall'],
'chat_enabled' => ((boolean)$_POST['chat_enabled']) && ((boolean)$this->commonSettings->get('soap_user_administration')),
'enable_smilies' => (boolean)$_POST['enable_smilies'],
'play_invitation_sound' => (boolean)$_POST['play_invitation_sound'],
);
$notificationSettings = new ilSetting('notifications');
$notificationSettings->set('osd_polling_intervall', (int)$_POST['osd_intervall']);
$notificationSettings->set('enable_osd', (boolean)$_POST['enable_osd']);
$chatSettings = new ilSetting('chatroom');
$chatSettings->set('chat_enabled', $settings['chat_enabled']);
$chatSettings->set('play_invitation_sound', (bool)$_POST['play_invitation_sound']);
require_once 'Modules/Chatroom/classes/class.ilChatroomAdmin.php';
$adminSettings = new ilChatroomAdmin( $this->gui->object->getId() );
$adminSettings->saveClientSettings( (object)$settings );
$this->writeClientSettingsToFile( $settings );
ilUtil::sendSuccess( $lng->txt( 'settings_has_been_saved' ), true );
$ilCtrl->redirect( $this->gui, 'view-clientsettings' );
}

+ Here is the call graph for this function:

ilChatroomViewTask::saveSettings ( )

Saves settings fetched from $_POST.

ilCtrl2 $ilCtrl ilLanguage $lng

Definition at line 48 of file class.ilChatroomViewTask.php.

References $_POST, $ilCtrl, $lng, checkPrivHosts(), clientsettings(), ilChatroomAdmin\saveGeneralSettings(), ilUtil\sendFailure(), ilUtil\sendSuccess(), and writeDataToFile().

{
global $ilCtrl, $lng;
require_once 'Modules/Chatroom/classes/class.ilChatroomFormFactory.php';
$factory = new ilChatroomFormFactory();
$form = $factory->getGeneralSettingsForm();
if( !$form->checkInput() )
{
$form->setValuesByPost();
return $this->clientsettings( $form );
}
if( !$this->checkPrivHosts($_POST['priv_hosts']) )
{
$form->setValuesByPost();
ilUtil::sendFailure( $lng->txt('invalid_priv_hosts') );
return $this->clientsettings( $form );
}
$settings = array(
'protocol' => $_POST['protocol'],
'instance' => $_POST['instance'],
'port' => $_POST['port'],
'address' => $_POST['address'],
'priv_hosts' => $_POST['priv_hosts'],
'keystore' => $_POST['keystore'],
'keypass' => $_POST['keypass'],
'storepass' => $_POST['storepass']
);
require_once 'Modules/Chatroom/classes/class.ilChatroomAdmin.php';
$adminSettings = new ilChatroomAdmin( $this->gui->object->getId() );
$adminSettings->saveGeneralSettings( (object)$settings );
$this->writeDataToFile( $settings );
ilUtil::sendSuccess( $lng->txt( 'settings_has_been_saved' ), true );
$ilCtrl->redirect( $this->gui, 'view-serversettings' );
}

+ Here is the call graph for this function:

ilChatroomViewTask::serversettings ( ilPropertyFormGUI  $form = null)

Prepares view form and displays it.

ilObjUser $ilUser ilTemplate $tpl ilCtrl2 $ilCtrl ilLanguage $lng

Parameters
ilPropertyFormGUI$form

Definition at line 290 of file class.ilChatroomViewTask.php.

References $ilCtrl, $lng, $tpl, ilUtil\_getHttpPath(), ilChatroomServerConnector\checkServerConnection(), ilChatroom\checkUserPermissions(), defaultActions(), ilChatroomAdmin\loadGeneralSettings(), ilUtil\sendInfo(), and showSoapWarningIfNeeded().

{
global $ilUser, $tpl, $ilCtrl, $lng;
include_once 'Modules/Chatroom/classes/class.ilChatroom.php';
ilChatroom::checkUserPermissions( 'read', $this->gui->ref_id );
$this->defaultActions();
$this->gui->switchToVisibleMode();
require_once 'Modules/Chatroom/classes/class.ilChatroomAdmin.php';
$adminSettings = new ilChatroomAdmin( $this->gui->object->getId() );
$serverSettings = (array)$adminSettings->loadGeneralSettings();
if( $form === null )
{
require_once 'Modules/Chatroom/classes/class.ilChatroomFormFactory.php';
$factory = new ilChatroomFormFactory();
$form = $factory->getGeneralSettingsForm();
$form->setValuesByArray( $serverSettings );
}
require_once 'Modules/Chatroom/classes/class.ilChatroomServerConnector.php';
if ($serverSettings['port'] && $serverSettings['address'] && !(boolean)@ilChatroomServerConnector::checkServerConnection()) {
ilUtil::sendInfo($lng->txt('chat_cannot_connect_to_server'));
}
$form->setTitle( $lng->txt('chatserver_settings_title') );
$form->addCommandButton( 'view-saveSettings', $lng->txt( 'save' ) );
//$form->addCommandButton( 'view-serversettings', $lng->txt( 'cancel' ) );
$form->setFormAction( $ilCtrl->getFormAction( $this->gui, 'view-saveSettings' ) );
$serverTpl = new ilTemplate('tpl.chatroom_serversettings.html', true, true, 'Modules/Chatroom');
$serverTpl->setVariable('VAL_SERVERSETTINGS_FORM', $form->getHTML());
$serverTpl->setVariable('LBL_SERVERSETTINGS_FURTHER_INFORMATION', sprintf($lng->txt('server_further_information'), ilUtil::_getHttpPath() . '/Modules/Chatroom/server/README.txt'));
$tpl->setVariable( 'ADM_CONTENT', $serverTpl->get() );
}

+ Here is the call graph for this function:

ilChatroomViewTask::setupTemplate ( )
private

Adds CSS and JavaScript files that should be included in the header.

ilTemplate $tpl

Definition at line 358 of file class.ilChatroomViewTask.php.

References $tpl.

{
global $tpl;
$tpl->addJavaScript('./Modules/Scorm2004/scripts/questions/jquery.js');
$tpl->addJavaScript('Modules/Chatroom/js/colorpicker/jquery.colorPicker.js');
$tpl->addJavaScript('Modules/Chatroom/js/chat.js');
$tpl->addJavaScript('Modules/Chatroom/js/iliaschat.jquery.js');
$tpl->addJavaScript('Modules/Chatroom/js/json2.js');
$tpl->addJavaScript('./Services/UIComponent/AdvancedSelectionList/js/AdvancedSelectionList.js');
$tpl->addCSS('Modules/Chatroom/js/colorpicker/colorPicker.css');
$tpl->addCSS('Modules/Chatroom/templates/default/style.css');
}
ilChatroomViewTask::showNameSelection ( ilChatroomUser  $chat_user)
private

Prepares and displays name selection.

Fetches name option by calling getChatNameSuggestions method on given $chat_user object.

ilLanguage $lng ilCtrl2 $ilCtrl iltemplate $tpl

Parameters
ilChatroomUser$chat_user

Definition at line 334 of file class.ilChatroomViewTask.php.

References $ilCtrl, $lng, $tpl, and ilChatroomUser\getChatNameSuggestions().

{
global $lng, $ilCtrl, $tpl;
require_once 'Modules/Chatroom/classes/class.ilChatroomFormFactory.php';
$name_options = $chat_user->getChatNameSuggestions();
$formFactory = new ilChatroomFormFactory();
$selectionForm = $formFactory->getUserChatNameSelectionForm($name_options);
$ilCtrl->saveParameter($this->gui, 'sub');
$selectionForm->addCommandButton('view-joinWithCustomName', $lng->txt('enter'));
$selectionForm->setFormAction(
$ilCtrl->getFormAction($this->gui, 'view-joinWithCustomName')
);
$tpl->setVariable('ADM_CONTENT', $selectionForm->getHtml());
}

+ Here is the call graph for this function:

ilChatroomViewTask::showRoom ( ilChatroom  $room,
ilChatroomUser  $chat_user 
)
private

Prepares and displays chatroom and connects user to it.

iltemplate $tpl ilObjUser $ilUser ilCtrl2 $ilCtrl ilLanguage $lng

Parameters
ilChatroom$room
ilChatroomUser$chat_user

Definition at line 52 of file class.ilChatroomViewTask.php.

References $_GET, $_REQUEST, $_SESSION, $ilCtrl, $lng, $query, $tpl, ilChatroomSmilies\_getSmilies(), ilChatroom\addHistoryEntry(), cancelJoin(), ilChatroom\checkUserPermissions(), ilChatroom\connectUser(), exit, ilChatroom\getActivePrivateRooms(), ilChatroom\getConnectedUsers(), ilChatroom\getLastMessages(), ilChatroom\getRoomId(), ilChatroom\getSetting(), ilChatroomUser\getUserId(), ilChatroomUser\getUsername(), ilChatroom\isAllowedToEnterPrivateRoom(), ilChatroom\isSubscribed(), ilChatroom\isUserBanned(), ilUtil\redirect(), ilUtil\sendFailure(), and ilChatroom\subscribeUserToPrivateRoom().

{
global $tpl, $ilUser, $ilCtrl, $lng, $ilAccess, $lng, $ilNavigationHistory;
if ( !ilChatroom::checkUserPermissions( 'read', $this->gui->ref_id ) )
{
ilUtil::redirect("repository.php");
}
$user_id = $chat_user->getUserId($ilUser);
$ilNavigationHistory->addItem($_GET['ref_id'], 'repository.php?cmd=view&ref_id='.$_GET['ref_id'], 'chtr');
if( $room->isUserBanned($user_id) )
{
$this->cancelJoin( $lng->txt('banned') );
return;
}
$scope = $room->getRoomId();
$connector = $this->gui->getConnector();
$response = @$connector->connect($scope, $user_id);
if( !$response )
{
ilUtil::sendFailure($lng->txt('unable_to_connect'), true);
$link = $ilCtrl->getLinkTargetByClass(
'ilinfoscreengui', 'info', '', false, false
);
}
if( !$room->isSubscribed($chat_user->getUserId()) && $room->connectUser($chat_user) )
{
$messageObject = array(
'type' => 'connected',
'users' => array(
array(
'login' => $chat_user->getUsername(),
'id' => $user_id,
),
),
'timestamp' => time() * 1000//date( 'c' )
);
$message = json_encode($messageObject);
$connector->sendMessage(
$scope,
$message
);
if( true || $room->getSetting('enable_history') ) {
$room->addHistoryEntry($messageObject);
}
}
$connection_info = json_decode($response);
$settings = $connector->getSettings();
$known_private_room = $room->getActivePrivateRooms($ilUser->getId());
$initial = new stdClass();
$initial->users = $room->getConnectedUsers();
$initial->private_rooms = array_values($known_private_room);
$initial->redirect_url = $ilCtrl->getLinkTarget($this->gui, 'view-lostConnection', '', false, false);
$initial->private_rooms_enabled = (boolean)$room->getSetting('private_rooms_enabled');
$initial->userinfo = array(
'moderator' => $ilAccess->checkAccess('moderate', '', $_GET['ref_id']),
'userid' => $chat_user->getUserId()
);
$smileys = array();
include_once('Modules/Chatroom/classes/class.ilChatroomSmilies.php');
if ($settings->getSmiliesEnabled()) {
$smileys_array = ilChatroomSmilies::_getSmilies();
foreach( $smileys_array as $smiley_array )
{
foreach( $smiley_array as $key => $value )
{
if( $key == 'smiley_keywords' )
{
$new_keys = explode("\n", $value);
}
if( $key == 'smiley_fullpath' )
{
$new_val = $value;
}
}
foreach( $new_keys as $new_key )
{
$smileys[$new_key] = $new_val;
}
}
$initial->smileys = $smileys;
}
else {
$initial->smileys = '{}';
}
$initial->messages = array();
if( isset($_REQUEST['sub']) )
{
if( $known_private_room[$_REQUEST['sub']] )
{
if( !$room->isAllowedToEnterPrivateRoom( $chat_user->getUserId(), $_REQUEST['sub'] ) )
{
$initial->messages[] = array(
'type' => 'error',
'message' => $lng->txt('not_allowed_to_enter'),
);
}
else
{
$scope = $room->getRoomId();
$params = array();
$params['user'] = $chat_user->getUserId();
$params['sub'] = $_REQUEST['sub'];
$params['message'] = json_encode(
array( 'type' => 'private_room_entered',
'user' => $user_id
)
);
$query = http_build_query( $params );
$connector = $this->gui->getConnector();
$response = $connector->enterPrivateRoom( $scope, $query );
$responseObject = json_decode( $response );
if( $responseObject->success == true )
{
$room->subscribeUserToPrivateRoom( $params['sub'], $params['user'] );
}
$message = json_encode( array(
'type' => 'private_room_entered',
'user' => $params['user'],
'sub' => $params['sub']
));
$connector->sendMessage( $room->getRoomId(), $message, array('public' => 1, 'sub' => $params['sub']) );
$initial->enter_room = $_REQUEST['sub'];
$initial->messages[] = array(
'type' => 'notice',
'user' => $params['user'],
'sub' => $params['sub'],
'entersub' => 1
);
}
if ($_SESSION['show_invitation_message']) {
$initial->messages[] = array(
'type' => 'notice',
'message' => $lng->txt('user_invited'),
'sub' => $_REQUEST['sub']
);
unset ($_SESSION['show_invitation_message']);
}
}
else
{
$initial->messages[] = array(
'type' => 'error',
'message' => $lng->txt('user_invited'),
);
}
}
if ((int)$room->getSetting('display_past_msgs')) {
$initial->messages = array_merge($initial->messages, array_reverse($room->getLastMessages($room->getSetting('display_past_msgs'), $chat_user)));
}
//var_dump($initial->messages);
$roomTpl = new ilTemplate('tpl.chatroom.html', true, true, 'Modules/Chatroom');
$roomTpl->setVariable('SESSION_ID', $connection_info->{'session-id'});
$roomTpl->setVariable('BASEURL', $settings->getBaseURL());
$roomTpl->setVariable('INSTANCE', $settings->getInstance());
$roomTpl->setVariable('SCOPE', $scope);
$roomTpl->setVariable('MY_ID', $user_id);
$roomTpl->setVariable('INITIAL_DATA', json_encode($initial));
$roomTpl->setVariable('POSTURL', $ilCtrl->getLinkTarget($this->gui, 'postMessage', '', true, true));
$roomTpl->setVariable('ACTIONS', $lng->txt('actions'));
$roomTpl->setVariable('LBL_CREATE_PRIVATE_ROOM', $lng->txt('create_private_room_label'));
$roomTpl->setVariable('LBL_USER', $lng->txt('user'));
$roomTpl->setVariable('LBL_USER_TEXT', $lng->txt('invite_username'));
$roomTpl->setVariable('LBL_AUTO_SCROLL', $lng->txt('auto_scroll'));
$roomTpl->setVariable('INITIAL_USERS', json_encode($room->getConnectedUsers()));
$this->renderFontSettings($roomTpl, array());
$this->renderFileUploadForm($roomTpl);
$this->renderSendMessageBox($roomTpl);
$this->renderRightUsersDock($roomTpl);
$tpl->setVariable('ADM_CONTENT', $roomTpl->get());
}

+ Here is the call graph for this function:

ilChatroomViewTask::showSoapWarningIfNeeded ( )
private

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

References $lng, and ilUtil\sendInfo().

Referenced by clientsettings(), and serversettings().

{
if( !$this->commonSettings->get('soap_user_administration') )
{
global $lng;
ilUtil::sendInfo( $lng->txt('soap_must_be_enabled') );
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilChatroomViewTask::writeClientSettingsToFile (   $settings)
protected

Writes client settings to client.properties file.

Parameters
array$settings

Definition at line 153 of file class.ilChatroomViewTask.php.

References checkDirectory(), and getClientFileContent().

Referenced by saveClientSettings().

{
if( $srv_prp_path = $this->checkDirectory() )
{
$handle = fopen( $srv_prp_path.'client.properties', 'w' );
if( !fwrite($handle, $this->getClientFileContent($settings)) )
{
throw new Exception('Cannot write to file');
}
fclose($handle);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilChatroomViewTask::writeDataToFile (   $settings)
protected

Writes server settings to server.properties file.

Parameters
array$settings

Definition at line 193 of file class.ilChatroomViewTask.php.

References checkDirectory(), and getFileContent().

Referenced by saveSettings().

{
if( $srv_prp_path = $this->checkDirectory() )
{
$handle = fopen( $srv_prp_path.'server.properties', 'w' );
if( !fwrite($handle, $this->getFileContent($settings)) )
{
throw new Exception('Cannot write to file');
}
fclose($handle);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

ilChatroomViewTask::$commonSettings
private

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

ilChatroomViewTask::$gui
private

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

Referenced by __construct().


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