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

Class ilChatroomKickTask. More...

+ Inheritance diagram for ilChatroomKickTask:
+ Collaboration diagram for ilChatroomKickTask:

Public Member Functions

 __construct (ilDBayObjectGUI $gui)
 Constructor.
 executeDefault ($method)
 Displays window box to kick a user fetched from $_REQUEST['user'].
 sub ()
 Kicks user from subroom into mainroom.
 recantInvitation ($subroom_id, $user_id)
 Recant invitation for given $user_id in given $subroom_id.
- Public Member Functions inherited from ilDBayTaskHandler
 execute ($method)
 Executes given $method if existing, otherwise executes executeDefault() method.

Private Member Functions

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

Private Attributes

 $gui

Detailed Description

Class ilChatroomKickTask.

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.ilChatroomKickTask.php.

Constructor & Destructor Documentation

ilChatroomKickTask::__construct ( ilDBayObjectGUI  $gui)

Constructor.

Sets $this->gui using given $gui.

Parameters
ilDBayObjectGUI$gui

Reimplemented from ilDBayTaskHandler.

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

References $gui.

{
$this->gui = $gui;
}

Member Function Documentation

ilChatroomKickTask::buildMessage (   $messageString,
ilChatroomUser  $chat_user 
)
private

Instantiates stdClass, sets $data->user and $data->userToKick using given $messageString and $chat_user and returns $data.

Parameters
string$messageString
ilChatroomUser$chat_user
Returns
stdClass

Definition at line 110 of file class.ilChatroomKickTask.php.

References $data.

Referenced by executeDefault().

{
$data = new stdClass();
$data->user = $this->gui->object->getPersonalInformation( $chat_user );
$data->userToKick = $messageString;
$data->timestamp = date( 'c' );
$data->type = 'kick';
return $data;
}

+ Here is the caller graph for this function:

ilChatroomKickTask::executeDefault (   $method)

Displays window box to kick a user fetched from $_REQUEST['user'].

ilObjUser $ilUser

Parameters
string$method

Reimplemented from ilDBayTaskHandler.

Definition at line 36 of file class.ilChatroomKickTask.php.

References $_REQUEST, $query, buildMessage(), ilChatroom\byObjectId(), ilChatroom\checkUserPermissions(), exit, ilUtil\redirect(), and ilUtil\stripSlashes().

{
global $ilUser;
require_once 'Modules/Chatroom/classes/class.ilChatroom.php';
require_once 'Modules/Chatroom/classes/class.ilChatroomUser.php';
if(!ilChatroom::checkUserPermissions(array('read', 'moderate'), $this->gui->ref_id))
{
ilUtil::redirect("repository.php");
}
$room = ilChatroom::byObjectId($this->gui->object->getId());
if($room)
{
// if user is in scope
$scope = $room->getRoomId();
$chat_user = new ilChatroomUser($ilUser, $room);
$messageObject = $this->buildMessage(
ilUtil::stripSlashes($_REQUEST['user']), $chat_user
);
$message = json_encode($messageObject);
$params = array(
'message' => $message,
'userToKick' => $_REQUEST['user']
);
$query = http_build_query($params);
$connector = $this->gui->getConnector();
$response = $connector->kick($scope, $query);
$responseObject = json_decode($response);
if($responseObject->success == true)
{
$room->addHistoryEntry($messageObject, '', 1);
$message = json_encode(array(
'type' => 'userjustkicked',
'user' => $params['userToKick'],
'sub' => 0
));
$connector->sendMessage($room->getRoomId(), $message, array(
'public' => 1,
'sub' => 0
));
$room->disconnectUser(new ilObjUser($params['userToKick']));
}
}
else
{
$response = json_encode(array(
'success' => false,
'reason' => 'unkown room'
));
}
echo $response;
}

+ Here is the call graph for this function:

ilChatroomKickTask::recantInvitation (   $subroom_id,
  $user_id 
)

Recant invitation for given $user_id in given $subroom_id.

ilDB $ilDB

Parameters
integer$subroom_id
integer$user_id

Definition at line 197 of file class.ilChatroomKickTask.php.

References $ilDB, $query, $res, and $row.

Referenced by sub().

{
global $ilDB;
$query = "
SELECT proom_id
FROM chatroom_proomaccess
WHERE proom_id = %s
AND user_id = %s
";
$types = array( 'integer', 'integer' );
$values = array( $subroom_id, $user_id );
$res = $ilDB->queryF( $query, $types, $values );
if( $row = $ilDB->fetchAssoc( $res ) )
{
$delete = "
DELETE
FROM chatroom_proomaccess
WHERE proom_id = %s
AND user_id = %s
";
$ilDB->manipulateF( $delete, $types, $values );
}
}

+ Here is the caller graph for this function:

ilChatroomKickTask::sub ( )

Kicks user from subroom into mainroom.

ilObjUser $ilUser

Definition at line 127 of file class.ilChatroomKickTask.php.

References $_REQUEST, $query, ilChatroom\byObjectId(), ilChatroom\checkPermissionsOfUser(), exit, recantInvitation(), and ilUtil\redirect().

{
global $ilUser;
require_once 'Modules/Chatroom/classes/class.ilChatroom.php';
require_once 'Modules/Chatroom/classes/class.ilChatroomUser.php';
$room = ilChatroom::byObjectId($this->gui->object->getId());
if($room)
{
if(!$room->isOwnerOfPrivateRoom($ilUser->getId(), $_REQUEST['sub']))
{
if(!ilChatroom::checkPermissionsOfUser($ilUser->getId(), array('read', 'moderate'), $this->gui->ref_id))
{
ilUtil::redirect("repository.php");
}
}
$scope = $room->getRoomId();
$params = array();
$params['user'] = $_REQUEST['user'];
$params['sub'] = $_REQUEST['sub'];
if($room->userIsInPrivateRoom($params['sub'], $params['user']))
{
$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']);
$this->recantInvitation($params['sub'], $params['user']);
$message = json_encode(array(
'type' => 'userjustkicked',
'user' => $params['user'],
'sub' => $params['sub']
));
$connector->sendMessage($room->getRoomId(), $message, array(
'public' => 1,
'sub' => 0
));
}
else
{
$response = json_encode(array(
'success' => true,
'message' => 'was not in room'
));
}
echo $response;
}
}

+ Here is the call graph for this function:

Field Documentation

ilChatroomKickTask::$gui
private

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

Referenced by __construct().


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