From 78901e92a013ecbcf302de4135116f7315507134 Mon Sep 17 00:00:00 2001 From: liumengyi Date: Tue, 2 Jul 2024 16:59:14 +0800 Subject: [PATCH] * [bug#51887,start,0.5h] use action to check status. --- module/release/control.php | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/module/release/control.php b/module/release/control.php index 20d279cbad..0da814a6e5 100644 --- a/module/release/control.php +++ b/module/release/control.php @@ -542,16 +542,36 @@ class release extends control * Change status. * * @param int $releaseID - * @param string $status normal|terminate + * @param string $action publish|play|pause * @access public * @return void */ - public function changeStatus(int $releaseID, string $status) + public function changeStatus(int $releaseID, string $action) { + $status = 'normal'; + if($action == 'pause') $status = 'terminate'; + if($action == 'active') + { + $hasOld = false; + $actions = $this->loadModel('action')->getList('release', $releaseID); + foreach(array_reverse($actions) as $releaseAction) + { + foreach($releaseAction->history as $history) + { + if($history->field == 'status') + { + $status = $history->old; + $hasOld = true; + break; + } + } + if($hasOld) break; + } + } $this->release->changeStatus($releaseID, $status); if(dao::isError()) return $this->sendError(dao::getError()); - $this->loadModel('action')->create('release', $releaseID, 'changestatus', '', $status); + $this->loadModel('action')->create('release', $releaseID, 'changestatus', '', $action); return $this->sendSuccess(array('load' => true)); } }