1 | <?php |
||
41 | class Organization extends User |
||
42 | { |
||
43 | use SelfBlameableTrait; |
||
44 | |||
45 | const TYPE_ORGANIZATION = 1; |
||
46 | const TYPE_DEPARTMENT = 2; |
||
47 | |||
48 | /** |
||
49 | * @var boolean Organization does not need password and corresponding features. |
||
50 | */ |
||
51 | public $passwordHashAttribute = false; |
||
52 | |||
53 | /** |
||
54 | * @var boolean Organization does not need password and corresponding features. |
||
55 | */ |
||
56 | public $passwordResetTokenAttribute = false; |
||
57 | |||
58 | /** |
||
59 | * @var boolean Organization does not need password and corresponding features. |
||
60 | */ |
||
61 | public $passwordHistoryClass = false; |
||
62 | |||
63 | /** |
||
64 | * @var boolean Organization does not need source. |
||
65 | */ |
||
66 | public $sourceAttribute = false; |
||
67 | |||
68 | /** |
||
69 | * @var boolean Organization does not need auth key. |
||
70 | */ |
||
71 | public $authKeyAttribute = false; |
||
72 | |||
73 | /** |
||
74 | * @var boolean Organization does not need access token. |
||
75 | */ |
||
76 | public $accessTokenAttribute = false; |
||
77 | |||
78 | /** |
||
79 | * |
||
80 | * @var boolean Organization does not need login log. |
||
81 | */ |
||
82 | public $loginLogClass = false; |
||
83 | |||
84 | public $profileClass = Profile::class; |
||
85 | |||
86 | public $memberClass = Member::class; |
||
87 | private $noInitMember; |
||
88 | /** |
||
89 | * @return Member |
||
90 | */ |
||
91 | 16 | protected function getNoInitMember() |
|
99 | |||
100 | 25 | public function init() |
|
112 | |||
113 | /** |
||
114 | * @inheritdoc |
||
115 | */ |
||
116 | 1 | public function attributeLabels() |
|
130 | |||
131 | /** |
||
132 | * @inheritdoc |
||
133 | */ |
||
134 | 25 | public static function tableName() |
|
138 | |||
139 | 24 | protected function getTypeRules() |
|
147 | |||
148 | 24 | public function rules() |
|
152 | |||
153 | /** |
||
154 | * Get Member Query. |
||
155 | * @return MemberQuery |
||
156 | */ |
||
157 | 16 | public function getMembers() |
|
161 | |||
162 | /** |
||
163 | * Get organization member users' query. |
||
164 | * @return BaseUserQuery |
||
165 | */ |
||
166 | 2 | public function getMemberUsers() |
|
173 | |||
174 | /** |
||
175 | * Get member with specified user. |
||
176 | * @param User|string|integer $user |
||
177 | * @return Member Null if `user` is not in this organization. |
||
178 | */ |
||
179 | 7 | public function getMember($user) |
|
183 | |||
184 | /** |
||
185 | * Add member to organization. |
||
186 | * @param Member|User|string|integer $member |
||
187 | * @see createMemberModel |
||
188 | * @see createMemberModelWithUser |
||
189 | * @return boolean |
||
190 | */ |
||
191 | 5 | public function addMember(&$member) |
|
206 | |||
207 | /** |
||
208 | * Create member model, and set organization with this. |
||
209 | * @param Member $member If this parameter is not new record, it's organization |
||
210 | * will be set with this, and return it. Otherwise, it will extract `User` |
||
211 | * model and create new `Member` model. |
||
212 | * @see createMemberModelWithUser |
||
213 | * @return Member |
||
214 | */ |
||
215 | public function createMemberModel($member) |
||
223 | |||
224 | /** |
||
225 | * Create member model with user, and set organization with this. |
||
226 | * @param User|string|integer $user |
||
227 | * @return Member |
||
228 | */ |
||
229 | 23 | public function createMemberModelWithUser($user) |
|
241 | |||
242 | /** |
||
243 | * Remove member. |
||
244 | * @param Member|User $member |
||
245 | * @return boolean |
||
246 | */ |
||
247 | 1 | public function removeMember(&$member) |
|
258 | |||
259 | /** |
||
260 | * |
||
261 | * @param Event $event |
||
262 | */ |
||
263 | 13 | public function onRevokeCreatorBeforeDeregister($event) |
|
272 | |||
273 | /** |
||
274 | * |
||
275 | * @return boolean |
||
276 | */ |
||
277 | 2 | public function isOrganization() |
|
281 | |||
282 | /** |
||
283 | * |
||
284 | * @return boolean |
||
285 | */ |
||
286 | 2 | public function isDepartment() |
|
290 | |||
291 | /** |
||
292 | * Check whether the current organization has a member. |
||
293 | * @param User $user |
||
294 | * @return boolean |
||
295 | */ |
||
296 | 1 | public function hasMember($user) |
|
300 | |||
301 | /** |
||
302 | * Get creator query. |
||
303 | * @return MemberQuery |
||
304 | */ |
||
305 | 13 | public function getMemberCreators() |
|
312 | |||
313 | /** |
||
314 | * Get administrator query. |
||
315 | * @return MemberQuery |
||
316 | */ |
||
317 | public function getMemberAdministrators() |
||
324 | |||
325 | /** |
||
326 | * |
||
327 | * @param User $user |
||
328 | */ |
||
329 | 1 | public function addAdministrator($user) |
|
350 | } |
||
351 |