ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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)
 
 handleTableActions ()
 
 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...
 
 hasPermission (string $permission)
 

Private Attributes

readonly ilCtrlInterface $controller
 
readonly ilLanguage $language
 
readonly 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...
 
 sendJSONResponse ($response)
 Sends a json encoded response and exits the php process. More...
 
 sendResponse (string $content, string $type)
 Sends a response and exits the php process. More...
 
- Protected Attributes inherited from ilChatroomGUIHandler
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(), null, 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  }
readonly ilObjUser $user
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
readonly ilCtrlInterface $controller
global $DIC
Definition: shib_login.php:22
readonly ilLanguage $language
__construct(Container $dic, ilPlugin $plugin)
language()
description: > Example for rendring a language glyph.
Definition: language.php:41
+ Here is the call graph for this function:

Member Function Documentation

◆ active()

ilChatroomBanGUI::active ( )

Definition at line 146 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().

146  : void
147  {
148  $this->redirectIfNoPermission(['read', 'moderate']);
149 
150  $room = ilChatroom::byObjectId($this->gui->getObject()->getId());
151  $this->exitIfNoRoomExists($room);
152 
153  $userToBan = $this->getRequestValue('user', $this->refinery->kindlyTo()->int());
154 
155  $connector = $this->gui->getConnector();
156  $response = $connector->sendBan($room->getRoomId(), $userToBan);
157 
158  if ($this->isSuccessful($response)) {
159  $room->banUser($userToBan, $this->user->getId());
160  $room->disconnectUser($userToBan);
161  }
162 
163  $this->sendResponse($response, 'application/json');
164  }
redirectIfNoPermission($permission)
Checks for requested permissions and redirects if the permission check failed.
getRequestValue(string $key, Transformation $trafo, $default=null)
$response
Definition: xapitoken.php:93
exitIfNoRoomExists(?ilChatroom $room)
Checks if a ilChatroom exists.
sendResponse(string $content, string $type)
Sends a response and exits the php process.
isSuccessful($response)
Checks for success param in an json decoded response.
static byObjectId(int $object_id)
+ Here is the call graph for this function:

◆ delete()

ilChatroomBanGUI::delete ( )

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

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

75  : void
76  {
77  $userTrafo = $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int());
78 
79  $users = $this->getRequestValue('chat_ban_table_user_ids', $userTrafo, []);
80  if ($users === []) {
81  $this->mainTpl->setOnScreenMessage('info', $this->ilLng->txt('no_checkbox'), true);
82  $this->ilCtrl->redirect($this->gui, 'ban-show');
83  }
84 
85  $room = ilChatroom::byObjectId($this->gui->getObject()->getId());
86  $this->exitIfNoRoomExists($room);
87 
88  $room->unbanUser($users);
89 
90  $this->mainTpl->setOnScreenMessage(
91  $this->mainTpl::MESSAGE_TYPE_SUCCESS,
92  $this->ilLng->txt('saved_successfully'),
93  true
94  );
95  $this->ilCtrl->redirect($this->gui, 'ban-show');
96  }
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 98 of file class.ilChatroomBanGUI.php.

References show().

98  : void
99  {
100  $this->show();
101  }
show()
Displays banned users task.
+ Here is the call graph for this function:

◆ handleTableActions()

ilChatroomBanGUI::handleTableActions ( )

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

References ILIAS\FileDelivery\http(), and ILIAS\Repository\refinery().

60  : void
61  {
62  $action = $this->http->wrapper()->query()->retrieve(
63  'chat_ban_table_action',
64  $this->refinery->byTrying([
65  $this->refinery->kindlyTo()->string(),
66  $this->refinery->always('')
67  ])
68  );
69  match ($action) {
70  'delete' => $this->delete(),
71  default => $this->ilCtrl->redirect($this, 'show'),
72  };
73  }
static http()
Fetches the global http state from ILIAS.
+ Here is the call graph for this function:

◆ show()

ilChatroomBanGUI::show ( )

Displays banned users task.

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

References $data, ilChatroomGUIHandler\$http, ilChatroomGUIHandler\$ilCtrl, ilChatroomGUIHandler\$ilLng, ilChatroomGUIHandler\$uiFactory, ilChatroom\byObjectId(), ilChatroomGUIHandler\exitIfNoRoomExists(), ilUserUtil\getNamePresentation(), ILIAS\UI\examples\Symbol\Glyph\Language\language(), ilChatroomGUIHandler\redirectIfNoPermission(), and ILIAS\Repository\user().

Referenced by executeDefault().

106  : void
107  {
108  $this->redirectIfNoPermission('read');
109 
110  $this->gui->switchToVisibleMode();
111 
112  $room = ilChatroom::byObjectId($this->gui->getObject()->getId());
113  $this->exitIfNoRoomExists($room);
114 
115  $data = $room->getBannedUsers();
116  $actorId = array_filter(array_map(static function (array $row): int {
117  return (int) $row['actor_id'];
118  }, $data));
119 
120  $sortable_names = ilUserUtil::getNamePresentation($actorId);
121  $names = ilUserUtil::getNamePresentation($actorId, false, false, '', false, false, false);
122 
123  array_walk($data, function (&$row) use ($names, $sortable_names): void {
124  if ($row['actor_id'] > 0 && isset($names[$row['actor_id']])) {
125  $row['actor_display'] = $names[$row['actor_id']];
126  $row['actor'] = $sortable_names[$row['actor_id']];
127  } else {
128  $row['actor_display'] = $this->language->txt('unknown');
129  $row['actor'] = $this->language->txt('unknown');
130  }
131  });
132 
133  $tbl = new \ILIAS\Chatroom\Bans\BannedUsersTable(
134  $this->user,
135  $room->getRoomId(),
136  $data,
138  $this->ilLng,
139  $this->http,
141  );
142 
143  $this->mainTpl->setContent($this->uiRenderer->render($tbl->getComponent()));
144  }
redirectIfNoPermission($permission)
Checks for requested permissions and redirects if the permission check failed.
exitIfNoRoomExists(?ilChatroom $room)
Checks if a ilChatroom exists.
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:
static byObjectId(int $object_id)
language()
description: > Example for rendring a language glyph.
Definition: language.php:41
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $controller

readonly ilCtrlInterface ilChatroomBanGUI::$controller
private

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

Referenced by __construct().

◆ $language

readonly ilLanguage ilChatroomBanGUI::$language
private

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

Referenced by __construct().

◆ $user

readonly 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: