ILIAS  release_8 Revision v8.23
ilChatroomBanGUI Class Reference

Class ilChatroomBanGUI. More...

+ Inheritance diagram for ilChatroomBanGUI:
+ Collaboration diagram for ilChatroomBanGUI:

Public Member Functions

 __construct (ilChatroomObjectGUI $gui, ilCtrlInterface $controller=null, ilLanguage $language=null, ilObjUser $user=null)
 
 delete ()
 
 executeDefault (string $requestedMethod)
 
 show ()
 Displays banned users task. More...
 
 active ()
 
- Public Member Functions inherited from ilChatroomGUIHandler
 execute (string $method)
 
 executeDefault (string $requestedMethod)
 
 redirectIfNoPermission ($permission)
 Checks for requested permissions and redirects if the permission check failed. More...
 
 isSuccessful ($response)
 Checks for success param in an json decoded response. More...
 
 sendResponse ($response, bool $isJson=false)
 Sends a json encoded response and exits the php process. More...
 
 hasPermission (string $permission)
 

Private Attributes

ilCtrlInterface $controller
 
ilLanguage $language
 
ilObjUser $user
 

Additional Inherited Members

- Protected Member Functions inherited from ilChatroomGUIHandler
 getRequestValue (string $key, Transformation $trafo, $default=null)
 
 hasRequestValue (string $key)
 
 getRoomByObjectId (int $objectId)
 
 exitIfNoRoomExists (?ilChatroom $room)
 Checks if a ilChatroom exists. More...
 
 exitIfNoRoomModeratePermission (ilChatroom $room, int $subRoom, ilChatroomUser $chatUser)
 Check if user can moderate a chatroom. More...
 
 canModerate (ilChatroom $room, int $subRoom, int $usrId)
 
 isMainRoom (int $subRoomId)
 
- Protected Attributes inherited from ilChatroomGUIHandler
ilChatroomObjectGUI $gui
 
ilObjUser $ilUser
 
ilCtrlInterface $ilCtrl
 
ilLanguage $ilLng
 
Filesystem $webDirectory
 
ilObjectService $obj_service
 
FileUpload $upload
 
ilRbacSystem $rbacsystem
 
ilGlobalTemplateInterface $mainTpl
 
ILIAS $ilias
 
ilNavigationHistory $navigationHistory
 
ilTree $tree
 
ilTabsGUI $tabs
 
UIFactory $uiFactory
 
UIRenderer $uiRenderer
 
GlobalHttpState $http
 
Refinery $refinery
 

Detailed Description

Class ilChatroomBanGUI.

Author
Jan Posselt jposs.nosp@m.elt@.nosp@m.datab.nosp@m.ay.d.nosp@m.e
Version
$Id$

Definition at line 27 of file class.ilChatroomBanGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilChatroomBanGUI::__construct ( ilChatroomObjectGUI  $gui,
ilCtrlInterface  $controller = null,
ilLanguage  $language = null,
ilObjUser  $user = null 
)

Definition at line 33 of file class.ilChatroomBanGUI.php.

References $controller, $DIC, $language, $user, ILIAS\GlobalScreen\Provider\__construct(), ILIAS\UI\examples\Symbol\Glyph\Language\language(), and ILIAS\Repository\user().

38  {
39  if ($controller === null) {
40  global $DIC;
41  $controller = $DIC->ctrl();
42  }
43  $this->controller = $controller;
44 
45  if ($language === null) {
46  global $DIC;
47  $language = $DIC->language();
48  }
49  $this->language = $language;
50 
51  if ($user === null) {
52  global $DIC;
53  $user = $DIC->user();
54  }
55  $this->user = $user;
56 
57  parent::__construct($gui);
58  }
global $DIC
Definition: feed.php:28
ilCtrlInterface $controller
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ active()

ilChatroomBanGUI::active ( )

Definition at line 123 of file class.ilChatroomBanGUI.php.

References $response, ilChatroom\byObjectId(), ilChatroomGUIHandler\exitIfNoRoomExists(), ilChatroomGUIHandler\getRequestValue(), ilChatroomGUIHandler\isSuccessful(), ilChatroomGUIHandler\redirectIfNoPermission(), ILIAS\Repository\refinery(), ilChatroomGUIHandler\sendResponse(), and ILIAS\Repository\user().

123  : void
124  {
125  $this->redirectIfNoPermission(['read', 'moderate']);
126 
127  $room = ilChatroom::byObjectId($this->gui->getObject()->getId());
128  $this->exitIfNoRoomExists($room);
129 
130  $userToBan = $this->getRequestValue('user', $this->refinery->kindlyTo()->int());
131  $subRoomId = $this->getRequestValue('sub', $this->refinery->kindlyTo()->int());
132 
133  $connector = $this->gui->getConnector();
134  $response = $connector->sendBan($room->getRoomId(), $subRoomId, $userToBan);
135 
136  if ($this->isSuccessful($response)) {
137  $room->banUser($userToBan, $this->user->getId());
138  $room->disconnectUser($userToBan);
139  }
140 
141  $this->sendResponse($response);
142  }
redirectIfNoPermission($permission)
Checks for requested permissions and redirects if the permission check failed.
getRequestValue(string $key, Transformation $trafo, $default=null)
exitIfNoRoomExists(?ilChatroom $room)
Checks if a ilChatroom exists.
isSuccessful($response)
Checks for success param in an json decoded response.
sendResponse($response, bool $isJson=false)
Sends a json encoded response and exits the php process.
static byObjectId(int $object_id)
$response
+ Here is the call graph for this function:

