ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
ILIAS\Chatroom\Bans\BannedUsersTable Class Reference
+ Inheritance diagram for ILIAS\Chatroom\Bans\BannedUsersTable:
+ Collaboration diagram for ILIAS\Chatroom\Bans\BannedUsersTable:

Public Member Functions

 __construct (private readonly \ilObjUser $actor, private readonly int $room_id, private readonly array $banned_users, private readonly ilCtrlInterface $ctrl, private readonly ilLanguage $lng, GlobalHttpState $http, private readonly \ILIAS\UI\Factory $ui_factory)
 
 getComponent ()
 
 getRows (UI\Component\Table\DataRowBuilder $row_builder, array $visible_column_ids, Data\Range $range, Data\Order $order, mixed $additional_viewcontrol_data, mixed $filter_data, mixed $additional_parameters)
 
 getTotalRowCount (mixed $additional_viewcontrol_data, mixed $filter_data, mixed $additional_parameters)
 Mainly for the purpose of pagination-support, it is important to know about the total number of records available. More...
 
- Public Member Functions inherited from ILIAS\UI\Component\Table\DataRetrieval
 getRows (DataRowBuilder $row_builder, array $visible_column_ids, Range $range, Order $order, mixed $additional_viewcontrol_data, mixed $filter_data, mixed $additional_parameters)
 This is called by the table to retrieve rows; map data-records to rows using the $row_builder e.g. More...
 
 getTotalRowCount (mixed $additional_viewcontrol_data, mixed $filter_data, mixed $additional_parameters)
 Mainly for the purpose of pagination-support, it is important to know about the total number of records available. More...
 

Private Member Functions

 getColumns ()
 
 getActions ()
 
 initRecords ()
 
 sortedRecords (Data\Order $order)
 
 getRecords (Data\Range $range, Data\Order $order)
 
 limitRecords (array $records, Data\Range $range)
 

Private Attributes

readonly ServerRequestInterface $request
 
readonly Data Factory $data_factory
 
array $records = null
 

Detailed Description

Definition at line 35 of file BannedUsersTable.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Chatroom\Bans\BannedUsersTable::__construct ( private readonly \ilObjUser  $actor,
private readonly int  $room_id,
private readonly array  $banned_users,
private readonly ilCtrlInterface  $ctrl,
private readonly ilLanguage  $lng,
GlobalHttpState  $http,
private readonly \ILIAS\UI\Factory  $ui_factory 
)
Parameters
list<array<string,scalar|null>>$banned_users

Definition at line 45 of file BannedUsersTable.php.

53 {
54 $this->request = $http->request();
55 $this->data_factory = new Data\Factory();
56 }
$http
Definition: deliver.php:30

References $http.

Member Function Documentation

◆ getActions()

ILIAS\Chatroom\Bans\BannedUsersTable::getActions ( )
private
Returns
array<string, UI\Component\Table\Action\Action>

Definition at line 106 of file BannedUsersTable.php.

106 : array
107 {
108 $query_params_namespace = ['chat', 'ban', 'table'];
109
110 $uri = $this->data_factory->uri(
111 ILIAS_HTTP_PATH . '/' . $this->ctrl->getLinkTargetByClass(ilObjChatroomGUI::class, 'ban-handleTableActions')
112 );
113
114 $url_builder = new UI\URLBuilder($uri);
115 [
116 $url_builder,
117 $action_parameter_token_copy,
118 $row_id_token
119 ] = $url_builder->acquireParameters(
120 $query_params_namespace,
121 'action',
122 'user_ids'
123 );
124
125 return [
126 'delete' => $this->ui_factory->table()->action()->multi(
127 $this->lng->txt('unban'),
128 $url_builder->withParameter($action_parameter_token_copy, 'delete'),
129 $row_id_token
130 ),
131 ];
132 }

References ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

Referenced by ILIAS\Chatroom\Bans\BannedUsersTable\getComponent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getColumns()

ILIAS\Chatroom\Bans\BannedUsersTable::getColumns ( )
private
Returns
array<string, UI\Component\Table\Column\Column>

Definition at line 76 of file BannedUsersTable.php.

76 : array
77 {
78 if ((int) $this->actor->getTimeFormat() === \ilCalendarSettings::TIME_FORMAT_12) {
79 $date_format = $this->data_factory->dateFormat()->withTime12($this->actor->getDateFormat());
80 } else {
81 $date_format = $this->data_factory->dateFormat()->withTime24($this->actor->getDateFormat());
82 }
83
84 return [
85 'login' => $this->ui_factory
86 ->table()->column()->text($this->lng->txt('login'))
87 ->withIsSortable(true),
88 'firstname' => $this->ui_factory
89 ->table()->column()->text($this->lng->txt('firstname'))
90 ->withIsSortable(true),
91 'lastname' => $this->ui_factory
92 ->table()->column()->text($this->lng->txt('lastname'))
93 ->withIsSortable(true),
94 'datetime' => $this->ui_factory
95 ->table()->column()->date($this->lng->txt('chtr_ban_ts_tbl_head'), $date_format)
96 ->withIsSortable(true),
97 'actor' => $this->ui_factory
98 ->table()->column()->text($this->lng->txt('chtr_ban_actor_tbl_head'))
99 ->withIsSortable(true),
100 ];
101 }

References ILIAS\Repository\lng(), and ilCalendarSettings\TIME_FORMAT_12.

Referenced by ILIAS\Chatroom\Bans\BannedUsersTable\getComponent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getComponent()

ILIAS\Chatroom\Bans\BannedUsersTable::getComponent ( )

Definition at line 58 of file BannedUsersTable.php.

