ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilChatroomKickGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 require_once 'Modules/Chatroom/classes/class.ilChatroom.php';
4 require_once 'Modules/Chatroom/classes/class.ilChatroomUser.php';
5 
13 {
14 
22  private function buildMessage($messageString, ilChatroomUser $chat_user)
23  {
24  $data = new stdClass();
25 
26  $data->user = $this->gui->object->getPersonalInformation($chat_user);
27  $data->userToKick = $messageString;
28  $data->timestamp = date('c');
29  $data->type = 'kick';
30 
31  return $data;
32  }
33 
39  public function executeDefault($method)
40  {
41  $this->redirectIfNoPermission(array('read', 'moderate'));
42 
43  $room = ilChatroom::byObjectId($this->gui->object->getId());
44  $userToKick = $_REQUEST['user'];
45  $subRoomId = $_REQUEST['sub'];
46 
47  $this->exitIfNoRoomExists($room);
48 
49  $connector = $this->gui->getConnector();
50  $response = $connector->sendKick($room->getRoomId(), $subRoomId, $userToKick);
51 
52  if($this->isSuccessful($response) && !$subRoomId)
53  {
54  // 2013-09-11: Should already been done by the chat server
55  $room->disconnectUser($userToKick);
56  }
57 
58  $this->sendResponse($response);
59  }
60 
61  public function main()
62  {
63  $room = ilChatroom::byObjectId($this->gui->object->getId());
64  $userToKick = $_REQUEST['user'];
65  $subRoomId = $_REQUEST['sub'];
66 
67  $this->exitIfNoRoomExists($room);
68 
69  $connector = $this->gui->getConnector();
70  $response = $connector->sendKick($room->getRoomId(), $subRoomId, $userToKick);
71 
72  if($this->isSuccessful($response))
73  {
74  // 2013-09-11: Should already been done by the chat server
75  $room->disconnectUser($userToKick);
76  }
77 
78  $this->sendResponse($response);
79  }
80 
85  public function sub()
86  {
87  global $ilUser, $ilCtrl;
88 
89  $room = ilChatroom::byObjectId($this->gui->object->getId());
90 
91  if($room)
92  {
93  if(!$room->isOwnerOfPrivateRoom($ilUser->getId(), $_REQUEST['sub']))
94  {
95  if(!ilChatroom::checkPermissionsOfUser($ilUser->getId(), array('read', 'moderate'), $this->gui->ref_id))
96  {
97  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", ROOT_FOLDER_ID);
98  $ilCtrl->redirectByClass("ilrepositorygui", "");
99  }
100  }
101 
102  $roomId = $room->getRoomId();
103  $subRoomId = $_REQUEST['sub'];
104  $userToKick = $_REQUEST['user'];
105 
106  if($room->userIsInPrivateRoom($subRoomId, $userToKick))
107  {
108  $connector = $this->gui->getConnector();
109  $response = $connector->sendKick($roomId, $subRoomId, $userToKick);
110  $this->sendResponse($response);
111  }
112 
113  /*
114  if( $responseObject->success == true && $room->getSetting( 'enable_history' ) )
115  {
116  //$room->addHistoryEntry( $message, $recipient, $publicMessage );
117  }
118 
119 
120 
121  $message = json_encode(array(
122  'type' => 'userjustkicked',
123  'user' => $params['user'],
124  'sub' => $params['sub']
125  ));
126 
127  $connector->sendMessage($room->getRoomId(), $message, array(
128  'public' => 1,
129  'sub' => 0
130  ));
131  }
132  else
133  {
134  $response = json_encode(array(
135  'success' => true,
136  'message' => 'was not in room'
137  ));
138  }
139 
140  echo $response;
141  exit;*/
142  }
143  }
144 }
executeDefault($method)
Displays window box to kick a user fetched from $_REQUEST[&#39;user&#39;].
redirectIfNoPermission($permission)
Checks for requested permissions and redirects if the permission check failed.
sendResponse($response)
Sends a json encoded response and exits the php process.
sub()
Kicks user from subroom into mainroom ilObjUser $ilUser.
exitIfNoRoomExists($room)
Checks if a ilChatroom exists.
buildMessage($messageString, ilChatroomUser $chat_user)
Instantiates stdClass, sets $data->user and $data->userToKick using given $messageString and $chat_us...
Class ilChatroomGUIHandler.
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
isSuccessful($response)
Checks for success param in an json decoded response.
Create styles array
The data for the language used.
Class ilChatroomUser.
static byObjectId($object_id)
Returns ilChatroom object by given $object_id.
Class ilChatroomKickGUI.
static checkPermissionsOfUser($usr_id, $permissions, $ref_id)
Checks user permissions in question for a given user id in relation to a given ref_id.