19declare(strict_types=1);
58 private readonly UIFactory $create,
61 private readonly Http
$http,
62 private readonly Closure $link_to_profile,
70 public static function data(array $filter = []): array
74 $state_filter = (string) ($filter[
'state'] ??
'');
80 ->getTableFilterStateMapper(
$relation->getState())
81 ->filterMatchesRelation($state_filter,
$relation)
89 $logins = array_map(
static function (
string $value):
string {
91 preg_match_all(
'/\[([^\[]+?)\]/', $value, $matches);
92 return $matches[1][\count($matches[1]) - 1] ??
'';
95 $public_name_query = (string) ($filter[
'name'] ??
'');
96 if ($public_name_query) {
97 $relations = $relations->filter(
self::filter($public_name_query, $relations, $public_names, $logins));
102 $txt = $state_factory->getTableFilterStateMapper(
$relation->getState())->text(
$relation);
105 'public_name' => $public_names[
$user_id],
108 'target_states' =>
$relation->getCurrentPossibleTargetStates()->toArray(),
109 'state_text' => $txt,
121 public function build(array $multi_actions,
string $target_url, callable $action): array
124 $data = static::data($this->ui_service->filter()->getData($filter) ?: []);
133 new TableRows(
$data, array_keys($single_actions), $this->link_to_profile),
134 $this->
lng->txt(
'buddy_tbl_title_relations'),
136 'public_name' => $this->create->table()->column()->text($this->lng->txt(
'name')),
137 'login' => $this->create->table()->column()->text($this->lng->txt(
'login')),
138 'state_text' => $this->create
140 ->text($this->lng->txt(
'buddy_tbl_state_actions_col_label')),
143 ->withId(
'buddy_relations_table')
144 ->withRequest($this->
http->request())
145 ->withRange(
new Range(0, 50))
147 array_merge($single_actions, $multi_actions)
162 $in_string =
static fn(
string $needle,
string $haystack):
bool => ilStr::strpos(
163 ilStr::strtolower($haystack),
164 ilStr::strtolower($needle),
169 $in_string($public_name_query, $public_names[
$user_id]) ||
170 $in_string($public_name_query, $logins[
$user_id])
174 private static function pipe(Closure
$a, Closure
$b): Closure
176 return static fn($x) =>
$b(
$a($x));
188 foreach (
$data as $row) {
189 foreach ($row[
'target_states'] as $state) {
190 $actions[$row[
'state'] .
'->' . $state] = $action(
192 'buddy_bs_act_btn_txt_' . $row[
'state']->getSnakeName() .
'_to_' . $state->getSnakeName(),
204 $options = array_merge(...array_map(
205 static fn($m): array => $m->optionsForState(),
207 $state_factory->getTableFilterStateMapper(...),
208 array_filter($state_factory->getValidStates(),
static fn($s):
bool => !$s->isInitial())
213 'state' => $this->create->input()->field()->select($this->
lng->txt(
'buddy_tbl_filter_state'),
$options),
214 'name' => $this->create->input()->field()->text($this->
lng->txt(
'name')),
217 return $this->ui_service->filter()->standard(
221 array_map(
static fn():
bool =>
true, $fields),
Builds a Color from either hex- or rgb values.
A simple class to express a naive range of whole positive numbers.
static getInstanceByGlobalUser(?ilObjUser $user=null)
Class ilBuddySystemArrayCollection A generic array based collection class.
Class ilBuddySystemRelationStateFactory.
static getInstance(?ilLanguage $lng=null)
Class ilBuddySystemRelation.
static _lookupActive(int $a_usr_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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=null)
Default behaviour is:
Interface GlobalHttpState.
A component is the most general form of an entity in the UI.
Interface ilBuddySystemRelationState.
static http()
Fetches the global http state from ILIAS.
filter(string $filter_id, array $class_path, string $cmd, bool $activated=true, bool $expanded=true)
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples