ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilOrgUnitUserAssignmentDBRepository Class Reference
+ Inheritance diagram for ilOrgUnitUserAssignmentDBRepository:
+ Collaboration diagram for ilOrgUnitUserAssignmentDBRepository:

Public Member Functions

 __construct (ilDBInterface $db, ?ilAppEventHandler $handler=null)
 
 get (int $user_id, int $position_id, int $orgu_id)
 Get existing user assignment or create a new one. More...
 
 find (int $user_id, int $position_id, int $orgu_id)
 Find assignment for user, position and org-unit Does not create new assigment, returns null if no assignment exists. More...
 
 store (ilOrgUnitUserAssignment $assignment)
 Store assignment to db. More...
 
 delete (ilOrgUnitUserAssignment $assignment)
 Delete a single assignment Returns false if no assignment was found. More...
 
 deleteByUser (int $user_id)
 Delete all assignments for a user_id Returns false if no assignments were found. More...
 
 getByUsers (array $user_ids)
 Get assignments for one or more users. More...
 
 getByPosition (int $position_id)
 Get all assignments for a position. More...
 
 getByOrgUnit (int $orgu_id)
 Get all assignments for an org-unit. More...
 
 getByUserAndPosition (int $user_id, int $position_id)
 Get assignments for a user in a dedicated position. More...
 
 getUsersByOrgUnits (array $orgu_ids)
 Get all users for a given set of org-units. More...
 
 getUsersByPosition (int $position_id)
 Get all users with a certain position. More...
 
 getUsersByOrgUnitsAndPosition (array $orgu_ids, int $position_id)
 Get all users in a specific position for a given set of org-units. More...
 
 getUsersByUserAndPosition (int $user_id, int $position_id, bool $recursive=false)
 Get all users from org-units where the user has a certain position i.e. More...
 
 getFilteredUsersByUserAndPosition (int $user_id, int $position_id, int $position_filter_id, bool $recursive=false)
 Get all users with position $position_filter_id from those org-units, where the user has position $position_id i.e. More...
 
 getOrgUnitsByUser (int $user_id)
 Get all org-units a user is assigned to. More...
 
 getOrgUnitsByUserAndPosition (int $user_id, int $position_id, bool $recursive=false)
 Get all org-units where a user has a dedicated position. More...
 
 getPositionsByUser (int $user_id)
 Get all positions a user is assigned to. More...
 
 getSuperiorsByUsers (array $user_ids)
 Get all superiors of one or more users $user_id => [ $superior_ids ]. More...
 
 getTotalRowCount (?array $filter_data, ?array $additional_parameters)
 
 getRows (Table\DataRowBuilder $row_builder, array $visible_column_ids, Range $range, Order $order, ?array $filter_data, ?array $additional_parameters)
 
 get (int $user_id, int $position_id, int $orgu_id)
 Get existing user assignment or create a new one. More...
 
 find (int $user_id, int $position_id, int $orgu_id)
 Find assignment for user, position and org-unit Does not create new assigment, returns null if no assignment exists. More...
 
 store (ilOrgUnitUserAssignment $assignment)
 Store assignment to db. More...
 
 delete (ilOrgUnitUserAssignment $assignment)
 Delete a single assignment Returns false if no assignment was found. More...
 
 deleteByUser (int $user_id)
 Delete all assignments for a user_id Returns false if no assignments were found. More...
 
 getByUsers (array $user_ids)
 Get assignments for one or more users. More...
 
 getByPosition (int $position_id)
 Get all assignments for a position. More...
 
 getByOrgUnit (int $orgu_id)
 Get all assignments for an org-unit. More...
 
 getByUserAndPosition (int $user_id, int $position_id)
 Get assignments for a user in a dedicated position. More...
 
 getUsersByOrgUnits (array $orgu_ids)
 Get all users for a given set of org-units. More...
 
 getUsersByPosition (int $position_id)
 Get all users with a certain position. More...
 
 getUsersByOrgUnitsAndPosition (array $orgu_ids, int $position_id)
 Get all users in a specific position for a given set of org-units. More...
 
 getUsersByUserAndPosition (int $user_id, int $position_id, bool $recursive=false)
 Get all users from org-units where the user has a certain position i.e. More...
 
 getFilteredUsersByUserAndPosition (int $user_id, int $position_id, int $position_filter_id, bool $recursive=false)
 Get all users with position $position_filter_id from those org-units, where the user has position $position_id i.e. More...
 
 getOrgUnitsByUser (int $user_id)
 Get all org-units a user is assigned to. More...
 
 getOrgUnitsByUserAndPosition (int $user_id, int $position_id, bool $recursive=false)
 Get all org-units where a user has a dedicated position. More...
 
 getPositionsByUser (int $user_id)
 Get all positions a user is assigned to. More...
 
 getSuperiorsByUsers (array $user_ids)
 Get all superiors of one or more users $user_id => [ $superior_ids ]. More...
 

Data Fields

const TABLE_NAME = 'il_orgu_ua'
 

Protected Member Functions

 getPositionRepo ()
 
 insert (ilOrgUnitUserAssignment $assignment)
 
 update (ilOrgUnitUserAssignment $assignment)
 
 raiseEvent (string $event, ilOrgUnitUserAssignment $assignment)
 
 getUserDataByOrgUnitsAndPosition (array $orgu_ids, int $position_id, bool $count_only=false, ?Range $range=null, ?Order $order=null)
 

Protected Attributes

ilDBInterface $db
 
ilAppEventHandler $ilAppEventHandler
 
ilOrgUnitPositionDBRepository $positionRepo
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilOrgUnitUserAssignmentDBRepository::__construct ( ilDBInterface  $db,
?ilAppEventHandler  $handler = null 
)

Definition at line 32 of file class.ilOrgUnitUserAssignmentDBRepository.php.

33 {
34 $this->db = $db;
35
36 if ($handler) {
38 } else {
39 global $DIC;
40 $this->ilAppEventHandler = $DIC->event();
41 }
42 }
Global event handler.
$handler
Definition: oai.php:29
global $DIC
Definition: shib_login.php:26

References $db, $DIC, and $handler.

Member Function Documentation

◆ delete()

ilOrgUnitUserAssignmentDBRepository::delete ( ilOrgUnitUserAssignment  $assignment)

Delete a single assignment Returns false if no assignment was found.

Implements OrgUnitUserAssignmentRepository.

Definition at line 146 of file class.ilOrgUnitUserAssignmentDBRepository.php.

146 : bool
147 {
148 if ($assignment->getId() === 0) {
149 return false;
150 }
151
152 $query = 'DELETE FROM ' . self::TABLE_NAME . PHP_EOL
153 . ' WHERE id = ' . $this->db->quote($assignment->getId(), 'integer');
154 $rows = $this->db->manipulate($query);
155
156 if ($rows > 0) {
157 $this->raiseEvent('deassignUserFromPosition', $assignment);
158 return true;
159 }
160
161 return false;
162 }
raiseEvent(string $event, ilOrgUnitUserAssignment $assignment)

References raiseEvent().

+ Here is the call graph for this function:

◆ deleteByUser()

ilOrgUnitUserAssignmentDBRepository::deleteByUser ( int  $user_id)

Delete all assignments for a user_id Returns false if no assignments were found.

Implements OrgUnitUserAssignmentRepository.

Definition at line 164 of file class.ilOrgUnitUserAssignmentDBRepository.php.

164 : bool
165 {
166 if ($user_id <= 0) {
167 return false;
168 }
169
170 $query = 'DELETE FROM ' . self::TABLE_NAME . PHP_EOL
171 . ' WHERE user_id = ' . $this->db->quote($user_id, 'integer');
172 $rows = $this->db->manipulate($query);
173
174 if ($rows > 0) {
175 return true;
176 }
177
178 return false;
179 }

References $user_id.

Referenced by ilOrgUnitUserAssignmentQueries\deleteAllAssignmentsOfUser().

+ Here is the caller graph for this function:

◆ find()

ilOrgUnitUserAssignmentDBRepository::find ( int  $user_id,
int  $position_id,
int  $orgu_id 
)

Find assignment for user, position and org-unit Does not create new assigment, returns null if no assignment exists.

Implements OrgUnitUserAssignmentRepository.

Definition at line 79 of file class.ilOrgUnitUserAssignmentDBRepository.php.

80 {
81 $query = 'SELECT id, user_id, position_id, orgu_id FROM' . PHP_EOL
82 . self::TABLE_NAME
83 . ' WHERE ' . self::TABLE_NAME . '.user_id = ' . $this->db->quote($user_id, 'integer') . PHP_EOL
84 . ' AND ' . self::TABLE_NAME . '.position_id = ' . $this->db->quote($position_id, 'integer') . PHP_EOL
85 . ' AND ' . self::TABLE_NAME . '.orgu_id = ' . $this->db->quote($orgu_id, 'integer');
86
87 $res = $this->db->query($query);
88 if ($res->numRows() === 0) {
89 return null;
90 }
91
92 $rec = $this->db->fetchAssoc($res);
93 return (new ilOrgUnitUserAssignment((int) $rec['id']))
94 ->withUserId((int) $rec['user_id'])
95 ->withPositionId((int) $rec['position_id'])
96 ->withOrguId((int) $rec['orgu_id']);
97 }
Class ilOrgUnitUserAssignment.
$res
Definition: ltiservices.php:69

