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