Add new automatic action to assign tasks to its creator

This commit is contained in:
Frederic Guillot 2017-06-03 11:32:24 -04:00
parent 6251ac62d4
commit 43e4662b84
32 changed files with 316 additions and 92 deletions

View File

@ -1,3 +1,10 @@
Version 1.0.45 (unreleased)
---------------------------
New features:
* Automatic action to assign tasks to its creator
Version 1.0.44 (May 28, 2017)
-----------------------------

View File

@ -0,0 +1,98 @@
<?php
namespace Kanboard\Action;
use Kanboard\Model\TaskModel;
/**
* Assign a task to the creator
*
* @package Kanboard\Action
* @author Frederic Guillot
*/
class TaskAssignCreator extends Base
{
/**
* Get automatic action description
*
* @access public
* @return string
*/
public function getDescription()
{
return t('Assign the task to its creator');
}
/**
* Get the list of compatible events
*
* @access public
* @return array
*/
public function getCompatibleEvents()
{
return array(
TaskModel::EVENT_MOVE_COLUMN,
);
}
/**
* Get the required parameter for the action (defined by the user)
*
* @access public
* @return array
*/
public function getActionRequiredParameters()
{
return array(
'column_id' => t('Column'),
);
}
/**
* Get the required parameter for the event
*
* @access public
* @return string[]
*/
public function getEventRequiredParameters()
{
return array(
'task_id',
'task' => array(
'project_id',
'column_id',
'creator_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)
{
$values = array(
'id' => $data['task_id'],
'owner_id' => $data['task']['creator_id'],
);
return $this->taskModificationModel->update($values);
}
/**
* Check if the event data meet the action condition
*
* @access public
* @param array $data Event data dictionary
* @return bool
*/
public function hasRequiredCondition(array $data)
{
return $data['task']['column_id'] == $this->getParam('column_id');
}
}

View File

@ -1334,4 +1334,5 @@ return array(
// '[DUPLICATE]' => '',
// 'DKK - Danish Krona' => '',
// 'Remove user from group' => '',
// 'Assign the task to its creator' => '',
);

View File

@ -1334,4 +1334,5 @@ return array(
'[DUPLICATE]' => '[DUPLICATE]',
// 'DKK - Danish Krona' => '',
// 'Remove user from group' => '',
// 'Assign the task to its creator' => '',
);

View File

@ -847,44 +847,44 @@ return array(
// 'Remove group' => '',
// 'Group removed successfully.' => '',
// 'Unable to remove this group.' => '',
'Project Permissions' => 'Oprávnění projektu',
'Manager' => 'Správce',
'Project Manager' => 'Správce projektu',
'Project Member' => 'Člen projektu',
'Project Viewer' => 'Čtenář projektu',
'Project Permissions' => 'Oprávnění projektu',
'Manager' => 'Správce',
'Project Manager' => 'Správce projektu',
'Project Member' => 'Člen projektu',
'Project Viewer' => 'Čtenář projektu',
// 'Your account is locked for %d minutes' => '',
// 'Invalid captcha' => '',
// 'The name must be unique' => '',
'View all groups' => 'Zobrazit všechny skupiny',
'View all groups' => 'Zobrazit všechny skupiny',
// 'There is no user available.' => '',
// 'Do you really want to remove the user "%s" from the group "%s"?' => '',
// 'There is no group.' => '',
// 'Add group member' => '',
// 'Do you really want to remove this group: "%s"?' => '',
// 'There is no user in this group.' => '',
'Permissions' => 'Oprávnění',
'Allowed Users' => 'Povolení uživatelé',
'Permissions' => 'Oprávnění',
'Allowed Users' => 'Povolení uživatelé',
// 'No user have been allowed specifically.' => '',
'Role' => 'Role',
'Enter user name...' => 'Zadejte uživatelské jméno...',
'Allowed Groups' => 'Povolené skupiny',
'Role' => 'Role',
'Enter user name...' => 'Zadejte uživatelské jméno...',
'Allowed Groups' => 'Povolené skupiny',
// 'No group have been allowed specifically.' => '',
'Group' => 'Skupina',
'Group Name' => 'Jméno skupiny',
'Group' => 'Skupina',
'Group Name' => 'Jméno skupiny',
// 'Enter group name...' => '',
// 'Role:' => '',
'Project members' => 'Členové projektu',
'Project members' => 'Členové projektu',
// '%s mentioned you in the task #%d' => '',
// '%s mentioned you in a comment on the task #%d' => '',
// 'You were mentioned in the task #%d' => '',
// 'You were mentioned in a comment on the task #%d' => '',
// 'Estimated hours: ' => '',
// 'Actual hours: ' => '',
'Hours Spent' => 'Hodin stráveno',
'Hours Estimated' => 'Hodin odhadováno',
'Estimated Time' => 'Odhadovaný čas',
'Actual Time' => 'Aktuální čas',
'Estimated vs actual time' => 'Rozdíl mezi odhadovaným a aktuálním časem',
'Hours Spent' => 'Hodin stráveno',
'Hours Estimated' => 'Hodin odhadováno',
'Estimated Time' => 'Odhadovaný čas',
'Actual Time' => 'Aktuální čas',
'Estimated vs actual time' => 'Rozdíl mezi odhadovaným a aktuálním časem',
// 'RUB - Russian Ruble' => '',
// 'Assign the task to the person who does the action when the column is changed' => '',
// 'Close a task in a specific column' => '',
@ -894,7 +894,7 @@ return array(
// 'Enable two-factor authentication' => '',
// 'There is no integration registered at the moment.' => '',
// 'Password Reset for Kanboard' => '',
'Forgot password?' => 'Zapomenuté heslo?',
'Forgot password?' => 'Zapomenuté heslo?',
// 'Enable "Forget Password"' => '',
// 'Password Reset' => '',
// 'New password' => '',
@ -902,80 +902,80 @@ return array(
// 'To reset your password click on this link:' => '',
// 'Last Password Reset' => '',
// 'The password has never been reinitialized.' => '',
'Creation' => 'Vytvoření',
'Creation' => 'Vytvoření',
// 'Expiration' => '',
// 'Password reset history' => '',
// 'All tasks of the column "%s" and the swimlane "%s" have been closed successfully.' => '',
// 'Do you really want to close all tasks of this column?' => '',
// '%d task(s) in the column "%s" and the swimlane "%s" will be closed.' => '',
'Close all tasks of this column' => 'Uzavřít všechny úkoly v tomto sloupci',
'Close all tasks of this column' => 'Uzavřít všechny úkoly v tomto sloupci',
// 'No plugin has registered a project notification method. You can still configure individual notifications in your user profile.' => '',
'My dashboard' => 'Moje nástěnka',
'My profile' => 'Můj profil',
'Project owner: ' => 'Vlastník projektu: ',
'My dashboard' => 'Moje nástěnka',
'My profile' => 'Můj profil',
'Project owner: ' => 'Vlastník projektu: ',
// 'The project identifier is optional and must be alphanumeric, example: MYPROJECT.' => '',
'Project owner' => 'Vlastník projektu',
'Private projects do not have users and groups management.' => 'Soukromé projekty nemají správu uživatelů a skupin',
'There is no project member.' => 'Projekt nemá žádného člena',
'Priority' => 'Priorita',
'Task priority' => 'Priorita úkolu',
'General' => 'Všeobecné',
'Dates' => 'Termíny',
'Default priority' => 'Výchozí priorita',
'Lowest priority' => 'Nejnižší priorita',
'Highest priority' => 'Nejvyžší priorita',
'Close a task when there is no activity' => 'Uzavřít úkol pokud není žádná aktivita',
'Duration in days' => 'Trvání ve dnech',
'Send email when there is no activity on a task' => 'Odeslat mail pokud není žádná aktivita u úkolu',
'Project owner' => 'Vlastník projektu',
'Private projects do not have users and groups management.' => 'Soukromé projekty nemají správu uživatelů a skupin',
'There is no project member.' => 'Projekt nemá žádného člena',
'Priority' => 'Priorita',
'Task priority' => 'Priorita úkolu',
'General' => 'Všeobecné',
'Dates' => 'Termíny',
'Default priority' => 'Výchozí priorita',
'Lowest priority' => 'Nejnižší priorita',
'Highest priority' => 'Nejvyžší priorita',
'Close a task when there is no activity' => 'Uzavřít úkol pokud není žádná aktivita',
'Duration in days' => 'Trvání ve dnech',
'Send email when there is no activity on a task' => 'Odeslat mail pokud není žádná aktivita u úkolu',
// 'Unable to fetch link information.' => '',
// 'Daily background job for tasks' => '',
// 'Auto' => '',
'Related' => 'Související',
'Attachment' => 'Příloha',
'Title not found' => 'Název nenalezen',
'Web Link' => 'Webový odkaz',
'External links' => 'Externí odkazy',
'Add external link' => 'Přidat externí odkaz',
'Type' => 'Typ',
'Dependency' => 'Závislost',
'Add internal link' => 'Přidat interní odkaz',
'Add a new external link' => 'Přidat nový externí odkaz',
'Edit external link' => 'Upravit externí odkaz',
'External link' => 'Externí odkaz',
'Related' => 'Související',
'Attachment' => 'Příloha',
'Title not found' => 'Název nenalezen',
'Web Link' => 'Webový odkaz',
'External links' => 'Externí odkazy',
'Add external link' => 'Přidat externí odkaz',
'Type' => 'Typ',
'Dependency' => 'Závislost',
'Add internal link' => 'Přidat interní odkaz',
'Add a new external link' => 'Přidat nový externí odkaz',
'Edit external link' => 'Upravit externí odkaz',
'External link' => 'Externí odkaz',
'Copy and paste your link here...' => 'Zde vložte váš odkaz...',
// 'URL' => '',
'Internal links' => 'Interní odkazy',
'Internal links' => 'Interní odkazy',
// 'Assign to me' => '',
// 'Me' => '',
// 'Do not duplicate anything' => '',
'Projects management' => 'Správa projektů',
'Users management' => 'Správa uživatelů',
'Groups management' => 'Správa skupin',
'Create from another project' => 'Vytvořit z jiného projektu',
'open' => 'otevřeno',
'closed' => 'uzavřeno',
'Priority:' => 'Priorita:',
'Projects management' => 'Správa projektů',
'Users management' => 'Správa uživatelů',
'Groups management' => 'Správa skupin',
'Create from another project' => 'Vytvořit z jiného projektu',
'open' => 'otevřeno',
'closed' => 'uzavřeno',
'Priority:' => 'Priorita:',
// 'Reference:' => '',
'Complexity:' => 'Složitost:',
'Swimlane:' => 'Dráha:',
'Column:' => 'Sloupec:',
'Position:' => 'Pozice:',
'Creator:' => 'Autor:',
'Time estimated:' => 'Odhadovaný čas:',
'%s hours' => '%s hodin',
'Time spent:' => 'Strávený čas:',
'Created:' => 'Vytvořeno:',
'Modified:' => 'Změněno:',
'Completed:' => 'Dokončeno:',
'Started:' => 'Započato:',
'Moved:' => 'Přesunuto',
'Task #%d' => 'Úkol #%d',
'Time format' => 'Časový formát',
'Start date: ' => 'Počáteční datum',
'End date: ' => 'Koncové datum',
'New due date: ' => 'Nové datum splnění',
'Start date changed: ' => 'Počáteční datum změněno: ',
'Disable private projects' => 'Zakázat soukromé projekty',
'Complexity:' => 'Složitost:',
'Swimlane:' => 'Dráha:',
'Column:' => 'Sloupec:',
'Position:' => 'Pozice:',
'Creator:' => 'Autor:',
'Time estimated:' => 'Odhadovaný čas:',
'%s hours' => '%s hodin',
'Time spent:' => 'Strávený čas:',
'Created:' => 'Vytvořeno:',
'Modified:' => 'Změněno:',
'Completed:' => 'Dokončeno:',
'Started:' => 'Započato:',
'Moved:' => 'Přesunuto',
'Task #%d' => 'Úkol #%d',
'Time format' => 'Časový formát',
'Start date: ' => 'Počáteční datum',
'End date: ' => 'Koncové datum',
'New due date: ' => 'Nové datum splnění',
'Start date changed: ' => 'Počáteční datum změněno: ',
'Disable private projects' => 'Zakázat soukromé projekty',
// 'Do you really want to remove this custom filter: "%s"?' => '',
// 'Remove a custom filter' => '',
// 'User activated successfully.' => '',
@ -1101,13 +1101,13 @@ return array(
// 'Tag removed successfully.' => '',
// 'Unable to remove this tag.' => '',
// 'Global tags management' => '',
'Tags' => 'Štítky',
'Tags management' => 'Správa štítků',
'Add new tag' => 'Přidat nový štítek',
'Edit a tag' => 'Upravit štítek',
'Project tags' => 'Štítky projektu',
'Tags' => 'Štítky',
'Tags management' => 'Správa štítků',
'Add new tag' => 'Přidat nový štítek',
'Edit a tag' => 'Upravit štítek',
'Project tags' => 'Štítky projektu',
// 'There is no specific tag for this project at the moment.' => '',
'Tag' => 'Štítek',
'Tag' => 'Štítek',
// 'Remove a tag' => '',
// 'Do you really want to remove this tag: "%s"?' => '',
// 'Global tags' => '',
@ -1259,9 +1259,9 @@ return array(
// 'The project email is optional and could be used by several plugins.' => '',
// 'The project email must be unique across all projects' => '',
// 'The email configuration has been disabled by the administrator.' => '',
'Close this project' => 'Uzavřít tento projekt',
'Open this project' => 'Otevřít tento projekt',
'Close a project' => 'Uzavřít projekt',
'Close this project' => 'Uzavřít tento projekt',
'Open this project' => 'Otevřít tento projekt',
'Close a project' => 'Uzavřít projekt',
// 'Do you really want to close this project: "%s"?' => '',
// 'Reopen a project' => '',
// 'Do you really want to reopen this project: "%s"?' => '',
@ -1288,7 +1288,7 @@ return array(
// '%d projects' => '',
// '%d project' => '',
// 'There is no project.' => '',
'Sort' => 'Seřadit',
'Sort' => 'Seřadit',
// 'Project ID' => '',
// 'Project name' => '',
// 'Public' => '',
@ -1325,11 +1325,14 @@ return array(
// 'Changing assignee is not permitted' => '',
// 'Update only assigned tasks is permitted' => '',
// 'Only for tasks assigned to the current user' => '',
'My projects' => 'Moje projekty',
'My projects' => 'Moje projekty',
// 'Your are not member of any project.' => '',
'My subtasks' => 'Moje dílčí úkoly',
'My subtasks' => 'Moje dílčí úkoly',
// '%d subtasks' => '',
// '%d subtask' => '',
// 'Only moving task between those columns is permitted for tasks assigned to the current user' => '',
'[DUPLICATE]' => '[KOPIE]',
'[DUPLICATE]' => '[KOPIE]',
// 'DKK - Danish Krona' => '',
// 'Remove user from group' => '',
// 'Assign the task to its creator' => '',
);

View File

@ -1334,4 +1334,5 @@ return array(
// '[DUPLICATE]' => '',
// 'DKK - Danish Krona' => '',
// 'Remove user from group' => '',
// 'Assign the task to its creator' => '',
);

View File

@ -1334,4 +1334,5 @@ return array(
// '[DUPLICATE]' => '',
// 'DKK - Danish Krona' => '',
// 'Remove user from group' => '',
// 'Assign the task to its creator' => '',
);

View File

@ -1334,4 +1334,5 @@ return array(
// '[DUPLICATE]' => '',
// 'DKK - Danish Krona' => '',
// 'Remove user from group' => '',
// 'Assign the task to its creator' => '',
);

View File

@ -1334,4 +1334,5 @@ return array(
// '[DUPLICATE]' => '',
// 'DKK - Danish Krona' => '',
// 'Remove user from group' => '',
// 'Assign the task to its creator' => '',
);

View File

@ -1334,4 +1334,5 @@ return array(
// '[DUPLICATE]' => '',
// 'DKK - Danish Krona' => '',
// 'Remove user from group' => '',
// 'Assign the task to its creator' => '',
);

View File

@ -1334,4 +1334,5 @@ return array(
'[DUPLICATE]' => '[COPIE]',
'DKK - Danish Krona' => 'DKK - Couronne danoise',
'Remove user from group' => 'Supprimer cet utilisateur du groupe',
'Assign the task to its creator' => 'Assigner une tâche à son créateur',
);

View File

@ -1334,4 +1334,5 @@ return array(
// '[DUPLICATE]' => '',
// 'DKK - Danish Krona' => '',
// 'Remove user from group' => '',
// 'Assign the task to its creator' => '',
);

View File

@ -1334,4 +1334,5 @@ return array(
'[DUPLICATE]' => '[Duplikált]',
'DKK - Danish Krona' => 'Dán korona',
'Remove user from group' => 'Felhasználó eltávolítása a csoportból',
// 'Assign the task to its creator' => '',
);

View File

@ -1334,4 +1334,5 @@ return array(
// '[DUPLICATE]' => '',
// 'DKK - Danish Krona' => '',
// 'Remove user from group' => '',
// 'Assign the task to its creator' => '',
);

View File

@ -1334,4 +1334,5 @@ return array(
// '[DUPLICATE]' => '',
// 'DKK - Danish Krona' => '',
// 'Remove user from group' => '',
// 'Assign the task to its creator' => '',
);

View File

@ -1334,4 +1334,5 @@ return array(
// '[DUPLICATE]' => '',
// 'DKK - Danish Krona' => '',
// 'Remove user from group' => '',
// 'Assign the task to its creator' => '',
);

View File

@ -1334,4 +1334,5 @@ return array(
// '[DUPLICATE]' => '',
// 'DKK - Danish Krona' => '',
// 'Remove user from group' => '',
// 'Assign the task to its creator' => '',
);

View File

@ -1334,4 +1334,5 @@ return array(
// '[DUPLICATE]' => '',
// 'DKK - Danish Krona' => '',
// 'Remove user from group' => '',
// 'Assign the task to its creator' => '',
);

View File

@ -1334,4 +1334,5 @@ return array(
// '[DUPLICATE]' => '',
// 'DKK - Danish Krona' => '',
// 'Remove user from group' => '',
// 'Assign the task to its creator' => '',
);

View File

@ -1334,4 +1334,5 @@ return array(
// '[DUPLICATE]' => '',
// 'DKK - Danish Krona' => '',
// 'Remove user from group' => '',
// 'Assign the task to its creator' => '',
);

View File

@ -1334,4 +1334,5 @@ return array(
// '[DUPLICATE]' => '',
// 'DKK - Danish Krona' => '',
// 'Remove user from group' => '',
// 'Assign the task to its creator' => '',
);

View File

@ -1334,4 +1334,5 @@ return array(
'[DUPLICATE]' => '[DUPLICADO]',
'DKK - Danish Krona' => 'DKK - Coroa Dinamarquesa',
'Remove user from group' => 'Remover usuário do grupo',
// 'Assign the task to its creator' => '',
);

View File

@ -1334,4 +1334,5 @@ return array(
// '[DUPLICATE]' => '',
// 'DKK - Danish Krona' => '',
// 'Remove user from group' => '',
// 'Assign the task to its creator' => '',
);

View File

@ -1334,4 +1334,5 @@ return array(
// '[DUPLICATE]' => '',
// 'DKK - Danish Krona' => '',
// 'Remove user from group' => '',
// 'Assign the task to its creator' => '',
);

View File

@ -1334,4 +1334,5 @@ return array(
// '[DUPLICATE]' => '',
// 'DKK - Danish Krona' => '',
// 'Remove user from group' => '',
// 'Assign the task to its creator' => '',
);

View File

@ -1334,4 +1334,5 @@ return array(
// '[DUPLICATE]' => '',
// 'DKK - Danish Krona' => '',
// 'Remove user from group' => '',
// 'Assign the task to its creator' => '',
);

View File

@ -1334,4 +1334,5 @@ return array(
// '[DUPLICATE]' => '',
// 'DKK - Danish Krona' => '',
// 'Remove user from group' => '',
// 'Assign the task to its creator' => '',
);

View File

@ -1334,4 +1334,5 @@ return array(
// '[DUPLICATE]' => '',
// 'DKK - Danish Krona' => '',
// 'Remove user from group' => '',
// 'Assign the task to its creator' => '',
);

View File

@ -1334,4 +1334,5 @@ return array(
// '[DUPLICATE]' => '',
// 'DKK - Danish Krona' => '',
// 'Remove user from group' => '',
// 'Assign the task to its creator' => '',
);

View File

@ -19,6 +19,7 @@ use Kanboard\Action\TaskAssignColorCategory;
use Kanboard\Action\TaskAssignColorColumn;
use Kanboard\Action\TaskAssignColorLink;
use Kanboard\Action\TaskAssignColorUser;
use Kanboard\Action\TaskAssignCreator;
use Kanboard\Action\TaskAssignCurrentUser;
use Kanboard\Action\TaskAssignCurrentUserColumn;
use Kanboard\Action\TaskAssignSpecificUser;
@ -69,6 +70,7 @@ class ActionProvider implements ServiceProviderInterface
$container['actionManager']->register(new TaskAssignColorLink($container));
$container['actionManager']->register(new TaskAssignColorUser($container));
$container['actionManager']->register(new TaskAssignColorPriority($container));
$container['actionManager']->register(new TaskAssignCreator($container));
$container['actionManager']->register(new TaskAssignCurrentUser($container));
$container['actionManager']->register(new TaskAssignCurrentUserColumn($container));
$container['actionManager']->register(new TaskAssignSpecificUser($container));

View File

@ -0,0 +1,89 @@
<?php
require_once __DIR__.'/../Base.php';
use Kanboard\Action\TaskAssignCreator;
use Kanboard\Event\TaskEvent;
use Kanboard\Model\TaskCreationModel;
use Kanboard\Model\TaskFinderModel;
use Kanboard\Model\ProjectModel;
use Kanboard\Model\TaskModel;
class TaskAssignCreatorTest extends Base
{
public function testChangeUser()
{
$projectModel = new ProjectModel($this->container);
$taskCreationModel = new TaskCreationModel($this->container);
$taskFinderModel = new TaskFinderModel($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
$this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test', 'owner_id' => 0)));
$event = new TaskEvent(array(
'task_id' => 1,
'task' => array(
'project_id' => 1,
'column_id' => 2,
'creator_id' => 1,
)
));
$action = new TaskAssignCreator($this->container);
$action->setProjectId(1);
$action->setParam('column_id', 2);
$this->assertTrue($action->execute($event, TaskModel::EVENT_MOVE_COLUMN));
$task = $taskFinderModel->getById(1);
$this->assertNotEmpty($task);
$this->assertEquals(1, $task['owner_id']);
}
public function testWithoutCreator()
{
$projectModel = new ProjectModel($this->container);
$taskCreationModel = new TaskCreationModel($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
$this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test', 'owner_id' => 0)));
$event = new TaskEvent(array(
'task_id' => 1,
'task' => array(
'project_id' => 1,
'column_id' => 2,
)
));
$action = new TaskAssignCreator($this->container);
$action->setProjectId(1);
$action->setParam('column_id', 2);
$this->assertFalse($action->execute($event, TaskModel::EVENT_MOVE_COLUMN));
}
public function testWithWrongColumn()
{
$projectModel = new ProjectModel($this->container);
$taskCreationModel = new TaskCreationModel($this->container);
$this->assertEquals(1, $projectModel->create(array('name' => 'test1')));
$this->assertEquals(1, $taskCreationModel->create(array('project_id' => 1, 'title' => 'test')));
$event = new TaskEvent(array(
'task_id' => 1,
'task' => array(
'project_id' => 1,
'column_id' => 3,
'creator_id' => 1,
)
));
$action = new TaskAssignCreator($this->container);
$action->setProjectId(1);
$action->setParam('column_id', 2);
$this->assertFalse($action->execute($event, TaskModel::EVENT_MOVE_COLUMN));
}
}

View File

@ -2,7 +2,6 @@
require_once __DIR__.'/../Base.php';
use Kanboard\Event\GenericEvent;
use Kanboard\Event\TaskEvent;
use Kanboard\Model\TaskCreationModel;
use Kanboard\Model\TaskFinderModel;