References $res, and $user_id.

Referenced by ilOrgUnitUserAssignmentQueries\getAssignmentOrFail().

+ Here is the caller graph for this function:

◆ get()

ilOrgUnitUserAssignmentDBRepository::get ( int  $user_id,
int  $position_id,
int  $orgu_id 
)

Get existing user assignment or create a new one.

Implements OrgUnitUserAssignmentRepository.

Definition at line 54 of file class.ilOrgUnitUserAssignmentDBRepository.php.

55 {
56 $query = 'SELECT id, user_id, position_id, orgu_id FROM' . PHP_EOL
57 . self::TABLE_NAME
58 . ' WHERE ' . self::TABLE_NAME . '.user_id = ' . $this->db->quote($user_id, 'integer') . PHP_EOL
59 . ' AND ' . self::TABLE_NAME . '.position_id = ' . $this->db->quote($position_id, 'integer') . PHP_EOL
60 . ' AND ' . self::TABLE_NAME . '.orgu_id = ' . $this->db->quote($orgu_id, 'integer');
61
62 $res = $this->db->query($query);
63 if ($res->numRows() > 0) {
64 $rec = $this->db->fetchAssoc($res);
65 return (new ilOrgUnitUserAssignment((int) $rec['id']))
66 ->withUserId((int) $rec['user_id'])
67 ->withPositionId((int) $rec['position_id'])
68 ->withOrguId((int) $rec['orgu_id']);
69 }
70
71 $assignment = (new ilOrgUnitUserAssignment())
72 ->withUserId($user_id)
73 ->withPositionId($position_id)
74 ->withOrguId($orgu_id);
75 $assignment = $this->store($assignment);
76 return $assignment;
77 }
store(ilOrgUnitUserAssignment $assignment)
Store assignment to db.

References $res, $user_id, and store().

+ Here is the call graph for this function:

◆ getByOrgUnit()

ilOrgUnitUserAssignmentDBRepository::getByOrgUnit ( int  $orgu_id)

Get all assignments for an org-unit.

Returns
ilOrgUnitUserAssignment[]

Implements OrgUnitUserAssignmentRepository.

Definition at line 213 of file class.ilOrgUnitUserAssignmentDBRepository.php.

213 : array
214 {
215 $query = 'SELECT id, user_id, position_id, orgu_id FROM' . PHP_EOL
216 . self::TABLE_NAME
217 . ' WHERE ' . self::TABLE_NAME . '.orgu_id = ' . $this->db->quote($orgu_id, 'integer');
218 $res = $this->db->query($query);
219 $ret = [];
220 while ($rec = $this->db->fetchAssoc($res)) {
221 $ret[] = (new ilOrgUnitUserAssignment((int) $rec['id']))
222 ->withUserId((int) $rec['user_id'])
223 ->withPositionId((int) $rec['position_id'])
224 ->withOrguId((int) $rec['orgu_id']);
225 }
226 return $ret;
227 }

References $res.

◆ getByPosition()

ilOrgUnitUserAssignmentDBRepository::getByPosition ( int  $position_id)

Get all assignments for a position.

Returns
ilOrgUnitUserAssignment[]

Implements OrgUnitUserAssignmentRepository.

Definition at line 197 of file class.ilOrgUnitUserAssignmentDBRepository.php.

197 : array
198 {
199 $query = 'SELECT id, user_id, position_id, orgu_id FROM' . PHP_EOL
200 . self::TABLE_NAME
201 . ' WHERE ' . self::TABLE_NAME . '.position_id = ' . $this->db->quote($position_id, 'integer');
202 $res = $this->db->query($query);
203 $ret = [];
204 while ($rec = $this->db->fetchAssoc($res)) {
205 $ret[] = (new ilOrgUnitUserAssignment((int) $rec['id']))
206 ->withUserId((int) $rec['user_id'])
207 ->withPositionId((int) $rec['position_id'])
208 ->withOrguId((int) $rec['orgu_id']);
209 }
210 return $ret;
211 }

References $res.

Referenced by ilOrgUnitUserAssignmentQueries\getUserAssignmentsOfPosition().

+ Here is the caller graph for this function:

◆ getByUserAndPosition()

ilOrgUnitUserAssignmentDBRepository::getByUserAndPosition ( int  $user_id,
int  $position_id 
)

Get assignments for a user in a dedicated position.

Returns
ilOrgUnitUserAssignment[]

Implements OrgUnitUserAssignmentRepository.

Definition at line 230 of file class.ilOrgUnitUserAssignmentDBRepository.php.

