⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 projecttasklist.class.php

📁 ProjectPier 源码 很好的项目管理程序
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?php  /**  * ProjectTaskList class  * Generated on Wed, 08 Mar 2006 15:51:26 +0100 by DataObject generation tool  *  * @http://www.projectpier.org/  */  class ProjectTaskList extends BaseProjectTaskList {        /**    * This project object is taggable    *    * @var boolean    */    protected $is_taggable = true;        /**    * Message comments are searchable    *    * @var boolean    */    protected $is_searchable = true;        /**    * Array of searchable columns    *    * @var array    */    protected $searchable_columns = array('name', 'description');        /**    * Cached task array    *    * @var array    */    private $all_tasks;        /**    * Cached open task array    *    * @var array    */    private $open_tasks;        /**    * Cached completed task array    *    * @var array    */    private $completed_tasks;        /**    * Cached number of open tasks    *    * @var integer    */    private $count_all_tasks;        /**    * Cached number of open tasks in this list    *    * @var integer    */    private $count_open_tasks = null;        /**    * Cached number of completed tasks in this list    *    * @var integer    */    private $count_completed_tasks = null;        /**    * Cached array of related forms    *    * @var array    */    private $related_forms;        /**    * Cached completed by reference    *    * @var User    */    private $completed_by;      // ---------------------------------------------------    //  Operations    // ---------------------------------------------------        /**    * Add task to this list    *    * @param string $text    * @param User $assigned_to_user    * @param Company $assigned_to_company    * @return ProjectTask    * @throws DAOValidationError    */    function addTask($text, $assigned_to_user = null, $assigned_to_company = null) {      $task = new ProjectTask();      $task->setText($text);            if ($assigned_to_user instanceof User) {        $task->setAssignedToUserId($assigned_to_user->getId());        $task->setAssignedToCompanyId($assigned_to_user->getCompanyId());      } elseif ($assigned_to_company instanceof Company) {        $task->setAssignedToCompanyId($assigned_to_company->getId());      } // if            $this->attachTask($task); // this one will save task      return $task;    } // addTask        /**    * Attach task to this lists    *    * @param ProjectTask $task    * @return null    */    function attachTask(ProjectTask $task) {      if ($task->getTaskListId() == $this->getId()) {        return;      }            $task->setTaskListId($this->getId());      $task->save();              if ($this->isCompleted()) {        $this->open();      }    } // attachTask        /**    * Detach task from this list    *    * @param ProjectTask $task    * @param ProjectTaskList $attach_to If you wish you can detach and attach task to    *   other list with one save query    * @return null    */    function detachTask(ProjectTask $task, $attach_to = null) {      if ($task->getTaskListId() <> $this->getId()) {        return;      }            if ($attach_to instanceof ProjectTaskList) {        $attach_to->attachTask($task);      } else {        $task->setTaskListId(0);        $task->save();      } // if            $close = true;      $open_tasks = $this->getOpenTasks();      if (is_array($open_tasks)) {        foreach ($open_tasks as $open_task) {          if ($open_task->getId() <> $task->getId()) {            $close = false;          }        } // if      } // if            if ($close) {        $this->complete(DateTimeValueLib::now(), logged_user());      }    } // detachTask        /**    * Complete this task lists    *    * @access public    * @param DateTimeValue $on Completed on    * @param User $by Completed by    * @return null    */    function complete(DateTimeValue $on, User $by) {      $this->setCompletedOn($on);      $this->setCompletedById($by->getId());      $this->save();      ApplicationLogs::createLog($this, $this->getProject(), ApplicationLogs::ACTION_CLOSE);    } // complete        /**    * Open this list    *    * @access public    * @param void    * @return null    */    function open() {      $this->setCompletedOn(NULL);      $this->setCompletedById(0);      $this->save();      ApplicationLogs::createLog($this, $this->getProject(), ApplicationLogs::ACTION_OPEN);    } // open        // ---------------------------------------------------    //  Related object    // ---------------------------------------------------        /**    * Return all tasks from this list    *    * @access public    * @param void    * @return array    */    function getTasks() {      if (is_null($this->all_tasks)) {        $this->all_tasks = ProjectTasks::findAll(array(          'conditions' => '`task_list_id` = ' . DB::escape($this->getId()),          'order' => '`order`, `created_on`'        )); // findAll      } // if            return $this->all_tasks;    } // getTasks        /**    * Return open tasks    *    * @access public    * @param void    * @return array    */    function getOpenTasks() {      if (is_null($this->open_tasks)) {        $this->open_tasks = ProjectTasks::findAll(array(          'conditions' => '`task_list_id` = ' . DB::escape($this->getId()) . ' AND `completed_on` = ' . DB::escape(EMPTY_DATETIME),          'order' => '`order`, `created_on`'        )); // findAll      } // if            return $this->open_tasks;    } // getOpenTasks        /**    * Return completed tasks    *    * @access public    * @param void    * @return array    */    function getCompletedTasks() {      if (is_null($this->completed_tasks)) {        $this->completed_tasks = ProjectTasks::findAll(array(          'conditions' => '`task_list_id` = ' . DB::escape($this->getId()) . ' AND `completed_on` > ' . DB::escape(EMPTY_DATETIME),          'order' => '`completed_on` DESC'        )); // findAll      } // if            return $this->completed_tasks;    } // getCompletedTasks        /**    * Return number of all tasks in this list    *    * @access public    * @param void    * @return integer    */    function countAllTasks() {      if (is_null($this->count_all_tasks)) {        if (is_array($this->all_tasks)) {          $this->count_all_tasks = count($this->all_tasks);        } else {          $this->count_all_tasks = ProjectTasks::count('`task_list_id` = ' . DB::escape($this->getId()));        } // if      } // if      return $this->count_all_tasks;    } // countAllTasks        /**    * Return number of open tasks    *    * @access public    * @param void    * @return integer    */    function countOpenTasks() {      if (is_null($this->count_open_tasks)) {        if (is_array($this->open_tasks)) {          $this->count_open_tasks = count($this->open_tasks);        } else {          $this->count_open_tasks = ProjectTasks::count('`task_list_id` = ' . DB::escape($this->getId()) . ' AND `completed_on` = ' . DB::escape(EMPTY_DATETIME));        } // if      } // if      return $this->count_open_tasks;    } // countOpenTasks        /**    * Return number of completed tasks    *    * @access public    * @param void    * @return integer    */    function countCompletedTasks() {      if (is_null($this->count_completed_tasks)) {        if (is_array($this->completed_tasks)) {          $this->count_completed_tasks = count($this->completed_tasks);        } else {          $this->count_completed_tasks = ProjectTasks::count('`task_list_id` = ' . DB::escape($this->getId()) . ' AND `completed_on` > ' . DB::escape(EMPTY_DATETIME));        } // if      } // if      return $this->count_completed_tasks;    } // countCompletedTasks        /**    * Return owner project obj    *    * @access public    * @param void    * @return Project    */    function getProject() {      return Projects::findById($this->getProjectId());    } // getProject        /**    * Get project forms that are in relation with this task list    *    * @param void    * @return array    */    function getRelatedForms() {      if (is_null($this->related_forms)) {        $this->related_forms = ProjectForms::findAll(array(          'conditions' => '`action` = ' . DB::escape(ProjectForm::ADD_TASK_ACTION) . ' AND `in_object_id` = ' . DB::escape($this->getId()),          'order' => '`order`'        )); // findAll      } // if      return $this->related_forms;    } // getRelatedForms

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -