diff options
author | Frederic Guillot <fred@kanboard.net> | 2016-03-26 17:25:54 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2016-03-26 17:25:54 -0400 |
commit | 4ca716ec47863f3eef6c851de7a4f37650f8ea6e (patch) | |
tree | af7ca983e3cec6300c1689bd76eb99e37fc2f799 /app/Controller/AvatarFile.php | |
parent | 820c929ab38273c80d0930e2e6140dd7676ba4df (diff) |
Move avatar actions to controller AvatarFile
Diffstat (limited to 'app/Controller/AvatarFile.php')
-rw-r--r-- | app/Controller/AvatarFile.php | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/app/Controller/AvatarFile.php b/app/Controller/AvatarFile.php index f8298e16..a47cca66 100644 --- a/app/Controller/AvatarFile.php +++ b/app/Controller/AvatarFile.php @@ -14,10 +14,47 @@ use Kanboard\Core\Thumbnail; class AvatarFile extends Base { /** - * Show Avatar image and send aggressive caching headers + * Display avatar page */ public function show() { + $user = $this->getUser(); + + $this->response->html($this->helper->layout->user('avatar_file/show', array( + 'user' => $user, + ))); + } + + /** + * Upload Avatar + */ + public function upload() + { + $user = $this->getUser(); + + if (! $this->avatarFile->uploadFile($user['id'], $this->request->getFileInfo('avatar'))) { + $this->flash->failure(t('Unable to upload the file.')); + } + + $this->response->redirect($this->helper->url->to('AvatarFile', 'show', array('user_id' => $user['id']))); + } + + /** + * Remove Avatar image + */ + public function remove() + { + $this->checkCSRFParam(); + $user = $this->getUser(); + $this->avatarFile->remove($user['id']); + $this->response->redirect($this->helper->url->to('AvatarFile', 'show', array('user_id' => $user['id']))); + } + + /** + * Show Avatar image (public) + */ + public function image() + { $user_id = $this->request->getIntegerParam('user_id'); $size = $this->request->getStringParam('size', 48); $filename = $this->avatarFile->getFilename($user_id); |