示例#1
0
 protected function action_update()
 {
     if (!Permissions::has('access') or !Permissions::has('sys_installation_install')) {
         return $this->redirectForbidden();
     }
     $lang = i18n::load('diamondmvc-backend');
     if (!isset($_REQUEST['id']) or empty($_REQUEST['id'])) {
         $this->addMessage('Whoops!', $lang->get('ERROR_MISSING_ARGUMENTS'), 'error');
         $this->result = array('success' => false, 'msg' => $lang->get('ERROR_MISSING_ARGUMENTS'));
         return;
     }
     $path = jailpath(DIAMONDMVC_ROOT . DS . 'registry', $_REQUEST['id'] . '.json');
     if (!is_file($path)) {
         $this->addMessage('Whoops!', $lang->get('ERROR_NO_META', 'ControllerSystem.Installation', 'error'));
         $this->result = array('success' => false, 'msg' => $lang->get('ERROR_NO_META', 'ControllerSystem.Installation'));
         return;
     }
     try {
         $id = InstallationManager::update($path);
         $this->result = array('success' => true, 'id' => $id);
     } catch (Exception $ex) {
         $this->result = array('success' => false, 'msg' => $ex->getMessage());
         $this->addMessage('Whoops!', 'An exception occurred: ' . $ex->getMessage(), 'error');
         logMsg('DiamondMVC: failed to update installation ' . $_REQUEST['id'] . ' with exception (' . $ex->getCode() . '): ' . $ex->getMessage(), 9, false);
     }
 }