summaryrefslogtreecommitdiff
path: root/app/Model
diff options
context:
space:
mode:
Diffstat (limited to 'app/Model')
-rw-r--r--app/Model/Base.php19
-rw-r--r--app/Model/Category.php15
-rw-r--r--app/Model/Color.php2
-rw-r--r--app/Model/OverdueNotification.php58
4 files changed, 10 insertions, 84 deletions
diff --git a/app/Model/Base.php b/app/Model/Base.php
index 6fe3d74a..635ed09a 100644
--- a/app/Model/Base.php
+++ b/app/Model/Base.php
@@ -135,23 +135,4 @@ abstract class Base extends \Kanboard\Core\Base
return $start_column.' IS NOT NULL AND '.$start_column.' > 0 AND ('.implode(' OR ', $conditions).')';
}
-
- /**
- * Group a collection of records by a column
- *
- * @access public
- * @param array $collection
- * @param string $column
- * @return array
- */
- public function groupByColumn(array $collection, $column)
- {
- $result = array();
-
- foreach ($collection as $item) {
- $result[$item[$column]][] = $item;
- }
-
- return $result;
- }
}
diff --git a/app/Model/Category.php b/app/Model/Category.php
index 883fc282..6368f507 100644
--- a/app/Model/Category.php
+++ b/app/Model/Category.php
@@ -22,12 +22,11 @@ class Category extends Base
*
* @access public
* @param integer $category_id Category id
- * @param integer $project_id Project id
* @return boolean
*/
- public function exists($category_id, $project_id)
+ public function exists($category_id)
{
- return $this->db->table(self::TABLE)->eq('id', $category_id)->eq('project_id', $project_id)->exists();
+ return $this->db->table(self::TABLE)->eq('id', $category_id)->exists();
}
/**
@@ -115,25 +114,29 @@ class Category extends Base
}
/**
- * Create default cetegories during project creation (transaction already started in Project::create())
+ * Create default categories during project creation (transaction already started in Project::create())
*
* @access public
* @param integer $project_id
+ * @return boolean
*/
public function createDefaultCategories($project_id)
{
+ $results = array();
$categories = explode(',', $this->config->get('project_categories'));
foreach ($categories as $category) {
$category = trim($category);
if (! empty($category)) {
- $this->db->table(self::TABLE)->insert(array(
+ $results[] = $this->db->table(self::TABLE)->insert(array(
'project_id' => $project_id,
'name' => $category,
));
}
}
+
+ return in_array(false, $results, true);
}
/**
@@ -195,7 +198,7 @@ class Category extends Base
{
$categories = $this->db
->table(self::TABLE)
- ->columns('name')
+ ->columns('name', 'description')
->eq('project_id', $src_project_id)
->asc('name')
->findAll();
diff --git a/app/Model/Color.php b/app/Model/Color.php
index d341dd3c..1b11f175 100644
--- a/app/Model/Color.php
+++ b/app/Model/Color.php
@@ -177,7 +177,7 @@ class Color extends Base
}
/**
- * Get Bordercolor from string
+ * Get border color from string
*
* @access public
* @param string $color_id Color id
diff --git a/app/Model/OverdueNotification.php b/app/Model/OverdueNotification.php
deleted file mode 100644
index 84565548..00000000
--- a/app/Model/OverdueNotification.php
+++ /dev/null
@@ -1,58 +0,0 @@
-<?php
-
-namespace Kanboard\Model;
-
-/**
- * Task Overdue Notification model
- *
- * @package model
- * @author Frederic Guillot
- */
-class OverdueNotification extends Base
-{
- /**
- * Send overdue tasks
- *
- * @access public
- */
- public function sendOverdueTaskNotifications()
- {
- $tasks = $this->taskFinder->getOverdueTasks();
-
- foreach ($this->groupByColumn($tasks, 'project_id') as $project_id => $project_tasks) {
- $users = $this->userNotification->getUsersWithNotificationEnabled($project_id);
-
- foreach ($users as $user) {
- $this->sendUserOverdueTaskNotifications($user, $project_tasks);
- }
- }
-
- return $tasks;
- }
-
- /**
- * Send overdue tasks for a given user
- *
- * @access public
- * @param array $user
- * @param array $tasks
- */
- public function sendUserOverdueTaskNotifications(array $user, array $tasks)
- {
- $user_tasks = array();
-
- foreach ($tasks as $task) {
- if ($this->userNotificationFilter->shouldReceiveNotification($user, array('task' => $task))) {
- $user_tasks[] = $task;
- }
- }
-
- if (! empty($user_tasks)) {
- $this->userNotification->sendUserNotification(
- $user,
- Task::EVENT_OVERDUE,
- array('tasks' => $user_tasks, 'project_name' => $tasks[0]['project_name'])
- );
- }
- }
-}