Added group notifications per projects for each user for overdue task… (#2132)

This commit is contained in:
Kolesar 2016-04-19 03:51:35 +02:00 committed by Frédéric Guillot
parent 53c992d680
commit 4253df0854
27 changed files with 132 additions and 43 deletions

View File

@ -3,6 +3,8 @@
namespace Kanboard\Console;
use Kanboard\Model\Task;
use Kanboard\Core\Security\Role;
use Kanboard\Model\ProjectUserRole;
use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
@ -15,12 +17,20 @@ class TaskOverdueNotificationCommand extends BaseCommand
$this
->setName('notification:overdue-tasks')
->setDescription('Send notifications for overdue tasks')
->addOption('show', null, InputOption::VALUE_NONE, 'Show sent overdue tasks');
->addOption('show', null, InputOption::VALUE_NONE, 'Show sent overdue tasks')
->addOption('group', null, InputOption::VALUE_NONE, 'Group all overdue tasks for one user (from all projects) in one email')
->addOption('manager', null, InputOption::VALUE_NONE, 'Send all overdue tasks to project manager(s) in one email');
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$tasks = $this->sendOverdueTaskNotifications();
if($input->getOption('group')) {
$tasks = $this->sendGroupOverdueTaskNotifications();
} elseif ($input->getOption('manager')) {
$tasks = $this->sendOverdueTaskNotificationsToManagers();
} else {
$tasks = $this->sendOverdueTaskNotifications();
}
if ($input->getOption('show')) {
$this->showTable($output, $tasks);
@ -49,6 +59,54 @@ class TaskOverdueNotificationCommand extends BaseCommand
->render();
}
/**
* Send all overdue tasks for one user in one email
*
* @access public
*/
public function sendGroupOverdueTaskNotifications()
{
$tasks = $this->taskFinder->getOverdueTasks();
foreach ($this->groupByColumn($tasks, 'owner_id') as $user_tasks) {
$users = $this->userNotification->getUsersWithNotificationEnabled($user_tasks[0]['project_id']);
foreach ($users as $user) {
$this->sendUserOverdueTaskNotifications($user, $user_tasks);
}
}
return $tasks;
}
/**
* Send all overdue tasks in one email to project manager(s)
*
* @access public
*/
public function sendOverdueTaskNotificationsToManagers()
{
$tasks = $this->taskFinder->getOverdueTasks();
foreach ($this->groupByColumn($tasks, 'project_id') as $project_id => $project_tasks) {
$users = $this->userNotification->getUsersWithNotificationEnabled($project_id);
$managers = array();
foreach ($users as $user) {
$role = $this->projectUserRole->getUserRole($project_id, $user['id']);
if($role == Role::PROJECT_MANAGER) {
$managers[] = $user;
}
}
foreach ($managers as $manager) {
$this->sendUserOverdueTaskNotificationsToManagers($manager, $project_tasks);
}
}
return $tasks;
}
/**
* Send overdue tasks
*
@ -79,10 +137,12 @@ class TaskOverdueNotificationCommand extends BaseCommand
public function sendUserOverdueTaskNotifications(array $user, array $tasks)
{
$user_tasks = array();
$project_names = array();
foreach ($tasks as $task) {
if ($this->userNotificationFilter->shouldReceiveNotification($user, array('task' => $task))) {
$user_tasks[] = $task;
$project_names[$task['project_id']] = $task['project_name'];
}
}
@ -90,11 +150,27 @@ class TaskOverdueNotificationCommand extends BaseCommand
$this->userNotification->sendUserNotification(
$user,
Task::EVENT_OVERDUE,
array('tasks' => $user_tasks, 'project_name' => $tasks[0]['project_name'])
array('tasks' => $user_tasks, 'project_name' => implode(", ", $project_names))
);
}
}
/**
* Send overdue tasks for a project manager(s)
*
* @access public
* @param array $user
* @param array $tasks
*/
public function sendUserOverdueTaskNotificationsToManagers(array $manager, array $tasks)
{
$this->userNotification->sendUserNotification(
$manager,
Task::EVENT_OVERDUE,
array('tasks' => $tasks, 'project_name' => $tasks[0]['project_name'])
);
}
/**
* Group a collection of records by a column
*

View File

@ -709,7 +709,7 @@ return array(
'view the board on Kanboard' => 'pregled ploče na Kanboard-u',
'The task have been moved to the first swimlane' => 'Zadatak je premješten u prvu swimline traku',
'The task have been moved to another swimlane:' => 'Zadatak je premješten u drugu swimline traku',
'Overdue tasks for the project "%s"' => 'Zadaci u kašnjenju za projekat "%s"',
'Overdue tasks for the project(s) "%s"' => 'Zadaci u kašnjenju za projekat(te) "%s"',
'New title: %s' => 'Novi naslov: %s',
'The task is not assigned anymore' => 'Zadatak nema više izvršioca',
'New assignee: %s' => 'Novi izvršilac: %s',

View File

@ -709,7 +709,7 @@ return array(
'view the board on Kanboard' => 'Pinnwand in Kanboard anzeigen',
'The task have been moved to the first swimlane' => 'Die Aufgabe wurde in die erste Swimlane verschoben',
'The task have been moved to another swimlane:' => 'Die Aufgaben wurde in ene andere Swimlane verschoben',
'Overdue tasks for the project "%s"' => 'Überfällige Aufgaben für das Projekt "%s"',
// 'Overdue tasks for the project(s) "%s"' => 'Überfällige Aufgaben für das Projekt "%s"',
'New title: %s' => 'Neuer Titel: %s',
'The task is not assigned anymore' => 'Die Aufgabe ist nicht mehr zugewiesen',
'New assignee: %s' => 'Neue Zuordnung: %s',

View File

@ -709,7 +709,7 @@ return array(
// 'view the board on Kanboard' => '',
// 'The task have been moved to the first swimlane' => '',
// 'The task have been moved to another swimlane:' => '',
// 'Overdue tasks for the project "%s"' => '',
// 'Overdue tasks for the project(s) "%s"' => '',
// 'New title: %s' => '',
// 'The task is not assigned anymore' => '',
// 'New assignee: %s' => '',

View File

@ -709,7 +709,7 @@ return array(
'view the board on Kanboard' => 'Pinnwand in Kanboard anzeigen',
'The task have been moved to the first swimlane' => 'Die Aufgabe wurde in die erste Swimlane verschoben',
'The task have been moved to another swimlane:' => 'Die Aufgaben wurde in ene andere Swimlane verschoben',
'Overdue tasks for the project "%s"' => 'Überfällige Aufgaben für das Projekt "%s"',
// 'Overdue tasks for the project(s) "%s"' => 'Überfällige Aufgaben für das Projekt "%s"',
'New title: %s' => 'Neuer Titel: %s',
'The task is not assigned anymore' => 'Die Aufgabe ist nicht mehr zugewiesen',
'New assignee: %s' => 'Neue Zuordnung: %s',

View File

@ -709,7 +709,7 @@ return array(
'view the board on Kanboard' => 'δείτε τον πίνακα στο Kanboard',
'The task have been moved to the first swimlane' => 'Η εργασία αυτή έχει μετακινηθεί στην πρώτη λωρίδα',
'The task have been moved to another swimlane:' => 'Η εργασία αυτή έχει μετακινηθεί σε άλλη λωρίδα:',
'Overdue tasks for the project "%s"' => 'Εκπρόθεσμες εργασίες για το έργο « %s »',
// 'Overdue tasks for the project(s) "%s"' => 'Εκπρόθεσμες εργασίες για το έργο « %s »',
'New title: %s' => 'Νέος τίτλος: %s',
'The task is not assigned anymore' => 'Η εργασία δεν έχει ανατεθεί πλέον',
'New assignee: %s' => 'Καινούργια ανάθεση: %s',

View File

@ -709,7 +709,7 @@ return array(
'view the board on Kanboard' => 'ver el tablero en Kanboard',
'The task have been moved to the first swimlane' => 'Se ha movido la tarea a la primera calle',
'The task have been moved to another swimlane:' => 'Se ha movido la tarea a otra calle',
'Overdue tasks for the project "%s"' => 'Tareas atrasadas para el proyecto "%s"',
// 'Overdue tasks for the project(s) "%s"' => 'Tareas atrasadas para el proyecto "%s"',
'New title: %s' => 'Nuevo título: %s',
'The task is not assigned anymore' => 'La tarea ya no está asignada',
'New assignee: %s' => 'Nuevo concesionario: %s',

View File

@ -709,7 +709,7 @@ return array(
// 'view the board on Kanboard' => '',
// 'The task have been moved to the first swimlane' => '',
// 'The task have been moved to another swimlane:' => '',
// 'Overdue tasks for the project "%s"' => '',
// 'Overdue tasks for the project(s) "%s"' => '',
// 'New title: %s' => '',
// 'The task is not assigned anymore' => '',
// 'New assignee: %s' => '',

View File

@ -709,7 +709,7 @@ return array(
'view the board on Kanboard' => 'voir le tableau sur Kanboard',
'The task have been moved to the first swimlane' => 'La tâche a été déplacée dans la première swimlane',
'The task have been moved to another swimlane:' => 'La tâche a été déplacée dans une autre swimlane :',
'Overdue tasks for the project "%s"' => 'Tâches en retard pour le projet « %s »',
// 'Overdue tasks for the project(s) "%s"' => 'Tâches en retard pour le projet « %s »',
'New title: %s' => 'Nouveau titre : %s',
'The task is not assigned anymore' => 'La tâche n\'est plus assignée maintenant',
'New assignee: %s' => 'Nouvel assigné : %s',

View File

@ -709,7 +709,7 @@ return array(
// 'view the board on Kanboard' => '',
// 'The task have been moved to the first swimlane' => '',
// 'The task have been moved to another swimlane:' => '',
// 'Overdue tasks for the project "%s"' => '',
// 'Overdue tasks for the project(s) "%s"' => '',
// 'New title: %s' => '',
// 'The task is not assigned anymore' => '',
// 'New assignee: %s' => '',

View File

@ -709,7 +709,7 @@ return array(
'view the board on Kanboard' => 'lihat papan di Kanboard',
'The task have been moved to the first swimlane' => 'Tugas telah dipindahkan ke swimlane pertama',
'The task have been moved to another swimlane:' => 'Tugas telah dipindahkan ke swimlane lain:',
'Overdue tasks for the project "%s"' => 'Tugas terlambat untuk proyek « %s »',
// 'Overdue tasks for the project(s) "%s"' => 'Tugas terlambat untuk proyek « %s »',
'New title: %s' => 'Judul baru : %s',
'The task is not assigned anymore' => 'Tugas tidak ditugaskan lagi',
'New assignee: %s' => 'Penerima baru : %s',

View File

@ -709,7 +709,7 @@ return array(
'view the board on Kanboard' => 'guarda la bacheca su Kanboard',
'The task have been moved to the first swimlane' => 'Il task è stato spostato nella prima corsia',
'The task have been moved to another swimlane:' => 'Il task è stato spostato in un\'altra corsia:',
'Overdue tasks for the project "%s"' => 'Task scaduti per il progetto "%s"',
// 'Overdue tasks for the project(s) "%s"' => 'Task scaduti per il progetto "%s"',
'New title: %s' => 'Nuovo titolo: %s',
'The task is not assigned anymore' => 'Il task non è più assegnato a nessuno',
'New assignee: %s' => 'Nuovo assegnatario: %s',

View File

@ -709,7 +709,7 @@ return array(
// 'view the board on Kanboard' => '',
// 'The task have been moved to the first swimlane' => '',
// 'The task have been moved to another swimlane:' => '',
// 'Overdue tasks for the project "%s"' => '',
// 'Overdue tasks for the project(s) "%s"' => '',
// 'New title: %s' => '',
// 'The task is not assigned anymore' => '',
// 'New assignee: %s' => '',

View File

@ -709,7 +709,7 @@ return array(
// 'view the board on Kanboard' => '',
// 'The task have been moved to the first swimlane' => '',
// 'The task have been moved to another swimlane:' => '',
// 'Overdue tasks for the project "%s"' => '',
// 'Overdue tasks for the project(s) "%s"' => '',
'New title: %s' => '제목 변경: %s',
'The task is not assigned anymore' => '담당자 없음',
'New assignee: %s' => '담당자 변경: %s',

View File

@ -709,7 +709,7 @@ return array(
'view the board on Kanboard' => 'lihat papan di Kanboard',
'The task have been moved to the first swimlane' => 'Tugas telah dipindahkan ke swimlane pertama',
'The task have been moved to another swimlane:' => 'Tugas telah dipindahkan ke swimlane lain:',
'Overdue tasks for the project "%s"' => 'Tugas terlambat untuk projek « %s »',
'Overdue tasks for the project(s) "%s"' => 'Tugas terlambat untuk projek « %s »',
'New title: %s' => 'Judul baru : %s',
'The task is not assigned anymore' => 'Tugas tidak ditugaskan lagi',
'New assignee: %s' => 'Penerima baru : %s',

View File

@ -709,7 +709,7 @@ return array(
// 'view the board on Kanboard' => '',
// 'The task have been moved to the first swimlane' => '',
// 'The task have been moved to another swimlane:' => '',
// 'Overdue tasks for the project "%s"' => '',
// 'Overdue tasks for the project(s) "%s"' => '',
// 'New title: %s' => '',
// 'The task is not assigned anymore' => '',
// 'New assignee: %s' => '',

View File

@ -709,7 +709,7 @@ return array(
// 'view the board on Kanboard' => '',
// 'The task have been moved to the first swimlane' => '',
// 'The task have been moved to another swimlane:' => '',
// 'Overdue tasks for the project "%s"' => '',
// 'Overdue tasks for the project(s) "%s"' => '',
'New title: %s' => 'Nieuw titel: %s',
// 'The task is not assigned anymore' => '',
// 'New assignee: %s' => '',

View File

@ -709,7 +709,7 @@ return array(
// 'view the board on Kanboard' => '',
// 'The task have been moved to the first swimlane' => '',
// 'The task have been moved to another swimlane:' => '',
// 'Overdue tasks for the project "%s"' => '',
// 'Overdue tasks for the project(s) "%s"' => '',
'New title: %s' => 'Nowy tytuł: %s',
'The task is not assigned anymore' => 'Brak osoby odpowiedzialnej za zadanie',
'New assignee: %s' => 'Nowy odpowiedzialny: %s',

View File

@ -709,7 +709,7 @@ return array(
'view the board on Kanboard' => 'ver o painel no Kanboard',
'The task have been moved to the first swimlane' => 'A tarefa foi movida para a primeira swimlane',
'The task have been moved to another swimlane:' => 'A tarefa foi movida para outra swimlane:',
'Overdue tasks for the project "%s"' => 'Tarefas atrasadas para o projeto "%s"',
// 'Overdue tasks for the project(s) "%s"' => 'Tarefas atrasadas para o projeto "%s"',
'New title: %s' => 'Novo título: %s',
'The task is not assigned anymore' => 'Agora a tarefa não está mais atribuída',
'New assignee: %s' => 'Novo designado: %s',

View File

@ -709,7 +709,7 @@ return array(
'view the board on Kanboard' => 'ver o painel no Kanboard',
'The task have been moved to the first swimlane' => 'A tarefa foi movida para o primeiro Swimlane',
'The task have been moved to another swimlane:' => 'A tarefa foi movida para outro Swimlane:',
'Overdue tasks for the project "%s"' => 'Tarefas atrasadas para o projecto "%s"',
// 'Overdue tasks for the project(s) "%s"' => 'Tarefas atrasadas para o projecto "%s"',
'New title: %s' => 'Novo título: %s',
'The task is not assigned anymore' => 'Tarefa já não está atribuída',
'New assignee: %s' => 'Novo assignado: %s',

View File

@ -709,7 +709,7 @@ return array(
'view the board on Kanboard' => 'посмотреть доску на Kanboard',
'The task have been moved to the first swimlane' => 'Эта задача была перемещена в первую дорожку',
'The task have been moved to another swimlane:' => 'Эта задача была перемещена в другую дорожку:',
'Overdue tasks for the project "%s"' => 'Просроченные задачи для проекта "%s"',
// 'Overdue tasks for the project(s) "%s"' => 'Просроченные задачи для проекта "%s"',
'New title: %s' => 'Новый заголовок: %s',
'The task is not assigned anymore' => 'Задача больше не назначена',
'New assignee: %s' => 'Новый назначенный: %s',

View File

@ -709,7 +709,7 @@ return array(
// 'view the board on Kanboard' => '',
// 'The task have been moved to the first swimlane' => '',
// 'The task have been moved to another swimlane:' => '',
// 'Overdue tasks for the project "%s"' => '',
// 'Overdue tasks for the project(s) "%s"' => '',
// 'New title: %s' => '',
// 'The task is not assigned anymore' => '',
// 'New assignee: %s' => '',

View File

@ -709,7 +709,7 @@ return array(
'view the board on Kanboard' => 'visa tavlan på Kanboard',
'The task have been moved to the first swimlane' => 'Uppgiften har flyttats till första swimlane',
'The task have been moved to another swimlane:' => 'Uppgiften har flyttats till en annan swimlane:',
'Overdue tasks for the project "%s"' => 'Försenade uppgifter för projektet "%s"',
// 'Overdue tasks for the project(s) "%s"' => 'Försenade uppgifter för projektet "%s"',
'New title: %s' => 'Ny titel: %s',
'The task is not assigned anymore' => 'Uppgiften är inte länge tilldelad',
'New assignee: %s' => 'Ny tilldelning: %s',

View File

@ -709,7 +709,7 @@ return array(
'view the board on Kanboard' => 'แสดงบอร์ดบนคังบอร์ด',
'The task have been moved to the first swimlane' => 'งานถูกย้านไปสวิมเลนแรก',
'The task have been moved to another swimlane:' => 'งานถูกย้านไปสวิมเลนอื่น:',
'Overdue tasks for the project "%s"' => 'งานที่เกินกำหนดสำหรับโปรเจค "%s"',
// 'Overdue tasks for the project(s) "%s"' => 'งานที่เกินกำหนดสำหรับโปรเจค "%s"',
'New title: %s' => 'ชื่อเรื่องใหม่: %s',
'The task is not assigned anymore' => 'ไม่กำหนดผู้รับผิดชอบ',
'New assignee: %s' => 'ผู้รับผิดชอบใหม่: %s',

View File

@ -709,7 +709,7 @@ return array(
'view the board on Kanboard' => 'Tabloyu Kanboard\'da görüntüle',
'The task have been moved to the first swimlane' => 'Görev birinci kulvara taşındı',
'The task have been moved to another swimlane:' => 'Görev başka bir kulvara taşındı:',
'Overdue tasks for the project "%s"' => '"%s" projesi için gecikmiş görevler',
// 'Overdue tasks for the project(s) "%s"' => '"%s" projesi için gecikmiş görevler',
'New title: %s' => 'Yeni başlık: %s',
'The task is not assigned anymore' => 'Görev artık atanmamış',
'New assignee: %s' => 'Yeni atanan: %s',

View File

@ -709,7 +709,7 @@ return array(
'view the board on Kanboard' => '在看板上查看面板',
'The task have been moved to the first swimlane' => '该任务已被移动到首个里程碑',
'The task have been moved to another swimlane:' => '该任务已被移动到别的里程碑:',
'Overdue tasks for the project "%s"' => '"%s"项目下的超期任务',
// 'Overdue tasks for the project(s) "%s"' => '"%s"项目下的超期任务',
'New title: %s' => '新标题:%s',
'The task is not assigned anymore' => '该任务没有指派人',
'New assignee: %s' => '新指派到:%s',

View File

@ -1,18 +1,31 @@
<h2><?= t('Overdue tasks for the project "%s"', $project_name) ?></h2>
<h2><?= t('Overdue tasks for the project(s) "%s"', $project_name) ?></h2>
<table style="font-size: .8em; table-layout: fixed; width: 100%; border-collapse: collapse; border-spacing: 0; margin-bottom: 20px;" cellpadding=5 cellspacing=1>
<tr style="background: #fbfbfb; text-align: left; padding-top: .5em; padding-bottom: .5em; padding-left: 3px; padding-right: 3px;">
<th style="border: 1px solid #eee;"><?= t('ID') ?></th>
<th style="border: 1px solid #eee;"><?= t('Title') ?></th>
<th style="border: 1px solid #eee;"><?= t('Due date') ?></th>
<th style="border: 1px solid #eee;"><?= t('Project') ?></th>
<th style="border: 1px solid #eee;"><?= t('Assignee') ?></th>
</tr>
<ul>
<?php foreach ($tasks as $task): ?>
<li>
(<strong>#<?= $task['id'] ?></strong>)
<?php if ($application_url): ?>
<a href="<?= $this->url->href('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, '', true) ?>"><?= $this->text->e($task['title']) ?></a>
<?php else: ?>
<?= $this->text->e($task['title']) ?>
<?php endif ?>
(<?= $this->dt->date($task['date_due']) ?>)
<?php if ($task['assignee_username']): ?>
(<strong><?= t('Assigned to %s', $task['assignee_name'] ?: $task['assignee_username']) ?></strong>)
<?php endif ?>
</li>
<tr style="overflow: hidden; background: #fff; text-align: left; padding-top: .5em; padding-bottom: .5em; padding-left: 3px; padding-right: 3px;">
<td style="border: 1px solid #eee;">#<?= $task['id'] ?></td>
<td style="border: 1px solid #eee;">
<?php if ($application_url): ?>
<a href="<?= $this->url->href('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, '', true) ?>"><?= $this->text->e($task['title']) ?></a>
<?php else: ?>
<?= $this->text->e($task['title']) ?>
<?php endif ?>
</td>
<td style="border: 1px solid #eee;"><?= $this->dt->date($task['date_due']) ?></td>
<td style="border: 1px solid #eee;"><?= $task['project_name'] ?></td>
<td style="border: 1px solid #eee;">
<?php if ($task['assignee_username']): ?>
<?= t('%s', $task['assignee_name'] ?: $task['assignee_username']) ?>
<?php endif ?>
</td>
</tr>
<?php endforeach ?>
</ul>
</table>