ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
ILIAS\Contact\BuddySystem\Tables\RelationsTable Class Reference

@phpstan-type RelationRecord array{ user_id: int, public_name: string, login: string, state: ilBuddySystemRelationState, target_states: list<ilBuddySystemRelationState>, state_text: string } More...

+ 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, private readonly Closure $link_to_profile,)
 
 build (array $multi_actions, string $target_url, callable $action)
 

Private Member Functions

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

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

@phpstan-type RelationRecord array{ user_id: int, public_name: string, login: string, state: ilBuddySystemRelationState, target_states: list<ilBuddySystemRelationState>, state_text: string }

Definition at line 52 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,
private readonly Closure  $link_to_profile 
)
Parameters
Closure(int,string)string $link_to_profile

Definition at line 57 of file RelationsTable.php.

63 {
64 }

Member Function Documentation

◆ actions()

ILIAS\Contact\BuddySystem\Tables\RelationsTable::actions ( array  $data,
callable  $action 
)
private
Parameters
list<RelationRecord>$data
callable(string,string,string)Action $action
Returns
array<string, Action>

Definition at line 185 of file RelationsTable.php.

185 : array
186 {
187 $actions = [];
188 foreach ($data as $row) {
189 foreach ($row['target_states'] as $state) {
190 $actions[$row['state'] . '->' . $state] = $action(
191 'single',
192 'buddy_bs_act_btn_txt_' . $row['state']->getSnakeName() . '_to_' . $state->getSnakeName(),
193 $state->getAction()
194 );
195 }
196 }
197
198 return $actions;
199 }

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
list<Component>

Definition at line 121 of file RelationsTable.php.

121 : array
122 {
123 $filter = $this->filterComponent($target_url);
124 $data = static::data($this->ui_service->filter()->getData($filter) ?: []);
125 $single_actions = $this->actions($data, $action);
126
127 $components = [
128 $filter
129 ];
130 $components[] = $this->create
131 ->table()
132 ->data(
133 new TableRows($data, array_keys($single_actions), $this->link_to_profile),
134 $this->lng->txt('buddy_tbl_title_relations'),
135 [
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
139 ->table()->column()
140 ->text($this->lng->txt('buddy_tbl_state_actions_col_label')),
141 ]
142 )
143 ->withId('buddy_relations_table')
144 ->withRequest($this->http->request())
145 ->withRange(new Range(0, 50))
146 ->withActions(
147 array_merge($single_actions, $multi_actions)
148 );
149
150 return $components;
151 }
$components
static http()
Fetches the global http state from ILIAS.

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

+ 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 160 of file RelationsTable.php.

160 : Closure
161 {
162 $in_string = static fn(string $needle, string $haystack): bool => ilStr::strpos(
163 ilStr::strtolower($haystack),
164 ilStr::strtolower($needle),
165 0
166 ) !== false;
167
168 return self::pipe($relations->getKey(...), static fn(int $user_id): bool => (
169 $in_string($public_name_query, $public_names[$user_id]) ||
170 $in_string($public_name_query, $logins[$user_id])
172 }
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 201 of file RelationsTable.php.

201 : Filter
202 {
204 $options = array_merge(...array_map(
205 static fn($m): array => $m->optionsForState(),
206 array_map(
207 $state_factory->getTableFilterStateMapper(...),
208 array_filter($state_factory->getValidStates(), static fn($s): bool => !$s->isInitial())
209 )
210 ));
211
212 $fields = [
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')),
215 ];
216
217 return $this->ui_service->filter()->standard(
218 'contact-filter',
219 $target_url,
220 $fields,
221 array_map(static fn(): bool => true, $fields),
222 true,
223 true
224 );
225 }

References ILIAS\UI\Implementation\Component\Input\Field\$options, 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 174 of file RelationsTable.php.

174 : Closure
175 {
176 return static fn($x) => $b($a($x));
177 }
$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:

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