diff --git a/module/program/control.php b/module/program/control.php index 45e4329024..a63c82a7ef 100644 --- a/module/program/control.php +++ b/module/program/control.php @@ -395,24 +395,25 @@ class program extends control if(!empty($_POST)) { - $changes = $this->project->suspend($programID, 'program'); - if(dao::isError()) return print(js::error(dao::getError())); + $changes = $this->program->suspend($programID); + if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); if($this->post->comment != '' or !empty($changes)) { $actionID = $this->action->create('program', $programID, 'Suspended', $this->post->comment); $this->action->logHistory($actionID, $changes); } + $this->executeHooks($programID); - return print(js::reload('parent.parent')); + return $this->sendSuccess(array('closeModal' => true, 'load' => true)); } - $this->view->title = $this->lang->program->suspend; - $this->view->users = $this->loadModel('user')->getPairs('noletter'); - $this->view->actions = $this->action->getList('program', $programID); - $this->view->project = $this->project->getByID($programID, 'program'); + $this->view->title = $this->lang->program->suspend; + $this->view->users = $this->loadModel('user')->getPairs('noletter'); + $this->view->actions = $this->action->getList('program', $programID); + $this->view->program = $this->program->getByID($programID); - $this->display('project', 'suspend'); + $this->display(); } /** diff --git a/module/program/model.php b/module/program/model.php index b63b2d2559..4aa5d349fe 100644 --- a/module/program/model.php +++ b/module/program/model.php @@ -988,6 +988,35 @@ class programModel extends model return common::createChanges($oldProgram, $program); } + /** + * Suspend a program. + * + * @param int $programID + * @access public + * @return array + */ + public function suspend(int $programID) :array + { + $oldProgram = $this->getByID($programID); + $program = fixer::input('post') + ->add('id', $programID) + ->setDefault('status', 'suspended') + ->setDefault('lastEditedBy', $this->app->user->account) + ->setDefault('lastEditedDate', helper::now()) + ->setDefault('suspendedDate', helper::today()) + ->stripTags($this->config->program->editor->suspend['id'], $this->config->allowedTags) + ->remove('comment')->get(); + + $program = $this->loadModel('file')->processImgURL($program, $this->config->program->editor->suspend['id'], $this->post->uid); + $this->dao->update(TABLE_PROJECT)->data($program) + ->autoCheck() + ->checkFlow() + ->where('id')->eq((int)$programID) + ->exec(); + + if(!dao::isError()) return common::createChanges($oldProgram, $program); + } + /* * Get program swapper. * diff --git a/module/program/ui/suspend.html.php b/module/program/ui/suspend.html.php new file mode 100644 index 0000000000..bb914813c0 --- /dev/null +++ b/module/program/ui/suspend.html.php @@ -0,0 +1,27 @@ + + * @package project + * @link https://www.zentao.net + */ +namespace zin; + +modalHeader(); +formPanel +( + formGroup + ( + set::label($lang->comment), + editor + ( + set::name('comment'), + set::rows('6'), + ) + ), +); + +history();