230 : array
231 {
232 $query = 'SELECT id, user_id, position_id, orgu_id FROM' . PHP_EOL
233 . self::TABLE_NAME
234 . ' WHERE ' . self::TABLE_NAME . '.user_id = ' . $this->db->quote($user_id, 'integer') . PHP_EOL
235 . ' AND ' . self::TABLE_NAME . '.position_id = ' . $this->db->quote($position_id, 'integer');
236 $res = $this->db->query($query);
237 $ret = [];
238 while ($rec = $this->db->fetchAssoc($res)) {
239 $ret[] = (new ilOrgUnitUserAssignment((int) $rec['id']))
240 ->withUserId((int) $rec['user_id'])
241 ->withPositionId((int) $rec['position_id'])
242 ->withOrguId((int) $rec['orgu_id']);
243 }
244 return $ret;
245 }

References $res, and $user_id.

Referenced by ilOrgUnitUserAssignmentQueries\getAssignmentsOfUserIdAndPosition().

+ Here is the caller graph for this function:

◆ getByUsers()

ilOrgUnitUserAssignmentDBRepository::getByUsers ( array  $user_ids)

Get assignments for one or more users.

Parameters
int[]$user_ids
Returns
ilOrgUnitUserAssignment[]

Implements OrgUnitUserAssignmentRepository.

Definition at line 181 of file class.ilOrgUnitUserAssignmentDBRepository.php.

181 : array
182 {
183 $query = 'SELECT id, user_id, position_id, orgu_id FROM' . PHP_EOL
184 . self::TABLE_NAME
185 . ' WHERE ' . $this->db->in('user_id', $user_ids, false, 'integer');
186 $res = $this->db->query($query);
187 $ret = [];
188 while ($rec = $this->db->fetchAssoc($res)) {
189 $ret[] = (new ilOrgUnitUserAssignment((int) $rec['id']))
190 ->withUserId((int) $rec['user_id'])
191 ->withPositionId((int) $rec['position_id'])
192 ->withOrguId((int) $rec['orgu_id']);
193 }
194 return $ret;
195 }

References $res.

Referenced by ilOrgUnitUserAssignmentQueries\getAssignmentsOfUserId(), and ilOrgUnitUserAssignmentQueries\getAssignmentsOfUserIds().

+ Here is the caller graph for this function:

◆ getFilteredUsersByUserAndPosition()

ilOrgUnitUserAssignmentDBRepository::getFilteredUsersByUserAndPosition ( int  $user_id,
int  $position_id,
int  $position_filter_id,
bool  $recursive = false 
)

Get all users with position $position_filter_id from those org-units, where the user has position $position_id i.e.

all employees of all org-units where the user is a superior

Returns
int[]

Implements OrgUnitUserAssignmentRepository.

Definition at line 302 of file class.ilOrgUnitUserAssignmentDBRepository.php.

302 : array
303 {
304 $orgu_ids = $this->getOrgUnitsByUserAndPosition($user_id, $position_id, $recursive);
305
306 $query = 'SELECT user_id FROM' . PHP_EOL
307 . self::TABLE_NAME
308 . ' WHERE ' . $this->db->in(self::TABLE_NAME . '.orgu_id', $orgu_ids, false, 'integer') . PHP_EOL
309 . ' AND ' . self::TABLE_NAME . '.position_id = ' . $this->db->quote($position_filter_id, 'integer');
310 $res = $this->db->query($query);
311 $users = [];
312 while ($rec = $this->db->fetchAssoc($res)) {
313 $users[] = (int) $rec['user_id'];
314 }
315 return $users;
316 }
getOrgUnitsByUserAndPosition(int $user_id, int $position_id, bool $recursive=false)
Get all org-units where a user has a dedicated position.

References $res, getOrgUnitsByUserAndPosition(), and ILIAS\Repository\int().

Referenced by ilOrgUnitUserAssignmentQueries\getUserIdsOfUsersOrgUnitsInPosition().

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

◆ getOrgUnitsByUser()

ilOrgUnitUserAssignmentDBRepository::getOrgUnitsByUser ( int  $user_id)

Get all org-units a user is assigned to.

Returns
int[]

Implements OrgUnitUserAssignmentRepository.

Definition at line 318 of file class.ilOrgUnitUserAssignmentDBRepository.php.

318 : array
319 {
320 $query = 'SELECT orgu_id FROM' . PHP_EOL
321 . self::TABLE_NAME
322 . ' WHERE ' . self::TABLE_NAME . '.user_id = ' . $this->db->quote($user_id, 'integer');
323 $res = $this->db->query($query);
324 $orgu_ids = [];
325 while ($rec = $this->db->fetchAssoc($res)) {
326 $orgu_ids[] = (int) $rec['orgu_id'];
327 }
328 return $orgu_ids;
329 }