58 : UI\Component\Table\Data
59 {
60 $columns = $this->getColumns();
61 $actions = $this->getActions();
62
63 return $this->ui_factory
64 ->table()
65 ->data($this, $this->lng->txt('ban_table_title'), $columns)
66 ->withId(str_replace('\\', '', self::class) . '_' . $this->room_id)
67 ->withOrder(new \ILIAS\Data\Order('datetime', \ILIAS\Data\Order::DESC))
68 ->withRange(new Range(0, 50))
69 ->withActions($actions)
70 ->withRequest($this->request);
71 }
const DESC
Definition: Order.php:31
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.

References ILIAS\Data\Order\DESC, ILIAS\Chatroom\Bans\BannedUsersTable\getActions(), ILIAS\Chatroom\Bans\BannedUsersTable\getColumns(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getRecords()

ILIAS\Chatroom\Bans\BannedUsersTable::getRecords ( Data\Range  $range,
Data\Order  $order 
)
private
Returns
list<array<string, mixed>>

Definition at line 206 of file BannedUsersTable.php.

References ILIAS\UI\Implementation\Component\Table\$range.

◆ getRows()

ILIAS\Chatroom\Bans\BannedUsersTable::getRows ( UI\Component\Table\DataRowBuilder  $row_builder,
array  $visible_column_ids,
Data\Range  $range,
Data\Order  $order,
mixed  $additional_viewcontrol_data,
mixed  $filter_data,
mixed  $additional_parameters 
)

Definition at line 157 of file BannedUsersTable.php.

165 : \Generator {
166 $records = $this->getRecords($range, $order);
167
168 foreach ($records as $record) {
169 $row_id = (string) $record['user_id'];
170 yield $row_builder->buildDataRow($row_id, $record);
171 }
172 }
getRecords(Data\Range $range, Data\Order $order)

◆ getTotalRowCount()

ILIAS\Chatroom\Bans\BannedUsersTable::getTotalRowCount ( mixed  $additional_viewcontrol_data,
mixed  $filter_data,
mixed  $additional_parameters 
)

Mainly for the purpose of pagination-support, it is important to know about the total number of records available.

Given the nature of a DataTable, which is, opposite to a PresentationTable, rather administrative than explorative, this information will increase user experience quite a bit. However, you may return null, if the call is to costly, but expect the View Control to look a little different in this case.

Make sure that potential filters or user restrictions are being applied to the count.

Implements ILIAS\UI\Component\Table\DataRetrieval.

Definition at line 174 of file BannedUsersTable.php.

178 : ?int {
179 $this->initRecords();
180
181 return \count($this->records);
182 }

◆ initRecords()

ILIAS\Chatroom\Bans\BannedUsersTable::initRecords ( )
private

Definition at line 134 of file BannedUsersTable.php.

134 : void
135 {
136 if ($this->records === null) {
137 $this->records = [];
138 $i = 0;
139 $entries = $this->banned_users;
140
141 foreach ($entries as $entry) {
142 $this->records[$i]['user_id'] = $entry['user_id'];
143 $this->records[$i]['login'] = $entry['login'];
144 $this->records[$i]['firstname'] = $entry['firstname'];
145 $this->records[$i]['lastname'] = $entry['lastname'];
146 $this->records[$i]['timestamp'] = $entry['timestamp'];
147 $this->records[$i]['datetime'] = (new \DateTimeImmutable('@' . $entry['timestamp']))->setTimezone(
148 new \DateTimeZone($this->actor->getTimeZone())
149 );
150
151 $this->records[$i]['actor'] = $entry['actor'];
152 ++$i;
153 }
154 }
155 }

◆ limitRecords()

ILIAS\Chatroom\Bans\BannedUsersTable::limitRecords ( array  $records,
Data\Range  $range 
)
private
Parameters
list<array<string,mixed>>$records
Returns
list<array<string, mixed>>

Definition at line 219 of file BannedUsersTable.php.

219 : array
220 {
221 return \array_slice($records, $range->getStart(), $range->getLength());
222 }

References ILIAS\UI\Implementation\Component\Table\$range, ILIAS\Data\Range\getLength(), and ILIAS\Data\Range\getStart().

+ Here is the call graph for this function:

◆ sortedRecords()

ILIAS\Chatroom\Bans\BannedUsersTable::sortedRecords ( Data\Order  $order)
private
Returns
list<array<string, mixed>>

Definition at line 187 of file BannedUsersTable.php.

187 : array
188 {
189 [$order_field, $order_direction] = $order->join([], fn($ret, $key, $value) => [$key, $value]);
190
191 if ($order_field === 'datetime') {
192 $order_field = 'timestamp';
193 }
194
196 $this->records,
197 $order_field,
198 strtolower($order_direction),
199 $order_field === 'timestamp'
200 );
201 }
static stableSortArray(array $array, string $a_array_sortby, string $a_array_sortorder="asc", bool $a_numeric=false)
Sort an aray using a stable sort algorithm, which preveserves the sequence of array elements which ha...

References ilArrayUtil\stableSortArray().

+ Here is the call graph for this function:

Field Documentation

◆ $data_factory

readonly Data Factory ILIAS\Chatroom\Bans\BannedUsersTable::$data_factory
private

Definition at line 38 of file BannedUsersTable.php.

◆ $records

array ILIAS\Chatroom\Bans\BannedUsersTable::$records = null
private

Definition at line 40 of file BannedUsersTable.php.

◆ $request

readonly ServerRequestInterface ILIAS\Chatroom\Bans\BannedUsersTable::$request
private

Definition at line 37 of file BannedUsersTable.php.


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