ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\Contact\BuddySystem\Tables\RelationsTable Class Reference
+ Collaboration diagram for ILIAS\Contact\BuddySystem\Tables\RelationsTable:

Public Member Functions

 __construct (private readonly UIFactory $create, private readonly ilLanguage $lng, private readonly ilUIService $ui_service, private readonly Http $http)
 
 build (array $multi_actions, string $target_url, callable $action)
 

Private Member Functions

 actions (array $data, callable $action)
 
 filterComponent (string $target_url)
 
 rows (array $data, array $actions)
 

Static Private Member Functions

static filter (string $public_name_query, ilBuddySystemArrayCollection $relations, array $public_names, array $logins)
 @template A More...
 
static pipe (Closure $a, Closure $b)
 

Detailed Description

Definition at line 47 of file RelationsTable.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Contact\BuddySystem\Tables\RelationsTable::__construct ( private readonly UIFactory  $create,
private readonly ilLanguage  $lng,
private readonly ilUIService  $ui_service,
private readonly Http  $http 
)

Definition at line 49 of file RelationsTable.php.

54 {
55 }

Member Function Documentation

◆ actions()

ILIAS\Contact\BuddySystem\Tables\RelationsTable::actions ( array  $data,
callable  $action 
)
private
Parameters
array<array{stateilBuddySystemRelationState, points: ilBuddySystemRelationState[]}> $data
callable(string,string,string)Action $action
Returns
array<string, Action>

Definition at line 169 of file RelationsTable.php.

169 : array
170 {
171 $actions = [];
172 foreach ($data as $row) {
173 foreach ($row['points'] as $point) {
174 $actions[$row['state'] . '->' . $point] = $action(
175 'single',
176 'buddy_bs_act_btn_txt_' . $row['state']->getSnakeName() . '_to_' . $point->getSnakeName(),
177 $point->getAction()
178 );
179 }
180 }
181
182 return $actions;
183 }

References $data.

Referenced by ILIAS\Contact\BuddySystem\Tables\RelationsTable\build().

+ Here is the caller graph for this function:

◆ build()

ILIAS\Contact\BuddySystem\Tables\RelationsTable::build ( array  $multi_actions,
string  $target_url,
callable  $action 
)
Parameters
array<string,Action>$multi_actions
callable(string,string,string)Action $action
Returns
Component[]

Definition at line 112 of file RelationsTable.php.

112 : array
113 {
114 $filter = $this->filterComponent($target_url);
115 $data = static::data($this->ui_service->filter()->getData($filter) ?: []);
116 $single_actions = $this->actions($data, $action);
117
118 $rows = $this->rows($data, array_keys($single_actions));
119 $return = [];
120 $return[] = $filter;
121 $return[] = $this->create->table()->data(
122 new TableRows($rows),
123 $this->lng->txt('buddy_tbl_title_relations'),
124 [
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')),
129 ]
130 )->withRequest($this->http->request())->withActions(
131 array_merge($single_actions, $multi_actions)
132 );
133
134 return $return;
135 }
static http()
Fetches the global http state from ILIAS.

References $data, ILIAS\Contact\BuddySystem\Tables\RelationsTable\actions(), ILIAS\Contact\BuddySystem\Tables\RelationsTable\filterComponent(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), and ILIAS\Contact\BuddySystem\Tables\RelationsTable\rows().

+ Here is the call graph for this function:

◆ filter()

static ILIAS\Contact\BuddySystem\Tables\RelationsTable::filter ( string  $public_name_query,
ilBuddySystemArrayCollection  $relations,
array  $public_names,
array  $logins 
)
staticprivate

@template A

Parameters
ilBuddySystemArrayCollection<int,A>$relations
array<int,string>$public_names
array<int,string>$logins
Returns
Closure(A): bool

Definition at line 144 of file RelationsTable.php.

144 : Closure
145 {
146 $in_string = static fn(string $needle, string $haystack): bool => false !== ilStr::strpos(
147 ilStr::strtolower($haystack),
148 ilStr::strtolower($needle),
149 0
150 );
151
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])
156 }
static _lookupActive(int $a_usr_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: class.ilStr.php:20

References $user_id, ilObjUser\_lookupActive(), ilBuddySystemArrayCollection\getKey(), and ILIAS\Contact\BuddySystem\Tables\RelationsTable\pipe().

+ Here is the call graph for this function:

◆ filterComponent()

ILIAS\Contact\BuddySystem\Tables\RelationsTable::filterComponent ( string  $target_url)
private

Definition at line 185 of file RelationsTable.php.

185 : Filter
186 {
188 $options = array_merge(...array_map(
189 fn($m): array => $m->optionsForState(),
190 array_map(
191 $state_factory->getTableFilterStateMapper(...),
192 array_filter($state_factory->getValidStates(), fn($s): bool => !$s->isInitial())
193 )
194 ));
195
196 $fields = [
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')),
199 ];
200
201 return $this->ui_service->filter()->standard(
202 'contact-filter',
203 $target_url,
204 $fields,
205 array_map(fn(): bool => true, $fields),
206 true,
207 true
208 );
209 }

References ilBuddySystemRelationStateFactory\getInstance(), and ILIAS\Repository\lng().

Referenced by ILIAS\Contact\BuddySystem\Tables\RelationsTable\build().

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

◆ pipe()

static ILIAS\Contact\BuddySystem\Tables\RelationsTable::pipe ( Closure  $a,
Closure  $b 
)
staticprivate

Definition at line 158 of file RelationsTable.php.

158 : Closure
159 {
160 return static fn($x) => $b($a($x));
161 }
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples

References Vendor\Package\$a, and Vendor\Package\$b.

Referenced by ILIAS\Contact\BuddySystem\Tables\RelationsTable\filter().

+ Here is the caller graph for this function:

◆ rows()

ILIAS\Contact\BuddySystem\Tables\RelationsTable::rows ( array  $data,
array  $actions 
)
private
Parameters
array<array{user_idint, public_name: string, login: string, state: ilBuddySystemRelationState, points: ilBuddySystemRelationState[]}> $data
string[]$actions

Definition at line 215 of file RelationsTable.php.

215 : Closure
216 {
217 return static function (
218 DataRowBuilder $row_builder,
219 array $visible_column_ids,
220 Range $range,
221 Order $order
222 ) use ($data, $actions): Generator {
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']);
228 yield array_reduce(
229 $actions,
230 fn(DataRow $row, string $action): DataRow => in_array($action, $transitions, true) ?
231 $row :
232 $row->withDisabledAction($action),
233 $row_builder->buildDataRow((string) $row['user_id'], $row)
234 );
235 }
236 };
237 }

References Vendor\Package\$a, Vendor\Package\$b, $data, ILIAS\UI\Implementation\Component\Table\$range, ILIAS\UI\Component\Table\DataRowBuilder\buildDataRow(), and ILIAS\UI\Component\Table\DataRow\withDisabledAction().

Referenced by ILIAS\Contact\BuddySystem\Tables\RelationsTable\build().

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

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