ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilOrgUnitPermission.php
Go to the documentation of this file.
1 <?php
2 
9 {
10  const PARENT_TEMPLATE = -1;
11  const TABLE_NAME = 'il_orgu_permissions';
22  protected $id = 0;
30  protected $context_id = 0;
38  protected $operations = [];
42  protected $possible_operations = [];
46  protected $selected_operation_ids = [];
54  protected $parent_id = self::PARENT_TEMPLATE;
62  protected $position_id = 0;
66  protected $context;
74  protected $protected = false;
78  protected $newly_created = false;
79 
80 
81  public function update()
82  {
83  if ($this->isProtected()) {
84  throw new ilException('Cannot modify a protected ilOrgUnitPermission');
85  }
87  }
88 
89 
90  public function create()
91  {
92  if ($this->isProtected()) {
93  throw new ilException('Cannot modify a protected ilOrgUnitPermission');
94  }
95  parent::create();
96  }
97 
98 
99  public function delete()
100  {
101  if ($this->isProtected()) {
102  throw new ilException('Cannot modify a protected ilOrgUnitPermission');
103  }
104  parent::delete();
105  }
106 
107 
108  public function afterObjectLoad()
109  {
110  $this->possible_operations = ilOrgUnitOperationQueries::getOperationsForContextId($this->getContextId());
111  $this->operations = is_array($this->operations) ? $this->operations : array();
112  foreach ($this->operations as $operation) {
113  $this->selected_operation_ids[] = $operation->getOperationId();
114  }
115  $this->context = ilOrgUnitOperationContextQueries::findById($this->getContextId());
116  }
117 
118 
122  public function getId()
123  {
124  return $this->id;
125  }
126 
127 
131  public function setId($id)
132  {
133  $this->id = $id;
134  }
135 
136 
140  public function getContextId()
141  {
142  return $this->context_id;
143  }
144 
145 
149  public function setContextId($context_id)
150  {
151  $this->context_id = $context_id;
152  }
153 
154 
158  public function getOperations()
159  {
160  return $this->operations;
161  }
162 
163 
167  public function setOperations($operations)
168  {
169  $this->operations = $operations;
170  }
171 
172 
176  public function getParentId()
177  {
178  return $this->parent_id;
179  }
180 
181 
185  public function setParentId($parent_id)
186  {
187  $this->parent_id = $parent_id;
188  }
189 
190 
194  public function getPossibleOperations()
195  {
197  }
198 
199 
203  public function getSelectedOperationIds()
204  {
206  }
207 
208 
214  public function isOperationIdSelected($operation_id)
215  {
216  return in_array($operation_id, $this->selected_operation_ids);
217  }
218 
219 
223  public function getContext()
224  {
225  return $this->context;
226  }
227 
228 
232  public function setContext($context)
233  {
234  $this->context = $context;
235  }
236 
237 
241  public static function returnDbTableName()
242  {
243  return self::TABLE_NAME;
244  }
245 
246 
250  public function getPositionId()
251  {
252  return $this->position_id;
253  }
254 
255 
259  public function setPositionId($position_id)
260  {
261  $this->position_id = $position_id;
262  }
263 
264 
268  public function isTemplate()
269  {
270  return ($this->getParentId() == self::PARENT_TEMPLATE);
271  }
272 
273 
277  public function isDedicated()
278  {
279  return ($this->getParentId() != self::PARENT_TEMPLATE);
280  }
281 
282 
286  public function isProtected()
287  {
288  return $this->protected;
289  }
290 
291 
295  public function setProtected($protected)
296  {
297  $this->protected = $protected;
298  }
299 
300 
304  public function isNewlyCreated()
305  {
306  return $this->newly_created;
307  }
308 
309 
314  {
315  $this->newly_created = $newly_created;
316  }
317 
318 
324  public function sleep($field_name)
325  {
326  switch ($field_name) {
327  case 'operations':
328  $ids = [];
329  foreach ($this->operations as $operation) {
330  $ids[] = $operation->getOperationId();
331  }
332 
333  return json_encode($ids);
334  }
335 
336  return parent::sleep($field_name);
337  }
338 
339 
346  public function wakeUp($field_name, $field_value)
347  {
348  switch ($field_name) {
349  case 'operations':
350  $ids = json_decode($field_value);
351  $ids = is_array($ids) ? $ids : array();
352  $operations = [];
353  foreach ($ids as $id) {
354  $ilOrgUnitOperation = ilOrgUnitOperationQueries::findById($id);
355  if ($ilOrgUnitOperation) {
356  $operations[] = $ilOrgUnitOperation;
357  }
358  }
359 
360  return $operations;
361  }
362 
363  return parent::wakeUp($field_name, $field_value);
364  }
365 }
Class ActiveRecord.
wakeUp($field_name, $field_value)
Class ilOrgUnitPermissionGUI.
Create styles array
The data for the language used.
update($pash, $contents, Config $config)