* Merge 18.8 program module.

This commit is contained in:
hufangzhou
2023-11-23 14:31:00 +08:00
parent 50fe064690
commit 8fede00b0f
2 changed files with 30 additions and 27 deletions
+6 -2
View File
@@ -103,7 +103,11 @@ class program extends control
public function product(int $programID = 0, string $browseType = 'noclosed', string $orderBy = 'order_asc', int $recTotal = 0, int $recPerPage = 15, int $pageID = 1)
{
$programPairs = $this->program->getPairs();
if(defined('RUN_MODE') && RUN_MODE == 'api' && !isset($programPairs[$programID])) return $this->send(array('status' => 'fail', 'code' => 404, 'message' => '404 Not found'));
if(!isset($programPairs[$programID]))
{
if(defined('RUN_MODE') && RUN_MODE == 'api') return $this->send(array('status' => 'fail', 'message' => '404 Not found'));
return print(js::error($this->lang->notFound) . js::locate($this->createLink('program', 'browse')));
}
$programID = $this->program->checkAccess($programID, $programPairs);
@@ -575,7 +579,7 @@ class program extends control
if($this->post->exportType == 'selected')
{
$checkedItem = $this->cookie->checkedItem;
$checkedItem = $this->post->checkedItem;
if(strpos(",$checkedItem,", ",{$program->id},") === false) unset($programs[$programID]);
}
}
+24 -25
View File
@@ -589,14 +589,12 @@ class programModel extends model
$query = str_replace('`id`','t1.id', $this->session->projectQuery);
}
$projectList = $this->dao->select('DISTINCT t1.*')->from(TABLE_PROJECT)->alias('t1')
->leftJoin(TABLE_TEAM)->alias('t2')->on('t1.id=t2.root')
->leftJoin(TABLE_STAKEHOLDER)->alias('t3')->on('t1.id=t3.objectID')
->where('t1.deleted')->eq('0')
$stmt = $this->dao->select('DISTINCT t1.*')->from(TABLE_PROJECT)->alias('t1');
if($this->cookie->involved) $stmt->leftJoin(TABLE_TEAM)->alias('t2')->on('t1.id=t2.root')->leftJoin(TABLE_STAKEHOLDER)->alias('t3')->on('t1.id=t3.objectID');
$stmt->where('t1.deleted')->eq('0')
->andWhere('t1.vision')->eq($this->config->vision)
->beginIF($browseType == 'bysearch' && $query)->andWhere($query)->fi()
->andWhere('t1.type')->eq('project')
->beginIF($this->cookie->involved)->andWhere('t2.type')->eq('project')->fi()
->beginIF(!in_array($browseType, array('all', 'undone', 'bysearch', 'review', 'unclosed'), true))->andWhere('t1.status')->eq($browseType)->fi()
->beginIF($browseType == 'undone' || $browseType == 'unclosed')->andWhere('t1.status')->in('wait,doing')->fi()
->beginIF($browseType == 'review')
@@ -604,23 +602,24 @@ class programModel extends model
->andWhere('t1.reviewStatus')->eq('doing')
->fi()
->beginIF($path)->andWhere('t1.path')->like($path . '%')->fi()
->beginIF(!$queryAll && !$this->app->user->admin)->andWhere('t1.id')->in($this->app->user->view->projects)->fi()
->beginIF($this->cookie->involved)
->andWhere('t1.openedBy', true)->eq($this->app->user->account)
->orWhere('t1.PM')->eq($this->app->user->account)
->orWhere('t2.account')->eq($this->app->user->account)
->orWhere('(t3.user')->eq($this->app->user->account)
->andWhere('t3.deleted')->eq(0)
->markRight(1)
->orWhere("CONCAT(',', t1.whitelist, ',')")->like("%,{$this->app->user->account},%")
->markRight(1)
->fi()
->orderBy($orderBy)
->page($pager, 't1.id')
->fetchAll('id');
->beginIF(!$queryAll && !$this->app->user->admin)->andWhere('t1.id')->in($this->app->user->view->projects)->fi();
if($this->cookie->involved)
{
$stmt->andWhere('t2.type')->eq('project')
->andWhere('t1.openedBy', true)->eq($this->app->user->account)
->orWhere('t1.PM')->eq($this->app->user->account)
->orWhere('t2.account')->eq($this->app->user->account)
->orWhere('(t3.user')->eq($this->app->user->account)
->andWhere('t3.deleted')->eq(0)
->markRight(1)
->orWhere("CONCAT(',', t1.whitelist, ',')")->like("%,{$this->app->user->account},%")
->markRight(1);
}
$projectList = $stmt->orderBy($orderBy)->page($pager, 't1.id')->fetchAll('id');
/* Determine how to display the name of the program. */
if($programTitle and $this->config->systemMode == 'ALM') $projectList = $this->batchProcessProgramName($projectList, $programTitle);
if($programTitle and in_array($this->config->systemMode, array('ALM', 'PLM'))) $projectList = $this->batchProcessProgramName($projectList, $programTitle);
return $projectList;
}
@@ -694,7 +693,7 @@ class programModel extends model
->checkIF($program->begin != '', 'begin', 'date')
->checkIF($program->end != '', 'end', 'date')
->checkIF($program->end != '', 'end', 'gt', $program->begin)
->checkIF(!empty($program->name), 'name', 'unique', "`type`='program' and `parent` = $program->parent and `deleted` = '0'")
->checkIF(!empty($program->name), 'name', 'unique', "`type`='program' and `parent` = " . $this->dao->sqlobj->quote($program->parent) . " and `deleted` = '0'")
->checkFlow()
->exec();
if(dao::isError()) return false;
@@ -744,7 +743,7 @@ class programModel extends model
->checkIF($program->begin != '', 'begin', 'date')
->checkIF($program->end != '', 'end', 'date')
->checkIF($program->end != '', 'end', 'gt', $program->begin)
->checkIF(!empty($program->name), 'name', 'unique', "id!=$programID and `type`='program' and `parent` = " . (int)$program->parent . " and `deleted` = '0'")
->checkIF(!empty($program->name), 'name', 'unique', "id!=$programID and `type`='program' and `parent` = " . $this->dao->sqlobj->quote($program->parent) . " and `deleted` = '0'")
->checkFlow()
->where('id')->eq($programID)
->exec();
@@ -1218,10 +1217,10 @@ class programModel extends model
$projects = $this->getProjectList($programID, $browseType, $queryID, $orderBy, $programTitle, $queryAll, $pager);
if(empty($projects)) return array();
$stats = $this->appendStatToProjects($projects);
foreach($stats as $project) $project->name = htmlspecialchars_decode($project->name, ENT_QUOTES); // Convert predefined HTML entities to characters.
/* Get the members of project teams. */
$teamMembers = $this->loadModel('project')->getTeamMemberGroup(array_keys($projects));
return $stats;
return $this->appendStatToProjects($projects, $teamMembers);
}
/**