ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilChatroomInviteUsersToPrivateRoomTask.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 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 
16 {
17 
18  private $gui;
19 
27  public function __construct(ilDBayObjectGUI $gui)
28  {
29  $this->gui = $gui;
30  }
31 
41  public function executeDefault($method)
42  {
43  $this->byLogin();
44  }
45 
46  public function byLogin() {
47  $this->inviteById(ilObjUser::_lookupId($_REQUEST['users']));
48  }
49 
50  public function byId() {
51  $this->inviteById($_REQUEST['users']);
52  }
53 
54  private function inviteById($invited_id)
55  {
56  global $tpl, $ilUser;
57 
58  if ( !ilChatroom::checkUserPermissions( 'read', $this->gui->ref_id ) )
59  {
60  ilUtil::redirect("repository.php");
61  }
62 
63  $room = ilChatroom::byObjectId( $this->gui->object->getId() );
64 
65  $chat_user = new ilChatroomUser( $ilUser, $room );
66  $user_id = $chat_user->getUserId();
67 
68  if( !$room )
69  {
70  $response = json_encode( array(
71  'success' => false,
72  'reason' => 'unkown room'
73  ) );
74  echo json_encode( $response );
75  exit;
76  }
77  else if( $_REQUEST['sub'] && !$room->isOwnerOfPrivateRoom( $user_id, $_REQUEST['sub'] ) )
78  {
79  $response = json_encode( array(
80  'success' => false,
81  'reason' => 'not owner of private room'
82  ) );
83  echo json_encode( $response );
84  exit;
85  }
86 
87  $connector = $this->gui->getConnector();
88 
89  //if ($_REQUEST['sub']) {
90  $result = $connector->inviteToPrivateRoom($room, $_REQUEST['sub'], $ilUser, $invited_id);
91  //}
92 
93  $room->sendInvitationNotification($this->gui, $chat_user, $invited_id, (int)$_REQUEST['sub']);
94 
95  echo json_encode($result);
96  exit;
97  }
98 
99  public function getUserList()
100  {
104  global $ilUser;
105 
106  require_once 'Services/User/classes/class.ilUserAutoComplete.php';
107  $autocomplete = new ilUserAutoComplete();
108  if($ilUser->isAnonymous())
109  {
110  $autocomplete->setSearchType(ilUserAutoComplete::SEARCH_TYPE_EQUALS);
111  $autocomplete->setPrivacyMode(ilUserAutoComplete::PRIVACY_MODE_RESPECT_USER_SETTING);
112  $autocomplete->setUser($ilUser);
113  }
114  echo $autocomplete->getList($_REQUEST['q']);
115  exit;
116  }
117 
118 }
119 
120 ?>