ILIAS  release_8 Revision v8.24
class.ilOrgUnitAuthority.php
Go to the documentation of this file.
1<?php
19// namespace ILIAS\Modules\OrgUnit\Positions\Authorities;
20
26{
27 public const FIELD_OVER = 'over';
28 public const OVER_EVERYONE = -1;
29 public const POSITION_ID = "position_id";
30 public const SCOPE_SAME_ORGU = 1;
31 public const SCOPE_SUBSEQUENT_ORGUS = 2;
32 public const SCOPE_ALL_ORGUS = 3;
36 protected static $scopes
37 = array(
38 self::SCOPE_SAME_ORGU,
39 self::SCOPE_SUBSEQUENT_ORGUS
40 );
41
45 public static function getScopes(): array
46 {
47 return self::$scopes;
48 }
49
50 public static function returnDbTableName(): string
51 {
52 return "il_orgu_authority";
53 }
54
64 protected $id = 0;
71 protected int $over = self::OVER_EVERYONE;
85 protected int $position_id = 0;
86 protected static ?\Closure $name_render = null;
87
92 public function __construct($primary_key = 0)
93 {
94 parent::__construct($primary_key);
95 if (static::$name_render === null) {
96 self::$name_render = function ($id) {
97 return $id;
98 };
99 }
100 }
101
105 public static function replaceNameRenderer(Closure $closure)
106 {
107 self::$name_render = $closure;
108 }
109
110 public function __toString(): string
111 {
112 $renderer = self::$name_render;
113
114 return (string) $renderer($this->getId());
115 }
116
117 public function __toArray(): array
118 {
119 return array(
120 'id' => $this->getId(),
121 'over' => $this->getOver(),
122 'scope' => $this->getScope(),
123 'position_id' => $this->getPositionId(),
124 );
125 }
126
130 public function getId()
131 {
132 return $this->id;
133 }
134
138 public function setId($id): void
139 {
140 $this->id = $id;
141 }
142
143 public function getOver(): int
144 {
145 return $this->over;
146 }
147
151 public function setOver(int $over)
152 {
153 $this->over = $over;
154 }
155
156 public function getScope(): int
157 {
158 return $this->scope;
159 }
160
167 public function setScope(int $scope): void
168 {
169 if (!in_array($scope, self::$scopes)) {
170 throw new ilException('Selected Scop in ' . self::class . ' not allowed');
171 }
172 $this->scope = $scope;
173 }
174
175 public function getPositionId(): int
176 {
177 return $this->position_id;
178 }
179
180 public function setPositionId(int $position_id)
181 {
182 $this->position_id = $position_id;
183 }
184}
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...
setPositionId(int $position_id)
setScope(int $scope)
This is either ilOrgUnitAuthority::SCOPE_SAME_ORGU, ilOrgUnitAuthority::SCOPE_ALL_ORGUS or ilOrgUnitA...
setOver(int $over)
This is either an ID of a position or ilOrgUnitAuthority::OVER_EVERYONE.
__construct($primary_key=0)
ilOrgUnitAuthority constructor.
static replaceNameRenderer(Closure $closure)
$scopes
Definition: ltitoken.php:99
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc