Update document, comment, file modules to throw exceptions

This commit is contained in:
Kijin Sung 2018-09-05 23:55:50 +09:00
parent 5be05dd875
commit ad00ac800b
11 changed files with 142 additions and 110 deletions

View file

@ -140,7 +140,7 @@ class documentAdminController extends document
$eid = Context::get('eid');
$obj = new stdClass();
if(!$module_srl || !$name || !$eid) return $this->setError('msg_invalid_request');
if(!$module_srl || !$name || !$eid) throw new Rhymix\Framework\Exceptions\InvalidRequest;
// set the max value if idx is not specified
if(!$var_idx)
{
@ -156,7 +156,7 @@ class documentAdminController extends document
$output = executeQuery('document.isExistsExtraKey', $obj);
if(!$output->toBool() || $output->data->count)
{
return $this->setError('msg_extra_name_exists');
throw new Rhymix\Framework\Exception('msg_extra_name_exists');
}
// insert or update
@ -178,7 +178,7 @@ class documentAdminController extends document
{
$module_srl = Context::get('module_srl');
$var_idx = Context::get('var_idx');
if(!$module_srl || !$var_idx) return $this->setError('msg_invalid_request');
if(!$module_srl || !$var_idx) throw new Rhymix\Framework\Exceptions\InvalidRequest;
$oDocumentController = getController('document');
$output = $oDocumentController->deleteDocumentExtraKeys($module_srl, $var_idx);
@ -197,26 +197,26 @@ class documentAdminController extends document
$module_srl = Context::get('module_srl');
$var_idx = Context::get('var_idx');
if(!$type || !$module_srl || !$var_idx) return $this->setError('msg_invalid_request');
if(!$type || !$module_srl || !$var_idx) throw new Rhymix\Framework\Exceptions\InvalidRequest;
$oModuleModel = getModel('module');
$module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl);
if(!$module_info->module_srl) return $this->setError('msg_invalid_request');
if(!$module_info->module_srl) throw new Rhymix\Framework\Exceptions\InvalidRequest;
$oDocumentModel = getModel('document');
$extra_keys = $oDocumentModel->getExtraKeys($module_srl);
if(!$extra_keys[$var_idx]) return $this->setError('msg_invalid_request');
if(!$extra_keys[$var_idx]) throw new Rhymix\Framework\Exceptions\InvalidRequest;
if($type == 'up') $new_idx = $var_idx-1;
else $new_idx = $var_idx+1;
if($new_idx<1) return $this->setError('msg_invalid_request');
if($new_idx<1) throw new Rhymix\Framework\Exceptions\InvalidRequest;
$args = new stdClass();
$args->module_srl = $module_srl;
$args->var_idx = $new_idx;
$output = executeQuery('document.getDocumentExtraKeys', $args);
if (!$output->toBool()) return $output;
if (!$output->data) return $this->setError('msg_invalid_request');
if (!$output->data) throw new Rhymix\Framework\Exceptions\InvalidRequest;
unset($args);
// update immediately if there is no idx to change
@ -320,7 +320,7 @@ class documentAdminController extends document
$member_info = $oMemberModel->getMemberInfoByMemberSrl($oDocument->get('member_srl'));
if($member_info->is_admin == 'Y' && $logged_info->is_admin != 'Y')
{
return $this->setError('msg_admin_document_no_move_to_trash');
throw new Rhymix\Framework\Exception('msg_admin_document_no_move_to_trash');
}
$oModuleModel = getModel('module');
@ -627,7 +627,7 @@ class documentAdminController extends document
//DB restore
$output = $oDocumentController->insertDocument($originObject, false, true, false);
if(!$output->toBool()) return $this->setError($output->getMessage());
if(!$output->toBool()) return $output;
//FILE restore
$oDocument = $oDocumentModel->getDocument($originObject->document_srl);