References $res, $user_id, and ILIAS\Repository\int().

Referenced by ilOrgUnitUserAssignmentQueries\getOrgUnitIdsofUser().

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

◆ getOrgUnitsByUserAndPosition()

ilOrgUnitUserAssignmentDBRepository::getOrgUnitsByUserAndPosition ( int  $user_id,
int  $position_id,
bool  $recursive = false 
)

Get all org-units where a user has a dedicated position.

Returns
int[]

Implements OrgUnitUserAssignmentRepository.

Definition at line 331 of file class.ilOrgUnitUserAssignmentDBRepository.php.

331 : array
332 {
333 $query = 'SELECT orgu_id FROM' . PHP_EOL
334 . self::TABLE_NAME
335 . ' WHERE ' . self::TABLE_NAME . '.user_id = ' . $this->db->quote($user_id, 'integer') . PHP_EOL
336 . ' AND ' . self::TABLE_NAME . '.position_id = ' . $this->db->quote($position_id, 'integer');
337 $res = $this->db->query($query);
338 $orgu_ids = [];
339 while ($rec = $this->db->fetchAssoc($res)) {
340 $orgu_ids[] = (int) $rec['orgu_id'];
341 }
342
343 if (!$recursive) {
344 return $orgu_ids;
345 }
346
347 $recursive_orgu_ids = [];
349 foreach ($orgu_ids as $orgu_id) {
350 $recursive_orgu_ids = array_merge($recursive_orgu_ids, $tree->getAllChildren($orgu_id));
351 }
352 return $recursive_orgu_ids;
353 }

References $res, $user_id, ilObjOrgUnitTree\_getInstance(), and ILIAS\Repository\int().

Referenced by getFilteredUsersByUserAndPosition(), ilOrgUnitUserAssignmentQueries\getOrgUnitIdsOfUsersPosition(), and getUsersByUserAndPosition().

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

◆ getPositionRepo()

ilOrgUnitUserAssignmentDBRepository::getPositionRepo ( )
protected

Definition at line 44 of file class.ilOrgUnitUserAssignmentDBRepository.php.

45 {
46 if (!isset($this->positionRepo)) {
48 $this->positionRepo = $dic["repo.Positions"];
49 }
50
52 }
$dic
Definition: ltiresult.php:33

References $dic, $positionRepo, and ilOrgUnitLocalDIC\dic().

Referenced by getPositionsByUser().

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

◆ getPositionsByUser()

ilOrgUnitUserAssignmentDBRepository::getPositionsByUser ( int  $user_id)

Get all positions a user is assigned to.

Returns
ilOrgUnitPosition[]

Implements OrgUnitUserAssignmentRepository.

Definition at line 355 of file class.ilOrgUnitUserAssignmentDBRepository.php.

355 : array
356 {
357 $query = 'SELECT DISTINCT position_id FROM' . PHP_EOL
358 . self::TABLE_NAME
359 . ' WHERE ' . self::TABLE_NAME . '.user_id = ' . $this->db->quote($user_id, 'integer');
360 $res = $this->db->query($query);
361
362 $positions = [];
363 while ($rec = $this->db->fetchAssoc($res)) {
364 $positions[] = $this->getPositionRepo()->getSingle((int) $rec['position_id'], 'id');
365 }
366 return $positions;
367 }

References $res, $user_id, and getPositionRepo().

Referenced by ilOrgUnitUserAssignmentQueries\getPositionsOfUserId().

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

◆ getRows()

ilOrgUnitUserAssignmentDBRepository::getRows ( Table\DataRowBuilder  $row_builder,
array  $visible_column_ids,
Range  $range,
Order  $order,
?array  $filter_data,
?array  $additional_parameters 
)

Definition at line 449 of file class.ilOrgUnitUserAssignmentDBRepository.php.

456 : \Generator {
457 $orgu_ids = $additional_parameters['orgu_ids'];
458 $position_id = $additional_parameters['position_id'];
459 $lp_visible = $additional_parameters['lp_visible_ref_ids'];
460 $write_access = $additional_parameters['write_access'];
461
462 foreach ($this->getUserDataByOrgUnitsAndPosition($orgu_ids, $position_id, false, $range, $order) as $record) {
463 $row_id = implode('_', [(string) $position_id, (string) $record['usr_id']]);
464 yield $row_builder->buildDataRow($row_id, $record)
465 ->withDisabledAction(
466 'show_learning_progress',
467 !(
468 in_array($record['orgu_id'], $lp_visible)
471 )
472 )
473 ->withDisabledAction(
474 'remove',
475 !$write_access
476 );
477
478 }
479 }
getUserDataByOrgUnitsAndPosition(array $orgu_ids, int $position_id, bool $count_only=false, ?Range $range=null, ?Order $order=null)

