First commit
This commit is contained in:
121
Controller/CalendarController.php
Normal file
121
Controller/CalendarController.php
Normal file
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
|
||||
namespace Kanboard\Plugin\Calendar\Controller;
|
||||
|
||||
use Kanboard\Controller\BaseController;
|
||||
use Kanboard\Filter\TaskAssigneeFilter;
|
||||
use Kanboard\Filter\TaskProjectFilter;
|
||||
use Kanboard\Filter\TaskStatusFilter;
|
||||
use Kanboard\Model\TaskModel;
|
||||
|
||||
/**
|
||||
* Calendar Controller
|
||||
*
|
||||
* @package Kanboard\Controller
|
||||
* @author Frederic Guillot
|
||||
* @author Timo Litzbarski
|
||||
*/
|
||||
class CalendarController extends BaseController
|
||||
{
|
||||
/**
|
||||
* Show calendar view for a user
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function user()
|
||||
{
|
||||
$user = $this->getUser();
|
||||
|
||||
$this->response->html($this->helper->layout->app('Calendar:calendar/user', array(
|
||||
'user' => $user,
|
||||
)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show calendar view for a project
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function project()
|
||||
{
|
||||
$project = $this->getProject();
|
||||
|
||||
$this->response->html($this->helper->layout->app('Calendar:calendar/project', array(
|
||||
'project' => $project,
|
||||
'title' => $project['name'],
|
||||
'description' => $this->helper->projectHeader->getDescription($project),
|
||||
)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get tasks to display on the calendar (project view)
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function projectEvents()
|
||||
{
|
||||
$project_id = $this->request->getIntegerParam('project_id');
|
||||
$start = $this->request->getStringParam('start');
|
||||
$end = $this->request->getStringParam('end');
|
||||
$search = $this->userSession->getFilters($project_id);
|
||||
$queryBuilder = $this->taskLexer->build($search)->withFilter(new TaskProjectFilter($project_id));
|
||||
|
||||
$events = $this->helper->calendar->getTaskDateDueEvents(clone($queryBuilder), $start, $end);
|
||||
$events = array_merge($events, $this->helper->calendar->getTaskEvents(clone($queryBuilder), $start, $end));
|
||||
|
||||
$events = $this->hook->merge('controller:calendar:project:events', $events, array(
|
||||
'project_id' => $project_id,
|
||||
'start' => $start,
|
||||
'end' => $end,
|
||||
));
|
||||
|
||||
$this->response->json($events);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get tasks to display on the calendar (user view)
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function userEvents()
|
||||
{
|
||||
$user_id = $this->request->getIntegerParam('user_id');
|
||||
$start = $this->request->getStringParam('start');
|
||||
$end = $this->request->getStringParam('end');
|
||||
$queryBuilder = $this->taskQuery
|
||||
->withFilter(new TaskAssigneeFilter($user_id))
|
||||
->withFilter(new TaskStatusFilter(TaskModel::STATUS_OPEN));
|
||||
|
||||
$events = $this->helper->calendar->getTaskDateDueEvents(clone($queryBuilder), $start, $end);
|
||||
$events = array_merge($events, $this->helper->calendar->getTaskEvents(clone($queryBuilder), $start, $end));
|
||||
|
||||
if ($this->configModel->get('calendar_user_subtasks_time_tracking') == 1) {
|
||||
$events = array_merge($events, $this->helper->calendar->getSubtaskTimeTrackingEvents($user_id, $start, $end));
|
||||
}
|
||||
|
||||
$events = $this->hook->merge('controller:calendar:user:events', $events, array(
|
||||
'user_id' => $user_id,
|
||||
'start' => $start,
|
||||
'end' => $end,
|
||||
));
|
||||
|
||||
$this->response->json($events);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update task due date
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function save()
|
||||
{
|
||||
if ($this->request->isAjax() && $this->request->isPost()) {
|
||||
$values = $this->request->getJson();
|
||||
|
||||
$this->taskModificationModel->update(array(
|
||||
'id' => $values['task_id'],
|
||||
'date_due' => substr($values['date_due'], 0, 10),
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
32
Controller/ConfigController.php
Normal file
32
Controller/ConfigController.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Kanboard\Plugin\Calendar\Controller;
|
||||
|
||||
/**
|
||||
* Class ConfigController
|
||||
*
|
||||
* @package Kanboard\Plugin\Calendar\Controller
|
||||
*/
|
||||
class ConfigController extends \Kanboard\Controller\ConfigController
|
||||
{
|
||||
public function show()
|
||||
{
|
||||
$this->response->html($this->helper->layout->config('Calendar:config/calendar', array(
|
||||
'title' => t('Settings').' > '.t('Calendar settings'),
|
||||
)));
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
$values = $this->request->getValues();
|
||||
$values += array('calendar_user_subtasks_time_tracking' => 0);
|
||||
|
||||
if ($this->configModel->save($values)) {
|
||||
$this->flash->success(t('Settings saved successfully.'));
|
||||
} else {
|
||||
$this->flash->failure(t('Unable to save your settings.'));
|
||||
}
|
||||
|
||||
$this->response->redirect($this->helper->url->to('ConfigController', 'show', array('plugin' => 'Calendar')));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user