19 declare(strict_types=1);
61 public static function data(array $filter = []): array
65 $state_filter = (string) ($filter[
'state'] ??
'');
71 ->getTableFilterStateMapper($relation->
getState())
72 ->filterMatchesRelation($state_filter, $relation)
80 $logins =
array_map(
static function (
string $value):
string {
82 preg_match_all(
'/\[([^\[]+?)\]/', $value, $matches);
83 return $matches[1][count($matches[1]) - 1] ??
'';
86 $public_name_query = (string) ($filter[
'name'] ??
'');
87 if ($public_name_query) {
88 $relations = $relations->filter(
self::filter($public_name_query, $relations, $public_names, $logins));
96 'public_name' => $public_names[
$user_id],
99 'points' =>
$relation->getCurrentPossibleTargetStates()->toArray(),
100 'state-text' =>
$txt,
112 public function build(array $multi_actions,
string $target_url, callable $action): array
115 $data = static::data($this->ui_service->filter()->getData($filter) ?: []);
118 $rows = $this->
rows(
$data, array_keys($single_actions));
121 $return[] = $this->create->table()->data(
123 $this->
lng->txt(
'buddy_tbl_title_relations'),
125 'public_name' => $this->create->table()->column()->text($this->
lng->txt(
'name')),
126 'login' => $this->create->table()->column()->text($this->
lng->txt(
'login')),
127 'state-text' => $this->create->table()->column()
128 ->text($this->
lng->txt(
'buddy_tbl_state_actions_col_label')),
130 )->withRequest($this->
http->request())->withActions(
131 array_merge($single_actions, $multi_actions)
146 $in_string =
static fn(
string $needle,
string $haystack):
bool =>
false !== ilStr::strpos(
147 ilStr::strtolower($haystack),
148 ilStr::strtolower($needle),
152 return self::pipe($relations->
getKey(...),
static fn(
int $user_id):
bool => (
153 $in_string($public_name_query, $public_names[$user_id]) ||
154 $in_string($public_name_query, $logins[$user_id])
160 return static fn($x) =>
$b(
$a($x));
172 foreach ($data as $row) {
173 foreach ($row[
'points'] as $point) {
174 $actions[$row[
'state'] .
'->' . $point] = $action(
176 'buddy_bs_act_btn_txt_' . $row[
'state']->getSnakeName() .
'_to_' . $point->getSnakeName(),
189 fn($m): array => $m->optionsForState(),
191 $state_factory->getTableFilterStateMapper(...),
192 array_filter($state_factory->getValidStates(), fn($s):
bool => !$s->isInitial())
197 'state' => $this->create->input()->field()->select($this->
lng->txt(
'buddy_tbl_filter_state'), $options),
198 'name' => $this->create->input()->field()->text($this->
lng->txt(
'name')),
201 return $this->ui_service->filter()->standard(
217 return static function (
219 array $visible_column_ids,
223 $order = $order->get();
224 $times = current($order) ===
'ASC' ? 1 : -1;
225 usort($data, fn(array
$a, array
$b):
int => $times * strcasecmp($a[key($order)], $b[key($order)]));
226 foreach ($data as $row) {
227 $transitions =
array_map(fn($s):
string => $row[
'state'] .
'->' . $s, $row[
'points']);
230 fn(
DataRow $row,
string $action):
DataRow => in_array($action, $transitions,
true) ?
233 $row_builder->
buildDataRow((
string) $row[
'user_id'], $row)
withDisabledAction(string $action_id, bool $disable=true)
Refer to an Action by its id and disable it for this row/record only.
static getInstance(?ilLanguage $lng=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Both the subject and the direction need to be specified when expressing an order. ...
buildDataRow(string $id, array $record)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static http()
Fetches the global http state from ILIAS.
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:
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
filter(string $filter_id, $class_path, string $cmd, bool $activated=true, bool $expanded=true)
A simple class to express a naive range of whole positive numbers.
static _lookupActive(int $a_usr_id)
static getInstanceByGlobalUser(?ilObjUser $user=null)