* Optimize code for review code.

This commit is contained in:
wangyuting2
2022-11-04 06:35:21 +00:00
parent 74c7882fc6
commit 0cefde5d28
18 changed files with 137 additions and 142 deletions
+7
View File
@@ -408,3 +408,10 @@ $config->showMainMenu = true;
$config->maxPriValue = '256';
$config->importWhiteList = array('user', 'task', 'story', 'bug', 'testcase', 'feedback', 'ticket');
$config->featureGroup = new stdclass();
$config->featureGroup->product = array('roadmap', 'track', 'URStory');
$config->featureGroup->scrum = array();
$config->featureGroup->waterfall = array('track');
$config->featureGroup->assetlib = array();
$config->featureGroup->other = array('devops', 'kanban');
+44
View File
@@ -76,6 +76,50 @@ class helper extends baseHelper
return str_replace($escapers, $replacements, $json);
}
/**
* Verify that the system has opened on the feature.
*
* @param string $feature scrum_risk | risk | scrum
* @static
* @access public
* @return bool
*/
public static function hasFeature($feature)
{
global $config;
if(strpos($feature, '_') !== false)
{
$code = explode('_', $feature);
$code = $code[0] . ucfirst($code[1]);
return strpos(",$config->disabledFeatures,", ",{$code},") === false;
}
else
{
if($feature == 'product' or $feature == 'scrum' or $feature == 'waterfall') return strpos(",$config->disabledFeatures,", ",{$feature},") === false;
$hasFeature = false;
foreach($config->featureGroup as $group => $modules)
{
if($feature == $group)
{
foreach($modules as $module)
{
if(helper::hasFeature("{$group}_{$module}")) $hasFeature = true;
}
}
else
{
foreach($modules as $module)
{
if($feature == $module and helper::hasFeature("{$group}_{$module}")) $hasFeature = true;
}
}
}
return $hasFeature && strpos(",$config->disabledFeatures,", ",{$feature},") === false;
}
}
/**
* Convert encoding.
*
-7
View File
@@ -14,12 +14,5 @@ $config->admin->apiRoot = 'https://www.zentao.net';
$config->admin->log = new stdclass();
$config->admin->log->saveDays = 30;
$config->admin->module = new stdclass();
$config->admin->module->product = array('roadmap', 'track', 'URStory');
$config->admin->module->scrum = array();
$config->admin->module->waterfall = array('track');
$config->admin->module->assetlib = array();
$config->admin->module->other = array('devops', 'kanban');
if(!isset($config->safe)) $config->safe = new stdclass();
if(!isset($config->safe->weak)) $config->safe->weak = '123456,password,12345,12345678,qwerty,123456789,1234,1234567,abc123,111111,123123';
+11 -11
View File
@@ -29,37 +29,37 @@
</tr>
</thead>
<tbody>
<?php foreach($this->config->admin->module as $module => $options):?>
<?php if(strpos(",$disabledFeatures,", ",$module,") !== false) continue;?>
<?php foreach($config->featureGroup as $group => $features):?>
<?php if(strpos(",$disabledFeatures,", ",$group,") !== false) continue;?>
<?php $hasData = false;?>
<?php foreach($options as $option):?>
<?php $code = $module . ucfirst($option);?>
<?php foreach($features as $feature):?>
<?php $code = $group . ucfirst($feature);?>
<?php if(strpos(",$disabledFeatures,", ",$code,") !== false) continue;?>
<?php $hasData = true;?>
<?php endForeach;?>
<?php if($hasData):?>
<tr>
<td class='text-right'><?php echo $lang->admin->setModule->{$module};?></td>
<td class='text-right'><?php echo $lang->admin->setModule->{$group};?></td>
<td>
<?php foreach($options as $option):?>
<?php $code = $module . ucfirst($option);?>
<?php foreach($features as $feature):?>
<?php $code = $group. ucfirst($feature);?>
<?php if(strpos(",$disabledFeatures,", ",$code,") !== false) continue;?>
<?php if(strpos(",$closedFeatures,", ",$code,") !== false) continue;?>
<div class='group-item'>
<?php echo html::checkbox("module[{$code}]", array('1' => $lang->admin->setModule->{$option}), '1', "data-code='{$code}'", 'inline');?>
<?php echo html::checkbox("module[{$code}]", array('1' => $lang->admin->setModule->{$feature}), '1', "data-code='{$code}'", 'inline');?>
<?php echo html::hidden("module[{$code}][]", '1', 'disabled');?>
</div>
<?php endForeach;?>
</td>
<td>
<?php foreach($options as $option):?>
<?php $code = $module . ucfirst($option);?>
<?php foreach($features as $feature):?>
<?php $code = $group . ucfirst($feature);?>
<?php if(strpos(",$disabledFeatures,", ",$code,") !== false) continue;?>
<?php if(strpos(",$closedFeatures,", ",$code,") === false) continue;?>
<div class='group-item'>
<?php echo html::checkbox("module[{$code}]", array('1' => $lang->admin->setModule->{$option}), '0', "data-code='{$code}'", 'inline');?>
<?php echo html::checkbox("module[{$code}]", array('1' => $lang->admin->setModule->{$feature}), '0', "data-code='{$code}'", 'inline');?>
<?php echo html::hidden("module[{$code}][]", '0');?>
</div>
<?php endForeach;?>
+3 -10
View File
@@ -1752,16 +1752,9 @@ class block extends control
*/
public function printAssignToMeBlock($longBlock = true)
{
$hasWaterfall = strpos(",{$this->config->disabledFeatures},", ',waterfall,') === false;
$hasScrumIssue = strpos(",{$this->config->disabledFeatures},", ',scrumIssue,') === false;
$hasScrumRisk = strpos(",{$this->config->disabledFeatures},", ',scrumRisk,') === false;
$hasScrumMeeting = strpos(",{$this->config->disabledFeatures},", ',scrumMeeting,') === false;
$hasWaterfallIssue = (strpos(",{$this->config->disabledFeatures},", ',waterfallIssue,') === false and $hasWaterfall);
$hasWaterfallRisk = (strpos(",{$this->config->disabledFeatures},", ',waterfallRisk,') === false and $hasWaterfall);
$hasWaterfallMeeting = (strpos(",{$this->config->disabledFeatures},", ',waterfallMeeting,') === false and $hasWaterfall);
$hasIssue = ($hasScrumIssue or $hasWaterfallIssue);
$hasRisk = ($hasScrumRisk or $hasWaterfallRisk);
$hasMeeting = ($hasScrumMeeting or $hasWaterfallMeeting);
$hasIssue = helper::hasFeature('issue');
$hasRisk = helper::hasFeature('risk');
$hasMeeting = helper::hasFeature('meeting');
$hasViewPriv = array();
if(common::hasPriv('todo', 'view')) $hasViewPriv['todo'] = true;
+3 -14
View File
@@ -774,17 +774,6 @@ class blockModel extends model
*/
public function getAssignToMeParams()
{
$hasWaterfall = strpos(",{$this->config->disabledFeatures},", ',waterfall,') === false;
$hasScrumIssue = strpos(",{$this->config->disabledFeatures},", ',scrumIssue,') === false;
$hasScrumRisk = strpos(",{$this->config->disabledFeatures},", ',scrumRisk,') === false;
$hasScrumMeeting = strpos(",{$this->config->disabledFeatures},", ',scrumMeeting,') === false;
$hasWaterfallIssue = (strpos(",{$this->config->disabledFeatures},", ',waterfallIssue,') === false and $hasWaterfall);
$hasWaterfallRisk = (strpos(",{$this->config->disabledFeatures},", ',waterfallRisk,') === false and $hasWaterfall);
$hasWaterfallMeeting = (strpos(",{$this->config->disabledFeatures},", ',waterfallMeeting,') === false and $hasWaterfall);
$hasIssue = ($hasScrumIssue or $hasWaterfallIssue);
$hasRisk = ($hasScrumRisk or $hasWaterfallRisk);
$hasMeeting = ($hasScrumMeeting or $hasWaterfallMeeting);
$params = new stdclass();
$params->todoCount['name'] = $this->lang->block->todoCount;
$params->todoCount['default'] = 20;
@@ -800,21 +789,21 @@ class blockModel extends model
if($this->config->edition == 'max')
{
if($hasRisk)
if(helper::hasFeature('risk'))
{
$params->riskCount['name'] = $this->lang->block->riskCount;
$params->riskCount['default'] = 20;
$params->riskCount['control'] = 'input';
}
if($hasIssue)
if(helper::hasFeature('issue'))
{
$params->issueCount['name'] = $this->lang->block->issueCount;
$params->issueCount['default'] = 20;
$params->issueCount['control'] = 'input';
}
if($hasMeeting)
if(helper::hasFeature('meeting'))
{
$params->meetingCount['name'] = $this->lang->block->meetingCount;
$params->meetingCount['default'] = 20;
+8 -16
View File
@@ -772,39 +772,31 @@ $lang->navGroup->tree = 'tree';
$lang->navGroup->misc = 'misc';
$lang->navGroup->upgrade = 'upgrade';
$hasWaterfall = strpos(",$config->disabledFeatures,", ',waterfall,') === false;
$hasProductTrack = strpos(",$config->disabledFeatures,", ',productTrack,') === false;
$hasProductRoadmap = strpos(",$config->disabledFeatures,", ',productRoadmap,') === false;
$hasScrumAuditplan = strpos(",$config->disabledFeatures,", ',scrumAuditplan,') === false;
$hasScrumProcess = strpos(",$config->disabledFeatures,", ',scrumProcess,') === false;
$hasOtherDevops = strpos(",$config->disabledFeatures,", ',otherDevops,') === false;
$hasOtherKanban = strpos(",$config->disabledFeatures,", ',otherKanban,') === false;
if(!$config->URAndSR) unset($lang->product->menu->requirement, $lang->product->menuOrder[35]);
if(!$hasProductRoadmap) unset($lang->product->menu->roadmap, $lang->product->menuOrder[30]);
if(!$hasProductTrack)
if(!$config->URAndSR) unset($lang->product->menu->requirement, $lang->product->menuOrder[35]);
if(!helper::hasFeature('product_roadmap')) unset($lang->product->menu->roadmap, $lang->product->menuOrder[30]);
if(!helper::hasFeature('product_track'))
{
unset($lang->product->menu->track, $lang->product->menuOrder[40]);
$lang->product->dividerMenu = str_replace(',track,', ',doc,', $lang->product->dividerMenu);
}
if(!$hasWaterfall) unset($lang->admin->menu->model['dropMenu']->waterfall);
if(!helper::hasFeature('waterfall')) unset($lang->admin->menu->model['dropMenu']->waterfall);
if(!$hasOtherDevops)
if(!helper::hasFeature('devops'))
{
unset($lang->mainNav->devops, $lang->mainNav->menuOrder[35]);
unset($lang->scrum->menu->devops, $lang->scrum->menuOrder[25]);
unset($lang->waterfall->menu->devops, $lang->waterfall->menuOrder[35]);
}
if(!$hasOtherKanban)
if(!helper::hasFeature('kanban'))
{
unset($lang->mainNav->kanban, $lang->mainNav->menuOrder[40]);
$lang->dividerMenu = str_replace(',kanban,' , ',doc,', $lang->dividerMenu);
}
if(!$hasScrumAuditplan)
if($config->edition == 'max' and !helper::hasFeature('scrum_auditplan'))
{
if($hasScrumProcess)
if(!helper::hasFeature('scrum_process'))
{
$lang->admin->menu->model['dropMenu']->scrum = array('link' => "{$lang->scrumModel}|process|scrumbrowse|processID=0&browseType=scrum", 'subModule' => 'auditcl,process,activity,zoutput,classify,');
}
+2 -5
View File
@@ -1,8 +1,5 @@
<?php js::set('confirmDelete', $lang->doc->confirmDelete);?>
<?php $sessionString = session_name() . '=' . session_id();?>
<?php $hasAssetlib = strpos(",$config->disabledFeatures,", ',assetlib,') === false;?>
<?php $hasAssetlibPracticelib = strpos(",$config->disabledFeatures,", ',assetlibPracticelib,') === false;?>
<?php $hasAssetlibComponentlib = strpos(",$config->disabledFeatures,", ',assetlibComponentlib,') === false;?>
<div id="mainContent" class="main-row">
<div class="main-col col-8">
<div class="cell" id="content">
@@ -49,8 +46,8 @@
<?php if($this->config->edition == 'max' and $this->app->tab == 'project'):?>
<?php
$canImportToPracticeLib = (common::hasPriv('doc', 'importToPracticeLib') and $hasAssetlib and $hasAssetlibPracticelib);
$canImportToComponentLib = (common::hasPriv('doc', 'importToComponentLib') and $hasAssetlib and $hasAssetlibComponentlib);
$canImportToPracticeLib = (common::hasPriv('doc', 'importToPracticeLib') and helper::hasFeature('practicelib'));
$canImportToComponentLib = (common::hasPriv('doc', 'importToComponentLib') and helper::hasFeature('componentlib'));
if($canImportToPracticeLib or $canImportToComponentLib)
{
+39 -47
View File
@@ -1888,54 +1888,46 @@ $lang->dev->methodOrder[15] = 'editor';
$lang->dev->methodOrder[20] = 'translate';
global $config;
$inUpgrade = (defined('IN_UPGRADE') and IN_UPGRADE);
$isURSR = ($config->URAndSR or $inUpgrade);
$hasProgram = ($config->systemMode == 'ALM' or $inUpgrade);
$hasProductTrack = (strpos(",$config->disabledFeatures,", ',productTrack,') === false or $inUpgrade);
$hasProductRoadmap = (strpos(",$config->disabledFeatures,", ',productRoadmap,') === false or $inUpgrade);
$hasWaterfallTrack = (strpos(",$config->disabledFeatures,", ',waterfallTrack,') === false or $inUpgrade);
$hasWaterfall = (strpos(",$config->disabledFeatures,", ',waterfall,') === false or $inUpgrade);
$hasAssetlib = (strpos(",$config->disabledFeatures,", ',assetlib,') === false or $inUpgrade);
$hasOtherDevops = (strpos(",$config->disabledFeatures,", ',otherDevops,') === false or $inUpgrade);
$hasOtherKanban = (strpos(",$config->disabledFeatures,", ',otherKanban,') === false or $inUpgrade);
if(!$hasWaterfall)
$inUpgrade = (defined('IN_UPGRADE') and IN_UPGRADE);
if(!$inUpgrade)
{
unset($lang->resource->design);
unset($lang->resource->programplan);
unset($lang->resource->stage);
if(!$config->URAndSR)
{
unset($lang->resource->product->requirement);
unset($lang->resource->story->linkStory);
unset($lang->resource->requirement);
}
if($config->systemMode == 'light')
{
unset($lang->resource->program);
unset($lang->resource->project->programTitle);
}
if(!helper::hasFeature('waterfall'))
{
unset($lang->resource->design);
unset($lang->resource->programplan);
unset($lang->resource->stage);
}
if(!helper::hasFeature('product_track')) unset($lang->resource->product->track);
if(!helper::hasFeature('product_roadmap')) unset($lang->resource->product->roadmap);
if(!helper::hasFeature('waterfall_track')) unset($lang->resource->projectstory->track);
if(!helper::hasFeature('devops'))
{
unset($lang->resource->repo);
unset($lang->resource->svn);
unset($lang->resource->git);
unset($lang->resource->app);
unset($lang->resource->ci);
unset($lang->resource->compile);
unset($lang->resource->jenkins);
unset($lang->resource->job);
unset($lang->resource->gitlab);
unset($lang->resource->gogs);
unset($lang->resource->gitea);
unset($lang->resource->sonarqube);
unset($lang->resource->mr);
}
if(!helper::hasFeature('kanban')) unset($lang->resource->kanban);
}
if(!$hasProgram)
{
unset($lang->resource->program);
unset($lang->resource->project->programTitle);
}
if(!$isURSR)
{
unset($lang->resource->product->requirement);
unset($lang->resource->story->linkStory);
unset($lang->resource->requirement);
}
if(!$hasProductTrack) unset($lang->resource->product->track);
if(!$hasProductRoadmap) unset($lang->resource->product->roadmap);
if(!$hasWaterfallTrack) unset($lang->resource->projectstory->track);
if(!$hasOtherDevops)
{
unset($lang->resource->repo);
unset($lang->resource->svn);
unset($lang->resource->git);
unset($lang->resource->app);
unset($lang->resource->ci);
unset($lang->resource->compile);
unset($lang->resource->jenkins);
unset($lang->resource->job);
unset($lang->resource->gitlab);
unset($lang->resource->gogs);
unset($lang->resource->gitea);
unset($lang->resource->sonarqube);
unset($lang->resource->mr);
}
if(!$hasOtherKanban) unset($lang->resource->kanban);
include (dirname(__FILE__) . '/changelog.php');
+2 -2
View File
@@ -99,9 +99,9 @@ $lang->my->auditMenu->audit = new stdclass();
$lang->my->auditMenu->audit->all = 'All';
$lang->my->auditMenu->audit->story = 'Story';
$lang->my->auditMenu->audit->testcase = 'Case';
if($config->edition == 'max' and strpos(",$config->disabledFeatures,", ',waterfall,') === false) $lang->my->auditMenu->audit->project = 'Project';
if($config->edition == 'max' and helper::hasFeature('waterfall')) $lang->my->auditMenu->audit->project = 'Project';
if($config->edition != 'open') $lang->my->auditMenu->audit->feedback = 'Feedback';
if($config->edition != 'open' and strpos(",$config->disabledFeatures,", ',otherOA,') === false) $lang->my->auditMenu->audit->oa = 'OA';
if($config->edition != 'open' and helper::hasFeature('OA')) $lang->my->auditMenu->audit->oa = 'OA';
$lang->my->contributeMenu = new stdclass();
$lang->my->contributeMenu->audit = new stdclass();
+2 -2
View File
@@ -99,9 +99,9 @@ $lang->my->auditMenu->audit = new stdclass();
$lang->my->auditMenu->audit->all = 'All';
$lang->my->auditMenu->audit->story = 'Story';
$lang->my->auditMenu->audit->testcase = 'Case';
if($config->edition == 'max' and strpos(",$config->disabledFeatures,", ',waterfall,') === false) $lang->my->auditMenu->audit->project = 'Project';
if($config->edition == 'max' and helper::hasFeature('waterfall')) $lang->my->auditMenu->audit->project = 'Project';
if($config->edition != 'open') $lang->my->auditMenu->audit->feedback = 'Feedback';
if($config->edition != 'open' and strpos(",$config->disabledFeatures,", ',otherOA,') === false) $lang->my->auditMenu->audit->oa = 'OA';
if($config->edition != 'open' and helper::hasFeature('OA')) $lang->my->auditMenu->audit->oa = 'OA';
$lang->my->contributeMenu = new stdclass();
$lang->my->contributeMenu->audit = new stdclass();
+2 -2
View File
@@ -99,9 +99,9 @@ $lang->my->auditMenu->audit = new stdclass();
$lang->my->auditMenu->audit->all = 'All';
$lang->my->auditMenu->audit->story = 'Story';
$lang->my->auditMenu->audit->testcase = 'Case';
if($config->edition == 'max' and strpos(",$config->disabledFeatures,", ',waterfall,') === false) $lang->my->auditMenu->audit->project = 'Project';
if($config->edition == 'max' and helper::hasFeature('waterfall')) $lang->my->auditMenu->audit->project = 'Project';
if($config->edition != 'open') $lang->my->auditMenu->audit->feedback = 'Feedback';
if($config->edition != 'open' and strpos(",$config->disabledFeatures,", ',otherOA,') === false) $lang->my->auditMenu->audit->oa = 'OA';
if($config->edition != 'open' and helper::hasFeature('OA')) $lang->my->auditMenu->audit->oa = 'OA';
$lang->my->contributeMenu = new stdclass();
$lang->my->contributeMenu->audit = new stdclass();
+2 -2
View File
@@ -99,9 +99,9 @@ $lang->my->auditMenu->audit = new stdclass();
$lang->my->auditMenu->audit->all = '所有';
$lang->my->auditMenu->audit->story = '需求';
$lang->my->auditMenu->audit->testcase = '用例';
if($config->edition == 'max' and strpos(",$config->disabledFeatures,", ',waterfall,') === false) $lang->my->auditMenu->audit->project = '项目';
if($config->edition == 'max' and helper::hasFeature('waterfall')) $lang->my->auditMenu->audit->project = '项目';
if($config->edition != 'open') $lang->my->auditMenu->audit->feedback = '反馈';
if($config->edition != 'open' and strpos(",$config->disabledFeatures,", ',otherOA,') === false) $lang->my->auditMenu->audit->oa = '办公';
if($config->edition != 'open' and helper::hasFeature('OA')) $lang->my->auditMenu->audit->oa = '办公';
$lang->my->contributeMenu = new stdclass();
$lang->my->contributeMenu->audit = new stdclass();
+1 -4
View File
@@ -260,12 +260,9 @@ $lang->project->currencySymbol['SGD'] = 'S$';
$lang->project->modelList[''] = '';
$lang->project->modelList['scrum'] = "Scrum";
$lang->project->modelList['waterfall'] = "CMMI";
if(helper::hasFeature('waterfall')) $lang->project->modelList['waterfall'] = "CMMI";
$lang->project->modelList['kanban'] = "Kanban";
global $config;
if(strpos(",$config->disabledFeatures,", ',waterfall,') !== false) unset($lang->project->modelList['waterfall']);
$lang->project->featureBar['browse']['all'] = 'All';
$lang->project->featureBar['browse']['undone'] = 'Unfinished';
$lang->project->featureBar['browse']['wait'] = 'Waiting';
+1 -4
View File
@@ -260,12 +260,9 @@ $lang->project->currencySymbol['SGD'] = 'S$';
$lang->project->modelList[''] = '';
$lang->project->modelList['scrum'] = "Scrum";
$lang->project->modelList['waterfall'] = "CMMI";
if(helper::hasFeature('waterfall')) $lang->project->modelList['waterfall'] = "CMMI";
$lang->project->modelList['kanban'] = "Kanban";
global $config;
if(strpos(",$config->disabledFeatures,", ',waterfall,') !== false) unset($lang->project->modelList['waterfall']);
$lang->project->featureBar['browse']['all'] = 'All';
$lang->project->featureBar['browse']['undone'] = 'Unfinished';
$lang->project->featureBar['browse']['wait'] = 'Waiting';
+4 -7
View File
@@ -258,13 +258,10 @@ $lang->project->currencySymbol['NZD'] = 'NZ$';
$lang->project->currencySymbol['THB'] = '฿';
$lang->project->currencySymbol['SGD'] = 'S$';
$lang->project->modelList[''] = '';
$lang->project->modelList['scrum'] = "Scrum";
$lang->project->modelList['waterfall'] = "CMMI";
$lang->project->modelList['kanban'] = "Kanban";
global $config;
if(strpos(",$config->disabledFeatures,", ',waterfall,') !== false) unset($lang->project->modelList['waterfall']);
$lang->project->modelList[''] = '';
$lang->project->modelList['scrum'] = "Scrum";
if(helper::hasFeature('waterfall')) $lang->project->modelList['waterfall'] = "CMMI";
$lang->project->modelList['kanban'] = "Kanban";
$lang->project->featureBar['browse']['all'] = 'All';
$lang->project->featureBar['browse']['undone'] = 'Non Terminées';
+4 -7
View File
@@ -258,13 +258,10 @@ $lang->project->currencySymbol['NZD'] = 'NZ$';
$lang->project->currencySymbol['THB'] = '฿';
$lang->project->currencySymbol['SGD'] = 'S$';
$lang->project->modelList[''] = "";
$lang->project->modelList['scrum'] = "Scrum";
$lang->project->modelList['waterfall'] = "瀑布";
$lang->project->modelList['kanban'] = "看板";
global $config;
if(strpos(",$config->disabledFeatures,", ',waterfall,') !== false) unset($lang->project->modelList['waterfall']);
$lang->project->modelList[''] = "";
$lang->project->modelList['scrum'] = "Scrum";
if(helper::hasFeature('waterfall')) $lang->project->modelList['waterfall'] = "瀑布";
$lang->project->modelList['kanban'] = "看板";
$lang->project->featureBar['browse']['all'] = '全部';
$lang->project->featureBar['browse']['undone'] = '未完成';
+2 -2
View File
@@ -21,8 +21,8 @@
<h2 class='text-center'><?php echo $lang->project->chooseProgramType; ?></h2>
<div class='row'>
<?php
$hasWaterfall = strpos(",$config->disabledFeatures,", ',waterfall,') === false;
$colClass = $hasWaterfall ? 'col-xs-4' : 'col-xs-6';
$hasWaterfall = helper::hasFeature('waterfall');
$colClass = $hasWaterfall ? 'col-xs-4' : 'col-xs-6';
?>
<div class='<?php echo $colClass?>'>
<?php $tab = $from == 'global' ? 'project' : $app->tab;?>