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