From 4dd0589417f89826ba9e94db66398dff805660a4 Mon Sep 17 00:00:00 2001 From: Yagami <976204163@qq.com> Date: Wed, 21 Oct 2020 14:30:53 +0800 Subject: [PATCH] * Fix bug. --- module/program/control.php | 16 ++++++++++++++-- module/program/view/pgmstakeholder.html.php | 4 ++-- module/project/model.php | 4 ++-- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/module/program/control.php b/module/program/control.php index 0ae6b07ec2..6fd79b49fa 100644 --- a/module/program/control.php +++ b/module/program/control.php @@ -496,15 +496,27 @@ class program extends control * @access public * @return void */ - public function unlinkStakeholder($stakeholderID, $confirm = 'no') + public function unlinkStakeholder($stakeholderID, $programID, $confirm = 'no') { if($confirm == 'no') { - die(js::confirm($this->lang->program->confirmDelete, $this->inlink('unlinkStakeholder', "stakeholderID=$stakeholderID&confirm=yes"))); + die(js::confirm($this->lang->program->confirmDelete, $this->inlink('unlinkStakeholder', "stakeholderID=$stakeholderID&programID=$programID&confirm=yes"))); } else { + $account = $this->dao->select('user')->from(TABLE_STAKEHOLDER)->where('id')->eq($stakeholderID)->fetch('user'); $this->dao->delete()->from(TABLE_STAKEHOLDER)->where('id')->eq($stakeholderID)->exec(); + + $this->loadModel('user')->updateUserView($programID, 'program', array($account)); + + /* Update children user view. */ + $childPgmList = $this->dao->select('id')->from(TABLE_PROJECT)->where('path')->like("%,$programID,%")->andWhere('type')->eq('program')->fetchPairs(); + $childPRJList = $this->dao->select('id')->from(TABLE_PROJECT)->where('path')->like("%,$programID,%")->andWhere('type')->eq('project')->fetchPairs(); + $childProducts = $this->dao->select('id')->from(TABLE_PRODUCT)->where('program')->eq($programID)->fetchPairs(); + + if(!empty($childPGMList)) $this->user->updateUserView($childPGMList, 'program', array($account)); + if(!empty($childPRJList)) $this->user->updateUserView($childPRJList, 'project', array($account)); + if(!empty($childProducts)) $this->user->updateUserView($childProducts, 'product', array($account)); die(js::reload('parent')); } diff --git a/module/program/view/pgmstakeholder.html.php b/module/program/view/pgmstakeholder.html.php index 5a69ee3a10..5b1cbee931 100644 --- a/module/program/view/pgmstakeholder.html.php +++ b/module/program/view/pgmstakeholder.html.php @@ -54,8 +54,8 @@ email;?> createLink('program', 'unlinkStakeholder', "id=$stakeholder->id"), '', 'hiddenwin', "title='{$lang->delete}' class='{$deleteClass}'"); + $deleteClass = common::hasPriv('program', 'unlinkStakeholder') ? 'btn' : 'btn disabled'; + echo html::a($this->createLink('program', 'unlinkStakeholder', "id=$stakeholder->id&programID=$programID&confirm=no"), '', 'hiddenwin', "title='{$lang->delete}' class='{$deleteClass}'"); ?> diff --git a/module/project/model.php b/module/project/model.php index bf446183e5..e85e9d27a7 100644 --- a/module/project/model.php +++ b/module/project/model.php @@ -132,7 +132,7 @@ class projectModel extends model if(common::hasPriv('project', 'create')) $projectIndex .= '
  • ' . html::a(helper::createLink('project', 'create'), ' ' . $this->lang->project->create) . '
  • '; $projectIndex .= ''; - $projectIndex .= $this->select(null, $projectID, null, $moduleName, $methodName, $extra); + $projectIndex .= $this->select($projects, $projectID, null, $moduleName, $methodName, $extra); $this->lang->modulePageNav = $projectIndex; foreach($this->lang->project->menu as $key => $menu) @@ -733,7 +733,7 @@ class projectModel extends model /* Order by status's content whether or not done */ $projects = $this->dao->select('*, IF(INSTR(" done,closed", status) < 2, 0, 1) AS isDone')->from(TABLE_PROJECT) ->where('deleted')->eq(0) - ->beginIF($programID)->andWhere('parent')->eq($programID)->fi() + ->beginIF($programID)->andWhere('project')->eq($programID)->fi() ->beginIF(strpos($mode, 'withdelete') === false)->andWhere('deleted')->eq(0)->fi() ->beginIF(!$this->app->user->admin)->andWhere('id')->in($this->app->user->view->sprints)->fi() ->orderBy($orderBy)