mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-03 16:51:40 +09:00
Add 3 special exception classes for common situations
This commit is contained in:
parent
1863edcbb8
commit
fe4e336f2b
11 changed files with 82 additions and 25 deletions
18
common/framework/exceptions/invalidrequest.php
Normal file
18
common/framework/exceptions/invalidrequest.php
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace Rhymix\Framework\Exceptions;
|
||||
|
||||
/**
|
||||
* The "invalid request" exception class.
|
||||
*/
|
||||
class InvalidRequest extends \Rhymix\Framework\Exception
|
||||
{
|
||||
public function __construct($message = '', $code = 0, $previous = null)
|
||||
{
|
||||
if ($message === '')
|
||||
{
|
||||
$message = lang('msg_invalid_request');
|
||||
}
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
}
|
||||
18
common/framework/exceptions/notpermitted.php
Normal file
18
common/framework/exceptions/notpermitted.php
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace Rhymix\Framework\Exceptions;
|
||||
|
||||
/**
|
||||
* The "not permitted" exception class.
|
||||
*/
|
||||
class NotPermitted extends \Rhymix\Framework\Exception
|
||||
{
|
||||
public function __construct($message = '', $code = 0, $previous = null)
|
||||
{
|
||||
if ($message === '')
|
||||
{
|
||||
$message = lang('msg_not_permitted');
|
||||
}
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
}
|
||||
18
common/framework/exceptions/targetnotfound.php
Normal file
18
common/framework/exceptions/targetnotfound.php
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace Rhymix\Framework\Exceptions;
|
||||
|
||||
/**
|
||||
* The "target not found" exception class.
|
||||
*/
|
||||
class TargetNotFound extends \Rhymix\Framework\Exception
|
||||
{
|
||||
public function __construct($message = '', $code = 0, $previous = null)
|
||||
{
|
||||
if ($message === '')
|
||||
{
|
||||
$message = lang('msg_not_founded');
|
||||
}
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
}
|
||||
|
|
@ -35,7 +35,7 @@ class adminAdminController extends admin
|
|||
$menuSrl = Context::get('menu_srl');
|
||||
if(!$menuSrl)
|
||||
{
|
||||
return $this->stop('msg_invalid_request');
|
||||
throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
}
|
||||
|
||||
$oMenuAdminController = getAdminController('menu');
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@ class boardAdminController extends board {
|
|||
$module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl);
|
||||
if($module_info->mid != $mid)
|
||||
{
|
||||
throw new Rhymix\Framework\Exception('msg_invalid_request');
|
||||
throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
}
|
||||
|
||||
$module_info->hide_category = Context::get('hide_category') == 'Y' ? 'Y' : 'N';
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class boardController extends board
|
|||
// check grant
|
||||
if(!$this->grant->write_document)
|
||||
{
|
||||
throw new Rhymix\Framework\Exception('msg_not_permitted');
|
||||
throw new Rhymix\Framework\Exceptions\NotPermitted;
|
||||
}
|
||||
|
||||
// setup variables
|
||||
|
|
@ -107,7 +107,7 @@ class boardController extends board
|
|||
{
|
||||
if(!$oDocument->isGranted())
|
||||
{
|
||||
throw new Rhymix\Framework\Exception('msg_not_permitted');
|
||||
throw new Rhymix\Framework\Exceptions\NotPermitted;
|
||||
}
|
||||
|
||||
// Protect admin document
|
||||
|
|
@ -356,7 +356,7 @@ class boardController extends board
|
|||
// check grant
|
||||
if(!$this->grant->write_comment)
|
||||
{
|
||||
throw new Rhymix\Framework\Exception('msg_not_permitted');
|
||||
throw new Rhymix\Framework\Exceptions\NotPermitted;
|
||||
}
|
||||
$logged_info = Context::get('logged_info');
|
||||
|
||||
|
|
@ -398,7 +398,7 @@ class boardController extends board
|
|||
$oDocument = $oDocumentModel->getDocument($obj->document_srl);
|
||||
if(!$oDocument->isExists())
|
||||
{
|
||||
throw new Rhymix\Framework\Exception('msg_not_founded');
|
||||
throw new Rhymix\Framework\Exceptions\TargetNotFound;
|
||||
}
|
||||
|
||||
// For anonymous use, remove writer's information and notifying information
|
||||
|
|
@ -461,7 +461,7 @@ class boardController extends board
|
|||
$parent_comment = $oCommentModel->getComment($obj->parent_srl);
|
||||
if(!$parent_comment->comment_srl)
|
||||
{
|
||||
throw new Rhymix\Framework\Exception('msg_invalid_request');
|
||||
throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
}
|
||||
if($parent_comment->isSecret() && $this->module_info->secret === 'Y')
|
||||
{
|
||||
|
|
@ -496,7 +496,7 @@ class boardController extends board
|
|||
// check the grant
|
||||
if(!$comment->isGranted())
|
||||
{
|
||||
throw new Rhymix\Framework\Exception('msg_not_permitted');
|
||||
throw new Rhymix\Framework\Exceptions\NotPermitted;
|
||||
}
|
||||
$obj->parent_srl = $comment->parent_srl;
|
||||
$output = $oCommentController->updateComment($obj, $this->grant->manager);
|
||||
|
|
@ -530,7 +530,7 @@ class boardController extends board
|
|||
|
||||
if(!$comment_srl)
|
||||
{
|
||||
throw new Rhymix\Framework\Exception('msg_invalid_request');
|
||||
throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
}
|
||||
|
||||
$oCommentModel = getModel('comment');
|
||||
|
|
@ -662,7 +662,7 @@ class boardController extends board
|
|||
$oComment = $oCommentModel->getComment($comment_srl);
|
||||
if(!$oComment->isExists())
|
||||
{
|
||||
throw new Rhymix\Framework\Exception('msg_invalid_request');
|
||||
throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
}
|
||||
|
||||
// compare the comment password and the user input password
|
||||
|
|
@ -678,7 +678,7 @@ class boardController extends board
|
|||
$oDocument = $oDocumentModel->getDocument($document_srl);
|
||||
if(!$oDocument->isExists())
|
||||
{
|
||||
throw new Rhymix\Framework\Exception('msg_invalid_request');
|
||||
throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
}
|
||||
|
||||
// compare the document password and the user input password
|
||||
|
|
|
|||
|
|
@ -998,7 +998,7 @@ class boardView extends board
|
|||
// if the parent comment is not existed
|
||||
if(!$parent_srl)
|
||||
{
|
||||
throw new Rhymix\Framework\Exception('msg_invalid_request');
|
||||
throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
}
|
||||
|
||||
// get the comment
|
||||
|
|
@ -1060,7 +1060,7 @@ class boardView extends board
|
|||
// if the comment is not existed
|
||||
if(!$comment_srl)
|
||||
{
|
||||
throw new Rhymix\Framework\Exception('msg_invalid_request');
|
||||
throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
}
|
||||
|
||||
// get comment information
|
||||
|
|
@ -1233,7 +1233,7 @@ class boardView extends board
|
|||
|
||||
if($this->grant->update_view !== true)
|
||||
{
|
||||
throw new Rhymix\Framework\Exception('msg_not_permitted');
|
||||
throw new Rhymix\Framework\Exceptions\NotPermitted;
|
||||
}
|
||||
|
||||
$updatelog = $oDocumentModel->getDocumentUpdateLog($document_srl);
|
||||
|
|
@ -1253,7 +1253,7 @@ class boardView extends board
|
|||
|
||||
if($this->grant->update_view !== true)
|
||||
{
|
||||
throw new Rhymix\Framework\Exception('msg_not_permitted');
|
||||
throw new Rhymix\Framework\Exceptions\NotPermitted;
|
||||
}
|
||||
|
||||
$update_log = $oDocumentModel->getUpdateLog($update_id);
|
||||
|
|
@ -1289,7 +1289,7 @@ class boardView extends board
|
|||
{
|
||||
iF($this->grant->vote_log_view !== true)
|
||||
{
|
||||
throw new Rhymix\Framework\Exception('msg_not_permitted');
|
||||
throw new Rhymix\Framework\Exceptions\NotPermitted;
|
||||
}
|
||||
|
||||
$oMemberModel = getModel('member');
|
||||
|
|
|
|||
|
|
@ -297,7 +297,7 @@ class importerAdminController extends importer
|
|||
switch($type)
|
||||
{
|
||||
case 'ttxml' :
|
||||
if(!$target_module) throw new Rhymix\Framework\Exception('msg_invalid_request');
|
||||
if(!$target_module) throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
|
||||
$oModuleModel = getModel('module');
|
||||
$columnList = array('module_srl', 'module');
|
||||
|
|
@ -317,7 +317,7 @@ class importerAdminController extends importer
|
|||
break;
|
||||
case 'module' :
|
||||
// Check if the target module exists
|
||||
if(!$target_module) throw new Rhymix\Framework\Exception('msg_invalid_request');
|
||||
if(!$target_module) throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
$cur = $this->importModule($key, $cur, $index_file, $target_module);
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ class installAdminController extends install
|
|||
function procInstallAdminInstall()
|
||||
{
|
||||
$module_name = Context::get('module_name');
|
||||
if(!$module_name) throw new Rhymix\Framework\Exception('invalid_request');
|
||||
if(!$module_name) throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
|
||||
$oInstallController = getController('install');
|
||||
$oInstallController->installModule($module_name, './modules/'.$module_name);
|
||||
|
|
@ -35,10 +35,10 @@ class installAdminController extends install
|
|||
{
|
||||
@set_time_limit(0);
|
||||
$module_name = Context::get('module_name');
|
||||
if(!$module_name) throw new Rhymix\Framework\Exception('invalid_request');
|
||||
if(!$module_name) throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
|
||||
$oModule = getModule($module_name, 'class');
|
||||
if(!$oModule) throw new Rhymix\Framework\Exception('invalid_request');
|
||||
if(!$oModule) throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
|
||||
$output = $oModule->moduleUpdate();
|
||||
if($output instanceof BaseObject && !$output->toBool())
|
||||
|
|
|
|||
|
|
@ -49,7 +49,10 @@ class integration_searchView extends integration_search
|
|||
}
|
||||
|
||||
// Check permissions
|
||||
if(!$this->grant->access) throw new Rhymix\Framework\Exception('msg_not_permitted');
|
||||
if(!$this->grant->access)
|
||||
{
|
||||
throw new Rhymix\Framework\Exceptions\NotPermitted;
|
||||
}
|
||||
|
||||
$config = $oModuleModel->getModuleConfig('integration_search');
|
||||
if(!$config) $config = new stdClass;
|
||||
|
|
|
|||
|
|
@ -198,7 +198,7 @@ class pointAdminController extends point
|
|||
function procPointAdminInsertPointModuleConfig()
|
||||
{
|
||||
$module_srl = Context::get('target_module_srl');
|
||||
if(!$module_srl) throw new Rhymix\Framework\Exception('msg_invalid_request');
|
||||
if(!$module_srl) throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
// In case of batch configuration of several modules
|
||||
if(preg_match('/^([0-9,]+)$/',$module_srl)) $module_srl = explode(',',$module_srl);
|
||||
else $module_srl = array($module_srl);
|
||||
|
|
@ -375,7 +375,7 @@ class pointAdminController extends point
|
|||
$position = (int)Context::get('position');
|
||||
$total = (int)Context::get('total');
|
||||
|
||||
if(!file_exists('./files/cache/pointRecal.txt')) throw new Rhymix\Framework\Exception('msg_invalid_request');
|
||||
if(!file_exists('./files/cache/pointRecal.txt')) throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
|
||||
$idx = 0;
|
||||
$f = fopen("./files/cache/pointRecal.txt","r");
|
||||
|
|
@ -418,7 +418,7 @@ class pointAdminController extends point
|
|||
function procPointAdminReset()
|
||||
{
|
||||
$module_srl = Context::get('module_srls');
|
||||
if(!$module_srl) throw new Rhymix\Framework\Exception('msg_invalid_request');
|
||||
if(!$module_srl) throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
// In case of batch configuration of several modules
|
||||
if(preg_match('/^([0-9,]+)$/',$module_srl)) $module_srl = explode(',',$module_srl);
|
||||
else $module_srl = array($module_srl);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue