ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilOrgUnitUserAssignmentQueries.php
Go to the documentation of this file.
1 <?php
2 
9 {
10 
14  protected static $instance;
15 
16 
20  public static function getInstance()
21  {
22  if (!isset(self::$instance)) {
23  self::$instance = new self();
24  }
25 
26  return self::$instance;
27  }
28 
29 
35  public function getPositionsOfUserId($user_id)
36  {
40  $positions = [];
41  foreach ($this->getAssignmentsOfUserId($user_id) as $assignment) {
42  $positions[] = ilOrgUnitPosition::find($assignment->getPositionId());
43  }
44 
45  return $positions;
46  }
47 
48 
57  public function getAssignmentOrFail($user_id, $position_id, $orgu_id)
58  {
60  'user_id' => $user_id,
61  'position_id' => $position_id,
62  'orgu_id' => $orgu_id,
63  ])->first();
64  if (!$ua) {
65  throw new ilException('UserAssignement not found');
66  }
67 
68  return $ua;
69  }
70 
71 
72  public function filterUserIdsDueToAuthorities($user_id, array $user_ids)
73  {
74  }
75 
76 
82  public function getAssignmentsOfUserId($user_id)
83  {
84  return ilOrgUnitUserAssignment::where([ 'user_id' => $user_id ])->get();
85  }
86 
87 
93  public function getUserIdsOfOrgUnit($orgunit_ref_id)
94  {
95  return ilOrgUnitUserAssignment::where([ 'orgu_id' => $orgunit_ref_id ])
96  ->getArray(null, 'user_id');
97  }
98 
99 
105  public function getUserIdsOfOrgUnits(array $orgunit_ref_id)
106  {
107  return ilOrgUnitUserAssignment::where([ 'orgu_id' => $orgunit_ref_id ])
108  ->getArray(null, 'user_id');
109  }
110 
111 
121  public function getUserIdsOfOrgUnitsOfUsersPosition($position_id, $user_id, $recursive = false)
122  {
123  return ilOrgUnitUserAssignment::where([ 'orgu_id' => $this->getOrgUnitIdsOfUsersPosition($position_id, $user_id, $recursive) ])
124  ->getArray(null, 'user_id');
125  }
126 
127 
134  public function getUserIdsOfOrgUnitsInPosition(array $orgu_ids, $position_id)
135  {
137  'orgu_id' => $orgu_ids,
138  'position_id' => $position_id,
139  ])->getArray(null, 'user_id');
140  }
141 
142 
152  public function getUserIdsOfUsersOrgUnitsInPosition($user_id, $users_position_id, $position_id, $recursive = false)
153  {
155  'orgu_id' => $this->getOrgUnitIdsOfUsersPosition($users_position_id, $user_id, $recursive),
156  'position_id' => $position_id,
157  ])->getArray(null, 'user_id');
158  }
159 
160 
169  public function getOrgUnitIdsOfUsersPosition($position_id, $user_id, $recursive = false)
170  {
171  $orgu_ids = ilOrgUnitUserAssignment::where([
172  'position_id' => $position_id,
173  'user_id' => $user_id,
174  ])->getArray(null, 'orgu_id');
175 
176  if (!$recursive) {
177  return $orgu_ids;
178  }
179 
180  $recursive_orgu_ids = [];
182  foreach ($orgu_ids as $orgu_id) {
183  $recursive_orgu_ids = $recursive_orgu_ids + $tree->getAllChildren($orgu_id);
184  }
185 
186  return $recursive_orgu_ids;
187  }
188 
189 
195  public function getUserIdsOfPosition($position_id)
196  {
198  'position_id' => $position_id,
199  ])->getArray(null, 'user_id');
200  }
201 
202 
208  public function getUserAssignmentsOfPosition($position_id)
209  {
211  'position_id' => $position_id,
212  ])->get();
213  }
214 
220  public function deleteAllAssignmentsOfUser($user_id)
221  {
222  global $DIC;
223  $q = "DELETE FROM il_orgu_ua WHERE user_id = " . $DIC->database()->quote($user_id, "integer");
224  $DIC->database()->manipulate($q);
225  }
226 }
getUserIdsOfOrgUnitsInPosition(array $orgu_ids, $position_id)
global $DIC
Definition: saml.php:7
static where($where, $operator=null)
getAssignmentOrFail($user_id, $position_id, $orgu_id)
getOrgUnitIdsOfUsersPosition($position_id, $user_id, $recursive=false)
getUserIdsOfUsersOrgUnitsInPosition($user_id, $users_position_id, $position_id, $recursive=false)
Class ilOrgUnitUserAssignmentQueries.
Create styles array
The data for the language used.
getUserIdsOfOrgUnitsOfUsersPosition($position_id, $user_id, $recursive=false)