summaryrefslogtreecommitdiff
path: root/app/Model
diff options
context:
space:
mode:
author85pando <85pando@googlemail.com>2016-02-05 10:28:40 +0100
committer85pando <85pando@googlemail.com>2016-02-05 10:28:40 +0100
commit791d13c87bf510d913973b77a5f6d152311a1d87 (patch)
tree81412e8dbd3ac4fa0047030a6068afafd975687e /app/Model
parent2074aaaa9a75455097e4e77ca09f4fba3e567052 (diff)
parent12aaec03b19a07635f59b00f532c92c37ac1df5f (diff)
Merge remote-tracking branch 'refs/remotes/upstream/master'
Conflicts: app/Locale/de_DE/translations.php
Diffstat (limited to 'app/Model')
-rw-r--r--app/Model/Category.php11
-rw-r--r--app/Model/Config.php4
-rw-r--r--app/Model/LastLogin.php16
-rw-r--r--app/Model/ProjectDuplication.php140
-rw-r--r--app/Model/Subtask.php15
-rw-r--r--app/Model/SubtaskTimeTracking.php10
-rw-r--r--app/Model/Swimlane.php143
-rw-r--r--app/Model/Task.php22
-rw-r--r--app/Model/TaskExternalLink.php99
-rw-r--r--app/Model/TaskFinder.php28
-rw-r--r--app/Model/TaskLink.php1
-rw-r--r--app/Model/User.php17
12 files changed, 349 insertions, 157 deletions
diff --git a/app/Model/Category.php b/app/Model/Category.php
index 58cee738..883fc282 100644
--- a/app/Model/Category.php
+++ b/app/Model/Category.php
@@ -193,11 +193,12 @@ class Category extends Base
*/
public function duplicate($src_project_id, $dst_project_id)
{
- $categories = $this->db->table(self::TABLE)
- ->columns('name')
- ->eq('project_id', $src_project_id)
- ->asc('name')
- ->findAll();
+ $categories = $this->db
+ ->table(self::TABLE)
+ ->columns('name')
+ ->eq('project_id', $src_project_id)
+ ->asc('name')
+ ->findAll();
foreach ($categories as $category) {
$category['project_id'] = $dst_project_id;
diff --git a/app/Model/Config.php b/app/Model/Config.php
index 55999310..6f009175 100644
--- a/app/Model/Config.php
+++ b/app/Model/Config.php
@@ -76,6 +76,7 @@ class Config extends Setting
'en_US' => 'English',
'es_ES' => 'Español',
'fr_FR' => 'Français',
+ 'el_GR' => 'Grec',
'it_IT' => 'Italiano',
'hu_HU' => 'Magyar',
'my_MY' => 'Melayu',
@@ -131,7 +132,8 @@ class Config extends Setting
'zh_CN' => 'zh-cn',
'ja_JP' => 'ja',
'th_TH' => 'th',
- 'id_ID' => 'id'
+ 'id_ID' => 'id',
+ 'el_GR' => 'el',
);
$lang = $this->getCurrentLanguage();
diff --git a/app/Model/LastLogin.php b/app/Model/LastLogin.php
index f5be020e..a1734819 100644
--- a/app/Model/LastLogin.php
+++ b/app/Model/LastLogin.php
@@ -39,14 +39,14 @@ class LastLogin extends Base
$this->cleanup($user_id);
return $this->db
- ->table(self::TABLE)
- ->insert(array(
- 'auth_type' => $auth_type,
- 'user_id' => $user_id,
- 'ip' => $ip,
- 'user_agent' => substr($user_agent, 0, 255),
- 'date_creation' => time(),
- ));
+ ->table(self::TABLE)
+ ->insert(array(
+ 'auth_type' => $auth_type,
+ 'user_id' => $user_id,
+ 'ip' => $ip,
+ 'user_agent' => substr($user_agent, 0, 255),
+ 'date_creation' => time(),
+ ));
}
/**
diff --git a/app/Model/ProjectDuplication.php b/app/Model/ProjectDuplication.php
index f0c66834..9c5f80ad 100644
--- a/app/Model/ProjectDuplication.php
+++ b/app/Model/ProjectDuplication.php
@@ -2,6 +2,8 @@
namespace Kanboard\Model;
+use Kanboard\Core\Security\Role;
+
/**
* Project Duplication
*
@@ -12,6 +14,28 @@ namespace Kanboard\Model;
class ProjectDuplication extends Base
{
/**
+ * Get list of optional models to duplicate
+ *
+ * @access public
+ * @return string[]
+ */
+ public function getOptionalSelection()
+ {
+ return array('category', 'projectPermission', 'action', 'swimlane', 'task');
+ }
+
+ /**
+ * Get list of all possible models to duplicate
+ *
+ * @access public
+ * @return string[]
+ */
+ public function getPossibleSelection()
+ {
+ return array('board', 'category', 'projectPermission', 'action', 'swimlane', 'task');
+ }
+
+ /**
* Get a valid project name for the duplication
*
* @access public
@@ -31,78 +55,106 @@ class ProjectDuplication extends Base
}
/**
- * Create a project from another one
- *
- * @param integer $project_id Project Id
- * @return integer Cloned Project Id
- */
- public function copy($project_id)
- {
- $project = $this->project->getById($project_id);
-
- $values = array(
- 'name' => $this->getClonedProjectName($project['name']),
- 'is_active' => true,
- 'last_modified' => 0,
- 'token' => '',
- 'is_public' => 0,
- 'is_private' => empty($project['is_private']) ? 0 : 1,
- );
-
- if (! $this->db->table(Project::TABLE)->save($values)) {
- return 0;
- }
-
- return $this->db->getLastId();
- }
-
- /**
* Clone a project with all settings
*
- * @param integer $project_id Project Id
- * @param array $part_selection Selection of optional project parts to duplicate. Possible options: 'swimlane', 'action', 'category', 'task'
- * @return integer Cloned Project Id
+ * @param integer $src_project_id Project Id
+ * @param array $selection Selection of optional project parts to duplicate
+ * @param integer $owner_id Owner of the project
+ * @param string $name Name of the project
+ * @param boolean $private Force the project to be private
+ * @return integer Cloned Project Id
*/
- public function duplicate($project_id, $part_selection = array('category', 'action'))
+ public function duplicate($src_project_id, $selection = array('projectPermission', 'category', 'action'), $owner_id = 0, $name = null, $private = null)
{
$this->db->startTransaction();
// Get the cloned project Id
- $clone_project_id = $this->copy($project_id);
+ $dst_project_id = $this->copy($src_project_id, $owner_id, $name, $private);
- if (! $clone_project_id) {
+ if ($dst_project_id === false) {
$this->db->cancelTransaction();
return false;
}
// Clone Columns, Categories, Permissions and Actions
- $optional_parts = array('swimlane', 'action', 'category');
- foreach (array('board', 'category', 'projectPermission', 'action', 'swimlane') as $model) {
+ foreach ($this->getPossibleSelection() as $model) {
// Skip if optional part has not been selected
- if (in_array($model, $optional_parts) && ! in_array($model, $part_selection)) {
+ if (in_array($model, $this->getOptionalSelection()) && ! in_array($model, $selection)) {
continue;
}
- if (! $this->$model->duplicate($project_id, $clone_project_id)) {
+ // Skip permissions for private projects
+ if ($private && $model === 'projectPermission') {
+ continue;
+ }
+
+ if (! $this->$model->duplicate($src_project_id, $dst_project_id)) {
$this->db->cancelTransaction();
return false;
}
}
+ if (! $this->makeOwnerManager($dst_project_id, $owner_id)) {
+ $this->db->cancelTransaction();
+ return false;
+ }
+
$this->db->closeTransaction();
- // Clone Tasks if in $part_selection
- if (in_array('task', $part_selection)) {
- $tasks = $this->taskFinder->getAll($project_id);
+ return (int) $dst_project_id;
+ }
+
+ /**
+ * Create a project from another one
+ *
+ * @access private
+ * @param integer $src_project_id
+ * @param integer $owner_id
+ * @param string $name
+ * @param boolean $private
+ * @return integer
+ */
+ private function copy($src_project_id, $owner_id = 0, $name = null, $private = null)
+ {
+ $project = $this->project->getById($src_project_id);
+ $is_private = empty($project['is_private']) ? 0 : 1;
+
+ $values = array(
+ 'name' => $name ?: $this->getClonedProjectName($project['name']),
+ 'is_active' => 1,
+ 'last_modified' => time(),
+ 'token' => '',
+ 'is_public' => 0,
+ 'is_private' => $private ? 1 : $is_private,
+ 'owner_id' => $owner_id,
+ );
+
+ if (! $this->db->table(Project::TABLE)->save($values)) {
+ return false;
+ }
+
+ return $this->db->getLastId();
+ }
+
+ /**
+ * Make sure that the creator of the duplicated project is alsp owner
+ *
+ * @access private
+ * @param integer $dst_project_id
+ * @param integer $owner_id
+ * @return boolean
+ */
+ private function makeOwnerManager($dst_project_id, $owner_id)
+ {
+ if ($owner_id > 0) {
+ $this->projectUserRole->removeUser($dst_project_id, $owner_id);
- foreach ($tasks as $task) {
- if (! $this->taskDuplication->duplicateToProject($task['id'], $clone_project_id)) {
- return false;
- }
+ if (! $this->projectUserRole->addUser($dst_project_id, $owner_id, Role::PROJECT_MANAGER)) {
+ return false;
}
}
- return (int) $clone_project_id;
+ return true;
}
}
diff --git a/app/Model/Subtask.php b/app/Model/Subtask.php
index 0e039bb3..14853941 100644
--- a/app/Model/Subtask.php
+++ b/app/Model/Subtask.php
@@ -353,15 +353,16 @@ class Subtask extends Base
*
* @access public
* @param integer $subtask_id
- * @return bool
+ * @return boolean|integer
*/
public function toggleStatus($subtask_id)
{
$subtask = $this->getById($subtask_id);
+ $status = ($subtask['status'] + 1) % 3;
$values = array(
'id' => $subtask['id'],
- 'status' => ($subtask['status'] + 1) % 3,
+ 'status' => $status,
'task_id' => $subtask['task_id'],
);
@@ -369,7 +370,7 @@ class Subtask extends Base
$values['user_id'] = $this->userSession->getId();
}
- return $this->update($values);
+ return $this->update($values) ? $status : false;
}
/**
@@ -435,10 +436,10 @@ class Subtask extends Base
return $this->db->transaction(function (Database $db) use ($src_task_id, $dst_task_id) {
$subtasks = $db->table(Subtask::TABLE)
- ->columns('title', 'time_estimated', 'position')
- ->eq('task_id', $src_task_id)
- ->asc('position')
- ->findAll();
+ ->columns('title', 'time_estimated', 'position')
+ ->eq('task_id', $src_task_id)
+ ->asc('position')
+ ->findAll();
foreach ($subtasks as &$subtask) {
$subtask['task_id'] = $dst_task_id;
diff --git a/app/Model/SubtaskTimeTracking.php b/app/Model/SubtaskTimeTracking.php
index a741dbb5..b766b542 100644
--- a/app/Model/SubtaskTimeTracking.php
+++ b/app/Model/SubtaskTimeTracking.php
@@ -302,11 +302,11 @@ class SubtaskTimeTracking extends Base
{
$hook = 'model:subtask-time-tracking:calculate:time-spent';
$start_time = $this->db
- ->table(self::TABLE)
- ->eq('subtask_id', $subtask_id)
- ->eq('user_id', $user_id)
- ->eq('end', 0)
- ->findOneColumn('start');
+ ->table(self::TABLE)
+ ->eq('subtask_id', $subtask_id)
+ ->eq('user_id', $user_id)
+ ->eq('end', 0)
+ ->findOneColumn('start');
if (empty($start_time)) {
return 0;
diff --git a/app/Model/Swimlane.php b/app/Model/Swimlane.php
index e5124e8e..6b0dcdc5 100644
--- a/app/Model/Swimlane.php
+++ b/app/Model/Swimlane.php
@@ -96,10 +96,11 @@ class Swimlane extends Base
*/
public function getDefault($project_id)
{
- $result = $this->db->table(Project::TABLE)
- ->eq('id', $project_id)
- ->columns('id', 'default_swimlane', 'show_default_swimlane')
- ->findOne();
+ $result = $this->db
+ ->table(Project::TABLE)
+ ->eq('id', $project_id)
+ ->columns('id', 'default_swimlane', 'show_default_swimlane')
+ ->findOne();
if ($result['default_swimlane'] === 'Default swimlane') {
$result['default_swimlane'] = t($result['default_swimlane']);
@@ -117,10 +118,11 @@ class Swimlane extends Base
*/
public function getAll($project_id)
{
- return $this->db->table(self::TABLE)
- ->eq('project_id', $project_id)
- ->orderBy('position', 'asc')
- ->findAll();
+ return $this->db
+ ->table(self::TABLE)
+ ->eq('project_id', $project_id)
+ ->orderBy('position', 'asc')
+ ->findAll();
}
/**
@@ -133,9 +135,10 @@ class Swimlane extends Base
*/
public function getAllByStatus($project_id, $status = self::ACTIVE)
{
- $query = $this->db->table(self::TABLE)
- ->eq('project_id', $project_id)
- ->eq('is_active', $status);
+ $query = $this->db
+ ->table(self::TABLE)
+ ->eq('project_id', $project_id)
+ ->eq('is_active', $status);
if ($status == self::ACTIVE) {
$query->asc('position');
@@ -155,17 +158,19 @@ class Swimlane extends Base
*/
public function getSwimlanes($project_id)
{
- $swimlanes = $this->db->table(self::TABLE)
- ->columns('id', 'name', 'description')
- ->eq('project_id', $project_id)
- ->eq('is_active', self::ACTIVE)
- ->orderBy('position', 'asc')
- ->findAll();
-
- $default_swimlane = $this->db->table(Project::TABLE)
- ->eq('id', $project_id)
- ->eq('show_default_swimlane', 1)
- ->findOneColumn('default_swimlane');
+ $swimlanes = $this->db
+ ->table(self::TABLE)
+ ->columns('id', 'name', 'description')
+ ->eq('project_id', $project_id)
+ ->eq('is_active', self::ACTIVE)
+ ->orderBy('position', 'asc')
+ ->findAll();
+
+ $default_swimlane = $this->db
+ ->table(Project::TABLE)
+ ->eq('id', $project_id)
+ ->eq('show_default_swimlane', 1)
+ ->findOneColumn('default_swimlane');
if ($default_swimlane) {
if ($default_swimlane === 'Default swimlane') {
@@ -200,11 +205,12 @@ class Swimlane extends Base
$swimlanes[0] = $default === 'Default swimlane' ? t($default) : $default;
}
- return $swimlanes + $this->db->hashtable(self::TABLE)
- ->eq('project_id', $project_id)
- ->in('is_active', $only_active ? array(self::ACTIVE) : array(self::ACTIVE, self::INACTIVE))
- ->orderBy('position', 'asc')
- ->getAll('id', 'name');
+ return $swimlanes + $this->db
+ ->hashtable(self::TABLE)
+ ->eq('project_id', $project_id)
+ ->in('is_active', $only_active ? array(self::ACTIVE) : array(self::ACTIVE, self::INACTIVE))
+ ->orderBy('position', 'asc')
+ ->getAll('id', 'name');
}
/**
@@ -232,9 +238,10 @@ class Swimlane extends Base
*/
public function update(array $values)
{
- return $this->db->table(self::TABLE)
- ->eq('id', $values['id'])
- ->update($values);
+ return $this->db
+ ->table(self::TABLE)
+ ->eq('id', $values['id'])
+ ->update($values);
}
/**
@@ -247,12 +254,12 @@ class Swimlane extends Base
public function updateDefault(array $values)
{
return $this->db
- ->table(Project::TABLE)
- ->eq('id', $values['id'])
- ->update(array(
- 'default_swimlane' => $values['default_swimlane'],
- 'show_default_swimlane' => $values['show_default_swimlane'],
- ));
+ ->table(Project::TABLE)
+ ->eq('id', $values['id'])
+ ->update(array(
+ 'default_swimlane' => $values['default_swimlane'],
+ 'show_default_swimlane' => $values['show_default_swimlane'],
+ ));
}
/**
@@ -264,10 +271,11 @@ class Swimlane extends Base
*/
public function getLastPosition($project_id)
{
- return $this->db->table(self::TABLE)
- ->eq('project_id', $project_id)
- ->eq('is_active', 1)
- ->count() + 1;
+ return $this->db
+ ->table(self::TABLE)
+ ->eq('project_id', $project_id)
+ ->eq('is_active', 1)
+ ->count() + 1;
}
/**
@@ -281,12 +289,12 @@ class Swimlane extends Base
public function disable($project_id, $swimlane_id)
{
$result = $this->db
- ->table(self::TABLE)
- ->eq('id', $swimlane_id)
- ->update(array(
- 'is_active' => self::INACTIVE,
- 'position' => 0,
- ));
+ ->table(self::TABLE)
+ ->eq('id', $swimlane_id)
+ ->update(array(
+ 'is_active' => self::INACTIVE,
+ 'position' => 0,
+ ));
if ($result) {
// Re-order positions
@@ -307,12 +315,12 @@ class Swimlane extends Base
public function enable($project_id, $swimlane_id)
{
return $this->db
- ->table(self::TABLE)
- ->eq('id', $swimlane_id)
- ->update(array(
- 'is_active' => self::ACTIVE,
- 'position' => $this->getLastPosition($project_id),
- ));
+ ->table(self::TABLE)
+ ->eq('id', $swimlane_id)
+ ->update(array(
+ 'is_active' => self::ACTIVE,
+ 'position' => $this->getLastPosition($project_id),
+ ));
}
/**
@@ -353,11 +361,12 @@ class Swimlane extends Base
public function updatePositions($project_id)
{
$position = 0;
- $swimlanes = $this->db->table(self::TABLE)
- ->eq('project_id', $project_id)
- ->eq('is_active', 1)
- ->asc('position')
- ->findAllByColumn('id');
+ $swimlanes = $this->db
+ ->table(self::TABLE)
+ ->eq('project_id', $project_id)
+ ->eq('is_active', 1)
+ ->asc('position')
+ ->findAllByColumn('id');
if (! $swimlanes) {
return false;
@@ -365,8 +374,8 @@ class Swimlane extends Base
foreach ($swimlanes as $swimlane_id) {
$this->db->table(self::TABLE)
- ->eq('id', $swimlane_id)
- ->update(array('position' => ++$position));
+ ->eq('id', $swimlane_id)
+ ->update(array('position' => ++$position));
}
return true;
@@ -383,10 +392,10 @@ class Swimlane extends Base
public function moveDown($project_id, $swimlane_id)
{
$swimlanes = $this->db->hashtable(self::TABLE)
- ->eq('project_id', $project_id)
- ->eq('is_active', self::ACTIVE)
- ->asc('position')
- ->getAll('id', 'position');
+ ->eq('project_id', $project_id)
+ ->eq('is_active', self::ACTIVE)
+ ->asc('position')
+ ->getAll('id', 'position');
$positions = array_flip($swimlanes);
@@ -416,10 +425,10 @@ class Swimlane extends Base
public function moveUp($project_id, $swimlane_id)
{
$swimlanes = $this->db->hashtable(self::TABLE)
- ->eq('project_id', $project_id)
- ->eq('is_active', self::ACTIVE)
- ->asc('position')
- ->getAll('id', 'position');
+ ->eq('project_id', $project_id)
+ ->eq('is_active', self::ACTIVE)
+ ->asc('position')
+ ->getAll('id', 'position');
$positions = array_flip($swimlanes);
diff --git a/app/Model/Task.php b/app/Model/Task.php
index 7aa9e312..38fdd0d5 100644
--- a/app/Model/Task.php
+++ b/app/Model/Task.php
@@ -42,6 +42,7 @@ class Task extends Base
const EVENT_ASSIGNEE_CHANGE = 'task.assignee_change';
const EVENT_OVERDUE = 'task.overdue';
const EVENT_USER_MENTION = 'task.user.mention';
+ const EVENT_DAILY_CRONJOB = 'task.cronjob.daily';
/**
* Recurrence: status
@@ -198,4 +199,25 @@ class Task extends Base
return round(($position * 100) / count($columns), 1);
}
+
+ /**
+ * Helper method to duplicate all tasks to another project
+ *
+ * @access public
+ * @param integer $src_project_id
+ * @param integer $dst_project_id
+ * @return boolean
+ */
+ public function duplicate($src_project_id, $dst_project_id)
+ {
+ $task_ids = $this->taskFinder->getAllIds($src_project_id, array(Task::STATUS_OPEN, Task::STATUS_CLOSED));
+
+ foreach ($task_ids as $task_id) {
+ if (! $this->taskDuplication->duplicateToProject($task_id, $dst_project_id)) {
+ return false;
+ }
+ }
+
+ return true;
+ }
}
diff --git a/app/Model/TaskExternalLink.php b/app/Model/TaskExternalLink.php
new file mode 100644
index 00000000..f2c756b4
--- /dev/null
+++ b/app/Model/TaskExternalLink.php
@@ -0,0 +1,99 @@
+<?php
+
+namespace Kanboard\Model;
+
+/**
+ * Task External Link Model
+ *
+ * @package model
+ * @author Frederic Guillot
+ */
+class TaskExternalLink extends Base
+{
+ /**
+ * SQL table name
+ *
+ * @var string
+ */
+ const TABLE = 'task_has_external_links';
+
+ /**
+ * Get all links
+ *
+ * @access public
+ * @param integer $task_id
+ * @return array
+ */
+ public function getAll($task_id)
+ {
+ $types = $this->externalLinkManager->getTypes();
+
+ $links = $this->db->table(self::TABLE)
+ ->columns(self::TABLE.'.*', User::TABLE.'.name AS creator_name', User::TABLE.'.username AS creator_username')
+ ->eq('task_id', $task_id)
+ ->asc('title')
+ ->join(User::TABLE, 'id', 'creator_id')
+ ->findAll();
+
+ foreach ($links as &$link) {
+ $link['dependency_label'] = $this->externalLinkManager->getDependencyLabel($link['link_type'], $link['dependency']);
+ $link['type'] = isset($types[$link['link_type']]) ? $types[$link['link_type']] : t('Unknown');
+ }
+
+ return $links;
+ }
+
+ /**
+ * Get link
+ *
+ * @access public
+ * @param integer $link_id
+ * @return array
+ */
+ public function getById($link_id)
+ {
+ return $this->db->table(self::TABLE)->eq('id', $link_id)->findOne();
+ }
+
+ /**
+ * Add a new link in the database
+ *
+ * @access public
+ * @param array $values Form values
+ * @return boolean|integer
+ */
+ public function create(array $values)
+ {
+ unset($values['id']);
+ $values['creator_id'] = $this->userSession->getId();
+ $values['date_creation'] = time();
+ $values['date_modification'] = $values['date_creation'];
+
+ return $this->persist(self::TABLE, $values);
+ }
+
+ /**
+ * Modify external link
+ *
+ * @access public
+ * @param array $values Form values
+ * @return boolean
+ */
+ public function update(array $values)
+ {
+ $values['date_modification'] = time();
+ return $this->db->table(self::TABLE)->eq('id', $values['id'])->update($values);
+ }
+
+ /**
+ * Remove a link
+ *
+ * @access public
+ * @param integer $link_id
+ * @return boolean
+ */
+ public function remove($link_id)
+ {
+ return $this->db->table(self::TABLE)->eq('id', $link_id)->remove();
+ }
+}
diff --git a/app/Model/TaskFinder.php b/app/Model/TaskFinder.php
index 1c83136b..4d673097 100644
--- a/app/Model/TaskFinder.php
+++ b/app/Model/TaskFinder.php
@@ -88,11 +88,12 @@ class TaskFinder extends Base
return $this->db
->table(Task::TABLE)
->columns(
- '(SELECT count(*) FROM '.Comment::TABLE.' WHERE task_id=tasks.id) AS nb_comments',
- '(SELECT count(*) FROM '.File::TABLE.' WHERE task_id=tasks.id) AS nb_files',
- '(SELECT count(*) FROM '.Subtask::TABLE.' WHERE '.Subtask::TABLE.'.task_id=tasks.id) AS nb_subtasks',
- '(SELECT count(*) FROM '.Subtask::TABLE.' WHERE '.Subtask::TABLE.'.task_id=tasks.id AND status=2) AS nb_completed_subtasks',
- '(SELECT count(*) FROM '.TaskLink::TABLE.' WHERE '.TaskLink::TABLE.'.task_id = tasks.id) AS nb_links',
+ '(SELECT COUNT(*) FROM '.Comment::TABLE.' WHERE task_id=tasks.id) AS nb_comments',
+ '(SELECT COUNT(*) FROM '.File::TABLE.' WHERE task_id=tasks.id) AS nb_files',
+ '(SELECT COUNT(*) FROM '.Subtask::TABLE.' WHERE '.Subtask::TABLE.'.task_id=tasks.id) AS nb_subtasks',
+ '(SELECT COUNT(*) FROM '.Subtask::TABLE.' WHERE '.Subtask::TABLE.'.task_id=tasks.id AND status=2) AS nb_completed_subtasks',
+ '(SELECT COUNT(*) FROM '.TaskLink::TABLE.' WHERE '.TaskLink::TABLE.'.task_id = tasks.id) AS nb_links',
+ '(SELECT COUNT(*) FROM '.TaskExternalLink::TABLE.' WHERE '.TaskExternalLink::TABLE.'.task_id = tasks.id) AS nb_external_links',
'(SELECT DISTINCT 1 FROM '.TaskLink::TABLE.' WHERE '.TaskLink::TABLE.'.task_id = tasks.id AND '.TaskLink::TABLE.'.link_id = 9) AS is_milestone',
'tasks.id',
'tasks.reference',
@@ -179,6 +180,23 @@ class TaskFinder extends Base
}
/**
+ * Get all tasks for a given project and status
+ *
+ * @access public
+ * @param integer $project_id
+ * @param array $status
+ * @return array
+ */
+ public function getAllIds($project_id, array $status = array(Task::STATUS_OPEN))
+ {
+ return $this->db
+ ->table(Task::TABLE)
+ ->eq(Task::TABLE.'.project_id', $project_id)
+ ->in(Task::TABLE.'.is_active', $status)
+ ->findAllByColumn('id');
+ }
+
+ /**
* Get overdue tasks query
*
* @access public
diff --git a/app/Model/TaskLink.php b/app/Model/TaskLink.php
index 87aae55e..034fcf45 100644
--- a/app/Model/TaskLink.php
+++ b/app/Model/TaskLink.php
@@ -75,6 +75,7 @@ class TaskLink extends Base
Task::TABLE.'.title',
Task::TABLE.'.is_active',
Task::TABLE.'.project_id',
+ Task::TABLE.'.column_id',
Task::TABLE.'.time_spent AS task_time_spent',
Task::TABLE.'.time_estimated AS task_time_estimated',
Task::TABLE.'.owner_id AS task_assignee_id',
diff --git a/app/Model/User.php b/app/Model/User.php
index ac0e7491..dd622207 100644
--- a/app/Model/User.php
+++ b/app/Model/User.php
@@ -48,20 +48,7 @@ class User extends Base
*/
public function getQuery()
{
- return $this->db
- ->table(self::TABLE)
- ->columns(
- 'id',
- 'username',
- 'name',
- 'email',
- 'role',
- 'is_ldap_user',
- 'notifications_enabled',
- 'google_id',
- 'github_id',
- 'twofactor_activated'
- );
+ return $this->db->table(self::TABLE);
}
/**
@@ -278,7 +265,7 @@ class User extends Base
*
* @access public
* @param array $values Form values
- * @return array
+ * @return boolean
*/
public function update(array $values)
{