Skip to content

Commit

Permalink
added extend to define multiple ad fields that contain an image
Browse files Browse the repository at this point in the history
  • Loading branch information
Benedikt Hofstaetter committed Jun 5, 2019
1 parent 1a19689 commit d70dccf
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/Services/LDAPService.php
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,11 @@ public function updateMemberFromLDAP(Member $member, $data = null, $updateGroups
continue;
}

if ($attribute == 'thumbnailphoto') {
$photoAttributes = ['thumbnailphoto'];

$this->extend('updatePhotoAttributes', $photoAttributes);

if (in_array($attribute, $photoAttributes)) {
$this->processThumbnailPhoto($member, $field, $data, $attribute);
} else {
$member->$field = $data[$attribute];
Expand Down Expand Up @@ -637,7 +641,7 @@ protected function processThumbnailPhoto(Member $member, $fieldName, $data, $att
if ($imageClass !== Image::class && !is_subclass_of($imageClass, Image::class)) {
$this->getLogger()->warning(
sprintf(
'Member field %s configured for thumbnailphoto AD attribute, but it isn\'t a valid relation to an '
'Member field %s configured for ' . $attributeName . ' AD attribute, but it isn\'t a valid relation to an '
. 'Image class',
$fieldName
)
Expand All @@ -663,7 +667,7 @@ protected function processThumbnailPhoto(Member $member, $fieldName, $data, $att

// Setup variables
$thumbnailFolder = Folder::find_or_make($member->config()->ldap_thumbnail_path);
$filename = sprintf('thumbnailphoto-%s.jpg', $data['objectguid']);
$filename = sprintf($attributeName . '-%s.jpg', $data['objectguid']);
$filePath = File::join_paths($thumbnailFolder->getFilename(), $filename);
$fileCfg = [
// if there's a filename conflict we've got new content so overwrite it.
Expand Down

0 comments on commit d70dccf

Please sign in to comment.