mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-28 14:52:24 +09:00
Update document, comment, file modules to throw exceptions
This commit is contained in:
parent
5be05dd875
commit
ad00ac800b
11 changed files with 142 additions and 110 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -28,21 +28,21 @@ class documentController extends document
|
|||
{
|
||||
if(!Context::get('is_logged'))
|
||||
{
|
||||
return $this->setError('msg_invalid_request');
|
||||
throw new Rhymix\Framework\Exceptions\NotPermitted;
|
||||
}
|
||||
}
|
||||
|
||||
$document_srl = Context::get('target_srl');
|
||||
if(!$document_srl) return $this->setError('msg_invalid_request');
|
||||
if(!$document_srl) throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
|
||||
$oDocumentModel = getModel('document');
|
||||
$oDocument = $oDocumentModel->getDocument($document_srl, false, false);
|
||||
$module_srl = $oDocument->get('module_srl');
|
||||
if(!$module_srl) return $this->setError('msg_invalid_request');
|
||||
if(!$module_srl) throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
|
||||
$oModuleModel = getModel('module');
|
||||
$document_config = $oModuleModel->getModulePartConfig('document',$module_srl);
|
||||
if($document_config->use_vote_up=='N') return $this->setError('msg_invalid_request');
|
||||
if($document_config->use_vote_up=='N') throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
|
||||
$point = 1;
|
||||
$output = $this->updateVotedCount($document_srl, $point);
|
||||
|
|
@ -60,18 +60,18 @@ class documentController extends document
|
|||
{
|
||||
if(!Context::get('is_logged'))
|
||||
{
|
||||
return $this->setError('msg_invalid_request');
|
||||
throw new Rhymix\Framework\Exceptions\NotPermitted;
|
||||
}
|
||||
}
|
||||
|
||||
$document_srl = Context::get('target_srl');
|
||||
if(!$document_srl) return $this->setError('msg_invalid_request');
|
||||
if(!$document_srl) throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
|
||||
$oDocumentModel = getModel('document');
|
||||
$oDocument = $oDocumentModel->getDocument($document_srl, false, false);
|
||||
if($oDocument->get('voted_count') <= 0)
|
||||
{
|
||||
return $this->setError('msg_document_voted_cancel_not');
|
||||
throw new Rhymix\Framework\Exception('msg_document_voted_cancel_not');
|
||||
}
|
||||
$point = 1;
|
||||
$output = $this->updateVotedCountCancel($document_srl, $oDocument, $point);
|
||||
|
|
@ -114,21 +114,21 @@ class documentController extends document
|
|||
{
|
||||
if(!Context::get('is_logged'))
|
||||
{
|
||||
return $this->setError('msg_invalid_request');
|
||||
throw new Rhymix\Framework\Exceptions\NotPermitted;
|
||||
}
|
||||
}
|
||||
|
||||
$document_srl = Context::get('target_srl');
|
||||
if(!$document_srl) return $this->setError('msg_invalid_request');
|
||||
if(!$document_srl) throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
|
||||
$oDocumentModel = getModel('document');
|
||||
$oDocument = $oDocumentModel->getDocument($document_srl, false, false);
|
||||
$module_srl = $oDocument->get('module_srl');
|
||||
if(!$module_srl) return $this->setError('msg_invalid_request');
|
||||
if(!$module_srl) throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
|
||||
$oModuleModel = getModel('module');
|
||||
$document_config = $oModuleModel->getModulePartConfig('document',$module_srl);
|
||||
if($document_config->use_vote_down=='N') return $this->setError('msg_invalid_request');
|
||||
if($document_config->use_vote_down=='N') throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
|
||||
$point = -1;
|
||||
$output = $this->updateVotedCount($document_srl, $point);
|
||||
|
|
@ -146,18 +146,18 @@ class documentController extends document
|
|||
{
|
||||
if(!Context::get('is_logged'))
|
||||
{
|
||||
return $this->setError('msg_invalid_request');
|
||||
throw new Rhymix\Framework\Exceptions\NotPermitted;
|
||||
}
|
||||
}
|
||||
|
||||
$document_srl = Context::get('target_srl');
|
||||
if(!$document_srl) return $this->setError('msg_invalid_request');
|
||||
if(!$document_srl) throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
|
||||
$oDocumentModel = getModel('document');
|
||||
$oDocument = $oDocumentModel->getDocument($document_srl, false, false);
|
||||
if($oDocument->get('blamed_count') >= 0)
|
||||
{
|
||||
return $this->setError('msg_document_voted_cancel_not');
|
||||
throw new Rhymix\Framework\Exception('msg_document_voted_cancel_not');
|
||||
}
|
||||
$point = -1;
|
||||
$output = $this->updateVotedCountCancel($document_srl, $oDocument, $point);
|
||||
|
|
@ -229,13 +229,13 @@ class documentController extends document
|
|||
{
|
||||
if(!Context::get('is_logged'))
|
||||
{
|
||||
return $this->setError('msg_not_logged');
|
||||
throw new Rhymix\Framework\Exceptions\MustLogin;
|
||||
}
|
||||
|
||||
$document_srl = intval(Context::get('target_srl'));
|
||||
if(!$document_srl)
|
||||
{
|
||||
return $this->setError('msg_invalid_request');
|
||||
throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
}
|
||||
|
||||
// if an user select message from options, message would be the option.
|
||||
|
|
@ -2495,7 +2495,10 @@ class documentController extends document
|
|||
*/
|
||||
function procDocumentAddCart()
|
||||
{
|
||||
if(!Context::get('is_logged')) return $this->setError('msg_not_permitted');
|
||||
if(!Context::get('is_logged'))
|
||||
{
|
||||
throw new Rhymix\Framework\Exceptions\NotPermitted;
|
||||
}
|
||||
|
||||
// Get document_srl
|
||||
$srls = explode(',',Context::get('srls'));
|
||||
|
|
@ -2587,12 +2590,12 @@ class documentController extends document
|
|||
$module_info = getModel('module')->getModuleInfoByModuleSrl($obj->target_module_srl);
|
||||
if (!$module_info->module_srl)
|
||||
{
|
||||
return $this->setError('msg_invalid_request');
|
||||
throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
}
|
||||
$module_grant = getModel('module')->getGrant($module_info, $logged_info);
|
||||
if (!$module_grant->manager)
|
||||
{
|
||||
return $this->setError('msg_not_permitted');
|
||||
throw new Rhymix\Framework\Exceptions\NotPermitted;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2608,7 +2611,7 @@ class documentController extends document
|
|||
$obj->document_list = getModel('document')->getDocuments($obj->document_srl_list, false, false);
|
||||
if(empty($obj->document_list))
|
||||
{
|
||||
return $this->setError('msg_invalid_request');
|
||||
throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
}
|
||||
|
||||
// Call a trigger (before)
|
||||
|
|
@ -2623,7 +2626,7 @@ class documentController extends document
|
|||
{
|
||||
if(!$obj->target_module_srl)
|
||||
{
|
||||
return $this->setError('fail_to_move');
|
||||
throw new Rhymix\Framework\Exception('fail_to_move');
|
||||
}
|
||||
|
||||
$output = $oController->moveDocumentModule($obj->document_srl_list, $obj->target_module_srl, $obj->target_category_srl);
|
||||
|
|
@ -2638,7 +2641,7 @@ class documentController extends document
|
|||
{
|
||||
if(!$obj->target_module_srl)
|
||||
{
|
||||
return $this->setError('fail_to_move');
|
||||
throw new Rhymix\Framework\Exception('fail_to_move');
|
||||
}
|
||||
|
||||
$output = $oController->copyDocumentModule($obj->document_srl_list, $obj->target_module_srl, $obj->target_category_srl);
|
||||
|
|
@ -2695,7 +2698,7 @@ class documentController extends document
|
|||
}
|
||||
else
|
||||
{
|
||||
return $this->setError('msg_invalid_request');
|
||||
throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
}
|
||||
|
||||
// Call a trigger (after)
|
||||
|
|
@ -2764,13 +2767,13 @@ Content;
|
|||
$module_info = $oModuleModel->getModuleInfoByModuleSrl($srl);
|
||||
if (!$module_info->module_srl)
|
||||
{
|
||||
return $this->setError('msg_invalid_request');
|
||||
throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
}
|
||||
|
||||
$module_grant = $oModuleModel->getGrant($module_info, $logged_info);
|
||||
if (!$module_grant->manager)
|
||||
{
|
||||
return $this->setError('msg_not_permitted');
|
||||
throw new Rhymix\Framework\Exceptions\NotPermitted;
|
||||
}
|
||||
|
||||
$module_srl[] = $srl;
|
||||
|
|
@ -2811,7 +2814,7 @@ Content;
|
|||
{
|
||||
if(!$this->module_srl)
|
||||
{
|
||||
return $this->setError('msg_invalid_request');
|
||||
throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
}
|
||||
|
||||
$obj = Context::getRequestVars();
|
||||
|
|
@ -2834,12 +2837,12 @@ Content;
|
|||
{
|
||||
if(!$oDocument->isGranted())
|
||||
{
|
||||
return $this->setError('msg_invalid_request');
|
||||
throw new Rhymix\Framework\Exceptions\NotPermitted;
|
||||
}
|
||||
|
||||
if($oDocument->get('status') != $this->getConfigStatus('temp'))
|
||||
{
|
||||
return $this->setError('msg_invalid_request');
|
||||
throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
}
|
||||
|
||||
$output = $this->updateDocument($oDocument, $obj);
|
||||
|
|
@ -2871,7 +2874,11 @@ Content;
|
|||
*/
|
||||
function procDocumentGetList()
|
||||
{
|
||||
if(!Context::get('is_logged')) return $this->setError('msg_not_permitted');
|
||||
if(!Context::get('is_logged'))
|
||||
{
|
||||
throw new Rhymix\Framework\Exceptions\NotPermitted;
|
||||
}
|
||||
|
||||
$documentSrls = Context::get('document_srls');
|
||||
if($documentSrls) $documentSrlList = explode(',', $documentSrls);
|
||||
|
||||
|
|
|
|||
|
|
@ -448,7 +448,7 @@ class documentModel extends document
|
|||
$oDocument = $oDocumentModel->getDocument($document_srl, false, false, $columnList);
|
||||
$module_srl = $oDocument->get('module_srl');
|
||||
$member_srl = $oDocument->get('member_srl');
|
||||
if(!$module_srl) return $this->setError('msg_invalid_request');
|
||||
if(!$module_srl) throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
|
||||
$oModuleModel = getModel('module');
|
||||
$document_config = $oModuleModel->getModulePartConfig('document',$module_srl);
|
||||
|
|
@ -855,7 +855,7 @@ class documentModel extends document
|
|||
*/
|
||||
function getDocumentCategories()
|
||||
{
|
||||
if(!Context::get('is_logged')) return $this->setError('msg_not_permitted');
|
||||
if(!Context::get('is_logged')) throw new Rhymix\Framework\Exceptions\NotPermitted;
|
||||
$module_srl = Context::get('module_srl');
|
||||
$categories= $this->getCategoryList($module_srl);
|
||||
$lang = Context::get('lang');
|
||||
|
|
@ -950,13 +950,13 @@ class documentModel extends document
|
|||
$module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl);
|
||||
// Check permissions
|
||||
$grant = $oModuleModel->getGrant($module_info, Context::get('logged_info'));
|
||||
if(!$grant->manager) return $this->setError('msg_not_permitted');
|
||||
if(!$grant->manager) throw new Rhymix\Framework\Exceptions\NotPermitted;
|
||||
|
||||
$category_srl = Context::get('category_srl');
|
||||
$category_info = $this->getCategory($category_srl);
|
||||
if(!$category_info)
|
||||
{
|
||||
return $this->setError('msg_invalid_request');
|
||||
throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
}
|
||||
|
||||
$this->add('category_info', $category_info);
|
||||
|
|
@ -1138,7 +1138,7 @@ class documentModel extends document
|
|||
{
|
||||
$args = new stdClass;
|
||||
$document_srl = Context::get('document_srl');
|
||||
if(!$document_srl) return $this->setError('msg_invalid_request');
|
||||
if(!$document_srl) throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
|
||||
$point = Context::get('point');
|
||||
if($point != -1) $point = 1;
|
||||
|
|
@ -1147,18 +1147,18 @@ class documentModel extends document
|
|||
$columnList = array('document_srl', 'module_srl');
|
||||
$oDocument = $oDocumentModel->getDocument($document_srl, false, false, $columnList);
|
||||
$module_srl = $oDocument->get('module_srl');
|
||||
if(!$module_srl) return $this->setError('msg_invalid_request');
|
||||
if(!$module_srl) throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
|
||||
$oModuleModel = getModel('module');
|
||||
$document_config = $oModuleModel->getModulePartConfig('document',$module_srl);
|
||||
if($point == -1)
|
||||
{
|
||||
if($document_config->use_vote_down!='S') return $this->setError('msg_invalid_request');
|
||||
if($document_config->use_vote_down!='S') throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
$args->below_point = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if($document_config->use_vote_up!='S') return $this->setError('msg_invalid_request');
|
||||
if($document_config->use_vote_up!='S') throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
$args->more_point = 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,9 +36,9 @@ class documentView extends document
|
|||
$oDocumentModel = getModel('document');
|
||||
// Creates an object for displaying the selected document
|
||||
$oDocument = $oDocumentModel->getDocument($document_srl, $this->grant->manager);
|
||||
if(!$oDocument->isExists()) return $this->setError('msg_invalid_request');
|
||||
if(!$oDocument->isExists()) throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
// Check permissions
|
||||
if(!$oDocument->isAccessible()) return $this->setError('msg_not_permitted');
|
||||
if(!$oDocument->isAccessible()) throw new Rhymix\Framework\Exceptions\NotPermitted;
|
||||
// Information setting module
|
||||
//Context::set('module_info', $module_info); //module_info not use in UI
|
||||
// Browser title settings
|
||||
|
|
@ -58,7 +58,7 @@ class documentView extends document
|
|||
{
|
||||
if(!checkCSRF())
|
||||
{
|
||||
return $this->setError('msg_invalid_request');
|
||||
throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
}
|
||||
|
||||
$content = Context::get('content');
|
||||
|
|
@ -87,7 +87,7 @@ class documentView extends document
|
|||
*/
|
||||
function dispDocumentManageDocument()
|
||||
{
|
||||
if(!Context::get('is_logged')) return $this->setError('msg_not_permitted');
|
||||
if(!Context::get('is_logged')) throw new Rhymix\Framework\Exceptions\NotPermitted;
|
||||
// Taken from a list of selected sessions
|
||||
$flag_list = $_SESSION['document_management'];
|
||||
if(count($flag_list))
|
||||
|
|
@ -206,7 +206,7 @@ class documentView extends document
|
|||
// A message appears if the user is not logged-in
|
||||
if(!$oMemberModel->isLogged())
|
||||
{
|
||||
return $this->stop('msg_not_logged');
|
||||
throw new Rhymix\Framework\Exceptions\MustLogin;
|
||||
}
|
||||
|
||||
// Create the document object. If the document module of basic data structures, write it all works .. -_-;
|
||||
|
|
@ -215,12 +215,12 @@ class documentView extends document
|
|||
$oDocument = $oDocumentModel->getDocument($document_srl, $this->grant->manager, FALSE);
|
||||
if(!$oDocument->isExists())
|
||||
{
|
||||
return $this->setError('msg_invalid_request');
|
||||
throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
}
|
||||
// Check permissions
|
||||
if(!$oDocument->isAccessible())
|
||||
{
|
||||
return $this->setError('msg_not_permitted');
|
||||
throw new Rhymix\Framework\Exceptions\NotPermitted;
|
||||
}
|
||||
|
||||
// Browser title settings
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue