ILIAS  Release_4_2_x_branch Revision 61807
 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 (ilDBayObjectGUI $gui)
 Constructor.
 show ()
 Displays banned users task.
 delete ()
 Unbans users fetched from $_REQUEST['banned_user_id'].
 executeDefault ($method)
 Calls $this->show method.
 active ()
 Kicks and bans user, fetched from $_REQUEST['user'] and adds history entry.
- Public Member Functions inherited from ilDBayTaskHandler
 execute ($method)
 Executes given $method if existing, otherwise executes executeDefault() method.

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 ( ilDBayObjectGUI  $gui)

Constructor.

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

Parameters
ilDBayObjectGUI$gui

Reimplemented from ilDBayTaskHandler.

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 101 of file class.ilChatroomBanTask.php.

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

{
global $ilUser;
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(
$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
));
$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:

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 177 of file class.ilChatroomBanTask.php.

References $data.

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::delete ( )

Unbans users fetched from $_REQUEST['banned_user_id'].

ilCtrl2 $ilCtrl

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

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

{
global $ilCtrl;
$users = $_REQUEST['banned_user_id'];
if( !is_array( $users ) )
{
return;
}
$room = ilChatroom::byObjectId( $this->gui->object->getId() );
$room->unbanUser( $users );
$ilCtrl->redirect( $this->gui, 'ban-show' );
}

+ Here is the call graph for this function:

ilChatroomBanTask::executeDefault (   $method)

Calls $this->show method.

Parameters
string$method

Reimplemented from ilDBayTaskHandler.

Definition at line 91 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: