ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilOrgUnitUser.php
Go to the documentation of this file.
1<?php
2
3namespace OrgUnit\User;
4
5use OrgUnit\Positions\ilOrgUnitPosition;
6
8{
9
13 protected static $instances;
17 protected $user_id;
21 protected $login;
25 protected $email;
29 protected $second_email;
33 protected $org_unit_positions = [];
37 protected $superiors = [];
38
39
45 public static function getInstanceById(int $user_id) : self
46 {
47 if (null === static::$instances[$user_id]) {
48 $org_unit_user_repository = new ilOrgUnitUserRepository();
49 static::$instances[$user_id] = $org_unit_user_repository->getOrgUnitUser($user_id);
50 }
51
52 return static::$instances[$user_id];
53 }
54
55
63 public static function getInstance(int $user_id, string $login, string $email, string $second_email) : self
64 {
65 if (null === static::$instances[$user_id]) {
66 static::$instances[$user_id] = new static($user_id, $login, $email, $second_email);
67 }
68
69 return static::$instances[$user_id];
70 }
71
72
73 private function __construct(int $user_id, string $login, string $email, string $second_email)
74 {
75 $this->user_id = $user_id;
76 $this->login = $login;
77 $this->email = $email;
78 $this->second_email = $second_email;
79 }
80
81
85 public function addSuperior(ilOrgUnitUser $org_unit_user)
86 {
87 $this->superiors[] = $org_unit_user;
88 }
89
90
94 public function addPositions(ilOrgUnitPosition $org_unit_position)
95 {
96 $this->org_unit_positions[] = $org_unit_position;
97 }
98
99
106 public function getSuperiors() : array
107 {
108 if (count($this->superiors) == 0) {
109 $this->loadSuperiors();
110 }
111
112 return $this->superiors;
113 }
114
115
116 public function loadSuperiors() : void
117 {
118 $org_unit_user_repository = new ilOrgUnitUserRepository();
119 $org_unit_user_repository->loadSuperiors([$this->user_id]);
120 }
121
122
128 public function getOrgUnitPositions() : array
129 {
130 if (count($this->org_unit_positions) == 0) {
131 $this->loadOrgUnitPositions();
132 }
133
135 }
136
137
143 protected function loadOrgUnitPositions() : array
144 {
145 $org_unit_user_repository = new ilOrgUnitUserRepository();
146 $org_unit_user_repository->loadPositions([$this->user_id]);
147 }
148
149
153 public function getUserId() : int
154 {
155 return $this->user_id;
156 }
157
158
162 public function getLogin() : string
163 {
164 return $this->login;
165 }
166
167
171 public function getEmail() : string
172 {
173 return $this->email;
174 }
175
176
180 public function getSecondEmail() : string
181 {
182 return $this->second_email;
183 }
184
185
189 public function setSecondEmail(string $second_email) : void
190 {
191 $this->second_email = $second_email;
192 }
193}
An exception for terminatinating execution or to throw for unit testing.
__construct(int $user_id, string $login, string $email, string $second_email)
static getInstanceById(int $user_id)
addSuperior(ilOrgUnitUser $org_unit_user)
setSecondEmail(string $second_email)
addPositions(ilOrgUnitPosition $org_unit_position)
static getInstance(int $user_id, string $login, string $email, string $second_email)
login()
Definition: login.php:2