diff options
author | Frederic Guillot <fred@kanboard.net> | 2016-05-07 12:59:35 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2016-05-07 12:59:35 -0400 |
commit | 300dabe6b4e9e648c1111363fad8154def7cfb5f (patch) | |
tree | 1eb9cac2b56401e3c6f0fe8b46233f01909d4885 /app/Model/AvatarFile.php | |
parent | 94989663eca0d0dc2e9adb6d3190f0ab3cca9d2a (diff) |
Added support for LDAP user photo profile
Diffstat (limited to 'app/Model/AvatarFile.php')
-rw-r--r-- | app/Model/AvatarFile.php | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/app/Model/AvatarFile.php b/app/Model/AvatarFile.php index 36784e60..9f47ccc7 100644 --- a/app/Model/AvatarFile.php +++ b/app/Model/AvatarFile.php @@ -75,20 +75,20 @@ class AvatarFile extends Base } /** - * Upload avatar image + * Upload avatar image file * * @access public * @param integer $user_id * @param array $file * @return boolean */ - public function uploadFile($user_id, array $file) + public function uploadImageFile($user_id, array $file) { try { if ($file['error'] == UPLOAD_ERR_OK && $file['size'] > 0) { - $destination_filename = $this->generatePath($user_id, $file['name']); - $this->objectStorage->moveUploadedFile($file['tmp_name'], $destination_filename); - $this->create($user_id, $destination_filename); + $destinationFilename = $this->generatePath($user_id, $file['name']); + $this->objectStorage->moveUploadedFile($file['tmp_name'], $destinationFilename); + $this->create($user_id, $destinationFilename); } else { throw new Exception('File not uploaded: '.var_export($file['error'], true)); } @@ -102,6 +102,28 @@ class AvatarFile extends Base } /** + * Upload avatar image content + * + * @access public + * @param integer $user_id + * @param string $blob + * @return boolean + */ + public function uploadImageContent($user_id, &$blob) + { + try { + $destinationFilename = $this->generatePath($user_id, 'imageContent'); + $this->objectStorage->put($destinationFilename, $blob); + $this->create($user_id, $destinationFilename); + } catch (Exception $e) { + $this->logger->error($e->getMessage()); + return false; + } + + return true; + } + + /** * Generate the path for a new filename * * @access public |