ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilChatroomBanTask Class Reference

Class ilChatroomBanTask. More...

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

Public Member Functions

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

Private Member Functions

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

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

◆ __construct()

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.

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

References $gui.

Member Function Documentation

◆ active()

ilChatroomBanTask::active ( )

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

@global ilObjUser $ilUser

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

107 {
108 global $ilUser, $ilCtrl;
109
110 if ( !ilChatroom::checkUserPermissions( array('read', 'moderate') , $this->gui->ref_id ) )
111 {
112 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", ROOT_FOLDER_ID);
113 $ilCtrl->redirectByClass("ilrepositorygui", "");
114 }
115
116 $room = ilChatroom::byObjectId($this->gui->object->getId());
117
118 if($room)
119 {
120 // if user is in scope
121 $scope = $room->getRoomId();
122
123 $chat_user = new ilChatroomUser($ilUser, $room);
124
125 $messageObject = $this->buildMessage(
127 $chat_user
128 );
129
130 $message = json_encode($messageObject);
131
132
133 $params = array(
134 'message' => $message,
135 'userToKick' => $_REQUEST['user']
136 );
137
138 $query = http_build_query($params);
139 $connector = $this->gui->getConnector();
140 $response = $connector->kick($scope, $query);
141 $responseObject = json_decode($response);
142
143 $room->banUser($_REQUEST['user']);
144
145 if($responseObject->success == true)
146 {
147 $room->addHistoryEntry($messageObject, '', 1);
148
149 $message = json_encode(array(
150 'type' => 'userjustkicked',
151 'user' => $params['userToKick'],
152 'sub' => 0
153 ));
154
155 $connector->sendMessage($room->getRoomId(), $message, array(
156 'public' => 1,
157 'sub' => 0
158 ));
159
160 // 2013-09-11: Should already been done by the chat server
161 $room->disconnectUser($params['userToKick']);
162 }
163 }
164 else
165 {
166 $response = json_encode(array(
167 'success' => false,
168 'reason' => 'unkown room'
169 ));
170 }
171
172 echo $response;
173 exit;
174 }
buildMessage($messageString, ilChatroomUser $user)
Instantiates stdClass, sets $data->user and $data->userToKick using given $messageString and $chat_us...
Class ilChatroomUser.
static byObjectId($object_id)
Returns ilChatroom object by given $object_id.
static checkUserPermissions($permissions, $ref_id, $send_info=true)
Checks user permissions by given array and ref_id.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
$params
Definition: example_049.php:96
global $ilCtrl
Definition: ilias.php:18
exit
Definition: login.php:54
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7
global $ilUser
Definition: imgupload.php:15

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

+ Here is the call graph for this function:

◆ buildMessage()

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.

185 {
186 $data = new stdClass();
187
188 $data->user = $this->gui->object->getPersonalInformation( $user );
189 $data->userToKick = $messageString;
190 $data->timestamp = date( 'c' );
191 $data->type = 'kick';
192
193 return $data;
194 }
$data

References $data.

Referenced by active().

+ Here is the caller graph for this function:

◆ executeDefault()

ilChatroomBanTask::executeDefault (   $method)

Calls $this->show method.

Parameters
string$method

Reimplemented from ilChatroomTaskHandler.

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

97 {
98 $this->show();
99 }
show()
Displays banned users task.

References show().

+ Here is the call graph for this function:

◆ show()

ilChatroomBanTask::show ( )

Displays banned users task.

@global ilCtrl2 $ilCtrl

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

39 {
40 //global $lng, $ilCtrl;
41 global $ilCtrl;
42
43 include_once 'Modules/Chatroom/classes/class.ilChatroom.php';
44
45 ilChatroom::checkUserPermissions( 'read', $this->gui->ref_id );
46
47 $this->gui->switchToVisibleMode();
48
49 require_once 'Modules/Chatroom/classes/class.ilBannedUsersTableGUI.php';
50
51 $table = new ilBannedUsersTableGUI( $this->gui, 'ban-show' );
52 $table->setFormAction( $ilCtrl->getFormAction( $this->gui, 'ban-show' ) );
53
54 $room = ilChatroom::byObjectId( $this->gui->object->getId() );
55
56 if( $room )
57 {
58 $table->setData( $room->getBannedUsers() );
59 }
60
61 $this->gui->tpl->setVariable( 'ADM_CONTENT', $table->getHTML() );
62 }
Class ilBannedUsersTableGUI.

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

Referenced by executeDefault().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $gui

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: