Add categories for projects and tasks

This commit is contained in:
Frédéric Guillot
2014-05-21 22:33:57 -04:00
parent 57e40671af
commit a750b8ab2a
39 changed files with 815 additions and 44 deletions

View File

@@ -0,0 +1,85 @@
<?php
namespace Action;
require_once __DIR__.'/base.php';
/**
* Assign a color to a specific category
*
* @package action
* @author Frederic Guillot
*/
class TaskAssignColorCategory extends Base
{
/**
* Task model
*
* @accesss private
* @var \Model\Task
*/
private $task;
/**
* Constructor
*
* @access public
* @param integer $project_id Project id
* @param \Model\Task $task Task model instance
*/
public function __construct($project_id, \Model\Task $task)
{
parent::__construct($project_id);
$this->task = $task;
}
/**
* Get the required parameter for the action (defined by the user)
*
* @access public
* @return array
*/
public function getActionRequiredParameters()
{
return array(
'color_id' => t('Color'),
'category_id' => t('Category'),
);
}
/**
* Get the required parameter for the event
*
* @access public
* @return string[]
*/
public function getEventRequiredParameters()
{
return array(
'task_id',
'category_id',
);
}
/**
* Execute the action
*
* @access public
* @param array $data Event data dictionary
* @return bool True if the action was executed or false when not executed
*/
public function doAction(array $data)
{
if ($data['category_id'] == $this->getParam('category_id')) {
$this->task->update(array(
'id' => $data['task_id'],
'color_id' => $this->getParam('color_id'),
));
return true;
}
return false;
}
}

View File

@@ -42,7 +42,6 @@ class TaskAssignColorUser extends Base
public function getActionRequiredParameters()
{
return array(
'column_id' => t('Column'),
'color_id' => t('Color'),
'user_id' => t('Assignee'),
);
@@ -59,7 +58,6 @@ class TaskAssignColorUser extends Base
return array(
'task_id',
'owner_id',
'column_id',
);
}
@@ -72,7 +70,7 @@ class TaskAssignColorUser extends Base
*/
public function doAction(array $data)
{
if ($data['column_id'] == $this->getParam('column_id') && $data['owner_id'] == $this->getParam('user_id')) {
if ($data['owner_id'] == $this->getParam('user_id')) {
$this->task->update(array(
'id' => $data['task_id'],