References ilObjUserTracking\_enabledLearningProgress(), and ilObjUserTracking\_enabledUserRelatedData().

+ Here is the call graph for this function:

◆ getSuperiorsByUsers()

ilOrgUnitUserAssignmentDBRepository::getSuperiorsByUsers ( array  $user_ids)

Get all superiors of one or more users $user_id => [ $superior_ids ].

Parameters
int[]$user_ids
Returns
int[]

Implements OrgUnitUserAssignmentRepository.

Definition at line 369 of file class.ilOrgUnitUserAssignmentDBRepository.php.

369 : array
370 {
371 $query = 'SELECT ' . PHP_EOL
372 . ' ua.orgu_id AS orgu_id,' . PHP_EOL
373 . ' ua.user_id AS empl,' . PHP_EOL
374 . ' ua2.user_id as sup' . PHP_EOL
375 . ' FROM' . PHP_EOL
376 . self::TABLE_NAME . ' as ua,' . PHP_EOL
377 . self::TABLE_NAME . ' as ua2' . PHP_EOL
378 . ' WHERE ua.orgu_id = ua2.orgu_id' . PHP_EOL
379 . ' AND ua.user_id <> ua2.user_id' . PHP_EOL
380 . ' AND ua.position_id = ' . $this->db->quote(ilOrgUnitPosition::CORE_POSITION_EMPLOYEE, 'integer') . PHP_EOL
381 . ' AND ua2.position_id = ' . $this->db->quote(ilOrgUnitPosition::CORE_POSITION_SUPERIOR, 'integer') . PHP_EOL
382 . ' AND ' . $this->db->in('ua.user_id', $user_ids, false, 'integer');
383 $res = $this->db->query($query);
384 if ($res->numRows() === 0) {
385 return [];
386 }
387
388 $ret = [];
389 while ($rec = $this->db->fetchAssoc($res)) {
390 $ret[$rec['empl']][] = $rec['sup'];
391 }
392 return $ret;
393 }

References $res, ilOrgUnitPosition\CORE_POSITION_EMPLOYEE, and ilOrgUnitPosition\CORE_POSITION_SUPERIOR.

◆ getTotalRowCount()

ilOrgUnitUserAssignmentDBRepository::getTotalRowCount ( ?array  $filter_data,
?array  $additional_parameters 
)

Definition at line 440 of file class.ilOrgUnitUserAssignmentDBRepository.php.

443 : ?int {
444 $orgu_ids = $additional_parameters['orgu_ids'];
445 $position_id = $additional_parameters['position_id'];
446 return $this->getUserDataByOrgUnitsAndPosition($orgu_ids, $position_id, true);
447 }

◆ getUserDataByOrgUnitsAndPosition()

ilOrgUnitUserAssignmentDBRepository::getUserDataByOrgUnitsAndPosition ( array  $orgu_ids,
int  $position_id,
bool  $count_only = false,
?Range  $range = null,
?Order  $order = null 
)
protected

Definition at line 404 of file class.ilOrgUnitUserAssignmentDBRepository.php.

410 {
411 $sql_order_part = $order ? $order->join('ORDER BY', fn(...$o) => implode(' ', $o)) : '';
412 $sql_range_part = $range ? sprintf('LIMIT %2$s OFFSET %1$s', ...$range->unpack()) : '';
413
414 $query = 'SELECT usr_id, login, firstname, lastname, active, orgu_id' . PHP_EOL
415 . ', GROUP_CONCAT (od.title SEPARATOR ", ") as orgu_title ' . PHP_EOL
416 . 'FROM ' . self::TABLE_NAME . PHP_EOL
417 . 'JOIN usr_data ud on ud.usr_id = user_id' . PHP_EOL
418 . 'JOIN object_reference oref on oref.ref_id = orgu_id' . PHP_EOL
419 . 'JOIN object_data od on od.obj_id = oref.obj_id' . PHP_EOL
420 . 'WHERE ' . $this->db->in(self::TABLE_NAME . '.orgu_id', $orgu_ids, false, 'integer') . PHP_EOL
421 . 'AND ' . self::TABLE_NAME . '.position_id = ' . $this->db->quote($position_id, 'integer') . PHP_EOL
422 . 'group by login' . PHP_EOL
423 . $sql_order_part . PHP_EOL
424 . $sql_range_part . PHP_EOL
425 ;
426 $res = $this->db->query($query);
427
428 if ($count_only) {
429 return $this->db->numRows($res);
430 }
431
432 $users = [];
433 while ($rec = $this->db->fetchAssoc($res)) {
434 $rec['active'] = (bool) $rec['active'];
435 $users[] = $rec;
436 }
437 return $users;
438 }

