summaryrefslogtreecommitdiff
path: root/app/Controller/AvatarFile.php
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-05-28 11:31:54 -0400
committerFrederic Guillot <fred@kanboard.net>2016-05-28 11:31:54 -0400
commitab48a09f0d674b703467975b376c5ac7352670ae (patch)
tree99fbb0cf719acee8c500622d498bd7f6375b62a1 /app/Controller/AvatarFile.php
parent82b5b491bec94cb3d40a5820fbef9959435309be (diff)
Rename controllers
Diffstat (limited to 'app/Controller/AvatarFile.php')
-rw-r--r--app/Controller/AvatarFile.php94
1 files changed, 0 insertions, 94 deletions
diff --git a/app/Controller/AvatarFile.php b/app/Controller/AvatarFile.php
deleted file mode 100644
index 1891a2fc..00000000
--- a/app/Controller/AvatarFile.php
+++ /dev/null
@@ -1,94 +0,0 @@
-<?php
-
-namespace Kanboard\Controller;
-
-use Kanboard\Core\ObjectStorage\ObjectStorageException;
-use Kanboard\Core\Thumbnail;
-
-/**
- * Avatar File Controller
- *
- * @package controller
- * @author Frederic Guillot
- */
-class AvatarFile extends BaseController
-{
- /**
- * 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->uploadImageFile($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->userSession->refresh($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);
- $etag = md5($filename.$size);
-
- $this->response->withCache(365 * 86400, $etag);
- $this->response->withContentType('image/jpeg');
-
- if ($this->request->getHeader('If-None-Match') !== '"'.$etag.'"') {
- $this->response->send();
- $this->render($filename, $size);
- } else {
- $this->response->status(304);
- }
- }
-
- /**
- * Render thumbnail from object storage
- *
- * @access private
- * @param string $filename
- * @param integer $size
- */
- private function render($filename, $size)
- {
- try {
- $blob = $this->objectStorage->get($filename);
-
- Thumbnail::createFromString($blob)
- ->resize($size, $size)
- ->toOutput();
- } catch (ObjectStorageException $e) {
- $this->logger->error($e->getMessage());
- }
- }
-}