diff options
Diffstat (limited to 'app/Controller')
-rw-r--r-- | app/Controller/AvatarFileController.php | 2 | ||||
-rw-r--r-- | app/Controller/ProjectFileController.php | 17 | ||||
-rw-r--r-- | app/Controller/TaskFileController.php | 17 |
3 files changed, 27 insertions, 9 deletions
diff --git a/app/Controller/AvatarFileController.php b/app/Controller/AvatarFileController.php index 6879c577..2a63c5ae 100644 --- a/app/Controller/AvatarFileController.php +++ b/app/Controller/AvatarFileController.php @@ -33,7 +33,7 @@ class AvatarFileController extends BaseController $user = $this->getUser(); if (! $this->avatarFileModel->uploadImageFile($user['id'], $this->request->getFileInfo('avatar'))) { - $this->flash->failure(t('Unable to upload the file.')); + $this->flash->failure(t('Unable to upload files, check the permissions of your data folder.')); } $this->response->redirect($this->helper->url->to('AvatarFileController', 'show', array('user_id' => $user['id']))); diff --git a/app/Controller/ProjectFileController.php b/app/Controller/ProjectFileController.php index 9c38f684..83c7779f 100644 --- a/app/Controller/ProjectFileController.php +++ b/app/Controller/ProjectFileController.php @@ -33,12 +33,21 @@ class ProjectFileController extends BaseController public function save() { $project = $this->getProject(); + $result = $this->projectFileModel->uploadFiles($project['id'], $this->request->getFileInfo('files')); - if (! $this->projectFileModel->uploadFiles($project['id'], $this->request->getFileInfo('files'))) { - $this->flash->failure(t('Unable to upload the file.')); - } + if ($this->request->isAjax()) { + if (! $result) { + $this->response->json(array('message' => t('Unable to upload files, check the permissions of your data folder.')), 500); + } else { + $this->response->json(array('message' => 'OK')); + } + } else { + if (! $result) { + $this->flash->failure(t('Unable to upload files, check the permissions of your data folder.')); + } - $this->response->redirect($this->helper->url->to('ProjectOverviewController', 'show', array('project_id' => $project['id'])), true); + $this->response->redirect($this->helper->url->to('ProjectOverviewController', 'show', array('project_id' => $project['id'])), true); + } } /** diff --git a/app/Controller/TaskFileController.php b/app/Controller/TaskFileController.php index 8a0971e4..ff0c299e 100644 --- a/app/Controller/TaskFileController.php +++ b/app/Controller/TaskFileController.php @@ -52,12 +52,21 @@ class TaskFileController extends BaseController public function save() { $task = $this->getTask(); + $result = $this->taskFileModel->uploadFiles($task['id'], $this->request->getFileInfo('files')); - if (! $this->taskFileModel->uploadFiles($task['id'], $this->request->getFileInfo('files'))) { - $this->flash->failure(t('Unable to upload the file.')); - } + if ($this->request->isAjax()) { + if (! $result) { + $this->response->json(array('message' => t('Unable to upload files, check the permissions of your data folder.')), 500); + } else { + $this->response->json(array('message' => 'OK')); + } + } else { + if (! $result) { + $this->flash->failure(t('Unable to upload files, check the permissions of your data folder.')); + } - $this->response->redirect($this->helper->url->to('TaskViewController', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])), true); + $this->response->redirect($this->helper->url->to('TaskViewController', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])), true); + } } /** |