ILIAS  trunk Revision v11.0_alpha-2645-g16283d3b3f8
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, ?array $filter_data, ?array $additional_parameters)
 
 getTotalRowCount (?array $filter_data, ?array $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, ?array $filter_data, ?array $additional_parameters)
 This is called by the table to retrieve rows; map data-records to rows using the $row_builder e.g. 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 34 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 44 of file BannedUsersTable.php.

References ILIAS\HTTP\GlobalHttpState\request().

52  {
53  $this->request = $http->request();
54  $this->data_factory = new Data\Factory();
55  }
$http
Definition: deliver.php:30
+ Here is the call graph for this function:

Member Function Documentation

◆ getActions()

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

Definition at line 104 of file BannedUsersTable.php.

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

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

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

Definition at line 74 of file BannedUsersTable.php.

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

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

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

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

57  : UI\Component\Table\Data
58  {
59  $columns = $this->getColumns();
60  $actions = $this->getActions();
61 
62  return $this->ui_factory
63  ->table()
64  ->data($this, $this->lng->txt('ban_table_title'), $columns)
65  ->withId(self::class . '_' . $this->room_id)
66  ->withOrder(new \ILIAS\Data\Order('datetime', \ILIAS\Data\Order::DESC))
67  ->withActions($actions)
68  ->withRequest($this->request);
69  }
Interface Observer Contains several chained tasks and infos about them.
const DESC
Definition: Order.php:31
+ 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 202 of file BannedUsersTable.php.

References ILIAS\Chatroom\Bans\BannedUsersTable\initRecords(), ILIAS\Chatroom\Bans\BannedUsersTable\limitRecords(), and ILIAS\Chatroom\Bans\BannedUsersTable\sortedRecords().

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

202  : array
203  {
204  $this->initRecords();
205 
206  $records = $this->sortedRecords($order);
207 
208  return $this->limitRecords($records, $range);
209  }
limitRecords(array $records, Data\Range $range)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRows()

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

Definition at line 155 of file BannedUsersTable.php.

References ILIAS\Chatroom\Bans\BannedUsersTable\getRecords().

162  : \Generator {
163  $records = $this->getRecords($range, $order);
164 
165  foreach ($records as $record) {
166  $row_id = (string) $record['user_id'];
167  yield $row_builder->buildDataRow($row_id, $record);
168  }
169  }
getRecords(Data\Range $range, Data\Order $order)
+ Here is the call graph for this function:

◆ getTotalRowCount()

ILIAS\Chatroom\Bans\BannedUsersTable::getTotalRowCount ( ?array  $filter_data,
?array  $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 171 of file BannedUsersTable.php.

References ILIAS\Chatroom\Bans\BannedUsersTable\initRecords().

174  : ?int {
175  $this->initRecords();
176 
177  return \count($this->records);
178  }
+ Here is the call graph for this function:

◆ initRecords()

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

Definition at line 132 of file BannedUsersTable.php.

References null.

Referenced by ILIAS\Chatroom\Bans\BannedUsersTable\getRecords(), and ILIAS\Chatroom\Bans\BannedUsersTable\getTotalRowCount().

132  : void
133  {
134  if ($this->records === null) {
135  $this->records = [];
136  $i = 0;
137  $entries = $this->banned_users;
138 
139  foreach ($entries as $entry) {
140  $this->records[$i]['user_id'] = $entry['user_id'];
141  $this->records[$i]['login'] = $entry['login'];
142  $this->records[$i]['firstname'] = $entry['firstname'];
143  $this->records[$i]['lastname'] = $entry['lastname'];
144  $this->records[$i]['timestamp'] = $entry['timestamp'];
145  $this->records[$i]['datetime'] = (new \DateTimeImmutable('@' . $entry['timestamp']))->setTimezone(
146  new \DateTimeZone($this->actor->getTimeZone())
147  );
148 
149  $this->records[$i]['actor'] = $entry['actor'];
150  ++$i;
151  }
152  }
153  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the caller graph for this function:

◆ 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 215 of file BannedUsersTable.php.

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

+ Here is the caller graph for this function:

◆ sortedRecords()

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

Definition at line 183 of file BannedUsersTable.php.

References ilArrayUtil\stableSortArray().

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

183  : array
184  {
185  [$order_field, $order_direction] = $order->join([], fn($ret, $key, $value) => [$key, $value]);
186 
187  if ($order_field === 'datetime') {
188  $order_field = 'timestamp';
189  }
190 
192  $this->records,
193  $order_field,
194  strtolower($order_direction),
195  $order_field === 'timestamp'
196  );
197  }
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...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $data_factory

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

Definition at line 37 of file BannedUsersTable.php.

◆ $records

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

Definition at line 39 of file BannedUsersTable.php.

◆ $request

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

Definition at line 36 of file BannedUsersTable.php.


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