ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 
19  protected $ilUser;
20 
26  {
27  global $ilUser;
28 
29  $this->ilUser = $ilUser;
30 
31  parent::__construct($gui);
32  }
33 
38  public function executeDefault($method)
39  {
40  $this->byLogin();
41  }
42 
46  public function byLogin()
47  {
48  $this->inviteById(ilObjUser::_lookupId($_REQUEST['user']));
49  }
50 
54  private function inviteById($invited_id)
55  {
56  $this->redirectIfNoPermission('read');
57 
58  $room = ilChatroom::byObjectId($this->gui->object->getId());
59  $subRoomId = (int)$_REQUEST['sub'];
60  $chat_user = new ilChatroomUser($this->ilUser, $room);
61 
62  $this->exitIfNoRoomExists($room);
63  $this->exitIfNoRoomPermission($room, $subRoomId, $chat_user);
64 
65  if(!$this->isMainRoom($subRoomId))
66  {
67  $room->inviteUserToPrivateRoom($invited_id, $subRoomId);
68  }
69 
70  $connector = $this->gui->getConnector();
71  $response = $connector->sendInviteToPrivateRoom($room->getRoomId(), $subRoomId, $chat_user->getUserId(), $invited_id);
72 
73  $room->sendInvitationNotification($this->gui, $chat_user, $invited_id, $subRoomId);
74 
75  $this->sendResponse($response);
76  }
77 
81  public function byId()
82  {
83  $this->inviteById($_REQUEST['user']);
84  }
85 
89  public function getUserList()
90  {
91  require_once 'Services/User/classes/class.ilUserAutoComplete.php';
92  $auto = new ilUserAutoComplete();
93  $auto->setUser($this->ilUser);
95  if($this->ilUser->isAnonymous())
96  {
97  $auto->setSearchType(ilUserAutoComplete::SEARCH_TYPE_EQUALS);
98  }
99 
100  if(($_REQUEST['fetchall']))
101  {
102  $auto->setLimit(ilUserAutoComplete::MAX_ENTRIES);
103  }
104  $auto->setMoreLinkAvailable(true);
105  $auto->setSearchFields(array('firstname', 'lastname'));
106  $auto->setResultField('login');
107  $auto->enableFieldSearchableCheck(true);
108  echo $auto->getList($_REQUEST['q']);
109  exit;
110  }
111 }
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.
__construct(ilChatroomObjectGUI $gui)
ilChatroomInviteUsersToPrivateRoomGUI constructor.
Class ilChatroomGUIHandler.
Create styles array
The data for the language used.
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.