📄 projecttasklist.class.php
字号:
/** * Return user who completed this task * * @access public * @param void * @return User */ function getCompletedBy() { if (!($this->completed_by instanceof User)) { $this->completed_by = Users::findById($this->getCompletedById()); } // if return $this->completed_by; } // getCompletedBy /** * Check if this list is completed * * @access public * @param void * @return boolean */ function isCompleted() { return (boolean) $this->getCompletedOn(); } // isCompleted /** * Returns true if this list is open * * @access public * @param void * @return boolean */ function isOpen() { return !$this->isCompleted(); } // isOpen // --------------------------------------------------- // Permissions // --------------------------------------------------- /** * Check if user have task management permissions for project this list belongs to * * @param User $user * @return boolean */ function canManage(User $user) { return $user->getProjectPermission($this->getProject(), ProjectUsers::CAN_MANAGE_TASKS); } // canManage /** * Return true if $user can view this task lists * * @param User $user * @return boolean */ function canView(User $user) { if (!$user->isProjectUser($this->getProject())) { return false; // user have access to project } // if if ($this->isPrivate() && !$user->isMemberOfOwnerCompany()) { return false; // user that is not member of owner company can't access private objects } // if return true; } // canView /** * Check if user can add task lists in specific project * * @param User $user * @param Project $project * @return boolean */ function canAdd(User $user, Project $project) { if ($user->isAccountOwner()) { return true; } // if return $user->getProjectPermission($project, ProjectUsers::CAN_MANAGE_TASKS); } // canAdd /** * Check if specific user can update this list * * @param User $user * @return boolean */ function canEdit(User $user) { if (!$user->isProjectUser($this->getProject())) { return false; // user is on project } // if if ($user->isAdministrator()) { return true; // user is administrator or root } // if if ($this->isPrivate() && !$user->isMemberOfOwnerCompany()) { return false; // user that is not member of owner company can't edit private objects } // if if ($user->getId() == $this->getCreatedById()) { return true; // user is list author } // if return false; // no no } // canEdit /** * Check if specific user can delete this list * * @param User $user * @return boolean */ function canDelete(User $user) { if (!$user->isProjectUser($this->getProject())) { return false; // user is on project } // if if ($user->isAdministrator()) { return true; // user is administrator or root } // if return false; // no no } // canDelete /** * Check if specific user can add task to this list * * @param User $user * @return boolean */ function canAddTask(User $user) { if (!$user->isProjectUser($this->getProject())) { return false; // user is on project } // if if ($user->isAdministrator()) { return true; // user is administrator or root } // if if ($this->isPrivate() && !$user->isMemberOfOwnerCompany()) { return false; // user that is not member of owner company can't add task lists } // if return $this->canManage($user, $this->getProject()); } // canAddTask /** * Check if user can reorder tasks in this list * * @param User $user * @return boolean */ function canReorderTasks(User $user) { if (!$user->isProjectUser($this->getProject())) { return false; // user is on project } // if if ($user->isAdministrator()) { return true; // user is administrator or root } // if if ($this->isPrivate() && !$user->isMemberOfOwnerCompany()) { return false; // user that is not member of owner company can't add task lists } // if return $this->canManage($user, $this->getProject()); } // canReorderTasks // --------------------------------------------------- // URLs // --------------------------------------------------- /** * Return view list URL * * @param void * @return string */ function getViewUrl() { return get_url('task', 'view_list', array('id' => $this->getId(), 'active_project' => $this->getProjectId())); } // getViewUrl /** * This function will return URL of this specific list on project tasks page * * @param void * @return string */ function getOverviewUrl() { $project = $this->getProject(); if ($project instanceof Project) { return $project->getTasksUrl() . '#taskList' . $this->getId(); } // if return ''; } // getOverviewUrl /** * Edit this task list * * @param void * @return string */ function getEditUrl() { return get_url('task', 'edit_list', array('id' => $this->getId(), 'active_project' => $this->getProjectId())); } // getEditUrl /** * Delete this task list * * @param void * @return string */ function getDeleteUrl() { return get_url('task', 'delete_list', array('id' => $this->getId(), 'active_project' => $this->getProjectId())); } // getDeleteUrl /** * Return add task url * * @param boolean $redirect_to_list Redirect back to the list when task is added. If false * after submission user will be redirected to projects tasks page * @return string */ function getAddTaskUrl($redirect_to_list = true) { $attributes = array('task_list_id' => $this->getId(), 'active_project' => $this->getProjectId()); if ($redirect_to_list) { $attributes['back_to_list'] = true; } // if return get_url('task', 'add_task', $attributes); } // getAddTaskUrl /** * Return reorder tasks URL * * @param boolean $redirect_to_list * @return string */ function getReorderTasksUrl($redirect_to_list = true) { $attributes = array('task_list_id' => $this->getId(), 'active_project' => $this->getProjectId()); if ($redirect_to_list) { $attributes['back_to_list'] = true; } // if return get_url('task', 'reorder_tasks', $attributes); } // getReorderTasksUrl // --------------------------------------------------- // System // --------------------------------------------------- /** * Validate before save * * @access public * @param array $errors * @return null */ function validate(&$errors) { if (!$this->validatePresenceOf('name')) { $errors[] = lang('task list name required'); } // if } // validate /** * Delete this task lists * * @access public * @param void * @return boolean */ function delete() { $this->deleteTasks(); $related_forms = $this->getRelatedForms(); if (is_array($related_forms)) { foreach ($related_forms as $related_form) { $related_form->setInObjectId(0); $related_form->save(); } // foreach } // if return parent::delete(); } // delete /** * Save this list * * @param void * @return boolean */ function save() { parent::save(); $tasks = $this->getTasks(); if (is_array($tasks)) { $task_ids = array(); foreach ($tasks as $task) { $task_ids[] = $task->getId(); } // if if (count($task_ids)) { ApplicationLogs::setIsPrivateForType($this->isPrivate(), 'ProjectTasks', $task_ids); } // if } // if return true; } // save /** * Drop all tasks that are in this list * * @access public * @param void * @return boolean */ function deleteTasks() { return ProjectTasks::delete(DB::escapeField('task_list_id') . ' = ' . DB::escape($this->getId())); } // deleteTasks // --------------------------------------------------- // ApplicationDataObject implementation // --------------------------------------------------- /** * Return object type name * * @param void * @return string */ function getObjectTypeName() { return lang('task list'); } // getObjectTypeName /** * Return object URl * * @access public * @param void * @return string */ function getObjectUrl() { return $this->getViewUrl(); } // getObjectUrl } // ProjectTaskList ?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -