@@ 184-200 (lines=17) @@ | ||
181 | * Create the user in LDAP, provided this configuration is enabled |
|
182 | * and a username was passed to a new Member record. |
|
183 | */ |
|
184 | public function onBeforeWrite() |
|
185 | { |
|
186 | if ($this->owner->LDAPMemberExtension_NoSync) { |
|
187 | return; |
|
188 | } |
|
189 | ||
190 | $service = Injector::inst()->get(LDAPService::class); |
|
191 | if (!$service->enabled() |
|
192 | || !$this->owner->config()->create_users_in_ldap |
|
193 | || !$this->owner->Username |
|
194 | || $this->owner->GUID |
|
195 | ) { |
|
196 | return; |
|
197 | } |
|
198 | ||
199 | $service->createLDAPUser($this->owner); |
|
200 | } |
|
201 | ||
202 | public function onAfterWrite() |
|
203 | { |
|
@@ 218-233 (lines=16) @@ | ||
215 | $this->sync(); |
|
216 | } |
|
217 | ||
218 | public function onAfterDelete() |
|
219 | { |
|
220 | if ($this->owner->LDAPMemberExtension_NoSync) { |
|
221 | return; |
|
222 | } |
|
223 | ||
224 | $service = Injector::inst()->get(LDAPService::class); |
|
225 | if (!$service->enabled() || |
|
226 | !$this->owner->config()->delete_users_in_ldap || |
|
227 | !$this->owner->GUID |
|
228 | ) { |
|
229 | return; |
|
230 | } |
|
231 | ||
232 | $service->deleteLDAPMember($this->owner); |
|
233 | } |
|
234 | ||
235 | /** |
|
236 | * Write DataObject without triggering this extension's hooks. |