| @@ 169-181 (lines=13) @@ | ||
| 166 | * Create the user in LDAP, provided this configuration is enabled |
|
| 167 | * and a username was passed to a new Member record. |
|
| 168 | */ |
|
| 169 | public function onBeforeWrite() |
|
| 170 | { |
|
| 171 | $service = Injector::inst()->get('LDAPService'); |
|
| 172 | if (!$service->enabled()) { |
|
| 173 | return; |
|
| 174 | } |
|
| 175 | if (!$this->owner->config()->create_users_in_ldap) { |
|
| 176 | return; |
|
| 177 | } |
|
| 178 | if ($this->owner->Username && !$this->owner->IsImportedFromLDAP) { |
|
| 179 | $service->createLDAPUser($this->owner); |
|
| 180 | } |
|
| 181 | } |
|
| 182 | ||
| 183 | /** |
|
| 184 | * Update the local data with LDAP, and ensure local membership is also set in |
|
| @@ 187-200 (lines=14) @@ | ||
| 184 | * Update the local data with LDAP, and ensure local membership is also set in |
|
| 185 | * LDAP too. This writes into LDAP, provided that feature is enabled. |
|
| 186 | */ |
|
| 187 | public function onAfterWrite() |
|
| 188 | { |
|
| 189 | $service = Injector::inst()->get('LDAPService'); |
|
| 190 | if (!$service->enabled()) { |
|
| 191 | return; |
|
| 192 | } |
|
| 193 | if (!$this->owner->config()->update_ldap_from_local) { |
|
| 194 | return; |
|
| 195 | } |
|
| 196 | if ($this->owner->IsImportedFromLDAP) { |
|
| 197 | $service->updateLDAPFromMember($this->owner); |
|
| 198 | $service->updateLDAPGroupsForMember($this->owner); |
|
| 199 | } |
|
| 200 | } |
|
| 201 | ||
| 202 | public function onAfterDelete() { |
|
| 203 | $service = Injector::inst()->get('LDAPService'); |
|
| @@ 202-213 (lines=12) @@ | ||
| 199 | } |
|
| 200 | } |
|
| 201 | ||
| 202 | public function onAfterDelete() { |
|
| 203 | $service = Injector::inst()->get('LDAPService'); |
|
| 204 | if (!$service->enabled()) { |
|
| 205 | return; |
|
| 206 | } |
|
| 207 | if (!$this->owner->config()->delete_users_in_ldap) { |
|
| 208 | return; |
|
| 209 | } |
|
| 210 | if ($this->owner->IsImportedFromLDAP) { |
|
| 211 | $service->deleteLDAPMember($this->owner); |
|
| 212 | } |
|
| 213 | } |
|
| 214 | ||
| 215 | /** |
|
| 216 | * Triggered by {@link Member::logIn()} when successfully logged in, |
|