References ILIAS\UI\Implementation\Component\Table\$range, $res, and ILIAS\Data\Range\unpack().

+ Here is the call graph for this function:

◆ getUsersByOrgUnits()

ilOrgUnitUserAssignmentDBRepository::getUsersByOrgUnits ( array  $orgu_ids)

Get all users for a given set of org-units.

Parameters
int[]$orgu_ids
Returns
int[]

Implements OrgUnitUserAssignmentRepository.

Definition at line 247 of file class.ilOrgUnitUserAssignmentDBRepository.php.

247 : array
248 {
249 $query = 'SELECT user_id FROM' . PHP_EOL
250 . self::TABLE_NAME
251 . ' WHERE ' . $this->db->in(self::TABLE_NAME . '.orgu_id', $orgu_ids, false, 'integer');
252 $res = $this->db->query($query);
253 $users = [];
254 while ($rec = $this->db->fetchAssoc($res)) {
255 $users[] = (int) $rec['user_id'];
256 }
257 return $users;
258 }

References $res, and ILIAS\Repository\int().

Referenced by ilOrgUnitUserAssignmentQueries\getUserIdsOfOrgUnit(), and ilOrgUnitUserAssignmentQueries\getUserIdsOfOrgUnits().

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

◆ getUsersByOrgUnitsAndPosition()

ilOrgUnitUserAssignmentDBRepository::getUsersByOrgUnitsAndPosition ( array  $orgu_ids,
int  $position_id 
)

Get all users in a specific position for a given set of org-units.

Parameters
int[]$orgu_ids
Returns
int[]

Implements OrgUnitUserAssignmentRepository.

Definition at line 273 of file class.ilOrgUnitUserAssignmentDBRepository.php.

273 : array
274 {
275 $query = 'SELECT user_id FROM' . PHP_EOL
276 . self::TABLE_NAME
277 . ' WHERE ' . $this->db->in(self::TABLE_NAME . '.orgu_id', $orgu_ids, false, 'integer') . PHP_EOL
278 . ' AND ' . self::TABLE_NAME . '.position_id = ' . $this->db->quote($position_id, 'integer');
279 $res = $this->db->query($query);
280 $users = [];
281 while ($rec = $this->db->fetchAssoc($res)) {
282 $users[] = (int) $rec['user_id'];
283 }
284 return $users;
285 }

References $res, and ILIAS\Repository\int().

Referenced by ilOrgUnitUserAssignmentQueries\getUserIdsOfOrgUnitsInPosition().

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

◆ getUsersByPosition()

ilOrgUnitUserAssignmentDBRepository::getUsersByPosition ( int  $position_id)

Get all users with a certain position.

Returns
int[]

Implements OrgUnitUserAssignmentRepository.

Definition at line 260 of file class.ilOrgUnitUserAssignmentDBRepository.php.

260 : array
261 {
262 $query = 'SELECT user_id FROM' . PHP_EOL
263 . self::TABLE_NAME
264 . ' WHERE ' . self::TABLE_NAME . '.position_id = ' . $this->db->quote($position_id, 'integer');
265 $res = $this->db->query($query);
266 $users = [];
267 while ($rec = $this->db->fetchAssoc($res)) {
268 $users[] = (int) $rec['user_id'];
269 }
270 return $users;
271 }

References $res, and ILIAS\Repository\int().

Referenced by ilOrgUnitUserAssignmentQueries\getUserIdsOfPosition().

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

◆ getUsersByUserAndPosition()

ilOrgUnitUserAssignmentDBRepository::getUsersByUserAndPosition ( int  $user_id,
int  $position_id,
bool  $recursive = false 
)

Get all users from org-units where the user has a certain position i.e.

all users from all org-units where the user is an employee

Returns
int[]

Implements OrgUnitUserAssignmentRepository.

Definition at line 287 of file class.ilOrgUnitUserAssignmentDBRepository.php.

287 : array
288 {
289 $orgu_ids = $this->getOrgUnitsByUserAndPosition($user_id, $position_id, $recursive);
290
291 $query = 'SELECT user_id FROM' . PHP_EOL
292 . self::TABLE_NAME
293 . ' WHERE ' . $this->db->in(self::TABLE_NAME . '.orgu_id', $orgu_ids, false, 'integer');
294 $res = $this->db->query($query);
295 $users = [];
296 while ($rec = $this->db->fetchAssoc($res)) {
297 $users[] = (int) $rec['user_id'];
298 }
299 return $users;
300 }

