@@ 158-175 (lines=18) @@ | ||
155 | * Create the user in LDAP, provided this configuration is enabled |
|
156 | * and a username was passed to a new Member record. |
|
157 | */ |
|
158 | public function onBeforeWrite() |
|
159 | { |
|
160 | if ($this->owner->LDAPMemberExtension_NoSync) { |
|
161 | return; |
|
162 | } |
|
163 | ||
164 | $service = Injector::inst()->get('LDAPService'); |
|
165 | if ( |
|
166 | !$service->enabled() || |
|
167 | !$this->owner->config()->create_users_in_ldap || |
|
168 | !$this->owner->Username || |
|
169 | $this->owner->GUID |
|
170 | ) { |
|
171 | return; |
|
172 | } |
|
173 | ||
174 | $service->createLDAPUser($this->owner); |
|
175 | } |
|
176 | ||
177 | public function onAfterWrite() |
|
178 | { |
|
@@ 189-204 (lines=16) @@ | ||
186 | $this->sync(); |
|
187 | } |
|
188 | ||
189 | public function onAfterDelete() { |
|
190 | if ($this->owner->LDAPMemberExtension_NoSync) { |
|
191 | return; |
|
192 | } |
|
193 | ||
194 | $service = Injector::inst()->get('LDAPService'); |
|
195 | if ( |
|
196 | !$service->enabled() || |
|
197 | !$this->owner->config()->delete_users_in_ldap || |
|
198 | !$this->owner->GUID |
|
199 | ) { |
|
200 | return; |
|
201 | } |
|
202 | ||
203 | $service->deleteLDAPMember($this->owner); |
|
204 | } |
|
205 | ||
206 | /** |
|
207 | * Write DataObject without triggering this extension's hooks. |