diff options
Diffstat (limited to 'app/Controller')
-rw-r--r-- | app/Controller/Board.php | 12 | ||||
-rw-r--r-- | app/Controller/Budget.php | 135 | ||||
-rw-r--r-- | app/Controller/Doc.php | 22 | ||||
-rw-r--r-- | app/Controller/File.php | 38 | ||||
-rw-r--r-- | app/Controller/Hourlyrate.php | 89 | ||||
-rw-r--r-- | app/Controller/Swimlane.php | 6 | ||||
-rw-r--r-- | app/Controller/Taskcreation.php | 36 | ||||
-rw-r--r-- | app/Controller/Taskmodification.php | 28 |
8 files changed, 77 insertions, 289 deletions
diff --git a/app/Controller/Board.php b/app/Controller/Board.php index 179c6b3c..a552b9cf 100644 --- a/app/Controller/Board.php +++ b/app/Controller/Board.php @@ -321,6 +321,18 @@ class Board extends Base } /** + * Display swimlane description in tooltip + * + * @access public + */ + public function swimlane() + { + $this->getProject(); + $swimlane = $this->swimlane->getById($this->request->getIntegerParam('swimlane_id')); + $this->response->html($this->template->render('board/tooltip_description', array('task' => $swimlane))); + } + + /** * Enable collapsed mode * * @access public diff --git a/app/Controller/Budget.php b/app/Controller/Budget.php deleted file mode 100644 index a2f7e0db..00000000 --- a/app/Controller/Budget.php +++ /dev/null @@ -1,135 +0,0 @@ -<?php - -namespace Controller; - -/** - * Budget - * - * @package controller - * @author Frederic Guillot - */ -class Budget extends Base -{ - /** - * Budget index page - * - * @access public - */ - public function index() - { - $project = $this->getProject(); - - $this->response->html($this->projectLayout('budget/index', array( - 'daily_budget' => $this->budget->getDailyBudgetBreakdown($project['id']), - 'project' => $project, - 'title' => t('Budget') - ), 'budget/sidebar')); - } - - /** - * Cost breakdown by users/subtasks/tasks - * - * @access public - */ - public function breakdown() - { - $project = $this->getProject(); - - $paginator = $this->paginator - ->setUrl('budget', 'breakdown', array('project_id' => $project['id'])) - ->setMax(30) - ->setOrder('start') - ->setDirection('DESC') - ->setQuery($this->budget->getSubtaskBreakdown($project['id'])) - ->calculate(); - - $this->response->html($this->projectLayout('budget/breakdown', array( - 'paginator' => $paginator, - 'project' => $project, - 'title' => t('Budget') - ), 'budget/sidebar')); - } - - /** - * Create budget lines - * - * @access public - */ - public function create(array $values = array(), array $errors = array()) - { - $project = $this->getProject(); - - if (empty($values)) { - $values['date'] = date('Y-m-d'); - } - - $this->response->html($this->projectLayout('budget/create', array( - 'lines' => $this->budget->getAll($project['id']), - 'values' => $values + array('project_id' => $project['id']), - 'errors' => $errors, - 'project' => $project, - 'title' => t('Budget lines') - ), 'budget/sidebar')); - } - - /** - * Validate and save a new budget - * - * @access public - */ - public function save() - { - $project = $this->getProject(); - - $values = $this->request->getValues(); - list($valid, $errors) = $this->budget->validateCreation($values); - - if ($valid) { - - if ($this->budget->create($values['project_id'], $values['amount'], $values['comment'], $values['date'])) { - $this->session->flash(t('The budget line have been created successfully.')); - $this->response->redirect($this->helper->url->to('budget', 'create', array('project_id' => $project['id']))); - } - else { - $this->session->flashError(t('Unable to create the budget line.')); - } - } - - $this->create($values, $errors); - } - - /** - * Confirmation dialog before removing a budget - * - * @access public - */ - public function confirm() - { - $project = $this->getProject(); - - $this->response->html($this->projectLayout('budget/remove', array( - 'project' => $project, - 'budget_id' => $this->request->getIntegerParam('budget_id'), - 'title' => t('Remove a budget line'), - ), 'budget/sidebar')); - } - - /** - * Remove a budget - * - * @access public - */ - public function remove() - { - $this->checkCSRFParam(); - $project = $this->getProject(); - - if ($this->budget->remove($this->request->getIntegerParam('budget_id'))) { - $this->session->flash(t('Budget line removed successfully.')); - } else { - $this->session->flashError(t('Unable to remove this budget line.')); - } - - $this->response->redirect($this->helper->url->to('budget', 'create', array('project_id' => $project['id']))); - } -} diff --git a/app/Controller/Doc.php b/app/Controller/Doc.php index 19644b84..f9f0a675 100644 --- a/app/Controller/Doc.php +++ b/app/Controller/Doc.php @@ -16,7 +16,7 @@ class Doc extends Base { $url = $this->helper->url; $data = file_get_contents($filename); - list($title,, $content) = explode("\n", $data, 3); + list($title,) = explode("\n", $data, 2); $replaceUrl = function (array $matches) use ($url) { return '('.$url->to('doc', 'show', array('file' => str_replace('.markdown', '', $matches[1]))).')'; @@ -32,16 +32,24 @@ class Doc extends Base public function show() { - $filename = $this->request->getStringParam('file', 'index'); + $page = $this->request->getStringParam('file', 'index'); - if (! preg_match('/^[a-z0-9\-]+/', $filename)) { - $filename = 'index'; + if (! preg_match('/^[a-z0-9\-]+/', $page)) { + $page = 'index'; } - $filename = __DIR__.'/../../doc/'.$filename.'.markdown'; + $filenames = array(__DIR__.'/../../doc/'.$page.'.markdown'); + $filename = __DIR__.'/../../doc/index.markdown'; - if (! file_exists($filename)) { - $filename = __DIR__.'/../../doc/index.markdown'; + if ($this->config->getCurrentLanguage() === 'fr_FR') { + array_unshift($filenames, __DIR__.'/../../doc/fr/'.$page.'.markdown'); + } + + foreach ($filenames as $file) { + if (file_exists($file)) { + $filename = $file; + break; + } } $this->response->html($this->template->layout('doc/show', $this->readFile($filename) + array( diff --git a/app/Controller/File.php b/app/Controller/File.php index f73a9de9..7b7c75ee 100644 --- a/app/Controller/File.php +++ b/app/Controller/File.php @@ -60,7 +60,7 @@ class File extends Base { $task = $this->getTask(); - if (! $this->file->upload($task['project_id'], $task['id'], 'files')) { + if (! $this->file->uploadFiles($task['project_id'], $task['id'], 'files')) { $this->session->flashError(t('Unable to upload the file.')); } @@ -76,14 +76,13 @@ class File extends Base { $task = $this->getTask(); $file = $this->file->getById($this->request->getIntegerParam('file_id')); - $filename = FILES_DIR.$file['path']; - if ($file['task_id'] == $task['id'] && file_exists($filename)) { - $this->response->forceDownload($file['name']); - $this->response->binary(file_get_contents($filename)); + if ($file['task_id'] != $task['id']) { + $this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']))); } - $this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']))); + $this->response->forceDownload($file['name']); + $this->objectStorage->passthru($file['path']); } /** @@ -113,16 +112,13 @@ class File extends Base { $task = $this->getTask(); $file = $this->file->getById($this->request->getIntegerParam('file_id')); - $filename = FILES_DIR.$file['path']; - - if ($file['task_id'] == $task['id'] && file_exists($filename)) { - $metadata = getimagesize($filename); - if (isset($metadata['mime'])) { - $this->response->contentType($metadata['mime']); - readfile($filename); - } + if ($file['task_id'] != $task['id']) { + $this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']))); } + + $this->response->contentType($this->file->getImageMimeType($file['name'])); + $this->objectStorage->passthru($file['path']); } /** @@ -134,17 +130,13 @@ class File extends Base { $task = $this->getTask(); $file = $this->file->getById($this->request->getIntegerParam('file_id')); - $filename = FILES_DIR.$file['path']; - - if ($file['task_id'] == $task['id'] && file_exists($filename)) { - $this->response->contentType('image/jpeg'); - $this->file->generateThumbnail( - $filename, - $this->request->getIntegerParam('width'), - $this->request->getIntegerParam('height') - ); + if ($file['task_id'] != $task['id']) { + $this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']))); } + + $this->response->contentType('image/jpeg'); + $this->objectStorage->passthru($this->file->getThumbnailPath($file['path'])); } /** diff --git a/app/Controller/Hourlyrate.php b/app/Controller/Hourlyrate.php deleted file mode 100644 index 19650ede..00000000 --- a/app/Controller/Hourlyrate.php +++ /dev/null @@ -1,89 +0,0 @@ -<?php - -namespace Controller; - -/** - * Hourly Rate controller - * - * @package controller - * @author Frederic Guillot - */ -class Hourlyrate extends User -{ - /** - * Display rate and form - * - * @access public - */ - public function index(array $values = array(), array $errors = array()) - { - $user = $this->getUser(); - - $this->response->html($this->layout('hourlyrate/index', array( - 'rates' => $this->hourlyRate->getAllByUser($user['id']), - 'currencies_list' => $this->config->getCurrencies(), - 'values' => $values + array('user_id' => $user['id']), - 'errors' => $errors, - 'user' => $user, - ))); - } - - /** - * Validate and save a new rate - * - * @access public - */ - public function save() - { - $values = $this->request->getValues(); - list($valid, $errors) = $this->hourlyRate->validateCreation($values); - - if ($valid) { - - if ($this->hourlyRate->create($values['user_id'], $values['rate'], $values['currency'], $values['date_effective'])) { - $this->session->flash(t('Hourly rate created successfully.')); - $this->response->redirect($this->helper->url->to('hourlyrate', 'index', array('user_id' => $values['user_id']))); - } - else { - $this->session->flashError(t('Unable to save the hourly rate.')); - } - } - - $this->index($values, $errors); - } - - /** - * Confirmation dialag box to remove a row - * - * @access public - */ - public function confirm() - { - $user = $this->getUser(); - - $this->response->html($this->layout('hourlyrate/remove', array( - 'rate_id' => $this->request->getIntegerParam('rate_id'), - 'user' => $user, - ))); - } - - /** - * Remove a row - * - * @access public - */ - public function remove() - { - $this->checkCSRFParam(); - $user = $this->getUser(); - - if ($this->hourlyRate->remove($this->request->getIntegerParam('rate_id'))) { - $this->session->flash(t('Rate removed successfully.')); - } - else { - $this->session->flash(t('Unable to remove this rate.')); - } - - $this->response->redirect($this->helper->url->to('hourlyrate', 'index', array('user_id' => $user['id']))); - } -} diff --git a/app/Controller/Swimlane.php b/app/Controller/Swimlane.php index 054fa4ba..f92e9fe3 100644 --- a/app/Controller/Swimlane.php +++ b/app/Controller/Swimlane.php @@ -59,13 +59,12 @@ class Swimlane extends Base public function save() { $project = $this->getProject(); - $values = $this->request->getValues(); list($valid, $errors) = $this->swimlane->validateCreation($values); if ($valid) { - if ($this->swimlane->create($project['id'], $values['name'])) { + if ($this->swimlane->create($values)) { $this->session->flash(t('Your swimlane have been created successfully.')); $this->response->redirect($this->helper->url->to('swimlane', 'index', array('project_id' => $project['id']))); } @@ -134,8 +133,7 @@ class Swimlane extends Base list($valid, $errors) = $this->swimlane->validateModification($values); if ($valid) { - - if ($this->swimlane->rename($values['id'], $values['name'])) { + if ($this->swimlane->update($values)) { $this->session->flash(t('Swimlane updated successfully.')); $this->response->redirect($this->helper->url->to('swimlane', 'index', array('project_id' => $project['id']))); } diff --git a/app/Controller/Taskcreation.php b/app/Controller/Taskcreation.php index ff25c5da..b9e9a33c 100644 --- a/app/Controller/Taskcreation.php +++ b/app/Controller/Taskcreation.php @@ -59,25 +59,29 @@ class Taskcreation extends Base list($valid, $errors) = $this->taskValidator->validateCreation($values); - if ($valid) { + if ($valid && $this->taskCreation->create($values)) { + $this->session->flash(t('Task created successfully.')); + $this->afterSave($project, $values); + } + else { + $this->session->flashError(t('Unable to create your task.')); + } - if ($this->taskCreation->create($values)) { - $this->session->flash(t('Task created successfully.')); + $this->create($values, $errors); + } - if (isset($values['another_task']) && $values['another_task'] == 1) { - unset($values['title']); - unset($values['description']); - $this->response->redirect($this->helper->url->to('taskcreation', 'create', $values)); - } - else { - $this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $project['id']))); - } - } - else { - $this->session->flashError(t('Unable to create your task.')); + private function afterSave(array $project, array &$values) + { + if (isset($values['another_task']) && $values['another_task'] == 1) { + unset($values['title']); + unset($values['description']); + + if (! $this->request->isAjax()) { + $this->response->redirect($this->helper->url->to('taskcreation', 'create', $values)); } } - - $this->create($values, $errors); + else { + $this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $project['id']))); + } } } diff --git a/app/Controller/Taskmodification.php b/app/Controller/Taskmodification.php index 56d2b9f9..638af594 100644 --- a/app/Controller/Taskmodification.php +++ b/app/Controller/Taskmodification.php @@ -126,11 +126,13 @@ class Taskmodification extends Base ); if ($ajax) { - $this->response->html($this->template->render('task_modification/edit_task', $params)); + $html = $this->template->render('task_modification/edit_task', $params); } else { - $this->response->html($this->taskLayout('task_modification/edit_task', $params)); + $html = $this->taskLayout('task_modification/edit_task', $params); } + + $this->response->html($html); } /** @@ -145,24 +147,20 @@ class Taskmodification extends Base list($valid, $errors) = $this->taskValidator->validateModification($values); - if ($valid) { - - if ($this->taskModification->update($values)) { - $this->session->flash(t('Task updated successfully.')); + if ($valid && $this->taskModification->update($values)) { + $this->session->flash(t('Task updated successfully.')); - if ($this->request->getIntegerParam('ajax')) { - $this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $task['project_id']))); - } - else { - $this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id']))); - } + if ($this->request->isAjax()) { + $this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $task['project_id']))); } else { - $this->session->flashError(t('Unable to update your task.')); + $this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id']))); } } - - $this->edit($values, $errors); + else { + $this->session->flashError(t('Unable to update your task.')); + $this->edit($values, $errors); + } } /** |