From 7f6ef8094024a18348c211c66fd456f25990e0ff Mon Sep 17 00:00:00 2001 From: tianshujie Date: Thu, 14 Sep 2023 16:17:24 +0800 Subject: [PATCH] * Refactor unlinkStakeholder method. --- module/program/control.php | 21 +++++++-------------- module/program/ui/stakeholder.html.php | 2 +- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/module/program/control.php b/module/program/control.php index 73b505ff08..97d4dccfa6 100644 --- a/module/program/control.php +++ b/module/program/control.php @@ -470,7 +470,7 @@ class program extends control * @access public * @return void */ - public function stakeholder($programID = 0, $orderBy = 't1.id_desc', $recTotal = 0, $recPerPage = 15, $pageID = 1) + public function stakeholder(int $programID = 0, string $orderBy = 't1.id_desc', int $recTotal = 0, int $recPerPage = 15, int $pageID = 1) { $this->app->loadLang('stakeholder'); common::setMenuVars('program', $programID); @@ -502,26 +502,19 @@ class program extends control } /** - * Unlink program stakeholder. + * 解除干系人跟项目集的关联关系。 + * Unlink stakeholder from the program. * - * @param int $stakeholderID * @param int $programID - * @param string $confirm + * @param int $stakeholderID * @access public * @return void */ - public function unlinkStakeholder($stakeholderID, $programID, $confirm = 'no') + public function unlinkStakeholder(int $programID, int $stakeholderID) { - if($confirm == 'no') - { - $actionUrl = $this->inlink('unlinkStakeholder', "stakeholderID=$stakeholderID&programID=$programID&confirm=yes"); - return $this->send(array('result' => 'success', 'callback' => "unlinkStakeholderConfirm('{$this->lang->program->confirmUnlink}', '$actionUrl')")); - } + $this->program->batchUnlinkStakeholders($programID, array($stakeholderID)); - $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->program->updateChildUserView($programID, array($account)); + if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); return $this->send(array('result' => 'success', 'load' => true)); } diff --git a/module/program/ui/stakeholder.html.php b/module/program/ui/stakeholder.html.php index ab1e297dc5..4c9ec613a3 100644 --- a/module/program/ui/stakeholder.html.php +++ b/module/program/ui/stakeholder.html.php @@ -74,7 +74,7 @@ $cols['actions']['list'] = array('unlinkStakeholder' => array( 'className' => 'ajax-submit', 'text' => $lang->program->unlinkStakeholder, 'hint' => $lang->program->unlinkStakeholder, - 'url' => $this->createLink('program', 'unlinkStakeholder', "id={id}&programID={$programID}"), + 'url' => $this->createLink('program', 'unlinkStakeholder', "programID={$programID}&id={id}"), 'data-confirm' => $lang->program->confirmUnlink, ) );