diff options
author | Christopher Geelen <christopher.geelen@vinotion.nl> | 2016-07-27 13:58:23 +0200 |
---|---|---|
committer | Christopher Geelen <christopher.geelen@vinotion.nl> | 2016-07-27 13:58:23 +0200 |
commit | 24745182724ca69092554eb5946e31584420f68a (patch) | |
tree | 386cdf7a8d7bf7ad2d80d938333bafbaf0fedcbc /app/Controller | |
parent | 160c0b885eb4f1a1a1baa2b6b9fc6d99fdb80d0c (diff) | |
parent | 9649f7ba82ba7fe6a470abfe9f65e214cc68fa34 (diff) |
Merge remote-tracking branch 'upstream/master'
Conflicts:
app/Job/NotificationJob.php
Diffstat (limited to 'app/Controller')
-rw-r--r-- | app/Controller/AnalyticController.php | 16 | ||||
-rw-r--r-- | app/Controller/DashboardController.php | 90 | ||||
-rw-r--r-- | app/Controller/FeedController.php | 60 | ||||
-rw-r--r-- | app/Controller/ProjectPermissionController.php | 2 | ||||
-rw-r--r-- | app/Controller/SubtaskController.php | 2 | ||||
-rw-r--r-- | app/Controller/SubtaskConverterController.php | 2 | ||||
-rw-r--r-- | app/Controller/SubtaskRestrictionController.php | 2 | ||||
-rw-r--r-- | app/Controller/SubtaskStatusController.php | 2 | ||||
-rw-r--r-- | app/Controller/UserListController.php | 7 |
9 files changed, 82 insertions, 101 deletions
diff --git a/app/Controller/AnalyticController.php b/app/Controller/AnalyticController.php index cf3ba034..ab0646a2 100644 --- a/app/Controller/AnalyticController.php +++ b/app/Controller/AnalyticController.php @@ -33,7 +33,7 @@ class AnalyticController extends BaseController 'metrics' => $this->projectDailyStatsModel->getRawMetrics($project['id'], $from, $to), 'date_format' => $this->configModel->get('application_date_format'), 'date_formats' => $this->dateParser->getAvailableFormats($this->dateParser->getDateFormats()), - 'title' => t('Lead and Cycle time for "%s"', $project['name']), + 'title' => t('Lead and cycle time'), ))); } @@ -60,7 +60,7 @@ class AnalyticController extends BaseController 'project' => $project, 'paginator' => $paginator, 'metrics' => $this->estimatedTimeComparisonAnalytic->build($project['id']), - 'title' => t('Compare hours for "%s"', $project['name']), + 'title' => t('Estimated vs actual time'), ))); } @@ -76,7 +76,7 @@ class AnalyticController extends BaseController $this->response->html($this->helper->layout->analytic('analytic/avg_time_columns', array( 'project' => $project, 'metrics' => $this->averageTimeSpentColumnAnalytic->build($project['id']), - 'title' => t('Average time spent into each column for "%s"', $project['name']), + 'title' => t('Average time into each column'), ))); } @@ -92,7 +92,7 @@ class AnalyticController extends BaseController $this->response->html($this->helper->layout->analytic('analytic/tasks', array( 'project' => $project, 'metrics' => $this->taskDistributionAnalytic->build($project['id']), - 'title' => t('Task repartition for "%s"', $project['name']), + 'title' => t('Task distribution'), ))); } @@ -108,7 +108,7 @@ class AnalyticController extends BaseController $this->response->html($this->helper->layout->analytic('analytic/users', array( 'project' => $project, 'metrics' => $this->userDistributionAnalytic->build($project['id']), - 'title' => t('User repartition for "%s"', $project['name']), + 'title' => t('User repartition'), ))); } @@ -119,7 +119,7 @@ class AnalyticController extends BaseController */ public function cfd() { - $this->commonAggregateMetrics('analytic/cfd', 'total', 'Cumulative flow diagram for "%s"'); + $this->commonAggregateMetrics('analytic/cfd', 'total', t('Cumulative flow diagram')); } /** @@ -129,7 +129,7 @@ class AnalyticController extends BaseController */ public function burndown() { - $this->commonAggregateMetrics('analytic/burndown', 'score', 'Burndown chart for "%s"'); + $this->commonAggregateMetrics('analytic/burndown', 'score', t('Burndown chart')); } /** @@ -157,7 +157,7 @@ class AnalyticController extends BaseController 'project' => $project, 'date_format' => $this->configModel->get('application_date_format'), 'date_formats' => $this->dateParser->getAvailableFormats($this->dateParser->getDateFormats()), - 'title' => t($title, $project['name']), + 'title' => $title, ))); } diff --git a/app/Controller/DashboardController.php b/app/Controller/DashboardController.php index 44874546..f32f8552 100644 --- a/app/Controller/DashboardController.php +++ b/app/Controller/DashboardController.php @@ -2,9 +2,6 @@ namespace Kanboard\Controller; -use Kanboard\Model\ProjectModel; -use Kanboard\Model\SubtaskModel; - /** * Dashboard Controller * @@ -14,63 +11,6 @@ use Kanboard\Model\SubtaskModel; class DashboardController extends BaseController { /** - * Get project pagination - * - * @access private - * @param integer $user_id - * @param string $action - * @param integer $max - * @return \Kanboard\Core\Paginator - */ - private function getProjectPaginator($user_id, $action, $max) - { - return $this->paginator - ->setUrl('DashboardController', $action, array('pagination' => 'projects', 'user_id' => $user_id)) - ->setMax($max) - ->setOrder(ProjectModel::TABLE.'.name') - ->setQuery($this->projectModel->getQueryColumnStats($this->projectPermissionModel->getActiveProjectIds($user_id))) - ->calculateOnlyIf($this->request->getStringParam('pagination') === 'projects'); - } - - /** - * Get task pagination - * - * @access private - * @param integer $user_id - * @param string $action - * @param integer $max - * @return \Kanboard\Core\Paginator - */ - private function getTaskPaginator($user_id, $action, $max) - { - return $this->paginator - ->setUrl('DashboardController', $action, array('pagination' => 'tasks', 'user_id' => $user_id)) - ->setMax($max) - ->setOrder('tasks.id') - ->setQuery($this->taskFinderModel->getUserQuery($user_id)) - ->calculateOnlyIf($this->request->getStringParam('pagination') === 'tasks'); - } - - /** - * Get subtask pagination - * - * @access private - * @param integer $user_id - * @param string $action - * @param integer $max - * @return \Kanboard\Core\Paginator - */ - private function getSubtaskPaginator($user_id, $action, $max) - { - return $this->paginator - ->setUrl('DashboardController', $action, array('pagination' => 'subtasks', 'user_id' => $user_id)) - ->setMax($max) - ->setOrder('tasks.id') - ->setQuery($this->subtaskModel->getUserQuery($user_id, array(SubTaskModel::STATUS_TODO, SubtaskModel::STATUS_INPROGRESS))) - ->calculateOnlyIf($this->request->getStringParam('pagination') === 'subtasks'); - } - - /** * Dashboard overview * * @access public @@ -80,10 +20,10 @@ class DashboardController extends BaseController $user = $this->getUser(); $this->response->html($this->helper->layout->dashboard('dashboard/show', array( - 'title' => t('Dashboard'), - 'project_paginator' => $this->getProjectPaginator($user['id'], 'show', 10), - 'task_paginator' => $this->getTaskPaginator($user['id'], 'show', 10), - 'subtask_paginator' => $this->getSubtaskPaginator($user['id'], 'show', 10), + 'title' => t('Dashboard for %s', $this->helper->user->getFullname($user)), + 'project_paginator' => $this->projectPagination->getDashboardPaginator($user['id'], 'show', 10), + 'task_paginator' => $this->taskPagination->getDashboardPaginator($user['id'], 'show', 10), + 'subtask_paginator' => $this->subtaskPagination->getDashboardPaginator($user['id'], 'show', 10), 'user' => $user, ))); } @@ -98,8 +38,8 @@ class DashboardController extends BaseController $user = $this->getUser(); $this->response->html($this->helper->layout->dashboard('dashboard/tasks', array( - 'title' => t('My tasks'), - 'paginator' => $this->getTaskPaginator($user['id'], 'tasks', 50), + 'title' => t('Tasks overview for %s', $this->helper->user->getFullname($user)), + 'paginator' => $this->taskPagination->getDashboardPaginator($user['id'], 'tasks', 50), 'user' => $user, ))); } @@ -114,8 +54,8 @@ class DashboardController extends BaseController $user = $this->getUser(); $this->response->html($this->helper->layout->dashboard('dashboard/subtasks', array( - 'title' => t('My subtasks'), - 'paginator' => $this->getSubtaskPaginator($user['id'], 'subtasks', 50), + 'title' => t('Subtasks overview for %s', $this->helper->user->getFullname($user)), + 'paginator' => $this->subtaskPagination->getDashboardPaginator($user['id'], 'subtasks', 50), 'user' => $user, ))); } @@ -130,8 +70,8 @@ class DashboardController extends BaseController $user = $this->getUser(); $this->response->html($this->helper->layout->dashboard('dashboard/projects', array( - 'title' => t('My projects'), - 'paginator' => $this->getProjectPaginator($user['id'], 'projects', 25), + 'title' => t('Projects overview for %s', $this->helper->user->getFullname($user)), + 'paginator' => $this->projectPagination->getDashboardPaginator($user['id'], 'projects', 25), 'user' => $user, ))); } @@ -146,7 +86,7 @@ class DashboardController extends BaseController $user = $this->getUser(); $this->response->html($this->helper->layout->dashboard('dashboard/activity', array( - 'title' => t('My activity stream'), + 'title' => t('Activity stream for %s', $this->helper->user->getFullname($user)), 'events' => $this->helper->projectActivity->getProjectsEvents($this->projectPermissionModel->getActiveProjectIds($user['id']), 100), 'user' => $user, ))); @@ -159,9 +99,11 @@ class DashboardController extends BaseController */ public function calendar() { + $user = $this->getUser(); + $this->response->html($this->helper->layout->dashboard('dashboard/calendar', array( - 'title' => t('My calendar'), - 'user' => $this->getUser(), + 'title' => t('Calendar for %s', $this->helper->user->getFullname($user)), + 'user' => $user, ))); } @@ -175,7 +117,7 @@ class DashboardController extends BaseController $user = $this->getUser(); $this->response->html($this->helper->layout->dashboard('dashboard/notifications', array( - 'title' => t('My notifications'), + 'title' => t('Notifications for %s', $this->helper->user->getFullname($user)), 'notifications' => $this->userUnreadNotificationModel->getAll($user['id']), 'user' => $user, ))); diff --git a/app/Controller/FeedController.php b/app/Controller/FeedController.php index cf2b1088..f9b0ed7c 100644 --- a/app/Controller/FeedController.php +++ b/app/Controller/FeedController.php @@ -2,7 +2,11 @@ namespace Kanboard\Controller; +use DateTime; use Kanboard\Core\Controller\AccessForbiddenException; +use PicoFeed\Syndication\AtomFeedBuilder; +use PicoFeed\Syndication\AtomItemBuilder; +use PicoFeed\Syndication\FeedBuilder; /** * Atom/RSS Feed controller @@ -27,10 +31,15 @@ class FeedController extends BaseController throw AccessForbiddenException::getInstance()->withoutLayout(); } - $this->response->xml($this->template->render('feed/user', array( - 'events' => $this->helper->projectActivity->getProjectsEvents($this->projectPermissionModel->getActiveProjectIds($user['id'])), - 'user' => $user, - ))); + $events = $this->helper->projectActivity->getProjectsEvents($this->projectPermissionModel->getActiveProjectIds($user['id'])); + + $feedBuilder = AtomFeedBuilder::create() + ->withTitle(e('Project activities for %s', $this->helper->user->getFullname($user))) + ->withFeedUrl($this->helper->url->to('FeedController', 'user', array('token' => $user['token']), '', true)) + ->withSiteUrl($this->helper->url->base()) + ->withDate(new DateTime()); + + $this->response->xml($this->buildFeedItems($events, $feedBuilder)->build()); } /** @@ -47,9 +56,44 @@ class FeedController extends BaseController throw AccessForbiddenException::getInstance()->withoutLayout(); } - $this->response->xml($this->template->render('feed/project', array( - 'events' => $this->helper->projectActivity->getProjectEvents($project['id']), - 'project' => $project, - ))); + $events = $this->helper->projectActivity->getProjectEvents($project['id']); + + $feedBuilder = AtomFeedBuilder::create() + ->withTitle(e('%s\'s activity', $project['name'])) + ->withFeedUrl($this->helper->url->to('FeedController', 'project', array('token' => $project['token']), '', true)) + ->withSiteUrl($this->helper->url->base()) + ->withDate(new DateTime()); + + $this->response->xml($this->buildFeedItems($events, $feedBuilder)->build()); + } + + /** + * Build feed items + * + * @access protected + * @param array $events + * @param FeedBuilder $feedBuilder + * @return FeedBuilder + */ + protected function buildFeedItems(array $events, FeedBuilder $feedBuilder) + { + foreach ($events as $event) { + $itemDate = new DateTime(); + $itemDate->setTimestamp($event['date_creation']); + + $itemUrl = $this->helper->url->to('TaskViewController', 'show', array('task_id' => $event['task_id']), '', true); + + $feedBuilder + ->withItem(AtomItemBuilder::create($feedBuilder) + ->withTitle($event['event_title']) + ->withUrl($itemUrl.'#event-'.$event['id']) + ->withAuthor($event['author']) + ->withPublishedDate($itemDate) + ->withUpdatedDate($itemDate) + ->withContent($event['event_content']) + ); + } + + return $feedBuilder; } } diff --git a/app/Controller/ProjectPermissionController.php b/app/Controller/ProjectPermissionController.php index f3ca6ed9..99f556e8 100644 --- a/app/Controller/ProjectPermissionController.php +++ b/app/Controller/ProjectPermissionController.php @@ -147,7 +147,7 @@ class ProjectPermissionController extends BaseController $values = $this->request->getValues(); if (empty($values['group_id']) && ! empty($values['external_id'])) { - $values['group_id'] = $this->groupModel->create($values['name'], $values['external_id']); + $values['group_id'] = $this->groupModel->getOrCreateExternalGroupId($values['name'], $values['external_id']); } if ($this->projectGroupRoleModel->addGroup($project['id'], $values['group_id'], $values['role'])) { diff --git a/app/Controller/SubtaskController.php b/app/Controller/SubtaskController.php index 93dab5cd..7502d84f 100644 --- a/app/Controller/SubtaskController.php +++ b/app/Controller/SubtaskController.php @@ -168,7 +168,7 @@ class SubtaskController extends BaseController $values = $this->request->getJson(); if (! empty($values) && $this->helper->user->hasProjectAccess('SubtaskController', 'movePosition', $project_id)) { - $result = $this->subtaskModel->changePosition($task_id, $values['subtask_id'], $values['position']); + $result = $this->subtaskPositionModel->changePosition($task_id, $values['subtask_id'], $values['position']); $this->response->json(array('result' => $result)); } else { throw new AccessForbiddenException(); diff --git a/app/Controller/SubtaskConverterController.php b/app/Controller/SubtaskConverterController.php index 65bcd2da..404c50d0 100644 --- a/app/Controller/SubtaskConverterController.php +++ b/app/Controller/SubtaskConverterController.php @@ -26,7 +26,7 @@ class SubtaskConverterController extends BaseController $project = $this->getProject(); $subtask = $this->getSubtask(); - $task_id = $this->subtaskModel->convertToTask($project['id'], $subtask['id']); + $task_id = $this->subtaskTaskConversionModel->convertToTask($project['id'], $subtask['id']); if ($task_id !== false) { $this->flash->success(t('Subtask converted to task successfully.')); diff --git a/app/Controller/SubtaskRestrictionController.php b/app/Controller/SubtaskRestrictionController.php index 084fc0d9..cb642e1c 100644 --- a/app/Controller/SubtaskRestrictionController.php +++ b/app/Controller/SubtaskRestrictionController.php @@ -27,7 +27,7 @@ class SubtaskRestrictionController extends BaseController SubtaskModel::STATUS_TODO => t('Todo'), SubtaskModel::STATUS_DONE => t('Done'), ), - 'subtask_inprogress' => $this->subtaskModel->getSubtaskInProgress($this->userSession->getId()), + 'subtask_inprogress' => $this->subtaskStatusModel->getSubtaskInProgress($this->userSession->getId()), 'subtask' => $subtask, 'task' => $task, ))); diff --git a/app/Controller/SubtaskStatusController.php b/app/Controller/SubtaskStatusController.php index 699951fe..d4d356c3 100644 --- a/app/Controller/SubtaskStatusController.php +++ b/app/Controller/SubtaskStatusController.php @@ -20,7 +20,7 @@ class SubtaskStatusController extends BaseController $task = $this->getTask(); $subtask = $this->getSubtask(); - $status = $this->subtaskModel->toggleStatus($subtask['id']); + $status = $this->subtaskStatusModel->toggleStatus($subtask['id']); if ($this->request->getIntegerParam('refresh-table') === 0) { $subtask['status'] = $status; diff --git a/app/Controller/UserListController.php b/app/Controller/UserListController.php index 31fcdd44..888583fa 100644 --- a/app/Controller/UserListController.php +++ b/app/Controller/UserListController.php @@ -17,12 +17,7 @@ class UserListController extends BaseController */ public function show() { - $paginator = $this->paginator - ->setUrl('UserListController', 'show') - ->setMax(30) - ->setOrder('username') - ->setQuery($this->userModel->getQuery()) - ->calculate(); + $paginator = $this->userPagination->getListingPaginator(); $this->response->html($this->helper->layout->app('user_list/show', array( 'title' => t('Users').' ('.$paginator->getTotal().')', |