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

📄 project.class.php

📁 ProjectPier 源码 很好的项目管理程序
💻 PHP
📖 第 1 页 / 共 3 页
字号:
            }            $this->late_milestones[] = $open_milestone;          } elseif ($open_milestone->isToday()) {            if (!is_array($this->today_milestones)) {              $this->today_milestones = array();            }            $this->today_milestones[] = $open_milestone;          } else {            if (!is_array($this->upcoming_milestones)) {              $this->upcoming_milestones = array();            }            $this->upcoming_milestones[] = $open_milestone;          } // if        } // foreach      } // if    } // splitOpenMilestones        // ---------------------------------------------------    //  Task lists    // ---------------------------------------------------        /**    * Return all task lists    *    * @param void    * @return array    */    function getAllTaskLists() {      if (is_null($this->all_task_lists)) {        $this->all_task_lists = ProjectTaskLists::findAll(array(          'conditions' => array('`project_id` = ?', $this->getId()),          'order' => '`order`'        )); // findAll      } // if      return $this->all_task_lists;    } // getAllTaskLists        /**    * Return all taks lists    *    * @access public    * @param void    * @return array    */    function getTaskLists() {      if (logged_user()->isMemberOfOwnerCompany()) {        return $this->getAllTaskLists();      }      if (is_null($this->task_lists)) {        $this->task_lists = ProjectTaskLists::findAll(array(          'conditions' => array('`project_id` = ? AND `is_private` = ?', $this->getId(), 0),          'order' => '`order`'        )); // findAll      } // if      return $this->task_lists;    } // getTaskLists        /**    * Return all open task lists from this project    *    * @param void    * @return array    */    function getAllOpenTaskLists() {      if (is_null($this->all_open_task_lists)) {        $this->all_open_task_lists = ProjectTaskLists::findAll(array(          'conditions' => array('`project_id` = ? AND `completed_on` = ?', $this->getId(), EMPTY_DATETIME),          'order' => '`order`'        )); // findAll      } // if      return $this->all_open_task_lists;    } // getAllOpenTaskLists        /**    * Return open task lists    *    * @access public    * @param void    * @return array    */    function getOpenTaskLists() {      if (logged_user()->isMemberOfOwnerCompany()) {        return $this->getAllOpenTaskLists();      }      if (is_null($this->open_task_lists)) {        $this->open_task_lists = ProjectTaskLists::findAll(array(          'conditions' => array('`project_id` = ? AND `completed_on` = ? AND `is_private` = ?', $this->getId(), EMPTY_DATETIME, 0),          'order' => '`order`'        )); // findAll      } // if      return $this->open_task_lists;    } // getOpenTaskLists        /**    * Return all completed task lists    *    * @param void    * @return array    */    function getAllCompletedTaskLists() {      if (is_null($this->all_completed_task_lists)) {        $this->all_completed_task_lists = ProjectTaskLists::findAll(array(          'conditions' => array('`project_id` = ? AND `completed_on` > ?', $this->getId(), EMPTY_DATETIME),          'order' => '`order`'        )); // findAll      } // if      return $this->all_completed_task_lists;    } // getAllCompletedTaskLists        /**    * Return completed task lists    *    * @access public    * @param void    * @return array    */    function getCompletedTaskLists() {      if (logged_user()->isMemberOfOwnerCompany()) {        return $this->getAllCompletedTaskLists();      }      if (is_null($this->completed_task_lists)) {        $this->completed_task_lists = ProjectTaskLists::findAll(array(          'conditions' => array('`project_id` = ? AND `completed_on` > ? AND `is_private` = ?', $this->getId(), EMPTY_DATETIME, 0),          'order' => '`order`'        )); // findAll      } // if      return $this->completed_task_lists;    } // getCompletedTaskLists        // ---------------------------------------------------    //  Tags    // ---------------------------------------------------        /**    * This function will return unique tags used on objects of this project. Result is cached!    *    * @access public    * @param void    * @return array    */    function getTagNames() {      $exclude_private = !logged_user()->isMemberOfOwnerCompany();      if (is_null($this->tag_names)) {        $this->tag_names = Tags::getProjectTagNames($this, $exclude_private);      } // if      return $this->tag_names;    } // getTagNames        /**    * This function return associative array of project objects tagged with specific tag. Array has following elements:    *     *  - messages    *  - milestones    *  - tast lists    *  - files    *    * @access public    * @param string $tag    * @return array    */    function getObjectsByTag($tag) {      $exclude_private = !logged_user()->isMemberOfOwnerCompany();      return array(        'messages'   => Tags::getProjectObjects($this, $tag, 'ProjectMessages', $exclude_private),        'milestones' => Tags::getProjectObjects($this, $tag, 'ProjectMilestones', $exclude_private),        'task_lists' => Tags::getProjectObjects($this, $tag, 'ProjectTaskLists', $exclude_private),        'files'      => Tags::getProjectObjects($this, $tag, 'ProjectFiles', $exclude_private),      ); // array    } // getObjectsByTag        /**    * Return number of project objects tagged with $tag    *    * @param string $tag    * @return integer    */    function countObjectsByTag($tag) {      $exclude_private = !logged_user()->isMemberOfOwnerCompany();      return Tags::countProjectObjectsByTag($tag, $this, $exclude_private);    } // countObjectsByTag        // ---------------------------------------------------    //  Project log    // ---------------------------------------------------        /**    * Return full project log    *    * @param integer $limit    * @param integer $offset    * @return array    */    function getFullProjectLog($limit = null, $offset = null) {      return ApplicationLogs::getProjectLogs($this, true, true, $limit, $offset);    } // getFullProjectLog        /**    * Return all project log entries that this user can see    *    * @param integer $limit Number of logs that will be returned    * @param integer $offset Return from this record    * @return array    */    function getProjectLog($limit = null, $offset = null) {      $include_private = logged_user()->isMemberOfOwnerCompany();      $include_silent = logged_user()->isAdministrator();            return ApplicationLogs::getProjectLogs($this, $include_private, $include_silent, $limit, $offset);    } // getProjectLog        /**    * Return number of logs for this project    *    * @access public    * @param void    * @return null    */    function countProjectLogs() {      return ApplicationLogs::count(array('`project_id` = ?', $this->getId()));    } // countProjectLogs        // ---------------------------------------------------    //  Project forms    // ---------------------------------------------------        /**    * Return all project forms    *    * @param void    * @return array    */    function getAllForms() {      if (is_null($this->all_forms)) {        $this->all_forms = ProjectForms::findAll(array(          'conditions' => array('`project_id` = ?', $this->getId()),          'order' => '`order`'        )); // findAll      } // if      return $this->all_forms;    } // getAllForms        /**    * Return only visible project forms    *    * @param void    * @return null    */    function getVisibleForms($only_enabled = false) {      $conditions = '`project_id` = ' . DB::escape($this->getId());      if ($only_enabled) {        $conditions .= ' AND `is_enabled` = ' . DB::escape(true);      } // if            return ProjectForms::findAll(array(        'conditions' => $conditions,        'order' => '`order`'      )); // findAll    } // getVisibleForms        /**    * Return owner company object    *    * @access public    * @param void    * @return Company    */    function getCompany() {      return owner_company();    } // getCompany        /**    * Get all companies involved in this project    *    * @access public    * @param boolean $include_owner_company Include owner in result    * @return array    */    function getCompanies($include_owner_company = true) {      $result = array();      if ($include_owner_company) {        $result[] = $this->getCompany();      }            $companies = ProjectCompanies::getCompaniesByProject($this);      if (is_array($companies)) {        $result = array_merge($result, $companies);      } // if            return $result;    } // getCompanies        /**    * Remove all companies from project    *    * @access public    * @param void    * @return boolean    */    function clearCompanies() {      return ProjectCompanies::clearByProject($this);    } // clearCompanies        /**    * Return all users involved in this project    *    * @access public    * @param void    * @return array    */    function getUsers($group_by_company = true) {      $users = ProjectUsers::getUsersByProject($this);      if (!is_array($users) || !count($users)) {        return null;      } // if            if ($group_by_company) {                $grouped = array();        foreach ($users as $user) {          if (!isset($grouped[$user->getCompanyId()]) || !is_array($grouped[$user->getCompanyId()])) {            $grouped[$user->getCompanyId()] = array();          } // if          $grouped[$user->getCompanyId()][] = $user;        } // foreach        return $grouped;              } else {        return $users;      } // if    } // getUsers        /**    * Remove all users from project    *    * @access public    * @param void    * @return boolean    */    function clearUsers() {      return ProjectUsers::clearByProject($this);    } // clearUsers        /**    * Return user who created this milestone    *    * @access public    * @param void    * @return User    */    function getCreatedBy() {      return Users::findById($this->getCreatedById());    } // getCreatedBy        /**    * Return user who completed this project    *    * @access public    * @param void    * @return User    */    function getCompletedBy() {      return Users::findById($this->getCompletedById());    } // getCompletedBy        /**    * Return display name of user who completed this project    *    * @access public    * @param void    * @return string    */    function getCompletedByDisplayName() {      $completed_by = $this->getCompletedBy();      return $completed_by instanceof User ? $completed_by->getDisplayName() : lang('n/a');    } // getCompletedByDisplayName        // ---------------------------------------------------    //  User tasks    // ---------------------------------------------------        /**    * Return array of milestones that are assigned to specific user or his company    *    * @param User $user    * @return array    */    function getUsersMilestones(User $user) {      $conditions = DB::prepareString('`project_id` = ? AND ((`assigned_to_user_id` = ? AND `assigned_to_company_id` = ?) OR (`assigned_to_user_id` = ? AND `assigned_to_company_id` = ?) OR (`assigned_to_user_id` = ? AND `assigned_to_company_id` = ?)) AND `completed_on` = ?', array($this->getId(), $user->getId(), $user->getCompanyId(), 0, $user->getCompanyId(), 0, 0, EMPTY_DATETIME));      if (!$user->isMemberOfOwnerCompany()) {        $conditions .= DB::prepareString(' AND `is_private` = ?', array(0));      } // if      return ProjectMilestones::findAll(array(        'conditions' => $conditions,        'order' => '`due_date`'      ));    } // getUsersMilestones        /**    * Return array of task that are assigned to specific user or his company    *    * @param User $user    * @return array    */    function getUsersTasks(User $user) {      $task_lists = $this->getTaskLists();      if (!is_array($task_lists)) {        return false;      } // if            $task_list_ids = array();      foreach ($task_lists as $task_list) {        if (!$user->isMemberOfOwnerCompany() && $task_list->isPrivate()) {          continue;        } // if        $task_list_ids[] = $task_list->getId();      } // if            return ProjectTasks::findAll(array(        'conditions' => array('`task_list_id` IN (?) AND ((`assigned_to_user_id` = ? AND `assigned_to_company_id` = ?) OR (`assigned_to_user_id` = ? AND `assigned_to_company_id` = ?) OR (`assigned_to_user_id` = ? AND `assigned_to_company_id` = ?)) AND `completed_on` = ?', $task_list_ids, $user->getId(), $user->getCompanyId(), 0, $user->getCompanyId(), 0, 0, EMPTY_DATETIME),        'order' => '`created_on`'      )); // findAll    } // getUsersTasks        // ---------------------------------------------------    //  Files    // ---------------------------------------------------        function getFolders() {      if (is_null($this->folders)) {        $this->folders = ProjectFolders::getProjectFolders($this);      } // if      return $this->folders;    } // getFolders        /**    * Return all important files    *    * @param void    * @return array    */    function getAllImportantFiles() {      if (is_null($this->all_important_files)) {        $this->all_important_files = ProjectFiles::getImportantProjectFiles($this, true);      } // if      return $this->all_important_files;    } // getAllImportantFiles        /**    * Return important files    *    * @param void    * @return array    */    function getImportantFiles() {      if (logged_user()->isMemberOfOwnerCompany()) {        return $this->getAllImportantFiles();      } // if            if (is_null($this->important_files)) {        $this->important_files = ProjectFiles::getImportantProjectFiles($this, false);      } // if      return $this->important_files;    } // getImportantFiles        /**    * Return all orphaned files    *    * @param void    * @return array    */    function getAllOrphanedFiles() {      if (is_null($this->all_orphaned_files)) {        $this->all_orphaned_files = ProjectFiles::getOrphanedFilesByProject($this, true);      } //      return $this->all_orphaned_files;    } // getAllOrphanedFiles        /**    * Return orphaned files    *    * @param void

⌨️ 快捷键说明

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