ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilChatroomInviteUsersToPrivateRoomGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once 'Modules/Chatroom/classes/class.ilChatroom.php';
5 require_once 'Modules/Chatroom/classes/class.ilChatroomUser.php';
6 
14 {
15 
20  public function executeDefault($method)
21  {
22  $this->byLogin();
23  }
24 
28  public function byLogin()
29  {
30  $this->inviteById(ilObjUser::_lookupId($_REQUEST['user']));
31  }
32 
36  private function inviteById($invited_id)
37  {
38  $this->redirectIfNoPermission('read');
39 
40  $room = ilChatroom::byObjectId($this->gui->object->getId());
41  $subRoomId = (int) $_REQUEST['sub'];
42  $chat_user = new ilChatroomUser($this->ilUser, $room);
43 
44  $this->exitIfNoRoomExists($room);
45  $this->exitIfNoRoomPermission($room, $subRoomId, $chat_user);
46 
47  if (!$this->isMainRoom($subRoomId)) {
48  $room->inviteUserToPrivateRoom($invited_id, $subRoomId);
49  }
50 
51  $connector = $this->gui->getConnector();
52  $response = $connector->sendInviteToPrivateRoom($room->getRoomId(), $subRoomId, $chat_user->getUserId(), $invited_id);
53 
54  $room->sendInvitationNotification($this->gui, $chat_user, $invited_id, $subRoomId);
55 
56  $this->sendResponse($response);
57  }
58 
62  public function byId()
63  {
64  $this->inviteById($_REQUEST['user']);
65  }
66 
70  public function getUserList()
71  {
72  require_once 'Services/User/classes/class.ilUserAutoComplete.php';
73  $auto = new ilUserAutoComplete();
74  $auto->setUser($this->ilUser);
76  if ($this->ilUser->isAnonymous()) {
77  $auto->setSearchType(ilUserAutoComplete::SEARCH_TYPE_EQUALS);
78  }
79 
80  if (($_REQUEST['fetchall'])) {
81  $auto->setLimit(ilUserAutoComplete::MAX_ENTRIES);
82  }
83  $auto->setMoreLinkAvailable(true);
84  $auto->setSearchFields(array('firstname', 'lastname'));
85  $auto->setResultField('login');
86  $auto->enableFieldSearchableCheck(true);
87  echo $auto->getList($_REQUEST['q']);
88  exit;
89  }
90 }
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.
exitIfNoRoomExists($room)
Checks if a ilChatroom exists.
static _lookupId($a_user_str)
Lookup id by login.
Auto completion class for user lists.
Class ilChatroomGUIHandler.
exit
Definition: backend.php:16
exitIfNoRoomPermission($room, $subRoom, $chat_user)
Check if user can moderate a chatroom.
Class ilChatroomUser.
static byObjectId($object_id)
Returns ilChatroom object by given $object_id.
$response