◆ delete()

ilChatroomBanGUI::delete ( )

Definition at line 60 of file class.ilChatroomBanGUI.php.

References ilChatroom\byObjectId(), ilChatroomGUIHandler\exitIfNoRoomExists(), ilChatroomGUIHandler\getRequestValue(), and ILIAS\Repository\refinery().

60  : void
61  {
62  $userTrafo = $this->refinery->kindlyTo()->listOf(
63  $this->refinery->kindlyTo()->int()
64  );
65 
66  $users = $this->getRequestValue('banned_user_id', $userTrafo, []);
67  if ($users === []) {
68  $this->mainTpl->setOnScreenMessage('info', $this->ilLng->txt('no_checkbox'), true);
69  $this->ilCtrl->redirect($this->gui, 'ban-show');
70  }
71 
72  $room = ilChatroom::byObjectId($this->gui->getObject()->getId());
73  $this->exitIfNoRoomExists($room);
74 
75  $room->unbanUser($users);
76 
77  $this->ilCtrl->redirect($this->gui, 'ban-show');
78  }
getRequestValue(string $key, Transformation $trafo, $default=null)
exitIfNoRoomExists(?ilChatroom $room)
Checks if a ilChatroom exists.
static byObjectId(int $object_id)
+ Here is the call graph for this function:

◆ executeDefault()

ilChatroomBanGUI::executeDefault ( string  $requestedMethod)

Definition at line 80 of file class.ilChatroomBanGUI.php.

References show().

80  : void
81  {
82  $this->show();
83  }
show()
Displays banned users task.
+ Here is the call graph for this function:

◆ show()

ilChatroomBanGUI::show ( )

Displays banned users task.

Definition at line 88 of file class.ilChatroomBanGUI.php.

References $data, ilChatroom\byObjectId(), ilChatroomGUIHandler\exitIfNoRoomExists(), ilUserUtil\getNamePresentation(), ILIAS\UI\examples\Symbol\Glyph\Language\language(), and ilChatroomGUIHandler\redirectIfNoPermission().

Referenced by executeDefault().

88  : void
89  {
90  $this->redirectIfNoPermission('read');
91 
92  $this->gui->switchToVisibleMode();
93 
94  $room = ilChatroom::byObjectId($this->gui->getObject()->getId());
95  $this->exitIfNoRoomExists($room);
96 
97  $table = new ilBannedUsersTableGUI($this->gui, 'ban-show');
98  $table->setFormAction($this->controller->getFormAction($this->gui, 'ban-show'));
99 
100  $data = $room->getBannedUsers();
101  $actorId = array_filter(array_map(static function (array $row): int {
102  return (int) $row['actor_id'];
103  }, $data));
104 
105  $sortable_names = ilUserUtil::getNamePresentation($actorId);
106  $names = ilUserUtil::getNamePresentation($actorId, false, false, '', false, false, false);
107 
108  array_walk($data, function (&$row) use ($names, $sortable_names): void {
109  if ($row['actor_id'] > 0 && isset($names[$row['actor_id']])) {
110  $row['actor_display'] = $names[$row['actor_id']];
111  $row['actor'] = $sortable_names[$row['actor_id']];
112  } else {
113  $row['actor_display'] = $this->language->txt('unknown');
114  $row['actor'] = $this->language->txt('unknown');
115  }
116  });
117 
118  $table->setData($data);
119 
120  $this->mainTpl->setVariable('ADM_CONTENT', $table->getHTML());
121  }
static getNamePresentation( $a_user_id, bool $a_user_image=false, bool $a_profile_link=false, string $a_profile_back_link="", bool $a_force_first_lastname=false, bool $a_omit_login=false, bool $a_sortable=true, bool $a_return_data_array=false, $a_ctrl_path="ilpublicuserprofilegui")
Default behaviour is:
redirectIfNoPermission($permission)
Checks for requested permissions and redirects if the permission check failed.
exitIfNoRoomExists(?ilChatroom $room)
Checks if a ilChatroom exists.
Class ilBannedUsersTableGUI.
static byObjectId(int $object_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $controller

ilCtrlInterface ilChatroomBanGUI::$controller
private

Definition at line 29 of file class.ilChatroomBanGUI.php.

Referenced by __construct().

◆ $language

ilLanguage ilChatroomBanGUI::$language
private

Definition at line 30 of file class.ilChatroomBanGUI.php.

Referenced by __construct().

◆ $user

ilObjUser ilChatroomBanGUI::$user
private

Definition at line 31 of file class.ilChatroomBanGUI.php.

Referenced by __construct().


The documentation for this class was generated from the following file: