ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilChatroomPrivateRoomTask Class Reference

Class ilChatroomPrivateRoomTask. More...

+ Inheritance diagram for ilChatroomPrivateRoomTask:
+ Collaboration diagram for ilChatroomPrivateRoomTask:

Public Member Functions

 __construct (ilChatroomObjectGUI $gui)
 Constructor.
 executeDefault ($method)
 create ()
 Prepares and posts message fetched from $_REQUEST['message'] to recipients fetched from $_REQUEST['recipient'] and adds an entry to history if successful.
 delete ()
 leave ()
 Prepares and posts message fetched from $_REQUEST['message'] to recipients fetched from $_REQUEST['recipient'] and adds an entry to history if successful.
 enter ()
 listUsers ()

Private Member Functions

 buildMessage ($messageString, $params, ilChatroomUser $chat_user)
 Instantiates stdClass, sets $data->user, $data->message, $data->public and $data->recipients using given $chat_user, $messageString and $params and returns $data.

Private Attributes

 $gui

Detailed Description

Constructor & Destructor Documentation

ilChatroomPrivateRoomTask::__construct ( ilChatroomObjectGUI  $gui)

Constructor.

Sets $this->gui using given $gui

Parameters
ilChatroomObjectGUI$gui

Reimplemented from ilChatroomTaskHandler.

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

References $gui.

{
$this->gui = $gui;
}

Member Function Documentation

ilChatroomPrivateRoomTask::buildMessage (   $messageString,
  $params,
ilChatroomUser  $chat_user 
)
private

Instantiates stdClass, sets $data->user, $data->message, $data->public and $data->recipients using given $chat_user, $messageString and $params and returns $data.

Parameters
string$messageString
array$params
ilChatroomUser$chat_user
Returns
stdClass

Definition at line 314 of file class.ilChatroomPrivateRoomTask.php.

References ilChatroomUser\getUserId().

{
$data = new stdClass();
$data->user = $chat_user->getUserId(); //$this->gui->object->getPersonalInformation( $chat_user );
$data->title = $params['title'];
$data->timestamp = date( 'c' );
$data->type = 'private_room_created';
return $data;
}

+ Here is the call graph for this function:

ilChatroomPrivateRoomTask::create ( )

Prepares and posts message fetched from $_REQUEST['message'] to recipients fetched from $_REQUEST['recipient'] and adds an entry to history if successful.

ilTemplate $tpl ilObjUser $ilUser

Parameters
string$method

Definition at line 45 of file class.ilChatroomPrivateRoomTask.php.

References $_REQUEST, $ilCtrl, $ilUser, $tpl, ilChatroom\byObjectId(), ilChatroom\checkUserPermissions(), and exit.

{
global $tpl, $ilUser, $ilCtrl;
require_once 'Modules/Chatroom/classes/class.ilChatroom.php';
require_once 'Modules/Chatroom/classes/class.ilChatroomUser.php';
if ( !ilChatroom::checkUserPermissions( 'read', $this->gui->ref_id ) )
{
$ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", ROOT_FOLDER_ID);
$ilCtrl->redirectByClass("ilrepositorygui", "");
}
$room = ilChatroom::byObjectId( $this->gui->object->getId() );
$chat_user = new ilChatroomUser($ilUser, $room);
$user_id = $chat_user->getUserId();
if( !$room )
{
$response = json_encode( array(
'success' => false,
'reason' => 'unkown room'
) );
echo json_encode( $response );
}
else if( !$room->isSubscribed( $chat_user->getUserId() ) )
{
$response = json_encode( array(
'success' => false,
'reason' => 'not subscribed'
) );
echo json_encode( $response );
}
$title = $room->getUniquePrivateRoomTitle($_REQUEST['title']);
$connector = $this->gui->getConnector();
$response = $connector->createPrivateRoom($room, $title, $chat_user);
echo json_encode($response);
}

+ Here is the call graph for this function:

ilChatroomPrivateRoomTask::delete ( )

Definition at line 90 of file class.ilChatroomPrivateRoomTask.php.

References $_REQUEST, $ilUser, $query, $tpl, ilChatroom\byObjectId(), and exit.

{
global $tpl, $ilUser, $rbacsystem;
require_once 'Modules/Chatroom/classes/class.ilChatroom.php';
require_once 'Modules/Chatroom/classes/class.ilChatroomUser.php';
$room = ilChatroom::byObjectId( $this->gui->object->getId() );
$chat_user = new ilChatroomUser($ilUser, $room);
$user_id = $chat_user->getUserId();
if( !$room )
{
$response = json_encode( array(
'success' => false,
'reason' => 'unkown room'
) );
echo json_encode( $response );
}
else if( !$room->isOwnerOfPrivateRoom( $user_id, $_REQUEST['sub'] ) && !$rbacsystem->checkAccess('moderate', $this->gui->getRefId()) )
{
$response = json_encode( array(
'success' => false,
'reason' => 'not owner of private room'
) );
echo json_encode( $response );
}
$scope = $room->getRoomId();
$params = array();
$params['user'] = $chat_user->getUserId();
$params['id'] = $room->closePrivateRoom($_REQUEST['sub'], $chat_user, $settings);
$query = http_build_query( $params );
$connector = $this->gui->getConnector();
if( true || $responseObject->success == true )
{
$message = json_encode( array(
'type' => 'private_room_deleted',
//'recipients' => $chat_user->getUserId(),//$users,
'timestamp' => date( 'c' ),
'public' => 1,
//'title' => $title,
'id' => $responseObject->id,
'proom_id' => $_REQUEST['sub'],
'message' => array(
'message' => 'room deleted',
'public' => '1',
'user' => 'system'
)
) );
$connector->sendMessage( $room->getRoomId(), $message, array('public' => 1) );
}
$response = json_encode(array('success' => true));
echo $response;
}

+ Here is the call graph for this function:

ilChatroomPrivateRoomTask::enter ( )

Definition at line 230 of file class.ilChatroomPrivateRoomTask.php.

References $_REQUEST, $ilUser, $query, $tpl, ilChatroom\byObjectId(), ilChatroom\checkUserPermissions(), and exit.

{
global $tpl, $ilUser;
ilChatroom::checkUserPermissions( 'read', $this->gui->ref_id );
$room = ilChatroom::byObjectId( $this->gui->object->getId() );
$chat_user = new ilChatroomUser( $ilUser, $room );
$user_id = $chat_user->getUserId();
if( !$room )
{
$response = json_encode( array(
'success' => false,
'reason' => 'unkown room'
) );
echo json_encode( $response );
}
else if( !$room->isAllowedToEnterPrivateRoom( $chat_user->getUserId(), $_REQUEST['sub'] ) )
{
$response = json_encode( array(
'success' => false,
'reason' => 'not allowed enter to private room'
) );
echo json_encode( $response );
}
$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 );
$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']) );
if( $responseObject->success == true )
{
$room->subscribeUserToPrivateRoom( $params['sub'], $params['user'] );
}
echo $response;
}

+ Here is the call graph for this function:

ilChatroomPrivateRoomTask::executeDefault (   $requestedMethod)
Parameters
string$requestedMethod
Returns
mixed

Reimplemented from ilChatroomTaskHandler.

Definition at line 32 of file class.ilChatroomPrivateRoomTask.php.

{
}
ilChatroomPrivateRoomTask::leave ( )

Prepares and posts message fetched from $_REQUEST['message'] to recipients fetched from $_REQUEST['recipient'] and adds an entry to history if successful.

ilTemplate $tpl ilObjUser $ilUser

Parameters
string$method

Definition at line 163 of file class.ilChatroomPrivateRoomTask.php.

References $_REQUEST, $ilUser, $query, $tpl, ilChatroom\byObjectId(), and exit.

{
global $tpl, $ilUser;
$room = ilChatroom::byObjectId( $this->gui->object->getId() );
$chat_user = new ilChatroomUser( $ilUser, $room );
$user_id = $chat_user->getUserId();
$connector = $this->gui->getConnector();
if( !$room )
{
$response = json_encode( array(
'success' => false,
'reason' => 'unkown room'
) );
echo json_encode( $response );
}
else if( !$room->isSubscribed( $chat_user->getUserId() ) )
{
$response = json_encode( array(
'success' => false,
'reason' => 'not subscribed'
) );
echo json_encode( $response );
}
$scope = $room->getRoomId();
$params = array();
$params['user'] = $chat_user->getUserId();
$params['sub'] = $_REQUEST['sub'];
$message = json_encode( array(
'type' => 'private_room_left',
'user' => $params['user'],
'sub' => $params['sub']
));
$connector->sendMessage( $room->getRoomId(), $message, array('public' => 1, 'sub' => $params['sub']) );
if( $room->userIsInPrivateRoom( $params['sub'], $params['user'] ) )
{
//$params = array_merge( $params, array('message' => $message) );
$query = http_build_query( $params );
$connector = $this->gui->getConnector();
$response = $connector->leavePrivateRoom( $scope, $query );
$responseObject = json_decode( $response );
/*
if( $responseObject->success == true && $room->getSetting( 'enable_history' ) )
{
//$room->addHistoryEntry( $message, $recipient, $publicMessage );
}
*/
$room->unsubscribeUserFromPrivateRoom( $params['sub'], $params['user'] );
}
else
{
$response = json_encode( array('success' => true, 'message' => 'was not in room') );
}
echo $response;
}

+ Here is the call graph for this function:

ilChatroomPrivateRoomTask::listUsers ( )

Definition at line 294 of file class.ilChatroomPrivateRoomTask.php.

References $_REQUEST, $ilUser, ilChatroom\byObjectId(), and exit.

{
global $ilUser;
$room = ilChatroom::byObjectId( $this->gui->object->getId() );
echo json_encode( $room->listUsersInPrivateRoom( $_REQUEST['sub'] ) );
}

+ Here is the call graph for this function:

Field Documentation

ilChatroomPrivateRoomTask::$gui
private

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

Referenced by __construct().


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