summaryrefslogtreecommitdiff
path: root/kanboard
diff options
context:
space:
mode:
Diffstat (limited to 'kanboard')
-rwxr-xr-xkanboard35
1 files changed, 32 insertions, 3 deletions
diff --git a/kanboard b/kanboard
index 95a977bd..34e183e4 100755
--- a/kanboard
+++ b/kanboard
@@ -8,8 +8,9 @@ use Core\Tool;
use Core\Translator;
use Model\Config;
use Model\Task;
+use Model\Notification;
-$config = new Config($registry->shared('db'), $registry->shared('event'));
+$config = new Config($registry);
// Load translations
$language = $config->get('language', 'en_US');
@@ -25,6 +26,7 @@ $cli = new Cli;
$cli->register('help', function() {
echo 'Kanboard command line interface'.PHP_EOL.'==============================='.PHP_EOL.PHP_EOL;
echo '- Task export to stdout (CSV format): '.$GLOBALS['argv'][0].' export-csv <project_id> <start_date> <end_date>'.PHP_EOL;
+ echo '- Send notifications for tasks due: '.$GLOBALS['argv'][0].' send-notifications-tasks-due'.PHP_EOL;
});
// CSV Export
@@ -40,12 +42,39 @@ $cli->register('export-csv', function() use ($cli, $registry) {
Translator::disableEscaping();
- $task = new Task($registry->shared('db'), $registry->shared('event'));
- $data = $task->export($project_id, $start_date, $end_date);
+ $taskModel = new Task($registry);
+ $data = $taskModel->export($project_id, $start_date, $end_date);
if (is_array($data)) {
Tool::csv($data);
}
});
+// Send notification for tasks due
+$cli->register('send-notifications-tasks-due', function() use ($cli, $registry) {
+
+ $notificationModel = new Notification($registry);
+ $taskModel = new Task($registry);
+ $tasks = $taskModel->getTasksDue();
+
+ // Group tasks by project
+ $projects = array();
+
+ foreach ($tasks as $task) {
+ $projects[$task['project_id']][] = $task;
+ }
+
+ // Send notifications for each project
+ foreach ($projects as $project_id => $project_tasks) {
+
+ $users = $notificationModel->getUsersList($project_id);
+
+ $notificationModel->sendEmails(
+ 'notification_task_due',
+ $users,
+ array('tasks' => $project_tasks, 'project' => $project_tasks[0]['project_name'])
+ );
+ }
+});
+
$cli->execute();