让禅道拥有“抄送给我”功能

278 阅读1分钟

实验环境

system: Windows 10 
zentao: 16.5.0
zentao lang: zh-cn

让禅道显示"抄送给我"

修改 PHP 文件

修改 xampp/zentao/module/bug/lang/zh-cn.php 文件。

<?php
$lang->bug->assignToNull       = '未指派';

/*增加下边的一行代码*/
$lang->bug->mailToMe           = '抄送给我';

$lang->bug->featureBar['browse']['all']          = $lang->bug->allBugs;

/*增加下边的一行代码*/
$lang->bug->featureBar['browse']['mailtome']     = $lang->bug->mailToMe;


修改完成后刷新 bug 页面,就可以显示 抄送给我 的按钮。

让禅道的 “抄送给我” 起效果

修改 PHP 文件

修改 xampp/zentao/module/bug/model.php 文件。

  • 修改 getBugs 函数
    /**
     * Get bugs.
     *
     * @param  array       $productIDList
     * @param  array       $executions
     * @param  int|string  $branch
     * @param  string      $browseType
     * @param  int         $moduleID
     * @param  int         $queryID
     * @param  string      $sort
     * @param  object      $pager
     * @param  int         $projectID
     * @access public
     * @return array
     */
    public function getBugs($productIDList, $executions, $branch, $browseType, $moduleID, $queryID, $sort, $pager, $projectID)
    {
        /* Set modules and browse type. */
        $modules    = $moduleID ? $this->loadModel('tree')->getAllChildId($moduleID) : '0';
        $browseType = ($browseType == 'bymodule' and $this->session->bugBrowseType and $this->session->bugBrowseType != 'bysearch') ? $this->session->bugBrowseType : $browseType;
        $browseType = $browseType == 'bybranch' ? 'bymodule' : $browseType;

        /* Get bugs by browse type. */
        $bugs = array();
        if($browseType == 'all')               $bugs = $this->getAllBugs($productIDList, $branch, $modules, $executions, $sort, $pager, $projectID);
        elseif($browseType == 'bymodule')      $bugs = $this->getModuleBugs($productIDList, $branch, $modules, $executions, $sort, $pager, $projectID);
        elseif($browseType == 'assigntome')    $bugs = $this->getByAssigntome($productIDList, $branch, $modules, $executions, $sort, $pager, $projectID);
        elseif($browseType == 'openedbyme')    $bugs = $this->getByOpenedbyme($productIDList, $branch, $modules, $executions, $sort, $pager, $projectID);
        elseif($browseType == 'resolvedbyme')  $bugs = $this->getByResolvedbyme($productIDList, $branch, $modules, $executions, $sort, $pager, $projectID);
        elseif($browseType == 'assigntonull')  $bugs = $this->getByAssigntonull($productIDList, $branch, $modules, $executions, $sort, $pager, $projectID);
        elseif($browseType == 'unconfirmed')   $bugs = $this->getUnconfirmed($productIDList, $branch, $modules, $executions, $sort, $pager, $projectID);
        elseif($browseType == 'unresolved')    $bugs = $this->getByStatus($productIDList, $branch, $modules, $executions, 'unresolved', $sort, $pager, $projectID);
        elseif($browseType == 'unclosed')      $bugs = $this->getByStatus($productIDList, $branch, $modules, $executions, 'unclosed', $sort, $pager, $projectID);
        elseif($browseType == 'toclosed')      $bugs = $this->getByStatus($productIDList, $branch, $modules, $executions, 'toclosed', $sort, $pager, $projectID);
        elseif($browseType == 'longlifebugs')  $bugs = $this->getByLonglifebugs($productIDList, $branch, $modules, $executions, $sort, $pager, $projectID);
        elseif($browseType == 'postponedbugs') $bugs = $this->getByPostponedbugs($productIDList, $branch, $modules, $executions, $sort, $pager, $projectID);
        elseif($browseType == 'needconfirm')   $bugs = $this->getByNeedconfirm($productIDList, $branch, $modules, $executions, $sort, $pager, $projectID);
        elseif($browseType == 'bysearch')      $bugs = $this->getBySearch($productIDList, $branch, $queryID, $sort, '', $pager, $projectID);
        elseif($browseType == 'overduebugs')   $bugs = $this->getOverdueBugs($productIDList, $branch, $modules, $executions, $sort, $pager, $projectID);
        /*增加的代码*/
        elseif($browseType == 'mailtome')      $bugs = $this->getMailToMeBugs($productIDList, $branch, $modules, $executions, $sort, $pager, $projectID);

        return $this->checkDelayedBugs($bugs);
    }
  • 增加 getMailToMeBugs 函数
    public function getMailToMeBugs($productIDList, $branch, $modules, $executions, $orderBy, $pager, $projectID)
    {
        return $this->dao->select('*')->from(TABLE_BUG)
            ->beginIF($projectID)->andWhere('project')->eq($projectID)->fi()
            ->where('product')->in($productIDList)
            ->beginIF($branch)->andWhere('branch')->in($branch)->fi()
            ->beginIF($modules)->andWhere('module')->in($modules)->fi()
            ->andWhere('deleted')->eq(0)
            ->andWhere('mailto', true)->like('%,' . $this->app->user->account . ',%')
            ->orWhere('mailto')->like('%,' . $this->app->user->account)
            ->markRight(1)
            ->andWhere('status')->eq('active')
            ->orderBy($orderBy)->page($pager)->fetchAll();
    }

完成

修改了上边介绍的两个文件之后,刷新浏览器即可使用 抄送给我 功能。