ILIAS  release_8 Revision v8.24
class.ilOrgUnitOperationContext.php
Go to the documentation of this file.
1<?php
24{
25 public const CONTEXT_OBJECT = "object";
26 public const CONTEXT_CRS = "crs";
27 public const CONTEXT_GRP = "grp";
28 public const CONTEXT_IASS = "iass";
29 public const CONTEXT_TST = "tst";
30 public const CONTEXT_EXC = "exc";
31 public const CONTEXT_SVY = "svy";
32 public const CONTEXT_USRF = "usrf";
33 public const CONTEXT_PRG = "prg";
34 public const CONTEXT_ETAL = "etal";
35
39 public static array $available_contexts = [
50 ];
51
55 public function getPopulatedContextNames(): array
56 {
57 $contexts = array($this->getContext());
58 $this->appendParentContextName($contexts);
59
60 return $contexts;
61 }
62
66 public function getPopulatedContextIds(): array
67 {
68 $contexts = array($this->getId());
69 $this->appendParentContextName($contexts);
70
71 return $contexts;
72 }
73
83 protected ?int $id = 0;
92 protected string $context = self::CONTEXT_OBJECT;
99 protected int $parent_context_id = 0;
100
101 public function getId(): ?int
102 {
103 return $this->id;
104 }
105
106 public function setId(?int $id): void
107 {
108 $this->id = $id;
109 }
110
111 public function getContext(): string
112 {
113 return $this->context;
114 }
115
116 public function setContext(string $context): void
117 {
118 $this->context = $context;
119 }
120
121 public function getParentContextId(): int
122 {
124 }
125
127 {
128 $this->parent_context_id = $parent_context_id;
129 }
130
131 public static function returnDbTableName(): string
132 {
133 return 'il_orgu_op_contexts';
134 }
135
136 public function create(): void
137 {
138 if (self::where(array('context' => $this->getContext()))->hasSets()) {
139 throw new ilException('Context already registered');
140 }
141 parent::create();
142 }
143
147 private function appendParentContextName(array $contexts): void
148 {
149 if ($this->getParentContextId()) {
153 $parent = self::find($this->getParentContextId());
154 if ($parent) {
155 $contexts[] = $parent->getContext();
156 $parent->appendParentContextName($contexts);
157 }
158 }
159 }
160
164 private function appendParentContextId(array $contexts): void
165 {
166 if ($this->getParentContextId()) {
170 $parent = self::find($this->getParentContextId());
171 if ($parent) {
172 $contexts[] = $parent->getId();
173 $parent->appendParentContextName($contexts);
174 }
175 }
176 }
177}
Class ActiveRecord.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...