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

📄 company.class.php

📁 ProjectPier 源码 很好的项目管理程序
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?php  /**  * Company class  * Generated on Sat, 25 Feb 2006 17:37:12 +0100 by DataObject generation tool  *  * @http://www.projectpier.org/  */  class Company extends BaseCompany {        /**    * Cached array of active company projects    *    * @var array    */    private $active_projects;        /**    * Cached array of completed projects    *    * @var array    */    private $completed_projects;        /**    * Return array of all company members    *    * @access public    * @param void    * @return array    */    function getUsers() {      return Users::findAll(array(        'conditions' => '`company_id` = ' . DB::escape($this->getId())      )); // findAll    } // getUsers        /**    * Return number of company users    *    * @access public    * @param void    * @return integer    */    function countUsers() {      return Users::count('`company_id` = ' . DB::escape($this->getId()));    } // countUsers        /**    * Return array of company users on specific project    *    * @access public    * @param Project $project    * @return array    */    function getUsersOnProject(Project $project) {      return ProjectUsers::getCompanyUsersByProject($this, $project);    } // getUsersOnProject        /**    * Return users that have auto assign value set to true    *    * @access public    * @param void    * @return array    */    function getAutoAssignUsers() {      return Users::findAll(array(        'conditions' => '`company_id` = ' . DB::escape($this->getId()) . ' AND `auto_assign` > ' . DB::escape(0)      )); // findAll    } // getAutoAssignUsers        /**    * Return all client companies    *    * @access public    * @param void    * @return array    */    function getClientCompanies() {      return Companies::getCompanyClients($this);    } // getClientCompanies        /**    * Return number of client companies    *    * @access public    * @param void    * @return integer    */    function countClientCompanies() {      return Companies::count('`client_of_id` = ' . DB::escape($this->getId()));    } // countClientCompanies        /**    * Return all projects that this company is member of    *    * @access public    * @param void    * @return array    */    function getProjects() {      return $this->isOwner() ? Projects::getAll() : ProjectCompanies::getProjectsByCompany($this);    } // getProjects        /**    * Return total number of projects    *    * @access public    * @param void    * @return integer    */    function countProjects() {      if ($this->isOwner()) {        return Projects::count(); // all      } else {        return ProjectCompanies::count('`company_id` = ' . DB::escape($this->getId()));      } // if    } // countProjects        /**    * Return active projects that are owned by this company    *    * @param void    * @return null    */    function getActiveProjects() {      if (is_null($this->active_projects)) {        if ($this->isOwner()) {          $this->active_projects = Projects::findAll(array(            'conditions' => '`completed_on` = ' . DB::escape(EMPTY_DATETIME)          )); // findAll        } else {          $this->active_projects = ProjectCompanies::getProjectsByCompany($this, '`completed_on` = ' . DB::escape(EMPTY_DATETIME));        } // if      } // if      return $this->active_projects;    } // getActiveProjects        /**    * Return all completed projects    *    * @param void    * @return null    */    function getCompletedProjects() {      if (is_null($this->completed_projects)) {        if ($this->isOwner()) {          $this->completed_projects = Projects::findAll(array(            'conditions' => '`completed_on` > ' . DB::escape(EMPTY_DATETIME)          )); // findAll        } else {          $this->completed_projects = ProjectCompanies::getProjectsByCompany($this, '`completed_on` > ' . DB::escape(EMPTY_DATETIME));        } // if      } // if      return $this->completed_projects;    } // getCompletedProjects        /**    * Return all milestones scheduled for today    *    * @param void    * @return array    */    function getTodayMilestones() {      return ProjectMilestones::getTodayMilestonesByCompany($this);    } // getTodayMilestones        /**    * Return all late milestones    *    * @param void    * @return array    */    function getLateMilestones() {      return ProjectMilestones::getLateMilestonesByCompany($this);    } // getLateMilestones        /**    * Check if this company is owner company    *    * @param void    * @return boolean    */    function isOwner() {      if ($this->isNew()) {        return false;      } else {        return $this->getClientOfId() == 0;      } // if    } // isOwner        /**    * Check if this company is part of specific project    *    * @param Project $project    * @return boolean    */    function isProjectCompany(Project $project) {      if ($this->isOwner() && ($project->getCompanyId() == $this->getId())) {        return true;      } // uf      return ProjectCompanies::findById(array('project_id' => $project->getId(), 'company_id' => $this->getId())) instanceof ProjectCompany;    } // isProjectCompany        /**    * This function will return true if we have data to show company address (address, city, country and zipcode)    *    * @access public    * @param void    * @return boolean    */    function hasAddress() {      return trim($this->getAddress()) <> '' &&             trim($this->getCity()) <> '' &&             //trim($this->getZipcode()) <> '' &&             trim($this->getCountry()) <> '';    } // hasAddress        /**    * Check if this company have valid homepage address set    *    * @access public    * @param void    * @return boolean    */    function hasHomepage() {      return trim($this->getHomepage()) <> '' && is_valid_url($this->getHomepage());    } // hasHomepage        /**    * Return name of country    *    * @access public    * @param void    * @return string    */    function getCountryName() {      return lang('country ' . $this->getCountry());    } // getCountryName        /**    * Returns true if company info is updated by the user since company is created. Company can be created    * with empty company info    *    * @access public    * @param void    * @return boolean    */    function isInfoUpdated() {      return $this->getCreatedOn()->getTimestamp() < $this->getUpdatedOn()->getTimestamp();    } // isInfoUpdated        /**    * Set homepage URL    *     * This function is simple setter but it will check if protocol is specified for given URL. If it is not than     * http will be used. Supported protocols are http and https for this type or URL    *    * @param string $value    * @return null    */    function setHomepage($value) {      if (trim($value) == '') {        return parent::setHomepage('');      } // if            $check_value = strtolower($value);      if (!str_starts_with($check_value, 'http://') && !str_starts_with($check_value, 'https://')) {        return parent::setHomepage('http://' . $value);      } else {        return parent::setHomepage($value);      } // if    } // setHomepage        // ---------------------------------------------------    //  Permissions    // ---------------------------------------------------        /**    * Check if specific user can update this company    *    * @access public    * @param User $user    * @return boolean    */    function canEdit(User $user) {      return $user->isAccountOwner() || $user->isAdministrator();    } // canEdit        /**    * Check if specific user can delete this company    *    * @access public    * @param User $user    * @return boolean    */    function canDelete(User $user) {      return $user->isAccountOwner() || $user->isAdministrator();    } // canDelete        /**    * Returns true if specific user can add clent company    *    * @access public    * @param User $user    * @return boolean

⌨️ 快捷键说明

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