diff options
Diffstat (limited to 'app/Model')
-rw-r--r-- | app/Model/ColumnMoveRestrictionModel.php | 8 | ||||
-rw-r--r-- | app/Model/CurrencyModel.php | 4 | ||||
-rw-r--r-- | app/Model/LanguageModel.php | 12 | ||||
-rw-r--r-- | app/Model/PredefinedTaskDescriptionModel.php | 52 | ||||
-rw-r--r-- | app/Model/ProjectActivityModel.php | 9 | ||||
-rw-r--r-- | app/Model/ProjectGroupRoleModel.php | 8 | ||||
-rw-r--r-- | app/Model/ProjectModel.php | 43 | ||||
-rw-r--r-- | app/Model/ProjectPermissionModel.php | 28 | ||||
-rw-r--r-- | app/Model/ProjectRoleRestrictionModel.php | 18 | ||||
-rw-r--r-- | app/Model/ProjectUserRoleModel.php | 24 | ||||
-rw-r--r-- | app/Model/SubtaskModel.php | 81 | ||||
-rw-r--r-- | app/Model/TaskCreationModel.php | 2 | ||||
-rw-r--r-- | app/Model/TaskDuplicationModel.php | 5 | ||||
-rw-r--r-- | app/Model/TaskFinderModel.php | 26 | ||||
-rw-r--r-- | app/Model/TaskModificationModel.php | 2 | ||||
-rw-r--r-- | app/Model/TaskPositionModel.php | 12 | ||||
-rw-r--r-- | app/Model/UserModel.php | 16 | ||||
-rw-r--r-- | app/Model/UserNotificationModel.php | 22 |
18 files changed, 209 insertions, 163 deletions
diff --git a/app/Model/ColumnMoveRestrictionModel.php b/app/Model/ColumnMoveRestrictionModel.php index c2603efd..9d2b2842 100644 --- a/app/Model/ColumnMoveRestrictionModel.php +++ b/app/Model/ColumnMoveRestrictionModel.php @@ -31,6 +31,7 @@ class ColumnMoveRestrictionModel extends Base self::TABLE.'.role_id', self::TABLE.'.src_column_id', self::TABLE.'.dst_column_id', + self::TABLE.'.only_assigned', 'pr.role', 'sc.title as src_column_title', 'dc.title as dst_column_title' @@ -59,6 +60,7 @@ class ColumnMoveRestrictionModel extends Base self::TABLE.'.role_id', self::TABLE.'.src_column_id', self::TABLE.'.dst_column_id', + self::TABLE.'.only_assigned', 'pr.role', 'sc.title as src_column_title', 'dc.title as dst_column_title' @@ -81,7 +83,7 @@ class ColumnMoveRestrictionModel extends Base { return $this->db ->table(self::TABLE) - ->columns(self::TABLE.'.src_column_id', self::TABLE.'.dst_column_id') + ->columns(self::TABLE.'.src_column_id', self::TABLE.'.dst_column_id', self::TABLE.'.only_assigned') ->left(ProjectRoleModel::TABLE, 'pr', 'role_id', self::TABLE, 'role_id') ->eq(self::TABLE.'.project_id', $project_id) ->eq('pr.role', $role) @@ -95,9 +97,10 @@ class ColumnMoveRestrictionModel extends Base * @param int $role_id * @param int $src_column_id * @param int $dst_column_id + * @param bool $only_assigned * @return bool|int */ - public function create($project_id, $role_id, $src_column_id, $dst_column_id) + public function create($project_id, $role_id, $src_column_id, $dst_column_id, $only_assigned = false) { return $this->db ->table(self::TABLE) @@ -106,6 +109,7 @@ class ColumnMoveRestrictionModel extends Base 'role_id' => $role_id, 'src_column_id' => $src_column_id, 'dst_column_id' => $dst_column_id, + 'only_assigned' => (int) $only_assigned, )); } diff --git a/app/Model/CurrencyModel.php b/app/Model/CurrencyModel.php index c858a6ae..6f009f61 100644 --- a/app/Model/CurrencyModel.php +++ b/app/Model/CurrencyModel.php @@ -38,6 +38,7 @@ class CurrencyModel extends Base 'INR' => t('INR - Indian Rupee'), 'JPY' => t('JPY - Japanese Yen'), 'RSD' => t('RSD - Serbian dinar'), + 'DKK' => t('DKK - Danish Krona'), 'SEK' => t('SEK - Swedish Krona'), 'NOK' => t('NOK - Norwegian Krone'), 'BAM' => t('BAM - Konvertible Mark'), @@ -45,6 +46,9 @@ class CurrencyModel extends Base 'CNY' => t('CNY - Chinese Yuan'), 'TRL' => t('TRL - Turkish Lira'), 'HRK' => t('HRK - Kuna'), + 'ARS' => t('ARS - Argentine Peso'), + 'COP' => t('COP - Colombian Peso'), + 'BRL' => t('BRL - Brazilian Real'), ); } diff --git a/app/Model/LanguageModel.php b/app/Model/LanguageModel.php index 7b12cac8..eff2191d 100644 --- a/app/Model/LanguageModel.php +++ b/app/Model/LanguageModel.php @@ -25,6 +25,7 @@ class LanguageModel extends Base return array( 'id_ID', 'bs_BA', + 'ca_ES', 'cs_CZ', 'da_DK', 'de_DE', @@ -41,6 +42,7 @@ class LanguageModel extends Base 'pl_PL', 'pt_PT', 'pt_BR', + 'ro_RO', 'ru_RU', 'sr_Latn_RS', 'fi_FI', @@ -50,6 +52,7 @@ class LanguageModel extends Base 'zh_CN', 'ja_JP', 'th_TH', + 'vi_VN', ); } @@ -80,6 +83,7 @@ class LanguageModel extends Base $languages = array( 'id_ID' => 'Bahasa Indonesia', 'bs_BA' => 'Bosanski', + 'ca_ES' => 'Català', 'cs_CZ' => 'Čeština', 'da_DK' => 'Dansk', 'de_DE' => 'Deutsch', @@ -96,6 +100,7 @@ class LanguageModel extends Base 'pl_PL' => 'Polski', 'pt_PT' => 'Português', 'pt_BR' => 'Português (Brasil)', + 'ro_RO' => 'Română', 'ru_RU' => 'Русский', 'sr_Latn_RS' => 'Srpski', 'fi_FI' => 'Suomi', @@ -105,6 +110,7 @@ class LanguageModel extends Base 'zh_CN' => '中文(简体)', 'ja_JP' => '日本語', 'th_TH' => 'ไทย', + 'vi_VN' => 'Tiếng Việt', ); if ($prepend) { @@ -124,6 +130,7 @@ class LanguageModel extends Base { $languages = array( 'cs_CZ' => 'cs', + 'ca_ES' => 'ca', 'da_DK' => 'da', 'de_DE' => 'de', 'en_US' => 'en', @@ -136,14 +143,15 @@ class LanguageModel extends Base 'nb_NO' => 'nb', 'pl_PL' => 'pl', 'pt_PT' => 'pt', - 'pt_BR' => 'pt-br', + 'pt_BR' => 'pt-BR', + 'ro_RO' => 'ro', 'ru_RU' => 'ru', 'sr_Latn_RS' => 'sr', 'fi_FI' => 'fi', 'sv_SE' => 'sv', 'tr_TR' => 'tr', 'ko_KR' => 'ko', - 'zh_CN' => 'zh-cn', + 'zh_CN' => 'zh-CN', 'ja_JP' => 'ja', 'th_TH' => 'th', 'id_ID' => 'id', diff --git a/app/Model/PredefinedTaskDescriptionModel.php b/app/Model/PredefinedTaskDescriptionModel.php new file mode 100644 index 00000000..aaa4d23e --- /dev/null +++ b/app/Model/PredefinedTaskDescriptionModel.php @@ -0,0 +1,52 @@ +<?php + +namespace Kanboard\Model; + +use Kanboard\Core\Base; + +class PredefinedTaskDescriptionModel extends Base +{ + const TABLE = 'predefined_task_descriptions'; + + public function getAll($projectId) + { + return $this->db->table(self::TABLE)->eq('project_id', $projectId)->findAll(); + } + + public function getList($projectId) + { + return array('' => t('None')) + $this->db->hashtable(self::TABLE)->eq('project_id', $projectId)->getAll('id', 'title'); + } + + public function getById($projectId, $id) + { + return $this->db->table(self::TABLE)->eq('project_id', $projectId)->eq('id', $id)->findOne(); + } + + public function getDescriptionById($projectId, $id) + { + return $this->db->table(self::TABLE)->eq('project_id', $projectId)->eq('id', $id)->findOneColumn('description'); + } + + public function create($projectId, $title, $description) + { + return $this->db->table(self::TABLE)->persist(array( + 'project_id' => $projectId, + 'title' => $title, + 'description' => $description, + )); + } + + public function update($projectId, $id, $title, $description) + { + return $this->db->table(self::TABLE)->eq('project_id', $projectId)->eq('id', $id)->update(array( + 'title' => $title, + 'description' => $description, + )); + } + + public function remove($projectId, $id) + { + return $this->db->table(self::TABLE)->eq('project_id', $projectId)->eq('id', $id)->remove(); + } +} diff --git a/app/Model/ProjectActivityModel.php b/app/Model/ProjectActivityModel.php index 380ea125..17cf6485 100644 --- a/app/Model/ProjectActivityModel.php +++ b/app/Model/ProjectActivityModel.php @@ -21,13 +21,6 @@ class ProjectActivityModel extends Base const TABLE = 'project_activities'; /** - * Maximum number of events - * - * @var integer - */ - const MAX_EVENTS = 1000; - - /** * Add a new event for the project * * @access public @@ -49,7 +42,7 @@ class ProjectActivityModel extends Base 'data' => json_encode($data), ); - $this->cleanup(self::MAX_EVENTS - 1); + $this->cleanup(PROJECT_ACTIVITIES_MAX_EVENTS - 1); return $this->db->table(self::TABLE)->insert($values); } diff --git a/app/Model/ProjectGroupRoleModel.php b/app/Model/ProjectGroupRoleModel.php index 2729d5a6..2b1973f5 100644 --- a/app/Model/ProjectGroupRoleModel.php +++ b/app/Model/ProjectGroupRoleModel.php @@ -85,7 +85,13 @@ class ProjectGroupRoleModel extends Base public function getUsers($project_id) { return $this->db->table(self::TABLE) - ->columns(UserModel::TABLE.'.id', UserModel::TABLE.'.username', UserModel::TABLE.'.name', self::TABLE.'.role') + ->columns( + UserModel::TABLE.'.id', + UserModel::TABLE.'.username', + UserModel::TABLE.'.name', + UserModel::TABLE.'.email', + self::TABLE.'.role' + ) ->join(GroupMemberModel::TABLE, 'group_id', 'group_id', self::TABLE) ->join(UserModel::TABLE, 'id', 'user_id', GroupMemberModel::TABLE) ->eq(self::TABLE.'.project_id', $project_id) diff --git a/app/Model/ProjectModel.php b/app/Model/ProjectModel.php index aa7c002d..097806d8 100644 --- a/app/Model/ProjectModel.php +++ b/app/Model/ProjectModel.php @@ -202,16 +202,23 @@ class ProjectModel extends Base * Return the list of all projects * * @access public - * @param bool $prepend If true, prepend to the list the value 'None' + * @param bool $prependNone + * @param bool $noPrivateProjects * @return array */ - public function getList($prepend = true) + public function getList($prependNone = true, $noPrivateProjects = true) { - if ($prepend) { - return array(t('None')) + $this->db->hashtable(self::TABLE)->asc('name')->getAll('id', 'name'); + if ($noPrivateProjects) { + $projects = $this->db->hashtable(self::TABLE)->eq('is_private', 0)->asc('name')->getAll('id', 'name'); + } else { + $projects = $this->db->hashtable(self::TABLE)->asc('name')->getAll('id', 'name'); } - return $this->db->hashtable(self::TABLE)->asc('name')->getAll('id', 'name'); + if ($prependNone) { + return array(t('None')) + $projects; + } + + return $projects; } /** @@ -310,11 +317,11 @@ class ProjectModel extends Base } return $this->db - ->table(ProjectModel::TABLE) - ->columns(self::TABLE.'.*', UserModel::TABLE.'.username AS owner_username', UserModel::TABLE.'.name AS owner_name') - ->join(UserModel::TABLE, 'id', 'owner_id') - ->in(self::TABLE.'.id', $project_ids) - ->callback(array($this, 'applyColumnStats')); + ->table(ProjectModel::TABLE) + ->columns(self::TABLE.'.*', UserModel::TABLE.'.username AS owner_username', UserModel::TABLE.'.name AS owner_name') + ->join(UserModel::TABLE, 'id', 'owner_id') + ->in(self::TABLE.'.id', $project_ids) + ->callback(array($this, 'applyColumnStats')); } /** @@ -348,6 +355,10 @@ class ProjectModel extends Base */ public function create(array $values, $userId = 0, $addUser = false) { + if (! empty($userId) && ! $this->userModel->exists($userId)) { + return false; + } + $this->db->startTransaction(); $values['token'] = ''; @@ -440,6 +451,10 @@ class ProjectModel extends Base $values['end_date'] = $this->dateParser->getIsoDate($values['end_date']); } + if (! empty($values['owner_id']) && ! $this->userModel->exists($values['owner_id'])) { + return false; + } + $this->helper->model->convertIntegerFields($values, array('priority_default', 'priority_start', 'priority_end')); return $this->exists($values['id']) && @@ -455,7 +470,13 @@ class ProjectModel extends Base */ public function remove($project_id) { - return $this->db->table(self::TABLE)->eq('id', $project_id)->remove(); + $this->db->startTransaction(); + + $this->db->table(TagModel::TABLE)->eq('project_id', $project_id)->remove(); + $result = $this->db->table(self::TABLE)->eq('id', $project_id)->remove(); + + $this->db->closeTransaction(); + return $result; } /** diff --git a/app/Model/ProjectPermissionModel.php b/app/Model/ProjectPermissionModel.php index dabd406c..d1351a6c 100644 --- a/app/Model/ProjectPermissionModel.php +++ b/app/Model/ProjectPermissionModel.php @@ -93,20 +93,22 @@ class ProjectPermissionModel extends Base return $members; } - /** - * Return true if everybody is allowed for the project - * - * @access public - * @param integer $project_id Project id - * @return bool - */ - public function isEverybodyAllowed($project_id) + public function getMembers($project_id) + { + $userMembers = $this->projectUserRoleModel->getUsers($project_id); + $groupMembers = $this->projectGroupRoleModel->getUsers($project_id); + + $userMembers = array_column_index_unique($userMembers, 'username'); + $groupMembers = array_column_index_unique($groupMembers, 'username'); + return array_merge($userMembers, $groupMembers); + } + + public function getMembersWithEmail($project_id) { - return $this->db - ->table(ProjectModel::TABLE) - ->eq('id', $project_id) - ->eq('is_everybody_allowed', 1) - ->exists(); + $members = $this->getMembers($project_id); + return array_filter($members, function (array $user) { + return ! empty($user['email']); + }); } /** diff --git a/app/Model/ProjectRoleRestrictionModel.php b/app/Model/ProjectRoleRestrictionModel.php index 8ccdcf9c..45e7ed2f 100644 --- a/app/Model/ProjectRoleRestrictionModel.php +++ b/app/Model/ProjectRoleRestrictionModel.php @@ -14,9 +14,12 @@ class ProjectRoleRestrictionModel extends Base { const TABLE = 'project_role_has_restrictions'; - const RULE_TASK_CREATION = 'task_creation'; - const RULE_TASK_OPEN_CLOSE = 'task_open_close'; - const RULE_TASK_MOVE = 'task_move'; + const RULE_TASK_CREATION = 'task_creation'; + const RULE_TASK_SUPPRESSION = 'task_remove'; + const RULE_TASK_OPEN_CLOSE = 'task_open_close'; + const RULE_TASK_MOVE = 'task_move'; + const RULE_TASK_CHANGE_ASSIGNEE = 'task_change_assignee'; + const RULE_TASK_UPDATE_ASSIGNED = 'task_update_assigned'; /** * Get rules @@ -26,9 +29,12 @@ class ProjectRoleRestrictionModel extends Base public function getRules() { return array( - self::RULE_TASK_CREATION => t('Task creation is not permitted'), - self::RULE_TASK_OPEN_CLOSE => t('Closing or opening a task is not permitted'), - self::RULE_TASK_MOVE => t('Moving a task is not permitted'), + self::RULE_TASK_CREATION => t('Task creation is not permitted'), + self::RULE_TASK_SUPPRESSION => t('Task suppression is not permitted'), + self::RULE_TASK_OPEN_CLOSE => t('Closing or opening a task is not permitted'), + self::RULE_TASK_MOVE => t('Moving a task is not permitted'), + self::RULE_TASK_CHANGE_ASSIGNEE => t('Changing assignee is not permitted'), + self::RULE_TASK_UPDATE_ASSIGNED => t('Update only assigned tasks is permitted'), ); } diff --git a/app/Model/ProjectUserRoleModel.php b/app/Model/ProjectUserRoleModel.php index 76094431..dc4add34 100644 --- a/app/Model/ProjectUserRoleModel.php +++ b/app/Model/ProjectUserRoleModel.php @@ -44,10 +44,7 @@ class ProjectUserRoleModel extends Base { $userProjects = $this->db ->hashtable(ProjectModel::TABLE) - ->beginOr() ->eq(self::TABLE.'.user_id', $user_id) - ->eq(ProjectModel::TABLE.'.is_everybody_allowed', 1) - ->closeOr() ->in(ProjectModel::TABLE.'.is_active', $status) ->join(self::TABLE, 'project_id', 'id') ->getAll(ProjectModel::TABLE.'.id', ProjectModel::TABLE.'.name'); @@ -70,15 +67,6 @@ class ProjectUserRoleModel extends Base */ public function getUserRole($project_id, $user_id) { - $projectInfo = $this->db->table(ProjectModel::TABLE) - ->eq('id', $project_id) - ->columns('owner_id', 'is_everybody_allowed') - ->findOne(); - - if ($projectInfo['is_everybody_allowed'] == 1) { - return $projectInfo['owner_id'] == $user_id ? Role::PROJECT_MANAGER : Role::PROJECT_MEMBER; - } - $role = $this->db->table(self::TABLE)->eq('user_id', $user_id)->eq('project_id', $project_id)->findOneColumn('role'); if (empty($role)) { @@ -98,7 +86,13 @@ class ProjectUserRoleModel extends Base public function getUsers($project_id) { return $this->db->table(self::TABLE) - ->columns(UserModel::TABLE.'.id', UserModel::TABLE.'.username', UserModel::TABLE.'.name', self::TABLE.'.role') + ->columns( + UserModel::TABLE.'.id', + UserModel::TABLE.'.username', + UserModel::TABLE.'.name', + UserModel::TABLE.'.email', + self::TABLE.'.role' + ) ->join(UserModel::TABLE, 'id', 'user_id') ->eq('project_id', $project_id) ->asc(UserModel::TABLE.'.username') @@ -157,10 +151,6 @@ class ProjectUserRoleModel extends Base */ public function getAssignableUsers($project_id) { - if ($this->projectPermissionModel->isEverybodyAllowed($project_id)) { - return $this->userModel->getActiveUsersList(); - } - $userMembers = $this->db->table(self::TABLE) ->columns(UserModel::TABLE.'.id', UserModel::TABLE.'.username', UserModel::TABLE.'.name') ->join(UserModel::TABLE, 'id', 'user_id') diff --git a/app/Model/SubtaskModel.php b/app/Model/SubtaskModel.php index c62ddb53..1e652ae2 100644 --- a/app/Model/SubtaskModel.php +++ b/app/Model/SubtaskModel.php @@ -70,35 +70,6 @@ class SubtaskModel extends Base } /** - * Get the query to fetch subtasks assigned to a user - * - * @access public - * @param integer $userId - * @param array $status - * @return \PicoDb\Table - */ - public function getUserQuery($userId, array $status) - { - return $this->db->table(SubtaskModel::TABLE) - ->columns( - SubtaskModel::TABLE.'.*', - TaskModel::TABLE.'.project_id', - TaskModel::TABLE.'.color_id', - TaskModel::TABLE.'.title AS task_name', - ProjectModel::TABLE.'.name AS project_name' - ) - ->subquery($this->subtaskTimeTrackingModel->getTimerQuery($userId), 'timer_start_date') - ->eq('user_id', $userId) - ->eq(ProjectModel::TABLE.'.is_active', ProjectModel::ACTIVE) - ->eq(ColumnModel::TABLE.'.hide_in_dashboard', 0) - ->in(SubtaskModel::TABLE.'.status', $status) - ->join(TaskModel::TABLE, 'id', 'task_id') - ->join(ProjectModel::TABLE, 'id', 'project_id', TaskModel::TABLE) - ->join(ColumnModel::TABLE, 'id', 'column_id', TaskModel::TABLE) - ->callback(array($this, 'addStatusName')); - } - - /** * Get common query * * @return \PicoDb\Table @@ -117,6 +88,15 @@ class SubtaskModel extends Base ->asc(self::TABLE.'.position'); } + public function countByAssigneeAndTaskStatus($userId) + { + return $this->db->table(self::TABLE) + ->eq('user_id', $userId) + ->eq(TaskModel::TABLE.'.is_active', TaskModel::STATUS_OPEN) + ->join(Taskmodel::TABLE, 'id', 'task_id') + ->count(); + } + /** * Get all subtasks for a given task * @@ -149,6 +129,24 @@ class SubtaskModel extends Base } /** + * Get subtasks for a list of tasks and a given assignee + * + * @param array $taskIds + * @param integer $userId + * @return array + */ + public function getAllByTaskIdsAndAssignee(array $taskIds, $userId) + { + if (empty($taskIds)) { + return array(); + } + + return $this->subtaskListFormatter + ->withQuery($this->getQuery()->in('task_id', $taskIds)->eq(self::TABLE.'.user_id', $userId)) + ->format(); + } + + /** * Get a subtask by the id * * @access public @@ -229,10 +227,11 @@ class SubtaskModel extends Base $result = $this->db->table(self::TABLE)->eq('id', $values['id'])->save($values); if ($result) { - $this->subtaskTimeTrackingModel->updateTaskTimeTracking($values['task_id']); + $subtask = $this->getById($values['id']); + $this->subtaskTimeTrackingModel->updateTaskTimeTracking($subtask['task_id']); if ($fireEvent) { - $this->queueManager->push($this->subtaskEventJob->withParams($values['id'], self::EVENT_UPDATE, $values)); + $this->queueManager->push($this->subtaskEventJob->withParams($subtask['id'], self::EVENT_UPDATE, $values)); } } @@ -310,24 +309,4 @@ class SubtaskModel extends Base $values['user_id'] = isset($values['user_id']) ? $values['user_id'] : 0; $this->hook->reference('model:subtask:creation:prepare', $values); } - - /** - * Add subtask status status to the resultset - * - * @access public - * @param array $subtasks Subtasks - * @return array - */ - public function addStatusName(array $subtasks) - { - $status = $this->getStatusList(); - - foreach ($subtasks as &$subtask) { - $subtask['status_name'] = $status[$subtask['status']]; - $subtask['timer_start_date'] = isset($subtask['timer_start_date']) ? $subtask['timer_start_date'] : 0; - $subtask['is_timer_started'] = ! empty($subtask['timer_start_date']); - } - - return $subtasks; - } } diff --git a/app/Model/TaskCreationModel.php b/app/Model/TaskCreationModel.php index 95f62ee5..dbec2b12 100644 --- a/app/Model/TaskCreationModel.php +++ b/app/Model/TaskCreationModel.php @@ -58,7 +58,7 @@ class TaskCreationModel extends Base */ protected function prepare(array &$values) { - $values = $this->dateParser->convert($values, array('date_due')); + $values = $this->dateParser->convert($values, array('date_due'), true); $values = $this->dateParser->convert($values, array('date_started'), true); $this->helper->model->removeFields($values, array('another_task', 'duplicate_multiple_projects')); diff --git a/app/Model/TaskDuplicationModel.php b/app/Model/TaskDuplicationModel.php index c07ebca0..eb59f555 100644 --- a/app/Model/TaskDuplicationModel.php +++ b/app/Model/TaskDuplicationModel.php @@ -47,7 +47,10 @@ class TaskDuplicationModel extends Base */ public function duplicate($task_id) { - $new_task_id = $this->save($task_id, $this->copyFields($task_id)); + $values = $this->copyFields($task_id); + $values['title'] = t('[DUPLICATE]').' '.$values['title']; + + $new_task_id = $this->save($task_id, $values); if ($new_task_id !== false) { $this->tagDuplicationModel->duplicateTaskTags($task_id, $new_task_id); diff --git a/app/Model/TaskFinderModel.php b/app/Model/TaskFinderModel.php index b610a371..e3b5e0b9 100644 --- a/app/Model/TaskFinderModel.php +++ b/app/Model/TaskFinderModel.php @@ -59,27 +59,11 @@ class TaskFinderModel extends Base */ public function getUserQuery($user_id) { - return $this->db - ->table(TaskModel::TABLE) - ->columns( - TaskModel::TABLE.'.id', - TaskModel::TABLE.'.title', - TaskModel::TABLE.'.date_due', - TaskModel::TABLE.'.date_creation', - TaskModel::TABLE.'.project_id', - TaskModel::TABLE.'.column_id', - TaskModel::TABLE.'.color_id', - TaskModel::TABLE.'.priority', - TaskModel::TABLE.'.time_spent', - TaskModel::TABLE.'.time_estimated', - TaskModel::TABLE.'.is_active', - TaskModel::TABLE.'.creator_id', - ProjectModel::TABLE.'.name AS project_name', - ColumnModel::TABLE.'.title AS column_title' - ) - ->join(ProjectModel::TABLE, 'id', 'project_id') - ->join(ColumnModel::TABLE, 'id', 'column_id') + return $this->getExtendedQuery() + ->beginOr() ->eq(TaskModel::TABLE.'.owner_id', $user_id) + ->addCondition(TaskModel::TABLE.".id IN (SELECT task_id FROM ".SubtaskModel::TABLE." WHERE ".SubtaskModel::TABLE.".user_id='$user_id')") + ->closeOr() ->eq(TaskModel::TABLE.'.is_active', TaskModel::STATUS_OPEN) ->eq(ProjectModel::TABLE.'.is_active', ProjectModel::ACTIVE) ->eq(ColumnModel::TABLE.'.hide_in_dashboard', 0); @@ -213,7 +197,7 @@ class TaskFinderModel extends Base ->eq(ProjectModel::TABLE.'.is_active', 1) ->eq(TaskModel::TABLE.'.is_active', 1) ->neq(TaskModel::TABLE.'.date_due', 0) - ->lte(TaskModel::TABLE.'.date_due', mktime(23, 59, 59)); + ->lte(TaskModel::TABLE.'.date_due', time()); } /** diff --git a/app/Model/TaskModificationModel.php b/app/Model/TaskModificationModel.php index 0ae29293..b10c0aa9 100644 --- a/app/Model/TaskModificationModel.php +++ b/app/Model/TaskModificationModel.php @@ -98,7 +98,7 @@ class TaskModificationModel extends Base */ protected function prepare(array &$values) { - $values = $this->dateParser->convert($values, array('date_due')); + $values = $this->dateParser->convert($values, array('date_due'), true); $values = $this->dateParser->convert($values, array('date_started'), true); $this->helper->model->removeFields($values, array('id')); diff --git a/app/Model/TaskPositionModel.php b/app/Model/TaskPositionModel.php index 8805d57e..9f7eb983 100644 --- a/app/Model/TaskPositionModel.php +++ b/app/Model/TaskPositionModel.php @@ -243,26 +243,26 @@ class TaskPositionModel extends Base ); if ($task['swimlane_id'] != $new_swimlane_id) { - $this->queueManager->push($this->taskEventJob->withParams( + $this->taskEventJob->execute( $task['id'], array(TaskModel::EVENT_MOVE_SWIMLANE), $changes, $changes - )); + ); } elseif ($task['column_id'] != $new_column_id) { - $this->queueManager->push($this->taskEventJob->withParams( + $this->taskEventJob->execute( $task['id'], array(TaskModel::EVENT_MOVE_COLUMN), $changes, $changes - )); + ); } elseif ($task['position'] != $new_position) { - $this->queueManager->push($this->taskEventJob->withParams( + $this->taskEventJob->execute( $task['id'], array(TaskModel::EVENT_MOVE_POSITION), $changes, $changes - )); + ); } } } diff --git a/app/Model/UserModel.php b/app/Model/UserModel.php index 56b1a960..af49ce7d 100644 --- a/app/Model/UserModel.php +++ b/app/Model/UserModel.php @@ -376,4 +376,20 @@ class UserModel extends Base ->eq('id', $user_id) ->save(array('token' => '')); } + + public function getOrCreateExternalUserId($username, $name, $externalIdColumn, $externalId) + { + $userId = $this->db->table(self::TABLE)->eq($externalIdColumn, $externalId)->findOneColumn('id'); + + if (empty($userId)) { + $userId = $this->create(array( + 'username' => $username, + 'name' => $name, + 'is_ldap_user' => 1, + $externalIdColumn => $externalId, + )); + } + + return $userId; + } } diff --git a/app/Model/UserNotificationModel.php b/app/Model/UserNotificationModel.php index d77526f6..9e90cf5d 100644 --- a/app/Model/UserNotificationModel.php +++ b/app/Model/UserNotificationModel.php @@ -68,10 +68,6 @@ class UserNotificationModel extends Base */ public function getUsersWithNotificationEnabled($project_id, $exclude_user_id = 0) { - if ($this->projectPermissionModel->isEverybodyAllowed($project_id)) { - return $this->getEverybodyWithNotificationEnabled($exclude_user_id); - } - $users = array(); $members = $this->getProjectUserMembersWithNotificationEnabled($project_id, $exclude_user_id); $groups = $this->getProjectGroupMembersWithNotificationEnabled($project_id, $exclude_user_id); @@ -183,22 +179,4 @@ class UserNotificationModel extends Base ->eq(UserModel::TABLE.'.is_active', 1) ->findAll(); } - - /** - * Get a list of project members with notification enabled - * - * @access private - * @param integer $exclude_user_id User id to exclude - * @return array - */ - private function getEverybodyWithNotificationEnabled($exclude_user_id) - { - return $this->db - ->table(UserModel::TABLE) - ->columns(UserModel::TABLE.'.id', UserModel::TABLE.'.username', UserModel::TABLE.'.name', UserModel::TABLE.'.email', UserModel::TABLE.'.language', UserModel::TABLE.'.notifications_filter') - ->eq('notifications_enabled', '1') - ->neq(UserModel::TABLE.'.id', $exclude_user_id) - ->eq(UserModel::TABLE.'.is_active', 1) - ->findAll(); - } } |