Skip to content

Commit

Permalink
Merge pull request #17 from creecros/events
Browse files Browse the repository at this point in the history
Patch
  • Loading branch information
creecros authored Dec 11, 2018
2 parents c12661b + 39e62dd commit c1c8b91
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Controller/GroupAssignTaskModificationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ public function update()
$values['id'] = $task['id'];
$values['project_id'] = $task['project_id'];
if (isset($values['owner_ms']) && !empty($values['owner_ms'])) {
$ms_id = $this->multiselectModel->create();
if (!empty($task['owner_ms'])) { $ms_id = $task['owner_ms']; $this->multiselectMemberModel->removeAllUsers($ms_id); } else { $ms_id = $this->multiselectModel->create(); }
foreach ($values['owner_ms'] as $user) {
$this->multiselectMemberModel->addUser($ms_id, $user);
if ($user !== 0) { $this->multiselectMemberModel->addUser($ms_id, $user); }
}
unset($values['owner_ms']);
$values['owner_ms'] = $ms_id;
Expand Down
15 changes: 15 additions & 0 deletions Model/MultiselectMemberModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,21 @@ public function removeUser($group_id, $user_id)
->remove();
}

/**
* Remove all users from a group
*
* @access public
* @param integer $group_id
* @param integer $user_id
* @return boolean
*/
public function removeAllUsers($group_id)
{
return $this->db->table(self::TABLE)
->eq('group_id', $group_id)
->remove();
}

/**
* Check if a user is member
*
Expand Down
7 changes: 5 additions & 2 deletions Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ class Plugin extends Base

public function initialize()
{

//Events & Changes
$this->template->setTemplateOverride('task/changes', 'group_assign:task/changes');


//Helpers
$this->helper->register('newTaskHelper', '\Kanboard\Plugin\Group_assign\Helper\NewTaskHelper');
$this->helper->register('smallAvatarHelperExtend', '\Kanboard\Plugin\Group_assign\Helper\SmallAvatarHelperExtend');
Expand Down Expand Up @@ -115,7 +118,7 @@ public function getPluginAuthor()
}
public function getPluginVersion()
{
return '1.2.0';
return '1.2.1';
}
public function getPluginHomepage()
{
Expand Down
1 change: 1 addition & 0 deletions Template/board/group.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
<?php if ($task['assigned_groupname']): ?>
<strong><?= t('Assigned Group:') ?></strong>
<?= $this->text->e($task['assigned_groupname'] ?: $task['owner_gp']) ?>
<br>
<?php endif ?>
</span>
92 changes: 92 additions & 0 deletions Template/task/changes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<?php if (! empty($changes)): ?>
<ul>
<?php

foreach ($changes as $field => $value) {
switch ($field) {
case 'title':
echo '<li>'.t('New title: %s', $task['title']).'</li>';
break;
case 'owner_id':
if (empty($task['owner_id'])) {
echo '<li>'.t('The task is not assigned anymore').'</li>';
} else {
echo '<li>'.t('New assignee: %s', $task['assignee_name'] ?: $task['assignee_username']).'</li>';
}
break;
case 'category_id':
if (empty($task['category_id'])) {
echo '<li>'.t('There is no category now').'</li>';
} else {
echo '<li>'.t('New category: %s', $task['category_name']).'</li>';
}
break;
case 'color_id':
echo '<li>'.t('New color: %s', $this->text->in($task['color_id'], $this->task->getColors())).'</li>';
break;
case 'score':
echo '<li>'.t('New complexity: %d', $task['score']).'</li>';
break;
case 'date_due':
if (empty($task['date_due'])) {
echo '<li>'.t('The due date have been removed').'</li>';
} else {
echo '<li>'.t('New due date: ').$this->dt->datetime($task['date_due']).'</li>';
}
break;
case 'description':
if (empty($task['description'])) {
echo '<li>'.t('There is no description anymore').'</li>';
}
break;
case 'recurrence_status':
case 'recurrence_trigger':
case 'recurrence_factor':
case 'recurrence_timeframe':
case 'recurrence_basedate':
case 'recurrence_parent':
case 'recurrence_child':
echo '<li>'.t('Recurrence settings have been modified').'</li>';
break;
case 'time_spent':
echo '<li>'.t('Time spent changed: %sh', $task['time_spent']).'</li>';
break;
case 'time_estimated':
echo '<li>'.t('Time estimated changed: %sh', $task['time_estimated']).'</li>';
break;
case 'date_started':
if ($value != 0) {
echo '<li>'.t('Start date changed: ').$this->dt->datetime($task['date_started']).'</li>';
}
break;
case 'owner_gp':
if (empty($task['owner_gp'])) {
echo '<li>'.t('The task is not assigned to a group anymore').'</li>';
} else {
echo '<li>'.t('New group assigned: %s', $task['assigned_groupname']).'</li>';
}
break;
case 'owner_ms':
if (empty($task['owner_ms'])) {
echo '<li>'.t('The task is not assigned to multiple users anymore').'</li>';
} else {
echo '<li>'.t('The task has been assigned other users').'</li>';
}
break;
default:
echo '<li>'.t('The field "%s" have been updated', $field).'</li>';
}
}

?>
</ul>

<?php if (! empty($changes['description'])): ?>
<p><strong><?= t('The description has been modified:') ?></strong></p>
<?php if (isset($public)): ?>
<div class="markdown"><?= $this->text->markdown($task['description'], true) ?></div>
<?php else: ?>
<div class="markdown"><?= $this->text->markdown($task['description']) ?></div>
<?php endif ?>
<?php endif ?>
<?php endif ?>

0 comments on commit c1c8b91

Please sign in to comment.