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

Class ilChatroomBanTask. More...

+ Inheritance diagram for ilChatroomBanTask:
+ Collaboration diagram for ilChatroomBanTask:

Public Member Functions

 __construct (ilChatroomObjectGUI $gui)
 Constructor.
 show ()
 Displays banned users task.
 executeDefault ($method)
 Calls $this->show method.
 active ()
 Kicks and bans user, fetched from $_REQUEST['user'] and adds history entry.

Private Member Functions

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

Private Attributes

 $gui

Detailed Description

Class ilChatroomBanTask.

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

Constructor & Destructor Documentation

ilChatroomBanTask::__construct ( ilChatroomObjectGUI  $gui)

Constructor.

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

Parameters
ilChatroomObjectGUI$gui

Reimplemented from ilChatroomTaskHandler.

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

References $gui.

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

Member Function Documentation

ilChatroomBanTask::active ( )

Kicks and bans user, fetched from $_REQUEST['user'] and adds history entry.

ilObjUser $ilUser

Definition at line 106 of file class.ilChatroomBanTask.php.

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

{
global $ilUser, $ilCtrl;
if ( !ilChatroom::checkUserPermissions( array('read', 'moderate') , $this->gui->ref_id ) )
{
$ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", ROOT_FOLDER_ID);
$ilCtrl->redirectByClass("ilrepositorygui", "");
}
$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(
$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);
$room->banUser($_REQUEST['user']);
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
));
// 2013-09-11: Should already been done by the chat server
$room->disconnectUser($params['userToKick']);
}
}
else
{
$response = json_encode(array(
'success' => false,
'reason' => 'unkown room'
));
}
echo $response;
}

+ Here is the call graph for this function:

ilChatroomBanTask::buildMessage (   $messageString,
ilChatroomUser  $user 
)
private

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

Parameters
string$messageString
ilChatroomUser$user
Returns
stdClass

Definition at line 184 of file class.ilChatroomBanTask.php.

Referenced by active().

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

+ Here is the caller graph for this function:

ilChatroomBanTask::executeDefault (   $method)

Calls $this->show method.

Parameters
string$method

Reimplemented from ilChatroomTaskHandler.

Definition at line 96 of file class.ilChatroomBanTask.php.

References show().

{
$this->show();
}

+ Here is the call graph for this function:

ilChatroomBanTask::show ( )

Displays banned users task.

ilCtrl2 $ilCtrl

Definition at line 38 of file class.ilChatroomBanTask.php.

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

Referenced by executeDefault().

{
//global $lng, $ilCtrl;
global $ilCtrl;
include_once 'Modules/Chatroom/classes/class.ilChatroom.php';
ilChatroom::checkUserPermissions( 'read', $this->gui->ref_id );
$this->gui->switchToVisibleMode();
require_once 'Modules/Chatroom/classes/class.ilBannedUsersTableGUI.php';
$table = new ilBannedUsersTableGUI( $this->gui, 'ban-show' );
$table->setFormAction( $ilCtrl->getFormAction( $this->gui, 'ban-show' ) );
$room = ilChatroom::byObjectId( $this->gui->object->getId() );
if( $room )
{
$table->setData( $room->getBannedUsers() );
}
$this->gui->tpl->setVariable( 'ADM_CONTENT', $table->getHTML() );
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

ilChatroomBanTask::$gui
private

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

Referenced by __construct().


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