References $res, getOrgUnitsByUserAndPosition(), and ILIAS\Repository\int().

Referenced by ilOrgUnitUserAssignmentQueries\getUserIdsOfOrgUnitsOfUsersPosition().

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

◆ insert()

ilOrgUnitUserAssignmentDBRepository::insert ( ilOrgUnitUserAssignment  $assignment)
protected

Definition at line 112 of file class.ilOrgUnitUserAssignmentDBRepository.php.

113 {
114 $id = $this->db->nextId(self::TABLE_NAME);
115
116 $values = [
117 'id' => [ 'integer', $id ],
118 'user_id' => [ 'integer', $assignment->getUserId() ],
119 'position_id' => [ 'integer', $assignment->getPositionId() ],
120 'orgu_id' => [ 'integer', $assignment->getOrguId() ]
121 ];
122
123 $this->db->insert(self::TABLE_NAME, $values);
124
125 $ret = (new ilOrgUnitUserAssignment($id))
126 ->withUserId($assignment->getUserId())
127 ->withPositionId($assignment->getPositionId())
128 ->withOrguId($assignment->getOrguId());
129
130 return $ret;
131 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

References $id, ilOrgUnitUserAssignment\getOrguId(), ilOrgUnitUserAssignment\getPositionId(), and ilOrgUnitUserAssignment\getUserId().

Referenced by store().

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

◆ raiseEvent()

ilOrgUnitUserAssignmentDBRepository::raiseEvent ( string  $event,
ilOrgUnitUserAssignment  $assignment 
)
protected

Definition at line 395 of file class.ilOrgUnitUserAssignmentDBRepository.php.

395 : void
396 {
397 $this->ilAppEventHandler->raise('components/ILIAS/OrgUnit', $event, array(
398 'obj_id' => $assignment->getOrguId(),
399 'usr_id' => $assignment->getUserId(),
400 'position_id' => $assignment->getPositionId()
401 ));
402 }
raise(string $a_component, string $a_event, array $a_parameter=[])
Raise an event.

References ilOrgUnitUserAssignment\getOrguId(), ilOrgUnitUserAssignment\getPositionId(), ilOrgUnitUserAssignment\getUserId(), and ilAppEventHandler\raise().

Referenced by delete(), and store().

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

◆ store()

ilOrgUnitUserAssignmentDBRepository::store ( ilOrgUnitUserAssignment  $assignment)

Store assignment to db.

Implements OrgUnitUserAssignmentRepository.

Definition at line 99 of file class.ilOrgUnitUserAssignmentDBRepository.php.

100 {
101 if ($assignment->getId() === 0) {
102 $assignment = $this->insert($assignment);
103 } else {
104 $this->update($assignment);
105 }
106
107 $this->raiseEvent('assignUserToPosition', $assignment);
108
109 return $assignment;
110 }

References ilOrgUnitUserAssignment\getId(), insert(), raiseEvent(), and update().

Referenced by get().

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

◆ update()

ilOrgUnitUserAssignmentDBRepository::update ( ilOrgUnitUserAssignment  $assignment)
protected

Definition at line 133 of file class.ilOrgUnitUserAssignmentDBRepository.php.

133 : void
134 {
135 $where = [ 'id' => [ 'integer', $assignment->getId() ] ];
136
137 $values = [
138 'user_id' => [ 'integer', $assignment->getUserId() ],
139 'position_id' => [ 'integer', $assignment->getPositionId(),
140 'orgu_id' => [ 'integer', $assignment->getOrguId() ]]
141 ];
142
143 $this->db->update(self::TABLE_NAME, $values, $where);
144 }

References ilOrgUnitUserAssignment\getId(), ilOrgUnitUserAssignment\getOrguId(), ilOrgUnitUserAssignment\getPositionId(), and ilOrgUnitUserAssignment\getUserId().

Referenced by store().

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

Field Documentation

◆ $db

ilDBInterface ilOrgUnitUserAssignmentDBRepository::$db
protected

Definition at line 28 of file class.ilOrgUnitUserAssignmentDBRepository.php.

Referenced by __construct().

◆ $ilAppEventHandler

ilAppEventHandler ilOrgUnitUserAssignmentDBRepository::$ilAppEventHandler
protected

◆ $positionRepo

ilOrgUnitPositionDBRepository ilOrgUnitUserAssignmentDBRepository::$positionRepo
protected

Definition at line 30 of file class.ilOrgUnitUserAssignmentDBRepository.php.

Referenced by getPositionRepo().

◆ TABLE_NAME

const ilOrgUnitUserAssignmentDBRepository::TABLE_NAME = 'il_orgu_ua'

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