Skip to content

Commit

Permalink
Merge pull request #19 from creecros/trigger-assignee-change
Browse files Browse the repository at this point in the history
Trigger assignee change
  • Loading branch information
creecros authored Dec 13, 2018
2 parents 07d13e6 + ba0a8b8 commit 51af9e9
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 7 deletions.
18 changes: 14 additions & 4 deletions Controller/GroupAssignTaskModificationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@


/**
* Task Modification controller
* Group Assign Task Modification controller
*
* @package Kanboard\Controller
* @author Frederic Guillot
* @package Kanboard\Plugin\Group_assign\
* @author Craig Crosby
*/
class GroupAssignTaskModificationController extends BaseController
{
Expand Down Expand Up @@ -141,17 +141,27 @@ protected function renderTemplate(array &$task, array &$params)
*/
public function update()
{
$previousMembers = array();
$task = $this->getTask();
$values = $this->request->getValues();
$values['id'] = $task['id'];
$values['project_id'] = $task['project_id'];
if (isset($values['owner_ms']) && !empty($values['owner_ms'])) {
if (!empty($task['owner_ms'])) { $ms_id = $task['owner_ms']; $this->multiselectMemberModel->removeAllUsers($ms_id); } else { $ms_id = $this->multiselectModel->create(); }
if (!empty($task['owner_ms'])) {
$ms_id = $task['owner_ms'];
$previousMembers = $this->multiselectMemberModel->getMembers($ms_id);
$this->multiselectMemberModel->removeAllUsers($ms_id);
} else {
$ms_id = $this->multiselectModel->create();
}
foreach ($values['owner_ms'] as $user) {
if ($user !== 0) { $this->multiselectMemberModel->addUser($ms_id, $user); }
}
unset($values['owner_ms']);
$values['owner_ms'] = $ms_id;
$newMembersSet = $this->multiselectMemberModel->getMembers($ms_id);
if (sort($previousMembers) !== sort($newMemberSet)) { $this->multiselectMemberModel->assigneeChanged($task, $values); }
if ($values['owner_gp'] !== $task['owner_gp']) { $this->multiselectMemberModel->assigneeChanged($task, $values); }
}

list($valid, $errors) = $this->taskValidator->validateModification($values);
Expand Down
21 changes: 21 additions & 0 deletions Model/MultiselectMemberModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

use Kanboard\Plugin\Group_assign\Model\MultiselectModel;
use Kanboard\Model\UserModel;
use Kanboard\Model\TaskModel;
use Kanboard\Core\Queue\QueueManager;
use Kanboard\Core\Base;

/**
Expand Down Expand Up @@ -145,4 +147,23 @@ public function getGroups($user_id)
->asc(MultiselectModel::TABLE.'.id')
->findAll();
}

/**
* Fire Assignee Change
*
* @access protected
* @param array $task
* @param array $changes
*/
public function assigneeChanged(array $task, array $changes)
{
$events = array();
$events[] = TaskModel::EVENT_ASSIGNEE_CHANGE;

if (! empty($events)) {
$this->queueManager->push($this->taskEventJob
->withParams($task['id'], $events, $changes, array(), $task)
);
}
}
}
2 changes: 1 addition & 1 deletion Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public function getPluginAuthor()
}
public function getPluginVersion()
{
return '1.3.0';
return '1.4.0';
}
public function getPluginHomepage()
{
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,15 @@ Kanboard v1.1.0 or Higher
* using ``assignee:GroupName`` in filter will find tasks assigned to a group by NAME of the group.
* using ``assignee:GroupID`` in filter will find tasks assigned to a group by ID number of group.
* using ``assignee:Username`` or ``assignee:Name`` will NOW find a task assigned to a group with that UserName or Name in the group or in Other Assignees.
* user assigneed via a group or multiselect will now recieve notifications
* User assigneed via a group or multiselect will now recieve notifications
* Changing assigned group or any multiselect users will now trigger `EVENT_ASSIGNEE_CHANGE`

# Future enhancments
Find bugs or missing functionality, please report it.

- [x] Add a few basic automatic actions that utilize Groups assigned
- [x] Add relationship for ``assignee:Username`` or ``assignee:Name`` in the table lookup
- [ ] Add an event for assigned group change.
- [x] Add an event for assigned group change.
- [x] Incorporate into notifications

# Screenshots
Expand Down

0 comments on commit 51af9e9

Please sign in to comment.