diff --git a/addons/recaptcha/recaptcha.class.php b/addons/recaptcha/recaptcha.class.php index dbf2bf86c..11177627b 100644 --- a/addons/recaptcha/recaptcha.class.php +++ b/addons/recaptcha/recaptcha.class.php @@ -18,7 +18,7 @@ class reCAPTCHA $response = Context::get('g-recaptcha-response'); if (!$response) { - return new BaseObject(-1, 'recaptcha.msg_recaptcha_invalid_response'); + throw new Rhymix\Framework\Exception('recaptcha.msg_recaptcha_invalid_response'); } try @@ -31,17 +31,17 @@ class reCAPTCHA } catch (\Requests_Exception $e) { - return new BaseObject(-1, 'recaptcha.msg_recaptcha_connection_error'); + throw new Rhymix\Framework\Exception('recaptcha.msg_recaptcha_connection_error'); } $verify = @json_decode($verify_request->body, true); if ($verify && isset($verify['error-codes']) && in_array('invalid-input-response', $verify['error-codes'])) { - return new BaseObject(-1, 'recaptcha.msg_recaptcha_invalid_response'); + throw new Rhymix\Framework\Exception('recaptcha.msg_recaptcha_invalid_response'); } elseif (!$verify || !$verify['success'] || (isset($verify['error-codes']) && $verify['error-codes'])) { - return new BaseObject(-1, 'recaptcha.msg_recaptcha_server_error'); + throw new Rhymix\Framework\Exception('recaptcha.msg_recaptcha_server_error'); } else { diff --git a/classes/module/ModuleHandler.class.php b/classes/module/ModuleHandler.class.php index 9f59bd6ca..3c091437f 100644 --- a/classes/module/ModuleHandler.class.php +++ b/classes/module/ModuleHandler.class.php @@ -86,7 +86,7 @@ class ModuleHandler extends Handler if($isInvalid) { htmlHeader(); - echo lang("msg_invalid_request"); + echo lang('msg_security_violation'); htmlFooter(); Context::close(); exit; @@ -464,7 +464,7 @@ class ModuleHandler extends Handler if(!in_array(strtoupper($_SERVER['REQUEST_METHOD']), $allowedMethodList)) { - $this->error = "msg_invalid_request"; + $this->error = 'msg_invalid_request'; $oMessageObject = self::getModuleInstance('message', $display_mode); $oMessageObject->setError(-1); $oMessageObject->setMessage($this->error); @@ -620,7 +620,7 @@ class ModuleHandler extends Handler if(!in_array(strtoupper($_SERVER['REQUEST_METHOD']), $allowedMethodList)) { - $this->error = "msg_invalid_request"; + $this->error = 'msg_security_violation'; $oMessageObject = self::getModuleInstance('message', $display_mode); $oMessageObject->setError(-1); $oMessageObject->setMessage($this->error); @@ -635,7 +635,7 @@ class ModuleHandler extends Handler if($xml_info->action->{$this->act} && $xml_info->action->{$this->act}->check_csrf !== 'false' && !checkCSRF()) { $this->_setInputErrorToContext(); - $this->error = 'msg_invalid_request'; + $this->error = 'msg_security_violation'; $oMessageObject = ModuleHandler::getModuleInstance('message', $display_mode); $oMessageObject->setError(-1); $oMessageObject->setMessage($this->error); @@ -1267,9 +1267,16 @@ class ModuleHandler extends Handler continue; } - $before_each_trigger_time = microtime(true); - $output = $oModule->{$called_method}($obj); - $after_each_trigger_time = microtime(true); + try + { + $before_each_trigger_time = microtime(true); + $output = $oModule->{$called_method}($obj); + $after_each_trigger_time = microtime(true); + } + catch (Rhymix\Framework\Exception $e) + { + $output = new BaseObject(-2, $e->getMessage()); + } if ($trigger_name !== 'common.flushDebugInfo') { diff --git a/classes/module/ModuleObject.class.php b/classes/module/ModuleObject.class.php index e1643bbfe..e6b6d9cfa 100644 --- a/classes/module/ModuleObject.class.php +++ b/classes/module/ModuleObject.class.php @@ -136,7 +136,7 @@ class ModuleObject extends BaseObject // Set privileges(granted) information if($this->setPrivileges() !== true) { - $this->stop('msg_invalid_request'); + $this->stop('msg_not_permitted'); return; } @@ -158,7 +158,14 @@ class ModuleObject extends BaseObject // Execute init if(method_exists($this, 'init')) { - $this->init(); + try + { + $this->init(); + } + catch (Rhymix\Framework\Exception $e) + { + $this->stop($e->getMessage()); + } } } @@ -569,8 +576,16 @@ class ModuleObject extends BaseObject $oModuleModel->syncSkinInfoToModuleInfo($this->module_info); Context::set('module_info', $this->module_info); + // Run - $output = $this->{$this->act}(); + try + { + $output = $this->{$this->act}(); + } + catch (Rhymix\Framework\Exception $e) + { + $output = new BaseObject(-2, $e->getMessage()); + } } else { diff --git a/common/framework/exceptions/featuredisabled.php b/common/framework/exceptions/featuredisabled.php new file mode 100644 index 000000000..2c22f992b --- /dev/null +++ b/common/framework/exceptions/featuredisabled.php @@ -0,0 +1,18 @@ +msg_input_password = 'Please type the password.'; $lang->msg_invalid_document = 'Invalid Article Number'; $lang->msg_invalid_request = 'Invalid Request'; $lang->msg_invalid_password = 'The password you entered is incorrect.'; +$lang->msg_security_violation = 'Security Violation'; +$lang->msg_feature_disabled = 'This feature is disabled.'; $lang->msg_error_occured = 'An error has occured.'; $lang->msg_not_founded = 'Cannot find the target.'; $lang->msg_no_result = 'No results found.'; diff --git a/common/lang/ko.php b/common/lang/ko.php index b5571ba87..76259ed8e 100644 --- a/common/lang/ko.php +++ b/common/lang/ko.php @@ -231,6 +231,8 @@ $lang->msg_input_password = '비밀번호를 입력하세요.'; $lang->msg_invalid_document = '잘못된 문서번호입니다.'; $lang->msg_invalid_request = '잘못된 요청입니다.'; $lang->msg_invalid_password = '비밀번호가 올바르지 않습니다.'; +$lang->msg_security_violation = '보안정책상 허용되지 않습니다.'; +$lang->msg_feature_disabled = '사용할 수 없는 기능입니다.'; $lang->msg_error_occured = '오류가 발생했습니다.'; $lang->msg_not_founded = '대상을 찾을 수 없습니다.'; $lang->msg_no_result = '검색 결과가 없습니다.'; diff --git a/modules/admin/admin.admin.controller.php b/modules/admin/admin.admin.controller.php index 80c7c3d67..275ec2730 100644 --- a/modules/admin/admin.admin.controller.php +++ b/modules/admin/admin.admin.controller.php @@ -18,11 +18,9 @@ class adminAdminController extends admin function init() { // forbit access if the user is not an administrator - $oMemberModel = getModel('member'); - $logged_info = $oMemberModel->getLoggedInfo(); - if($logged_info->is_admin != 'Y') + if (!$this->user->isAdmin()) { - return $this->stop("admin.msg_is_not_administrator"); + throw new Rhymix\Framework\Exceptions\NotPermitted('admin.msg_is_not_administrator'); } } @@ -35,7 +33,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'); @@ -477,7 +475,7 @@ class adminAdminController extends admin } else { - return $this->setError('fail_to_delete'); + throw new Rhymix\Framework\Exception('fail_to_delete'); } $this->setMessage('success_deleted'); } @@ -501,7 +499,7 @@ class adminAdminController extends admin Rhymix\Framework\Config::set('use_sso', $vars->use_sso === 'Y'); if (!Rhymix\Framework\Config::save()) { - return $this->setError('msg_failed_to_save_config'); + throw new Rhymix\Framework\Exception('msg_failed_to_save_config'); } $this->setMessage('success_updated'); @@ -521,19 +519,19 @@ class adminAdminController extends admin // Validate the mail sender's information. if (!$vars->mail_default_name) { - return $this->setError('msg_advanced_mailer_sender_name_is_empty'); + throw new Rhymix\Framework\Exception('msg_advanced_mailer_sender_name_is_empty'); } if (!$vars->mail_default_from) { - return $this->setError('msg_advanced_mailer_sender_email_is_empty'); + throw new Rhymix\Framework\Exception('msg_advanced_mailer_sender_email_is_empty'); } if (!Mail::isVaildMailAddress($vars->mail_default_from)) { - return $this->setError('msg_advanced_mailer_sender_email_is_invalid'); + throw new Rhymix\Framework\Exception('msg_advanced_mailer_sender_email_is_invalid'); } if ($vars->mail_default_reply_to && !Mail::isVaildMailAddress($vars->mail_default_reply_to)) { - return $this->setError('msg_advanced_mailer_reply_to_is_invalid'); + throw new Rhymix\Framework\Exception('msg_advanced_mailer_reply_to_is_invalid'); } // Validate the mail driver. @@ -541,7 +539,7 @@ class adminAdminController extends admin $mail_driver = $vars->mail_driver; if (!array_key_exists($mail_driver, $mail_drivers)) { - return $this->setError('msg_advanced_mailer_sending_method_is_invalid'); + throw new Rhymix\Framework\Exception('msg_advanced_mailer_sending_method_is_invalid'); } // Validate the mail driver settings. @@ -551,7 +549,7 @@ class adminAdminController extends admin $conf_value = $vars->{'mail_' . $mail_driver . '_' . $conf_name} ?: null; if (!$conf_value) { - return $this->setError('msg_advanced_mailer_smtp_host_is_invalid'); + throw new Rhymix\Framework\Exception('msg_advanced_mailer_smtp_host_is_invalid'); } $mail_driver_config[$conf_name] = $conf_value; } @@ -561,7 +559,7 @@ class adminAdminController extends admin $sms_driver = $vars->sms_driver; if (!array_key_exists($sms_driver, $sms_drivers)) { - return $this->setError('msg_advanced_mailer_sending_method_is_invalid'); + throw new Rhymix\Framework\Exception('msg_advanced_mailer_sending_method_is_invalid'); } // Validate the SMS driver settings. @@ -571,7 +569,7 @@ class adminAdminController extends admin $conf_value = $vars->{'sms_' . $sms_driver . '_' . $conf_name} ?: null; if (!$conf_value) { - return $this->setError('msg_advanced_mailer_smtp_host_is_invalid'); + throw new Rhymix\Framework\Exception('msg_advanced_mailer_smtp_host_is_invalid'); } $sms_driver_config[$conf_name] = $conf_value; } @@ -610,7 +608,7 @@ class adminAdminController extends admin Rhymix\Framework\Config::set("sms.allow_split.lms", toBool($vars->allow_split_lms)); if (!Rhymix\Framework\Config::save()) { - return $this->setError('msg_failed_to_save_config'); + throw new Rhymix\Framework\Exception('msg_failed_to_save_config'); } $this->setMessage('success_updated'); @@ -665,7 +663,7 @@ class adminAdminController extends admin return $item !== ''; })); if (!Rhymix\Framework\Filters\IpFilter::validateRanges($allowed_ip)) { - return $this->setError('msg_invalid_ip'); + throw new Rhymix\Framework\Exception('msg_invalid_ip'); } $denied_ip = array_map('trim', preg_split('/[\r\n]/', $vars->admin_denied_ip)); @@ -673,13 +671,13 @@ class adminAdminController extends admin return $item !== ''; })); if (!Rhymix\Framework\Filters\IpFilter::validateRanges($denied_ip)) { - return $this->setError('msg_invalid_ip'); + throw new Rhymix\Framework\Exception('msg_invalid_ip'); } $oMemberAdminModel = getAdminModel('member'); if (!$oMemberAdminModel->getMemberAdminIPCheck($allowed_ip, $denied_ip)) { - return $this->setError('msg_current_ip_will_be_denied'); + throw new Rhymix\Framework\Exception('msg_current_ip_will_be_denied'); } Rhymix\Framework\Config::set('admin.allow', array_values($allowed_ip)); @@ -691,7 +689,7 @@ class adminAdminController extends admin // Save if (!Rhymix\Framework\Config::save()) { - return $this->setError('msg_failed_to_save_config'); + throw new Rhymix\Framework\Exception('msg_failed_to_save_config'); } $this->setMessage('success_updated'); @@ -734,7 +732,7 @@ class adminAdminController extends admin } if (!Rhymix\Framework\Cache::getDriverInstance($vars->object_cache_type, $cache_servers)) { - return $this->setError('msg_cache_handler_not_supported'); + throw new Rhymix\Framework\Exception('msg_cache_handler_not_supported'); } Rhymix\Framework\Config::set('cache', array( 'type' => $vars->object_cache_type, @@ -794,7 +792,7 @@ class adminAdminController extends admin // Save if (!Rhymix\Framework\Config::save()) { - return $this->setError('msg_failed_to_save_config'); + throw new Rhymix\Framework\Exception('msg_failed_to_save_config'); } $this->setMessage('success_updated'); @@ -832,15 +830,15 @@ class adminAdminController extends admin ), $log_filename); if (file_exists(RX_BASEDIR . $log_filename_today) && !is_writable(RX_BASEDIR . $log_filename_today)) { - return $this->setError('msg_debug_log_filename_not_writable'); + throw new Rhymix\Framework\Exception('msg_debug_log_filename_not_writable'); } if (!file_exists(dirname(RX_BASEDIR . $log_filename)) && !FileHandler::makeDir(dirname(RX_BASEDIR . $log_filename))) { - return $this->setError('msg_debug_log_filename_not_writable'); + throw new Rhymix\Framework\Exception('msg_debug_log_filename_not_writable'); } if (!is_writable(dirname(RX_BASEDIR . $log_filename))) { - return $this->setError('msg_debug_log_filename_not_writable'); + throw new Rhymix\Framework\Exception('msg_debug_log_filename_not_writable'); } Rhymix\Framework\Config::set('debug.log_filename', $log_filename); @@ -850,14 +848,14 @@ class adminAdminController extends admin return $item !== ''; })); if (!Rhymix\Framework\Filters\IpFilter::validateRanges($allowed_ip)) { - return $this->setError('msg_invalid_ip'); + throw new Rhymix\Framework\Exception('msg_invalid_ip'); } Rhymix\Framework\Config::set('debug.allow', array_values($allowed_ip)); // Save if (!Rhymix\Framework\Config::save()) { - return $this->setError('msg_failed_to_save_config'); + throw new Rhymix\Framework\Exception('msg_failed_to_save_config'); } $this->setMessage('success_updated'); @@ -890,7 +888,7 @@ class adminAdminController extends admin // Save if (!Rhymix\Framework\Config::save()) { - return $this->setError('msg_failed_to_save_config'); + throw new Rhymix\Framework\Exception('msg_failed_to_save_config'); } $this->setMessage('success_updated'); @@ -911,7 +909,7 @@ class adminAdminController extends admin if (!Rhymix\Framework\Filters\IpFilter::validateRanges($allowed_ip)) { - return $this->setError('msg_invalid_ip'); + throw new Rhymix\Framework\Exception('msg_invalid_ip'); } Rhymix\Framework\Config::set('lock.locked', $vars->sitelock_locked === 'Y'); @@ -920,7 +918,7 @@ class adminAdminController extends admin Rhymix\Framework\Config::set('lock.allow', array_values($allowed_ip)); if (!Rhymix\Framework\Config::save()) { - return $this->setError('msg_failed_to_save_config'); + throw new Rhymix\Framework\Exception('msg_failed_to_save_config'); } $this->setMessage('success_updated'); @@ -941,7 +939,7 @@ class adminAdminController extends admin $domain_info = getModel('module')->getSiteInfo($domain_srl); if ($domain_info->domain_srl != $domain_srl) { - return $this->setError('msg_domain_not_found'); + throw new Rhymix\Framework\Exception('msg_domain_not_found'); } } @@ -950,7 +948,7 @@ class adminAdminController extends admin $vars->subtitle = utf8_trim($vars->subtitle); if ($vars->title === '') { - return $this->setError('msg_site_title_is_empty'); + throw new Rhymix\Framework\Exception('msg_site_title_is_empty'); } // Validate the domain. @@ -968,12 +966,12 @@ class adminAdminController extends admin } if (!$vars->domain) { - return $this->setError('msg_invalid_domain'); + throw new Rhymix\Framework\Exception('msg_invalid_domain'); } $existing_domain = getModel('module')->getSiteInfoByDomain($vars->domain); if ($existing_domain && $existing_domain->domain == $vars->domain && (!$domain_info || $existing_domain->domain_srl != $domain_info->domain_srl)) { - return $this->setError('msg_domain_already_exists'); + throw new Rhymix\Framework\Exception('msg_domain_already_exists'); } // Validate the ports. @@ -987,11 +985,11 @@ class adminAdminController extends admin } if ($vars->http_port !== 0 && ($vars->http_port < 1 || $vars->http_port > 65535 || $vars->http_port == 443)) { - return $this->setError('msg_invalid_http_port'); + throw new Rhymix\Framework\Exception('msg_invalid_http_port'); } if ($vars->https_port !== 0 && ($vars->https_port < 1 || $vars->https_port > 65535 || $vars->https_port == 80)) { - return $this->setError('msg_invalid_https_port'); + throw new Rhymix\Framework\Exception('msg_invalid_https_port'); } // Validate the security setting. @@ -1005,7 +1003,7 @@ class adminAdminController extends admin $module_info = getModel('module')->getModuleInfoByModuleSrl(intval($vars->index_module_srl)); if (!$module_info || $module_info->module_srl != $vars->index_module_srl) { - return $this->setError('msg_invalid_index_module_srl'); + throw new Rhymix\Framework\Exception('msg_invalid_index_module_srl'); } // Validate the index document setting. @@ -1014,11 +1012,11 @@ class adminAdminController extends admin $oDocument = getModel('document')->getDocument($vars->index_document_srl); if (!$oDocument || !$oDocument->isExists()) { - return $this->setError('msg_invalid_index_document_srl'); + throw new Rhymix\Framework\Exception('msg_invalid_index_document_srl'); } if (intval($oDocument->get('module_srl')) !== intval($vars->index_module_srl)) { - return $this->setError('msg_invalid_index_document_srl_module_srl'); + throw new Rhymix\Framework\Exception('msg_invalid_index_document_srl_module_srl'); } } else @@ -1030,14 +1028,14 @@ class adminAdminController extends admin $enabled_lang = Rhymix\Framework\Config::get('locale.enabled_lang'); if (!in_array($vars->default_lang, $enabled_lang)) { - return $this->setError('msg_lang_is_not_enabled'); + throw new Rhymix\Framework\Exception('msg_lang_is_not_enabled'); } // Validate the default time zone. $timezone_list = Rhymix\Framework\DateTime::getTimezoneList(); if (!isset($timezone_list[$vars->default_timezone])) { - return $this->setError('msg_invalid_timezone'); + throw new Rhymix\Framework\Exception('msg_invalid_timezone'); } // Clean up the header and footer scripts. @@ -1160,16 +1158,16 @@ class adminAdminController extends admin $domain_srl = strval(Context::get('domain_srl')); if ($domain_srl === '') { - return $this->setError('msg_domain_not_found'); + throw new Rhymix\Framework\Exception('msg_domain_not_found'); } $domain_info = getModel('module')->getSiteInfo($domain_srl); if ($domain_info->domain_srl != $domain_srl) { - return $this->setError('msg_domain_not_found'); + throw new Rhymix\Framework\Exception('msg_domain_not_found'); } if ($domain_info->is_default_domain === 'Y') { - return $this->setError('msg_cannot_delete_default_domain'); + throw new Rhymix\Framework\Exception('msg_cannot_delete_default_domain'); } // Delete the domain. @@ -1202,19 +1200,19 @@ class adminAdminController extends admin { if (!($conn = @ftp_connect($vars->ftp_host, $vars->ftp_port, 3))) { - return $this->setError('msg_ftp_not_connected'); + throw new Rhymix\Framework\Exception('msg_ftp_not_connected'); } if (!@ftp_login($conn, $vars->ftp_user, $vars->ftp_pass)) { - return $this->setError('msg_ftp_invalid_auth_info'); + throw new Rhymix\Framework\Exception('msg_ftp_invalid_auth_info'); } if (!@ftp_pasv($conn, $vars->ftp_pasv === 'Y')) { - return $this->setError('msg_ftp_cannot_set_passive_mode'); + throw new Rhymix\Framework\Exception('msg_ftp_cannot_set_passive_mode'); } if (!@ftp_chdir($conn, $vars->ftp_path)) { - return $this->setError('msg_ftp_invalid_path'); + throw new Rhymix\Framework\Exception('msg_ftp_invalid_path'); } ftp_close($conn); } @@ -1222,23 +1220,23 @@ class adminAdminController extends admin { if (!function_exists('ssh2_connect')) { - return $this->setError('disable_sftp_support'); + throw new Rhymix\Framework\Exception('disable_sftp_support'); } if (!($conn = ssh2_connect($vars->ftp_host, $vars->ftp_port))) { - return $this->setError('msg_ftp_not_connected'); + throw new Rhymix\Framework\Exception('msg_ftp_not_connected'); } if (!@ssh2_auth_password($conn, $vars->ftp_user, $vars->ftp_pass)) { - return $this->setError('msg_ftp_invalid_auth_info'); + throw new Rhymix\Framework\Exception('msg_ftp_invalid_auth_info'); } if (!@($sftp = ssh2_sftp($conn))) { - return $this->setError('msg_ftp_sftp_error'); + throw new Rhymix\Framework\Exception('msg_ftp_sftp_error'); } if (!@ssh2_sftp_stat($sftp, $vars->ftp_path . 'common/defaults/config.php')) { - return $this->setError('msg_ftp_invalid_path'); + throw new Rhymix\Framework\Exception('msg_ftp_invalid_path'); } unset($sftp, $conn); } @@ -1253,7 +1251,7 @@ class adminAdminController extends admin Rhymix\Framework\Config::set('ftp.sftp', $vars->ftp_sftp === 'Y'); if (!Rhymix\Framework\Config::save()) { - return $this->setError('msg_failed_to_save_config'); + throw new Rhymix\Framework\Exception('msg_failed_to_save_config'); } $this->setMessage('success_updated'); @@ -1274,7 +1272,7 @@ class adminAdminController extends admin Rhymix\Framework\Config::set('ftp.sftp', false); if (!Rhymix\Framework\Config::save()) { - return $this->setError('msg_failed_to_save_config'); + throw new Rhymix\Framework\Exception('msg_failed_to_save_config'); } $this->setMessage('success_deleted'); diff --git a/modules/admin/admin.admin.view.php b/modules/admin/admin.admin.view.php index d8c7e060a..5650b4f05 100644 --- a/modules/admin/admin.admin.view.php +++ b/modules/admin/admin.admin.view.php @@ -36,11 +36,9 @@ class adminAdminView extends admin function init() { // forbit access if the user is not an administrator - $oMemberModel = getModel('member'); - $logged_info = $oMemberModel->getLoggedInfo(); - if($logged_info->is_admin != 'Y') + if (!$this->user->isAdmin()) { - return $this->stop("admin.msg_is_not_administrator"); + throw new Rhymix\Framework\Exceptions\NotPermitted('admin.msg_is_not_administrator'); } // change into administration layout @@ -629,7 +627,7 @@ class adminAdminView extends admin $domain_info = getModel('module')->getSiteInfo($domain_srl); if ($domain_info->domain_srl != $domain_srl) { - return $this->setError('msg_domain_not_found'); + throw new Rhymix\Framework\Exception('msg_domain_not_found'); } } Context::set('domain_info', $domain_info); diff --git a/modules/adminlogging/adminlogging.controller.php b/modules/adminlogging/adminlogging.controller.php index 2b6b330fb..98269664f 100644 --- a/modules/adminlogging/adminlogging.controller.php +++ b/modules/adminlogging/adminlogging.controller.php @@ -23,7 +23,7 @@ class adminloggingController extends adminlogging $logged_info = $oMemberModel->getLoggedInfo(); if($logged_info->is_admin != 'Y') { - return $this->stop("admin.msg_is_not_administrator"); + throw new Rhymix\Framework\Exceptions\NotPermitted('admin.msg_is_not_administrator'); } } diff --git a/modules/advanced_mailer/advanced_mailer.admin.controller.php b/modules/advanced_mailer/advanced_mailer.admin.controller.php index 66de18923..3e575e3fe 100644 --- a/modules/advanced_mailer/advanced_mailer.admin.controller.php +++ b/modules/advanced_mailer/advanced_mailer.admin.controller.php @@ -61,7 +61,7 @@ class Advanced_MailerAdminController extends Advanced_Mailer { if ($method !== 'default' && !isset($sending_methods[$method])) { - return $this->setError('msg_advanced_mailer_sending_method_is_invalid'); + throw new Rhymix\Framework\Exception('msg_advanced_mailer_sending_method_is_invalid'); } if ($method !== 'default') { @@ -69,7 +69,7 @@ class Advanced_MailerAdminController extends Advanced_Mailer { if (!Rhymix\Framework\Config::get("mail.$method.$conf_name")) { - return $this->setError('msg_advanced_mailer_sending_method_is_not_configured', lang('cmd_advanced_mailer_sending_method_' . $method)); + throw new Rhymix\Framework\Exception(sprintf('msg_advanced_mailer_sending_method_is_not_configured', lang('cmd_advanced_mailer_sending_method_' . $method))); } } } @@ -155,11 +155,11 @@ class Advanced_MailerAdminController extends Advanced_Mailer $clear_before_days = intval(Context::get('clear_before_days')); if (!in_array($status, array('success', 'error'))) { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } if ($clear_before_days < 0) { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } $obj = new stdClass(); @@ -186,11 +186,11 @@ class Advanced_MailerAdminController extends Advanced_Mailer $clear_before_days = intval(Context::get('clear_before_days')); if (!in_array($status, array('success', 'error'))) { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } if ($clear_before_days < 0) { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } $obj = new stdClass(); diff --git a/modules/autoinstall/autoinstall.admin.view.php b/modules/autoinstall/autoinstall.admin.view.php index 77f660fee..0f9cb7ec4 100644 --- a/modules/autoinstall/autoinstall.admin.view.php +++ b/modules/autoinstall/autoinstall.admin.view.php @@ -414,7 +414,7 @@ class autoinstallAdminView extends autoinstall if(!$updateDate) { - return $this->stop('msg_connection_fail'); + throw new Rhymix\Framework\Exception('msg_connection_fail'); } $oModel = getModel('autoinstall'); @@ -535,13 +535,13 @@ class autoinstallAdminView extends autoinstall if(!$type || $type == "core") { - return $this->stop("msg_invalid_request"); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } $config_file = $oModel->getConfigFilePath($type); if(!$config_file) { - return $this->stop("msg_invalid_request"); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } $output = $oAdminModel->checkUseDirectModuleInstall($installedPackage); @@ -579,7 +579,7 @@ class autoinstallAdminView extends autoinstall } else { - return $this->stop('msg_connection_fail'); + throw new Rhymix\Framework\Exception('msg_connection_fail'); } } diff --git a/modules/board/board.admin.controller.php b/modules/board/board.admin.controller.php index 58d7709b8..112cb9c47 100644 --- a/modules/board/board.admin.controller.php +++ b/modules/board/board.admin.controller.php @@ -168,7 +168,7 @@ class boardAdminController extends board { $module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl); if($module_info->mid != $mid) { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } $module_info->hide_category = Context::get('hide_category') == 'Y' ? 'Y' : 'N'; diff --git a/modules/board/board.admin.view.php b/modules/board/board.admin.view.php index 2a0c7f130..75cf3ce11 100644 --- a/modules/board/board.admin.view.php +++ b/modules/board/board.admin.view.php @@ -39,7 +39,10 @@ class boardAdminView extends board { } } - if($module_info && $module_info->module != 'board') return $this->stop("msg_invalid_request"); + if($module_info && $module_info->module != 'board') + { + throw new Rhymix\Framework\Exceptions\InvalidRequest; + } // get the module category list $module_category = $oModuleModel->getModuleCategories(); diff --git a/modules/board/board.controller.php b/modules/board/board.controller.php index 671a1dbbc..d0775c016 100644 --- a/modules/board/board.controller.php +++ b/modules/board/board.controller.php @@ -24,7 +24,7 @@ class boardController extends board // check grant if(!$this->grant->write_document) { - return $this->setError('msg_not_permitted'); + throw new Rhymix\Framework\Exceptions\NotPermitted; } // setup variables @@ -35,14 +35,14 @@ class boardController extends board // Return error if content is empty. if (is_empty_html_content($obj->content)) { - return $this->setError('msg_empty_content'); + throw new Rhymix\Framework\Exception('msg_empty_content'); } // Return error if content is too large. $document_length_limit = ($this->module_info->document_length_limit ?: 1024) * 1024; if (strlen($obj->content) > $document_length_limit && !$this->grant->manager) { - return $this->setError('msg_content_too_long'); + throw new Rhymix\Framework\Exception('msg_content_too_long'); } // unset document style if not manager @@ -107,14 +107,14 @@ class boardController extends board { if(!$oDocument->isGranted()) { - return $this->setError('msg_not_permitted'); + throw new Rhymix\Framework\Exceptions\NotPermitted; } // Protect admin document $member_info = getModel('member')->getMemberInfoByMemberSrl($oDocument->get('member_srl')); if($member_info->is_admin == 'Y' && $logged_info->is_admin != 'Y') { - return $this->setError('msg_admin_document_no_modify'); + throw new Rhymix\Framework\Exception('msg_admin_document_no_modify'); } // if document status is temp @@ -138,7 +138,7 @@ class boardController extends board { if($oDocument->get('comment_count') > 0 && !$this->grant->manager) { - return $this->setError('msg_protect_update_content'); + throw new Rhymix\Framework\Exception('msg_protect_update_content'); } } @@ -147,7 +147,7 @@ class boardController extends board { if($oDocument->get('regdate') < date('YmdHis', strtotime('-' . $this->module_info->protect_document_regdate . ' day'))) { - return $this->setError(sprintf(lang('msg_protect_regdate_document'), $this->module_info->protect_document_regdate)); + throw new Rhymix\Framework\Exception(sprintf(lang('msg_protect_regdate_document'), $this->module_info->protect_document_regdate)); } } @@ -235,7 +235,7 @@ class boardController extends board $logged_info = Context::get('logged_info'); if(!$update_id) { - return $this->setError('msg_no_update_id'); + throw new Rhymix\Framework\Exception('msg_no_update_id'); } $oDocumentModel = getModel('document'); @@ -247,13 +247,13 @@ class boardController extends board $Exists_log = $oDocumentModel->getUpdateLogAdminisExists($update_log->document_srl); if($Exists_log === true) { - return $this->setError('msg_admin_update_log'); + throw new Rhymix\Framework\Exception('msg_admin_update_log'); } } if(!$update_log) { - return $this->setError('msg_no_update_log'); + throw new Rhymix\Framework\Exception('msg_no_update_log'); } $oDocument = $oDocumentModel->getDocument($update_log->document_srl); @@ -282,7 +282,7 @@ class boardController extends board // if the document is not existed if(!$document_srl) { - return $this->setError('msg_invalid_document'); + throw new Rhymix\Framework\Exception('msg_invalid_document'); } $oDocumentModel = &getModel('document'); @@ -292,7 +292,7 @@ class boardController extends board { if($oDocument->get('comment_count') > 0 && $this->grant->manager == false) { - return $this->setError('msg_protect_delete_content'); + throw new Rhymix\Framework\Exception('msg_protect_delete_content'); } } @@ -302,7 +302,7 @@ class boardController extends board { $format = lang('msg_protect_regdate_document'); $massage = sprintf($format, $this->module_info->protect_document_regdate); - return $this->setError($massage); + throw new Rhymix\Framework\Exception($massage); } } // generate document module controller object @@ -356,7 +356,7 @@ class boardController extends board // check grant if(!$this->grant->write_comment) { - return $this->setError('msg_not_permitted'); + throw new Rhymix\Framework\Exceptions\NotPermitted; } $logged_info = Context::get('logged_info'); @@ -367,14 +367,14 @@ class boardController extends board // Return error if content is empty. if (is_empty_html_content($obj->content)) { - return $this->setError('msg_empty_content'); + throw new Rhymix\Framework\Exception('msg_empty_content'); } // Return error if content is too large. $comment_length_limit = ($this->module_info->comment_length_limit ?: 128) * 1024; if (strlen($obj->content) > $comment_length_limit && !$this->grant->manager) { - return $this->setError('msg_content_too_long'); + throw new Rhymix\Framework\Exception('msg_content_too_long'); } if(!$this->module_info->use_status) $this->module_info->use_status = 'PUBLIC'; @@ -398,7 +398,7 @@ class boardController extends board $oDocument = $oDocumentModel->getDocument($obj->document_srl); if(!$oDocument->isExists()) { - return $this->setError('msg_not_founded'); + throw new Rhymix\Framework\Exceptions\TargetNotFound; } // For anonymous use, remove writer's information and notifying information @@ -436,7 +436,7 @@ class boardController extends board $childs = $oCommentModel->getChildComments($obj->comment_srl); if(count($childs) > 0) { - return $this->setError('msg_board_update_protect_comment'); + throw new Rhymix\Framework\Exception('msg_board_update_protect_comment'); } } } @@ -446,7 +446,7 @@ class boardController extends board if($member_info->is_admin == 'Y' && $logged_info->is_admin != 'Y') { - return $this->setError('msg_admin_comment_no_modify'); + throw new Rhymix\Framework\Exception('msg_admin_comment_no_modify'); } // INSERT if comment_srl does not exist. @@ -461,7 +461,7 @@ class boardController extends board $parent_comment = $oCommentModel->getComment($obj->parent_srl); if(!$parent_comment->comment_srl) { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\TargetNotFound; } if($parent_comment->isSecret() && $this->module_info->secret === 'Y') { @@ -490,13 +490,13 @@ class boardController extends board { $format = lang('msg_protect_regdate_comment'); $massage = sprintf($format, $this->module_info->protect_document_regdate); - return $this->setError($massage); + throw new Rhymix\Framework\Exception($massage); } } // check the grant if(!$comment->isGranted()) { - return $this->setError('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) { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } $oCommentModel = getModel('comment'); @@ -540,7 +540,7 @@ class boardController extends board $childs = $oCommentModel->getChildComments($comment_srl); if(count($childs) > 0) { - return $this->setError('msg_board_delete_protect_comment'); + throw new Rhymix\Framework\Exception('msg_board_delete_protect_comment'); } } $comment = $oCommentModel->getComment($comment_srl, $this->grant->manager); @@ -550,7 +550,7 @@ class boardController extends board { $format = lang('msg_protect_regdate_comment'); $massage = sprintf($format, $this->module_info->protect_document_regdate); - return $this->setError($massage); + throw new Rhymix\Framework\Exception($massage); } } // generate comment controller object @@ -662,13 +662,13 @@ class boardController extends board $oComment = $oCommentModel->getComment($comment_srl); if(!$oComment->isExists()) { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\TargetNotFound; } // compare the comment password and the user input password if(!$oMemberModel->isValidPassword($oComment->get('password'),$password)) { - return $this->setError('msg_invalid_password'); + throw new Rhymix\Framework\Exception('msg_invalid_password'); } $oComment->setGrantForSession(); @@ -678,13 +678,13 @@ class boardController extends board $oDocument = $oDocumentModel->getDocument($document_srl); if(!$oDocument->isExists()) { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\TargetNotFound; } // compare the document password and the user input password if(!$oMemberModel->isValidPassword($oDocument->get('password'),$password)) { - return $this->setError('msg_invalid_password'); + throw new Rhymix\Framework\Exception('msg_invalid_password'); } $oDocument->setGrantForSession(); diff --git a/modules/board/board.view.php b/modules/board/board.view.php index ea6b5f1be..6f0ddc597 100644 --- a/modules/board/board.view.php +++ b/modules/board/board.view.php @@ -262,7 +262,7 @@ class boardView extends board // if the module srl is not consistent if($oDocument->get('module_srl')!=$this->module_info->module_srl ) { - return $this->stop('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\TargetNotFound; } // check the manage grant @@ -383,7 +383,11 @@ class boardView extends board if(is_array($file_module_config->download_grant) && $downloadGrantCount>0) { - if(!Context::get('is_logged')) return $this->stop('msg_not_permitted_download'); + if(!Context::get('is_logged')) + { + throw new Rhymix\Framework\Exceptions\NotPermitted('msg_not_permitted_download'); + } + $logged_info = Context::get('logged_info'); if($logged_info->is_admin != 'Y') { @@ -406,7 +410,10 @@ class boardView extends board break; } } - if(!$is_permitted) return $this->stop('msg_not_permitted_download'); + if(!$is_permitted) + { + throw new Rhymix\Framework\Exceptions\NotPermitted('msg_not_permitted_download'); + } } } } @@ -672,18 +679,18 @@ class boardView extends board $document_srl = Context::get('document_srl'); if(!$document_srl) { - return $this->setError("msg_invalid_request"); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } if($this->grant->view == false || ($this->module_info->consultation == 'Y' && !$this->grant->manager && !$this->grant->consultation_read)) { - return $this->setError("msg_not_permitted"); + throw new Rhymix\Framework\Exceptions\NotPermitted; } $oDocument = getModel('document')->getDocument($document_srl); if(!$oDocument->isExists()) { - return $this->setError("msg_invalid_request"); + throw new Rhymix\Framework\Exceptions\TargetNotFound; } Context::set('oDocument', $oDocument); @@ -780,20 +787,20 @@ class boardView extends board { $format = lang('msg_protect_regdate_document'); $massage = sprintf($format, $this->module_info->protect_document_regdate); - return $this->setError($massage); + throw new Rhymix\Framework\Exception($massage); } } if($this->module_info->protect_content == "Y" || $this->module_info->protect_update_content == 'Y') { if($oDocument->get('comment_count') > 0 && $this->grant->manager == false) { - return $this->setError('msg_protect_update_content'); + throw new Rhymix\Framework\Exception('msg_protect_update_content'); } } } if($member_info->is_admin == 'Y' && $logged_info->is_admin != 'Y') { - return $this->setError('msg_admin_document_no_modify'); + throw new Rhymix\Framework\Exception('msg_admin_document_no_modify'); } // if the document is not granted, then back to the password input form @@ -913,7 +920,7 @@ class boardView extends board { $format = lang('msg_protect_regdate_document'); $massage = sprintf($format, $this->module_info->protect_document_regdate); - return $this->setError($massage); + throw new Rhymix\Framework\Exception($massage); } } @@ -921,7 +928,7 @@ class boardView extends board { if($oDocument->get('comment_count')>0 && $this->grant->manager == false) { - return $this->setError('msg_protect_delete_content'); + throw new Rhymix\Framework\Exception('msg_protect_delete_content'); } } @@ -953,7 +960,7 @@ class boardView extends board $oDocument = $oDocumentModel->getDocument($document_srl); if(!$oDocument->isExists()) { - return $this->dispBoardMessage('msg_invalid_request'); + return $this->dispBoardMessage('msg_not_founded'); } // Check allow comment @@ -998,7 +1005,7 @@ class boardView extends board // if the parent comment is not existed if(!$parent_srl) { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } // get the comment @@ -1008,11 +1015,11 @@ class boardView extends board // if the comment is not existed, opoup an error message if(!$oSourceComment->isExists()) { - return $this->dispBoardMessage('msg_invalid_request'); + return $this->dispBoardMessage('msg_not_founded'); } if(Context::get('document_srl') && $oSourceComment->get('document_srl') != Context::get('document_srl')) { - return $this->dispBoardMessage('msg_invalid_request'); + return $this->dispBoardMessage('msg_not_founded'); } // Check allow comment @@ -1060,7 +1067,7 @@ class boardView extends board // if the comment is not existed if(!$comment_srl) { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } // get comment information @@ -1075,7 +1082,7 @@ class boardView extends board { $format = lang('msg_protect_regdate_comment'); $massage = sprintf($format, $this->module_info->protect_document_regdate); - return $this->setError($massage); + throw new Rhymix\Framework\Exception($massage); } } if($this->module_info->protect_update_comment === 'Y' && $this->grant->manager == false) @@ -1083,19 +1090,19 @@ class boardView extends board $childs = $oCommentModel->getChildComments($comment_srl); if(count($childs) > 0) { - return $this->setError('msg_board_update_protect_comment'); + throw new Rhymix\Framework\Exception('msg_board_update_protect_comment'); } } if($member_info->is_admin == 'Y' && $logged_info->is_admin != 'Y') { - return $this->setError('msg_admin_comment_no_modify'); + throw new Rhymix\Framework\Exception('msg_admin_comment_no_modify'); } // if the comment is not exited, alert an error message if(!$oComment->isExists()) { - return $this->dispBoardMessage('msg_invalid_request'); + return $this->dispBoardMessage('msg_not_founded'); } // if the comment is not granted, then back to the password input form @@ -1143,7 +1150,7 @@ class boardView extends board { $format = lang('msg_protect_regdate_comment'); $massage = sprintf($format, $this->module_info->protect_document_regdate); - return $this->setError($massage); + throw new Rhymix\Framework\Exception($massage); } } @@ -1153,7 +1160,7 @@ class boardView extends board $childs = $oCommentModel->getChildComments($comment_srl); if(count($childs) > 0) { - return $this->setError('msg_board_delete_protect_comment'); + throw new Rhymix\Framework\Exception('msg_board_delete_protect_comment'); } } @@ -1233,7 +1240,7 @@ class boardView extends board if($this->grant->update_view !== true) { - return $this->setError('msg_not_permitted'); + throw new Rhymix\Framework\Exceptions\NotPermitted; } $updatelog = $oDocumentModel->getDocumentUpdateLog($document_srl); @@ -1253,7 +1260,7 @@ class boardView extends board if($this->grant->update_view !== true) { - return $this->setError('msg_not_permitted'); + throw new Rhymix\Framework\Exceptions\NotPermitted; } $update_log = $oDocumentModel->getUpdateLog($update_id); @@ -1289,7 +1296,7 @@ class boardView extends board { iF($this->grant->vote_log_view !== true) { - return $this->setError('msg_not_permitted'); + throw new Rhymix\Framework\Exceptions\NotPermitted; } $oMemberModel = getModel('member'); @@ -1310,7 +1317,7 @@ class boardView extends board } else { - return $this->setError('msg_not_target'); + throw new Rhymix\Framework\Exception('msg_not_target'); } $output = executeQueryArray($queryId, $args); diff --git a/modules/comment/comment.admin.controller.php b/modules/comment/comment.admin.controller.php index 9ad5709eb..183746461 100644 --- a/modules/comment/comment.admin.controller.php +++ b/modules/comment/comment.admin.controller.php @@ -56,7 +56,7 @@ class commentAdminController extends comment $cart = Context::get('cart'); if(!$cart) { - return $this->stop('msg_cart_is_null'); + throw new Rhymix\Framework\Exception('msg_cart_is_null'); } if(!is_array($cart)) { @@ -96,7 +96,7 @@ class commentAdminController extends comment $comment = $oCommentModel->getComment($comment_srl); if($comment->comment_srl != $comment_srl) { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } $document_srl = $comment->document_srl; if(!in_array($document_srl, $updated_documents_arr)) @@ -171,7 +171,7 @@ class commentAdminController extends comment $cart = Context::get('cart'); if(!$cart) { - return $this->stop('msg_cart_is_null'); + throw new Rhymix\Framework\Exception('msg_cart_is_null'); } if(!is_array($cart)) { @@ -184,7 +184,7 @@ class commentAdminController extends comment $comment_count = count($comment_srl_list); if(!$comment_count) { - return $this->stop('msg_cart_is_null'); + throw new Rhymix\Framework\Exception('msg_cart_is_null'); } $oCommentController = getController('comment'); @@ -329,7 +329,7 @@ class commentAdminController extends comment $oCommentController = getController('comment'); $oComment = $oCommentModel->getComment($comment_srl, false); - if(!$oComment->isGranted()) return $this->stop('msg_not_permitted'); + if(!$oComment->isGranted()) throw new Rhymix\Framework\Exceptions\NotPermitted; $message_content = ""; $this->_moveCommentToTrash(array($comment_srl), $oCommentController, $oDB, $message_content); diff --git a/modules/comment/comment.controller.php b/modules/comment/comment.controller.php index 46f3399bc..08f3e9c84 100644 --- a/modules/comment/comment.controller.php +++ b/modules/comment/comment.controller.php @@ -27,15 +27,18 @@ class commentController extends comment */ function procCommentVoteUp() { - if(!Context::get('is_logged')) + if($this->module_info->non_login_vote !== 'Y') { - return $this->setError('msg_invalid_request'); + if(!Context::get('is_logged')) + { + throw new Rhymix\Framework\Exceptions\NotPermitted; + } } $comment_srl = Context::get('target_srl'); if(!$comment_srl) { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } $oCommentModel = getModel('comment'); @@ -43,14 +46,14 @@ class commentController extends comment $module_srl = $oComment->get('module_srl'); if(!$module_srl) { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } $oModuleModel = getModel('module'); $comment_config = $oModuleModel->getModulePartConfig('comment', $module_srl); if($comment_config->use_vote_up == 'N') { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\FeatureDisabled; } $point = 1; @@ -61,16 +64,22 @@ class commentController extends comment function procCommentVoteUpCancel() { - if(!Context::get('logged_info')) return $this->setError('msg_invalid_request'); + if($this->module_info->non_login_vote !== 'Y') + { + if(!Context::get('is_logged')) + { + throw new Rhymix\Framework\Exceptions\NotPermitted; + } + } $comment_srl = Context::get('target_srl'); - if(!$comment_srl) return $this->setError('msg_invalid_request'); + if(!$comment_srl) throw new Rhymix\Framework\Exceptions\InvalidRequest; $oCommentModel = getModel('comment'); $oComment = $oCommentModel->getComment($comment_srl, FALSE, FALSE); if($oComment->get('voted_count') <= 0) { - return $this->setError('msg_comment_voted_cancel_not'); + throw new Rhymix\Framework\Exception('msg_comment_voted_cancel_not'); } $point = 1; $output = $this->updateVotedCountCancel($comment_srl, $oComment, $point); @@ -88,15 +97,18 @@ class commentController extends comment */ function procCommentVoteDown() { - if(!Context::get('is_logged')) + if($this->module_info->non_login_vote !== 'Y') { - return $this->setError('msg_invalid_request'); + if(!Context::get('is_logged')) + { + throw new Rhymix\Framework\Exceptions\NotPermitted; + } } $comment_srl = Context::get('target_srl'); if(!$comment_srl) { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } $oCommentModel = getModel('comment'); @@ -104,14 +116,14 @@ class commentController extends comment $module_srl = $oComment->get('module_srl'); if(!$module_srl) { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } $oModuleModel = getModel('module'); $comment_config = $oModuleModel->getModulePartConfig('comment', $module_srl); if($comment_config->use_vote_down == 'N') { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\FeatureDisabled; } $point = -1; @@ -122,16 +134,22 @@ class commentController extends comment function procCommentVoteDownCancel() { - if(!Context::get('logged_info')) return $this->setError('msg_invalid_request'); + if($this->module_info->non_login_vote !== 'Y') + { + if(!Context::get('is_logged')) + { + throw new Rhymix\Framework\Exceptions\NotPermitted; + } + } $comment_srl = Context::get('target_srl'); - if(!$comment_srl) return $this->setError('msg_invalid_request'); + if(!$comment_srl) throw new Rhymix\Framework\Exceptions\InvalidRequest; $oCommentModel = getModel('comment'); $oComment = $oCommentModel->getComment($comment_srl, FALSE, FALSE); if($oComment->get('blamed_count') >= 0) { - return $this->setError('msg_comment_blamed_cancel_not'); + throw new Rhymix\Framework\Exception('msg_comment_blamed_cancel_not'); } $point = -1; $output = $this->updateVotedCountCancel($comment_srl, $oComment, $point); @@ -193,13 +211,13 @@ class commentController extends comment { if(!Context::get('is_logged')) { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\NotPermitted; } $comment_srl = Context::get('target_srl'); if(!$comment_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. @@ -297,7 +315,7 @@ class commentController extends comment { if(!$manual_inserted && !checkCSRF()) { - return new BaseObject(-1, 'msg_invalid_request'); + return new BaseObject(-1, 'msg_security_violation'); } if(!is_object($obj)) @@ -699,7 +717,7 @@ class commentController extends comment { if(!$manual_updated && !checkCSRF()) { - return new BaseObject(-1, 'msg_invalid_request'); + return new BaseObject(-1, 'msg_security_violation'); } if(!is_object($obj)) @@ -1653,13 +1671,13 @@ class commentController extends comment $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; @@ -1727,7 +1745,7 @@ class commentController extends comment { if(!Context::get('is_logged')) { - return $this->setError('msg_not_permitted'); + throw new Rhymix\Framework\Exceptions\NotPermitted; } $commentSrls = Context::get('comment_srls'); diff --git a/modules/comment/comment.model.php b/modules/comment/comment.model.php index 2db5e9084..127454b10 100644 --- a/modules/comment/comment.model.php +++ b/modules/comment/comment.model.php @@ -977,7 +977,7 @@ class commentModel extends comment $comment_srl = Context::get('comment_srl'); if(!$comment_srl) { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } $point = Context::get('point'); @@ -991,7 +991,7 @@ class commentModel extends comment $module_srl = $oComment->get('module_srl'); if(!$module_srl) { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } $oModuleModel = getModel('module'); @@ -1003,7 +1003,7 @@ class commentModel extends comment { if($comment_config->use_vote_down != 'S') { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\FeatureDisabled; } $args->below_point = 0; @@ -1012,7 +1012,7 @@ class commentModel extends comment { if($comment_config->use_vote_up != 'S') { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\FeatureDisabled; } $args->more_point = 0; diff --git a/modules/comment/comment.view.php b/modules/comment/comment.view.php index c19d142cf..85052b8f9 100644 --- a/modules/comment/comment.view.php +++ b/modules/comment/comment.view.php @@ -73,7 +73,7 @@ class commentView extends comment // 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 comment object. @@ -82,12 +82,12 @@ class commentView extends comment $oComment = $oCommentModel->getComment($comment_srl); if(!$oComment->isExists()) { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\TargetNotFound; } // Check permissions if(!$oComment->isAccessible()) { - return $this->setError('msg_not_permitted'); + throw new Rhymix\Framework\Exceptions\NotPermitted; } // Browser title settings diff --git a/modules/communication/communication.controller.php b/modules/communication/communication.controller.php index ebd7b382c..c4088dc68 100644 --- a/modules/communication/communication.controller.php +++ b/modules/communication/communication.controller.php @@ -24,7 +24,7 @@ class communicationController extends communication { if(!Context::get('is_logged')) { - return $this->setError('msg_not_logged'); + throw new Rhymix\Framework\Exceptions\MustLogin; } $args = new stdClass(); @@ -54,7 +54,7 @@ class communicationController extends communication // Check login information if(!Context::get('is_logged')) { - return $this->setError('msg_not_logged'); + throw new Rhymix\Framework\Exceptions\MustLogin; } $logged_info = Context::get('logged_info'); @@ -63,19 +63,19 @@ class communicationController extends communication $receiver_srl = Context::get('receiver_srl'); if(!$receiver_srl) { - return $this->setError('msg_not_exists_member'); + throw new Rhymix\Framework\Exception('msg_not_exists_member'); } $title = trim(Context::get('title')); if(!$title) { - return $this->setError('msg_title_is_null'); + throw new Rhymix\Framework\Exception('msg_title_is_null'); } $content = trim(Context::get('content')); if(!$content) { - return $this->setError('msg_content_is_null'); + throw new Rhymix\Framework\Exception('msg_content_is_null'); } $send_mail = Context::get('send_mail'); @@ -91,13 +91,13 @@ class communicationController extends communication if(!$oCommunicationModel->checkGrant($config->grant_send)) { - return $this->setError('msg_not_permitted'); + throw new Rhymix\Framework\Exceptions\NotPermitted; } $receiver_member_info = $oMemberModel->getMemberInfoByMemberSrl($receiver_srl); if($receiver_member_info->member_srl != $receiver_srl) { - return $this->setError('msg_not_exists_member'); + throw new Rhymix\Framework\Exception('msg_not_exists_member'); } // check whether to allow to receive the message(pass if a top-administrator) @@ -107,12 +107,12 @@ class communicationController extends communication { if(!$oCommunicationModel->isFriend($receiver_member_info->member_srl)) { - return $this->setError('msg_allow_message_to_friend'); + throw new Rhymix\Framework\Exception('msg_allow_message_to_friend'); } } else if($receiver_member_info->allow_message == 'N') { - return $this->setError('msg_disallow_message'); + throw new Rhymix\Framework\Exception('msg_disallow_message'); } } @@ -269,7 +269,7 @@ class communicationController extends communication // Check login information if(!Context::get('is_logged')) { - return $this->setError('msg_not_logged'); + throw new Rhymix\Framework\Exceptions\MustLogin; } $logged_info = Context::get('logged_info'); @@ -277,7 +277,7 @@ class communicationController extends communication $message_srl = Context::get('message_srl'); if(!$message_srl) { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } // get the message @@ -285,7 +285,7 @@ class communicationController extends communication $message = $oCommunicationModel->getSelectedMessage($message_srl); if(!$message || $message->message_type != 'R') { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } $args = new stdClass(); @@ -309,7 +309,7 @@ class communicationController extends communication // Check login information if(!Context::get('is_logged')) { - return $this->setError('msg_not_logged'); + throw new Rhymix\Framework\Exceptions\MustLogin; } $logged_info = Context::get('logged_info'); @@ -319,7 +319,7 @@ class communicationController extends communication $message_srl = Context::get('message_srl'); if(!$message_srl) { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } // Get the message @@ -327,7 +327,7 @@ class communicationController extends communication $message = $oCommunicationModel->getSelectedMessage($message_srl); if(!$message) { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } // Check the grant @@ -336,14 +336,14 @@ class communicationController extends communication case 'S': if($message->sender_srl != $member_srl) { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } break; case 'R': if($message->receiver_srl != $member_srl) { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } break; } @@ -369,7 +369,7 @@ class communicationController extends communication // Check login information if(!Context::get('is_logged')) { - return $this->setError('msg_not_logged'); + throw new Rhymix\Framework\Exceptions\MustLogin; } $logged_info = Context::get('logged_info'); @@ -378,7 +378,7 @@ class communicationController extends communication // check variables if(!Context::get('message_srl_list')) { - return $this->setError('msg_cart_is_null'); + throw new Rhymix\Framework\Exception('msg_cart_is_null'); } $message_srl_list = Context::get('message_srl_list'); @@ -389,13 +389,13 @@ class communicationController extends communication if(!count($message_srl_list)) { - return $this->setError('msg_cart_is_null'); + throw new Rhymix\Framework\Exception('msg_cart_is_null'); } $message_type = Context::get('message_type'); if(!$message_type || !in_array($message_type, array('R', 'S', 'T', 'N'))) { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } $message_count = count($message_srl_list); @@ -412,7 +412,7 @@ class communicationController extends communication } if(!count($target)) { - return $this->setError('msg_cart_is_null'); + throw new Rhymix\Framework\Exception('msg_cart_is_null'); } // Delete @@ -458,7 +458,7 @@ class communicationController extends communication // Check login information if(!Context::get('is_logged')) { - return $this->setError('msg_not_logged'); + throw new Rhymix\Framework\Exceptions\MustLogin; } $logged_info = Context::get('logged_info'); @@ -466,11 +466,11 @@ class communicationController extends communication $target_srl = (int) trim(Context::get('target_srl')); if(!$target_srl) { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } if($target_srl == $logged_info->member_srl) { - return $this->setError('msg_no_self_friend'); + throw new Rhymix\Framework\Exception('msg_no_self_friend'); } // Check duplicate friend @@ -480,7 +480,7 @@ class communicationController extends communication $output = executeQuery('communication.isAddedFriend', $args); if($output->data->count) { - return $this->setError('msg_already_friend'); + throw new Rhymix\Framework\Exception('msg_already_friend'); } // Variable @@ -520,7 +520,7 @@ class communicationController extends communication // Check login information if(!Context::get('is_logged')) { - return $this->setError('msg_not_logged'); + throw new Rhymix\Framework\Exceptions\MustLogin; } $logged_info = Context::get('logged_info'); @@ -529,7 +529,7 @@ class communicationController extends communication $friend_srl_list = Context::get('friend_srl_list'); if(!$friend_srl_list) { - return $this->setError('msg_cart_is_null'); + throw new Rhymix\Framework\Exception('msg_cart_is_null'); } if(!is_array($friend_srl_list)) @@ -539,7 +539,7 @@ class communicationController extends communication if(!count($friend_srl_list)) { - return $this->setError('msg_cart_is_null'); + throw new Rhymix\Framework\Exception('msg_cart_is_null'); } $friend_count = count($friend_srl_list); @@ -557,7 +557,7 @@ class communicationController extends communication if(!count($target)) { - return $this->setError('msg_cart_is_null'); + throw new Rhymix\Framework\Exception('msg_cart_is_null'); } // Variables @@ -587,7 +587,7 @@ class communicationController extends communication // Check login information if(!Context::get('is_logged')) { - return $this->setError('msg_not_logged'); + throw new Rhymix\Framework\Exceptions\MustLogin; } $logged_info = Context::get('logged_info'); @@ -603,7 +603,7 @@ class communicationController extends communication if(!count($friend_srl_list)) { - return $this->setError('msg_cart_is_null'); + throw new Rhymix\Framework\Exception('msg_cart_is_null'); } $friend_count = count($friend_srl_list); @@ -622,7 +622,7 @@ class communicationController extends communication if(!count($target)) { - return $this->setError('msg_cart_is_null'); + throw new Rhymix\Framework\Exception('msg_cart_is_null'); } // Delete @@ -650,7 +650,7 @@ class communicationController extends communication // Check login information if(!Context::get('is_logged')) { - return $this->setError('msg_not_logged'); + throw new Rhymix\Framework\Exceptions\MustLogin; } $logged_info = Context::get('logged_info'); @@ -664,7 +664,7 @@ class communicationController extends communication if(!$args->title) { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } // modify if friend_group_srl exists. @@ -726,7 +726,7 @@ class communicationController extends communication // Check login information if(!Context::get('is_logged')) { - return $this->setError('msg_not_logged'); + throw new Rhymix\Framework\Exceptions\MustLogin; } $logged_info = Context::get('logged_info'); @@ -740,7 +740,7 @@ class communicationController extends communication if(!$args->title) { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } $output = executeQuery('communication.renameFriendGroup', $args); @@ -761,7 +761,7 @@ class communicationController extends communication // Check login information if(!Context::get('is_logged')) { - return $this->setError('msg_not_logged'); + throw new Rhymix\Framework\Exceptions\MustLogin; } $logged_info = Context::get('logged_info'); diff --git a/modules/communication/communication.view.php b/modules/communication/communication.view.php index e447e8543..8a43b1c48 100644 --- a/modules/communication/communication.view.php +++ b/modules/communication/communication.view.php @@ -52,13 +52,13 @@ class communicationView extends communication { if($this->config->enable_message == 'N') { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } // Error appears if not logged-in if(!Context::get('is_logged')) { - return $this->setError('msg_not_logged'); + throw new Rhymix\Framework\Exceptions\MustLogin; } $logged_info = Context::get('logged_info'); @@ -86,28 +86,28 @@ class communicationView extends communication case 'R': if($message->receiver_srl != $logged_info->member_srl) { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } break; case 'S': if($message->sender_srl != $logged_info->member_srl) { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } break; case 'T': if($message->receiver_srl != $logged_info->member_srl && $message->sender_srl != $logged_info->member_srl) { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } break; case 'N': if($message->receiver_srl != $logged_info->member_srl) { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } break; } @@ -151,13 +151,13 @@ class communicationView extends communication if($this->config->enable_message == 'N') { - return $this->stop('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } // Error appears if not logged-in if(!Context::get('is_logged')) { - return $this->stop('msg_not_logged'); + throw new Rhymix\Framework\Exceptions\MustLogin; } $logged_info = Context::get('logged_info'); @@ -190,17 +190,17 @@ class communicationView extends communication if($this->config->enable_message == 'N') { - return $this->stop('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } if(!getModel('communication')->checkGrant($this->config->grant_send)) { - return $this->stop('msg_not_permitted'); + throw new Rhymix\Framework\Exceptions\NotPermitted; } // Error appears if not logged-in if(!Context::get('is_logged')) { - return $this->stop('msg_not_logged'); + throw new Rhymix\Framework\Exceptions\MustLogin; } $logged_info = Context::get('logged_info'); @@ -210,13 +210,13 @@ class communicationView extends communication $receiver_srl = Context::get('receiver_srl'); if(!$receiver_srl) { - return $this->stop('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } // check receiver and sender are same if($logged_info->member_srl == $receiver_srl) { - return $this->stop('msg_cannot_send_to_yourself'); + throw new Rhymix\Framework\Exception('msg_cannot_send_to_yourself'); } $oCommunicationModel = getModel('communication'); @@ -241,7 +241,7 @@ class communicationView extends communication $receiver_info = $oMemberModel->getMemberInfoByMemberSrl($receiver_srl); if(!$receiver_info) { - return $this->stop('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } Context::set('receiver_info', $receiver_info); @@ -275,13 +275,13 @@ class communicationView extends communication { if($this->config->enable_friend == 'N') { - return $this->stop('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } // Error appears if not logged-in if(!Context::get('is_logged')) { - return $this->stop('msg_not_logged'); + throw new Rhymix\Framework\Exceptions\MustLogin; } $oCommunicationModel = getModel('communication'); @@ -339,13 +339,13 @@ class communicationView extends communication if($this->config->enable_friend == 'N') { - return $this->stop('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } // error appears if not logged-in if(!Context::get('is_logged')) { - return $this->stop('msg_not_logged'); + throw new Rhymix\Framework\Exceptions\MustLogin; } $logged_info = Context::get('logged_info'); @@ -353,11 +353,11 @@ class communicationView extends communication if(!$target_srl) { - return $this->stop('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } if($target_srl == $logged_info->member_srl) { - return $this->stop('msg_no_self_friend'); + throw new Rhymix\Framework\Exception('msg_no_self_friend'); } // get information of the member @@ -367,7 +367,7 @@ class communicationView extends communication if($communication_info->member_srl != $target_srl) { - return $this->stop('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } Context::set('target_info', $communication_info); @@ -390,13 +390,13 @@ class communicationView extends communication if($this->config->enable_friend == 'N') { - return $this->stop('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } // error apprears if not logged-in if(!Context::get('is_logged')) { - return $this->stop('msg_not_logged'); + throw new Rhymix\Framework\Exceptions\MustLogin; } $logged_info = Context::get('logged_info'); diff --git a/modules/document/document.admin.controller.php b/modules/document/document.admin.controller.php index c190ba84d..e54bd2065 100644 --- a/modules/document/document.admin.controller.php +++ b/modules/document/document.admin.controller.php @@ -27,10 +27,10 @@ class documentAdminController extends document { // error appears if no doc is selected $cart = Context::get('cart'); - if(!$cart) return $this->stop('msg_cart_is_null'); + if(!$cart) throw new Rhymix\Framework\Exception('msg_cart_is_null'); $document_srl_list= explode('|@|', $cart); $document_count = count($document_srl_list); - if(!$document_count) return $this->stop('msg_cart_is_null'); + if(!$document_count) throw new Rhymix\Framework\Exception('msg_cart_is_null'); // Delete a doc $oDocumentController = getController('document'); for($i=0;$i<$document_count;$i++) @@ -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 @@ -314,13 +314,16 @@ class documentAdminController extends document $oDocumentModel = getModel('document'); $oDocumentController = getController('document'); $oDocument = $oDocumentModel->getDocument($document_srl, false, false); - if(!$oDocument->isGranted()) return $this->stop('msg_not_permitted'); + if(!$oDocument->isGranted()) + { + throw new Rhymix\Framework\Exceptions\NotPermitted; + } $oMemberModel = getModel('member'); $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'); @@ -635,7 +638,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); diff --git a/modules/document/document.controller.php b/modules/document/document.controller.php index 875a25e97..2f03e19db 100644 --- a/modules/document/document.controller.php +++ b/modules/document/document.controller.php @@ -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\FeatureDisabled; $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\FeatureDisabled; $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. @@ -347,7 +347,7 @@ class documentController extends document { if(!$manual_inserted && !checkCSRF()) { - return new BaseObject(-1, 'msg_invalid_request'); + return new BaseObject(-1, 'msg_security_violation'); } // begin transaction @@ -576,7 +576,7 @@ class documentController extends document { if(!$manual_updated && !checkCSRF()) { - return new BaseObject(-1, 'msg_invalid_request'); + return new BaseObject(-1, 'msg_security_violation'); } if(!$source_obj->document_srl || !$obj->document_srl) return new BaseObject(-1, 'msg_invalied_request'); @@ -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); diff --git a/modules/document/document.model.php b/modules/document/document.model.php index 1684981d4..b505d5add 100644 --- a/modules/document/document.model.php +++ b/modules/document/document.model.php @@ -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\FeatureDisabled; $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\FeatureDisabled; $args->more_point = 0; } diff --git a/modules/document/document.view.php b/modules/document/document.view.php index a7aac9c9d..24ddf25ab 100644 --- a/modules/document/document.view.php +++ b/modules/document/document.view.php @@ -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\TargetNotFound; // 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\SecurityViolation; } $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)) @@ -172,7 +172,10 @@ class documentView extends document $oMemberModel = getModel('member'); // A message appears if the user is not logged-in - if(!$oMemberModel->isLogged()) return $this->stop('msg_not_logged'); + if(!$oMemberModel->isLogged()) + { + throw new Rhymix\Framework\Exceptions\MustLogin; + } // Get the saved document (module_srl is set to member_srl instead) $logged_info = Context::get('logged_info'); $args = new stdClass(); @@ -206,7 +209,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 +218,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\TargetNotFound; } // Check permissions if(!$oDocument->isAccessible()) { - return $this->setError('msg_not_permitted'); + throw new Rhymix\Framework\Exceptions\NotPermitted; } // Browser title settings diff --git a/modules/editor/editor.admin.controller.php b/modules/editor/editor.admin.controller.php index df3949fb7..674420585 100644 --- a/modules/editor/editor.admin.controller.php +++ b/modules/editor/editor.admin.controller.php @@ -250,9 +250,18 @@ class editorAdminController extends editor $args->enabled = $enabled; $args->site_srl = $site_srl; // Check if the component exists - if(!$site_srl) $output = executeQuery('editor.isComponentInserted', $args); - else $output = executeQuery('editor.isSiteComponentInserted', $args); - if($output->data->count) return $this->setError('msg_component_is_not_founded'); + if(!$site_srl) + { + $output = executeQuery('editor.isComponentInserted', $args); + } + else + { + $output = executeQuery('editor.isSiteComponentInserted', $args); + } + if($output->data->count) + { + return new BaseObject(-1, 'msg_component_is_not_founded'); + } // Inert a component $args->list_order = getNextSequence(); if(!$site_srl) $output = executeQuery('editor.insertComponent', $args); diff --git a/modules/editor/editor.admin.view.php b/modules/editor/editor.admin.view.php index 06b4eae66..a2aadde52 100644 --- a/modules/editor/editor.admin.view.php +++ b/modules/editor/editor.admin.view.php @@ -106,9 +106,9 @@ class editorAdminView extends editor $oEditorModel = getModel('editor'); $component = $oEditorModel->getComponent($component_name,$site_srl); - if(!$component->component_name) { - $this->stop('msg_invalid_request'); - return; + if(!$component->component_name) + { + throw new Rhymix\Framework\Exceptions\InvalidRequest; } Context::set('component', $component); diff --git a/modules/editor/editor.controller.php b/modules/editor/editor.controller.php index 0e9925548..3c0ea9062 100644 --- a/modules/editor/editor.controller.php +++ b/modules/editor/editor.controller.php @@ -47,18 +47,23 @@ class editorController extends editor { $component = Context::get('component'); $method = Context::get('method'); - if(!$component) return $this->setError('msg_component_is_not_founded', $component); + if(!$component) + { + throw new Rhymix\Framework\Exception('msg_component_is_not_founded', $component); + } $oEditorModel = getModel('editor'); $oComponent = &$oEditorModel->getComponentObject($component); if(!$oComponent->toBool()) return $oComponent; - if(!method_exists($oComponent, $method)) return $this->setError('msg_component_is_not_founded', $component); + if(!method_exists($oComponent, $method)) + { + throw new Rhymix\Framework\Exception('msg_component_is_not_founded', $component); + } //$output = call_user_method($method, $oComponent); //$output = call_user_func(array($oComponent, $method)); - if(method_exists($oComponent, $method)) $output = $oComponent->{$method}(); - else return $this->setError('%s method is not exists', $method); + $output = $oComponent->{$method}(); if($output instanceof BaseObject && !$output->toBool()) return $output; @@ -93,13 +98,13 @@ class editorController extends editor $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; diff --git a/modules/editor/editor.model.php b/modules/editor/editor.model.php index bf9082de9..68995a569 100644 --- a/modules/editor/editor.model.php +++ b/modules/editor/editor.model.php @@ -492,11 +492,11 @@ class editorModel extends editor // Create an object of the component and execute $class_path = sprintf('%scomponents/%s/', $this->module_path, $component); $class_file = sprintf('%s%s.class.php', $class_path, $component); - if(!file_exists($class_file)) return $this->setError('msg_component_is_not_founded', $component); + if(!file_exists($class_file)) return new BaseObject(-1, 'msg_component_is_not_founded', $component); // Create an object after loading the class file require_once($class_file); $oComponent = new $component($editor_sequence, $class_path); - if(!$oComponent) return $this->setError('msg_component_is_not_founded', $component); + if(!$oComponent) return new BaseObject(-1, 'msg_component_is_not_founded', $component); // Add configuration information $component_info = $this->getComponent($component, $site_srl); $oComponent->setInfo($component_info); diff --git a/modules/editor/editor.view.php b/modules/editor/editor.view.php index e1fbbb345..a13b84b6e 100644 --- a/modules/editor/editor.view.php +++ b/modules/editor/editor.view.php @@ -97,9 +97,9 @@ class editorView extends editor $oEditorModel = getModel('editor'); $component = $oEditorModel->getComponent($component_name, $site_srl); - if(!$component->component_name) { - $this->stop('msg_invalid_request'); - return; + if(!$component->component_name) + { + throw new Rhymix\Framework\Exceptions\InvalidRequest; } Context::set('component', $component); diff --git a/modules/file/file.admin.controller.php b/modules/file/file.admin.controller.php index 10f51c7df..46ba168a4 100644 --- a/modules/file/file.admin.controller.php +++ b/modules/file/file.admin.controller.php @@ -32,11 +32,11 @@ class fileAdminController extends file { // An error appears if no document is selected $cart = Context::get('cart'); - if(!$cart) return $this->stop('msg_file_cart_is_null'); + if(!$cart) throw new Rhymix\Framework\Exception('msg_file_cart_is_null'); if(!is_array($cart)) $file_srl_list= explode('|@|', $cart); else $file_srl_list = $cart; $file_count = count($file_srl_list); - if(!$file_count) return $this->stop('msg_file_cart_is_null'); + if(!$file_count) throw new Rhymix\Framework\Exception('msg_file_cart_is_null'); $oFileController = getController('file'); // Delete the post @@ -76,7 +76,7 @@ class fileAdminController extends file { if ($config->allowed_filesize > 2047 || $config->allowed_attach_size > 2047) { - return $this->setError('msg_32bit_max_2047mb'); + throw new Rhymix\Framework\Exception('msg_32bit_max_2047mb'); } } @@ -125,7 +125,7 @@ class fileAdminController extends file { if ($file_config->allowed_filesize > 2047 || $file_config->allowed_attach_size > 2047) { - return $this->setError('msg_32bit_max_2047mb'); + throw new Rhymix\Framework\Exception('msg_32bit_max_2047mb'); } } diff --git a/modules/file/file.controller.php b/modules/file/file.controller.php index 227b18499..0c165c264 100644 --- a/modules/file/file.controller.php +++ b/modules/file/file.controller.php @@ -39,7 +39,7 @@ class fileController extends file // Exit a session if there is neither upload permission nor information if(!$_SESSION['upload_info'][$editor_sequence]->enabled) { - return $this->setError('msg_not_permitted'); + throw new Rhymix\Framework\Exceptions\NotPermitted; } // Get upload_target_srl @@ -63,7 +63,7 @@ class fileController extends file $total_size = intval($matches[3]); if ($chunk_start < 0 || $chunk_size < 0 || $total_size < 0 || $chunk_start + $chunk_size > $total_size || $chunk_size != $file_info['size']) { - return $this->setError('msg_upload_invalid_chunk'); + throw new Rhymix\Framework\Exception('msg_upload_invalid_chunk'); } $this->add('chunk_current_size', $chunk_size); $this->add('chunk_uploaded_size', $chunk_start); @@ -76,13 +76,13 @@ class fileController extends file { Rhymix\Framework\Storage::delete($temp_filename); $this->add('chunk_status', 11); - return $this->setError('msg_upload_invalid_chunk'); + throw new Rhymix\Framework\Exception('msg_upload_invalid_chunk'); } if ($chunk_start != 0 && (!Rhymix\Framework\Storage::isFile($temp_filename) || Rhymix\Framework\Storage::getSize($temp_filename) != $chunk_start)) { Rhymix\Framework\Storage::delete($temp_filename); $this->add('chunk_status', 12); - return $this->setError('msg_upload_invalid_chunk'); + throw new Rhymix\Framework\Exception('msg_upload_invalid_chunk'); } // Check size limit @@ -95,13 +95,13 @@ class fileController extends file if ($total_size > $allowed_filesize) { $this->add('chunk_status', 21); - return $this->setError('msg_exceeds_limit_size'); + throw new Rhymix\Framework\Exception('msg_exceeds_limit_size'); } $output = executeQuery('file.getAttachedFileSize', (object)array('upload_target_srl' => $upload_target_srl)); if (intval($output->data->attached_size) + $total_size > $allowed_attach_size) { $this->add('chunk_status', 22); - return $this->setError('msg_exceeds_limit_size'); + throw new Rhymix\Framework\Exception('msg_exceeds_limit_size'); } } @@ -126,7 +126,7 @@ class fileController extends file { Rhymix\Framework\Storage::delete($temp_filename); $this->add('chunk_status', 40); - return $this->setError('msg_upload_invalid_chunk'); + throw new Rhymix\Framework\Exception('msg_upload_invalid_chunk'); } } else @@ -145,7 +145,10 @@ class fileController extends file $this->add('upload_target_srl', $output->get('upload_target_srl')); $this->add('download_url', $oFileModel->getDirectFileUrl($output->get('uploaded_filename'))); - if($output->error != '0') $this->stop($output->message); + if($output->error != '0') + { + throw new Rhymix\Framework\Exception($output->message); + } } /** @@ -207,14 +210,14 @@ class fileController extends file if(!$file_srl || !$width) { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } $oFileModel = getModel('file'); $fileInfo = $oFileModel->getFile($file_srl); if(!$fileInfo || $fileInfo->direct_download != 'Y') { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } $source_src = $fileInfo->uploaded_filename; @@ -230,7 +233,7 @@ class fileController extends file } else { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } $this->add('resized_info',$output); @@ -271,7 +274,10 @@ class fileController extends file { $oFileModel = getModel('file'); - if(isset($this->grant->access) && $this->grant->access !== true) return $this->setError('msg_not_permitted'); + if(isset($this->grant->access) && $this->grant->access !== true) + { + throw new Rhymix\Framework\Exceptions\NotPermitted; + } $file_srl = Context::get('file_srl'); $sid = Context::get('sid'); @@ -280,9 +286,15 @@ class fileController extends file $columnList = array('file_srl', 'sid', 'isvalid', 'source_filename', 'module_srl', 'uploaded_filename', 'file_size', 'member_srl', 'upload_target_srl', 'upload_target_type'); $file_obj = $oFileModel->getFile($file_srl, $columnList); // If the requested file information is incorrect, an error that file cannot be found appears - if($file_obj->file_srl!=$file_srl || $file_obj->sid!=$sid) return $this->stop('msg_file_not_found'); + if($file_obj->file_srl != $file_srl || $file_obj->sid !== $sid) + { + throw new Rhymix\Framework\Exceptions\TargetNotFound('msg_file_not_found'); + } // Notify that file download is not allowed when standing-by(Only a top-administrator is permitted) - if($logged_info->is_admin != 'Y' && $file_obj->isvalid!='Y') return $this->stop('msg_not_permitted_download'); + if($logged_info->is_admin != 'Y' && $file_obj->isvalid != 'Y') + { + throw new Rhymix\Framework\Exceptions\NotPermitted('msg_not_permitted_download'); + } // File name $filename = $file_obj->source_filename; $file_module_config = $oFileModel->getFileModuleConfig($file_obj->module_srl); @@ -331,7 +343,10 @@ class fileController extends file } else $file_module_config->allow_outlink = 'Y'; } - if($file_module_config->allow_outlink != 'Y') return $this->stop('msg_not_allowed_outlink'); + if($file_module_config->allow_outlink != 'Y') + { + throw new Rhymix\Framework\Exceptions\NotPermitted('msg_not_allowed_outlink'); + } } // Check if a permission for file download is granted @@ -344,7 +359,11 @@ class fileController extends file if(is_array($file_module_config->download_grant) && $downloadGrantCount>0) { - if(!Context::get('is_logged')) return $this->stop('msg_not_permitted_download'); + if(!Context::get('is_logged')) + { + throw new Rhymix\Framework\Exceptions\NotPermitted('msg_not_permitted_download'); + } + $logged_info = Context::get('logged_info'); if($logged_info->is_admin != 'Y') { @@ -367,14 +386,27 @@ class fileController extends file break; } } - if(!$is_permitted) return $this->stop('msg_not_permitted_download'); + if(!$is_permitted) + { + throw new Rhymix\Framework\Exceptions\NotPermitted('msg_not_permitted_download'); + } } } } // Call a trigger (before) $output = ModuleHandler::triggerCall('file.downloadFile', 'before', $file_obj); - if(!$output->toBool()) return $this->stop(($output->message)?$output->message:'msg_not_permitted_download'); + if(!$output->toBool()) + { + if ($output->message) + { + throw new Rhymix\Framework\Exception($output->message); + } + else + { + throw new Rhymix\Framework\Exceptions\NotPermitted('msg_not_permitted_download'); + } + } // Increase download_count $args = new stdClass(); @@ -413,20 +445,20 @@ class fileController extends file // Check file key if(strlen($file_key) != 32 || !isset($_SESSION['__XE_FILE_KEY__']) || !is_string($_SESSION['__XE_FILE_KEY__'])) { - return $this->stop('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } $file_key_data = $file_srl . $file_obj->file_size . $file_obj->uploaded_filename . $_SERVER['REMOTE_ADDR']; $file_key_compare = substr(hash_hmac('sha256', $file_key_data, $_SESSION['__XE_FILE_KEY__']), 0, 32); if($file_key !== $file_key_compare) { - return $this->stop('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } // Check if file exists $uploaded_filename = $file_obj->uploaded_filename; if(!file_exists($uploaded_filename)) { - return $this->stop('msg_file_not_found'); + throw new Rhymix\Framework\Exceptions\TargetNotFound('msg_file_not_found'); } // If client sent an If-None-Match header with the correct ETag, do not download again @@ -453,7 +485,7 @@ class fileController extends file $fp = fopen($uploaded_filename, 'rb'); if(!$fp) { - return $this->stop('msg_file_not_found'); + throw new Rhymix\Framework\Exceptions\TargetNotFound('msg_file_not_found'); } // Take care of pause and resume @@ -586,11 +618,15 @@ class fileController extends file */ function procFileGetList() { - if(!Context::get('is_logged')) return $this->setError('msg_not_permitted'); + if(!Context::get('is_logged')) + { + throw new Rhymix\Framework\Exceptions\NotPermitted; + } + $logged_info = Context::get('logged_info'); if($logged_info->is_admin !== 'Y' && !getModel('module')->isSiteAdmin($logged_info)) { - return $this->setError('msg_not_permitted'); + throw new Rhymix\Framework\Exceptions\NotPermitted; } $fileSrls = Context::get('file_srls'); @@ -835,20 +871,20 @@ class fileController extends file if(!in_array($uploaded_ext, $ext)) { - return $this->stop('msg_not_allowed_filetype'); + throw new Rhymix\Framework\Exception('msg_not_allowed_filetype'); } } $allowed_filesize = $config->allowed_filesize * 1024 * 1024; $allowed_attach_size = $config->allowed_attach_size * 1024 * 1024; // An error appears if file size exceeds a limit - if($allowed_filesize < filesize($file_info['tmp_name'])) return $this->setError('msg_exceeds_limit_size'); + if($allowed_filesize < filesize($file_info['tmp_name'])) throw new Rhymix\Framework\Exception('msg_exceeds_limit_size'); // Get total file size of all attachements (from DB) $size_args = new stdClass; $size_args->upload_target_srl = $upload_target_srl; $output = executeQuery('file.getAttachedFileSize', $size_args); $attached_size = (int)$output->data->attached_size + filesize($file_info['tmp_name']); - if($attached_size > $allowed_attach_size) return $this->setError('msg_exceeds_limit_size'); + if($attached_size > $allowed_attach_size) throw new Rhymix\Framework\Exception('msg_exceeds_limit_size'); } } @@ -885,7 +921,7 @@ class fileController extends file // Create a directory if(!Rhymix\Framework\Storage::isDirectory($path) && !Rhymix\Framework\Storage::createDirectory($path)) { - return $this->setError('msg_not_permitted_create'); + throw new Rhymix\Framework\Exception('msg_not_permitted_create'); } // Move the file @@ -897,7 +933,7 @@ class fileController extends file @copy($file_info['tmp_name'], $filename); if(!file_exists($filename)) { - return $this->setError('msg_file_upload_error'); + throw new Rhymix\Framework\Exception('msg_file_upload_error'); } } } @@ -907,7 +943,7 @@ class fileController extends file { if (!Rhymix\Framework\Storage::move($file_info['tmp_name'], $filename)) { - return $this->setError('msg_file_upload_error'); + throw new Rhymix\Framework\Exception('msg_file_upload_error'); } } } @@ -917,7 +953,7 @@ class fileController extends file { if(!@move_uploaded_file($file_info['tmp_name'], $filename)) { - return $this->setError('msg_file_upload_error'); + throw new Rhymix\Framework\Exception('msg_file_upload_error'); } } } @@ -1173,16 +1209,16 @@ class fileController extends file $vars = Context::getRequestVars(); $logged_info = Context::get('logged_info'); - if(!$vars->editor_sequence) return $this->setError('msg_invalid_request'); + if(!$vars->editor_sequence) throw new Rhymix\Framework\Exceptions\InvalidRequest; $upload_target_srl = $_SESSION['upload_info'][$vars->editor_sequence]->upload_target_srl; $oFileModel = getModel('file'); $file_info = $oFileModel->getFile($vars->file_srl); - if(!$file_info) return $this->setError('msg_not_founded'); + if(!$file_info) throw new Rhymix\Framework\Exceptions\TargetNotFound; - if(!$this->manager && !$file_info->member_srl === $logged_info->member_srl) return $this->setError('msg_not_permitted'); + if(!$this->manager && !$file_info->member_srl === $logged_info->member_srl) throw new Rhymix\Framework\Exceptions\NotPermitted; $args = new stdClass(); $args->file_srl = $vars->file_srl; diff --git a/modules/file/file.model.php b/modules/file/file.model.php index ef667d052..c2cc861a3 100644 --- a/modules/file/file.model.php +++ b/modules/file/file.model.php @@ -45,7 +45,7 @@ class fileModel extends file $oComment = $oCommentModel->getComment($upload_target_srl); if($oComment->isExists() && !$oComment->isAccessible()) { - return $this->setError('msg_not_permitted'); + throw new Rhymix\Framework\Exceptions\NotPermitted; } $oDocument = $oDocumentModel->getDocument($oComment->get('document_srl')); @@ -54,7 +54,7 @@ class fileModel extends file // document 권한 확인 if($oDocument->isExists() && !$oDocument->isAccessible()) { - return $this->setError('msg_not_permitted'); + throw new Rhymix\Framework\Exceptions\NotPermitted; } // 모듈 권한 확인 @@ -63,7 +63,7 @@ class fileModel extends file $grant = $oModuleModel->getGrant($oModuleModel->getModuleInfoByModuleSrl($oDocument->get('module_srl')), $logged_info); if(!$grant->access) { - return $this->setError('msg_not_permitted'); + throw new Rhymix\Framework\Exceptions\NotPermitted; } } diff --git a/modules/importer/extract.class.php b/modules/importer/extract.class.php index 0051e3c32..b179bba3d 100644 --- a/modules/importer/extract.class.php +++ b/modules/importer/extract.class.php @@ -124,7 +124,7 @@ class extract // If local file if(strncasecmp('http://', $this->filename, 7) !== 0) { - if(!file_exists($this->filename)) return $this->setError('msg_no_xml_file'); + if(!file_exists($this->filename)) return new BaseObject(-1, 'msg_no_xml_file'); $this->fd = fopen($this->filename,"r"); // If remote file } @@ -135,7 +135,7 @@ class extract if(!$url_info['path']) $url_info['path'] = '/'; $this->fd = @fsockopen($url_info['host'], $url_info['port']); - if(!$this->fd) return $this->setError('msg_no_xml_file'); + if(!$this->fd) return new BaseObject(-1, 'msg_no_xml_file'); // If the file name contains Korean, do urlencode(iconv required) $path = $url_info['path']; if(preg_match('/[\xEA-\xED][\x80-\xFF]{2}/', $path)&&function_exists('iconv')) @@ -157,7 +157,7 @@ class extract $buff .= $str = fgets($this->fd, 1024); if(!trim($str)) break; } - if(preg_match('/404 Not Found/i',$buff)) return $this->setError('msg_no_xml_file'); + if(preg_match('/404 Not Found/i',$buff)) return new BaseObject(-1, 'msg_no_xml_file'); } if($this->startTag) diff --git a/modules/importer/importer.admin.controller.php b/modules/importer/importer.admin.controller.php index 81e813367..112e50406 100644 --- a/modules/importer/importer.admin.controller.php +++ b/modules/importer/importer.admin.controller.php @@ -292,12 +292,12 @@ class importerAdminController extends importer $this->unit_count = Context::get('unit_count'); // Check if an index file exists $index_file = './files/cache/importer/'.$key.'/index'; - if(!file_exists($index_file)) return $this->setError('msg_invalid_xml_file'); + if(!file_exists($index_file)) throw new Rhymix\Framework\Exception('msg_invalid_xml_file'); switch($type) { case 'ttxml' : - if(!$target_module) return $this->setError('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) return $this->setError('msg_invalid_request'); + if(!$target_module) throw new Rhymix\Framework\Exceptions\InvalidRequest; $cur = $this->importModule($key, $cur, $index_file, $target_module); break; } diff --git a/modules/install/install.admin.controller.php b/modules/install/install.admin.controller.php index f409a31b2..524530a73 100644 --- a/modules/install/install.admin.controller.php +++ b/modules/install/install.admin.controller.php @@ -20,7 +20,7 @@ class installAdminController extends install function procInstallAdminInstall() { $module_name = Context::get('module_name'); - if(!$module_name) return $this->setError('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) return $this->setError('invalid_request'); + if(!$module_name) throw new Rhymix\Framework\Exceptions\InvalidRequest; $oModule = getModule($module_name, 'class'); - if(!$oModule) return $this->setError('invalid_request'); + if(!$oModule) throw new Rhymix\Framework\Exceptions\InvalidRequest; $output = $oModule->moduleUpdate(); if($output instanceof BaseObject && !$output->toBool()) diff --git a/modules/install/install.controller.php b/modules/install/install.controller.php index df2b26b16..c4a2b8980 100644 --- a/modules/install/install.controller.php +++ b/modules/install/install.controller.php @@ -17,7 +17,7 @@ class installController extends install // Stop if already installed. if (Context::isInstalled()) { - $this->stop('msg_already_installed'); + throw new Rhymix\Framework\Exception('msg_already_installed'); } // Increase time limit. @@ -76,7 +76,7 @@ class installController extends install { if ($oDB->isTableExists($table_name)) { - return $this->setError('msg_table_already_exists'); + throw new Rhymix\Framework\Exception('msg_table_already_exists'); } } @@ -99,7 +99,7 @@ class installController extends install // Check if it is already installed if (Context::isInstalled()) { - return $this->setError('msg_already_installed'); + throw new Rhymix\Framework\Exception('msg_already_installed'); } // Get install parameters. @@ -227,7 +227,7 @@ class installController extends install catch(Exception $e) { $oDB->rollback(); - return $this->setError($e->getMessage()); + throw new Rhymix\Framework\Exception($e->getMessage()); } // Execute the install script. @@ -411,7 +411,7 @@ class installController extends install else { FileHandler::removeFile($this->flagLicenseAgreement); - return $this->setError('msg_must_accept_license_agreement'); + throw new Rhymix\Framework\Exception('msg_must_accept_license_agreement'); } if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) diff --git a/modules/install/install.view.php b/modules/install/install.view.php index a2696ae3a..f539ddcbb 100644 --- a/modules/install/install.view.php +++ b/modules/install/install.view.php @@ -19,7 +19,7 @@ class installView extends install // Stop if already installed. if (Context::isInstalled()) { - return $this->stop('msg_already_installed'); + throw new Rhymix\Framework\Exception('msg_already_installed'); } // Set the browser title. diff --git a/modules/integration_search/integration_search.view.php b/modules/integration_search/integration_search.view.php index 7c9db39c3..45567e810 100644 --- a/modules/integration_search/integration_search.view.php +++ b/modules/integration_search/integration_search.view.php @@ -49,7 +49,10 @@ class integration_searchView extends integration_search } // Check permissions - if(!$this->grant->access) return $this->setError('msg_not_permitted'); + if(!$this->grant->access) + { + throw new Rhymix\Framework\Exceptions\NotPermitted; + } $config = $oModuleModel->getModuleConfig('integration_search'); if(!$config) $config = new stdClass; diff --git a/modules/krzip/krzip.model.php b/modules/krzip/krzip.model.php index 3edbd4cc1..9980f2bc3 100644 --- a/modules/krzip/krzip.model.php +++ b/modules/krzip/krzip.model.php @@ -104,7 +104,7 @@ class krzipModel extends krzip $query = trim(strval($query)); if($query === '') { - return $this->stop('msg_krzip_no_query'); + return $this->setError('msg_krzip_no_query'); } $output = $this->getEpostapiSearch($query); diff --git a/modules/layout/layout.admin.controller.php b/modules/layout/layout.admin.controller.php index a20943ffb..3e170a4ba 100644 --- a/modules/layout/layout.admin.controller.php +++ b/modules/layout/layout.admin.controller.php @@ -23,7 +23,7 @@ class layoutAdminController extends layout */ function procLayoutAdminInsert() { - if(Context::get('layout') == 'faceoff') return $this->stop('not supported'); + if(Context::get('layout') == 'faceoff') throw new Rhymix\Framework\Exception('not supported'); // Get information to create a layout $site_module_info = Context::get('site_module_info'); @@ -130,7 +130,7 @@ class layoutAdminController extends layout $output = executeQuery('menu.getMenuItemByUrl', $tmpArgs); if(!$output->toBool()) { - return $this->setError('fail_to_update'); + throw new Rhymix\Framework\Exception('fail_to_update'); } $menu_srl = $output->data->menu_srl; @@ -313,7 +313,7 @@ class layoutAdminController extends layout if(!$output->toBool()) { - return $this->setError($output->message); + throw new Rhymix\Framework\Exception($output->message); } } } @@ -356,7 +356,7 @@ class layoutAdminController extends layout if(!$layout_srl || !$code || !$is_post) { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } $oLayoutModel = getModel('layout'); @@ -377,7 +377,7 @@ class layoutAdminController extends layout function procLayoutAdminCodeReset() { $layout_srl = Context::get('layout_srl'); - if(!$layout_srl) return $this->setError('msg_invalid_request'); + if(!$layout_srl) throw new Rhymix\Framework\Exceptions\InvalidRequest; // delete user layout file $oLayoutModel = getModel('layout'); @@ -480,13 +480,13 @@ class layoutAdminController extends layout $oModuleModel = getModel('module'); $mid = Context::get('mid'); - if(!$mid) return $this->setError('msg_invalid_request'); + if(!$mid) throw new Rhymix\Framework\Exceptions\InvalidRequest; $site_module_info = Context::get('site_module_info'); $columnList = array('layout_srl'); $module_info = $oModuleModel->getModuleInfoByMid($mid, $site_module_info->site_srl, $columnList); $layout_srl = $module_info->layout_srl; - if(!$layout_srl) return $this->setError('msg_invalid_request'); + if(!$layout_srl) throw new Rhymix\Framework\Exceptions\InvalidRequest; $oLayoutModel = getModel('layout'); @@ -683,7 +683,7 @@ class layoutAdminController extends layout */ function procLayoutAdminUserLayoutImport() { - return $this->stop('not supported'); + throw new Rhymix\Framework\Exception('not supported'); // check upload if(!Context::isUploaded()) exit(); @@ -713,12 +713,12 @@ class layoutAdminController extends layout $sourceArgs = Context::getRequestVars(); if($sourceArgs->layout == 'faceoff') { - return $this->stop('not supported'); + throw new Rhymix\Framework\Exception('not supported'); } if(!$sourceArgs->layout_srl) { - return $this->stop('msg_empty_origin_layout'); + throw new Rhymix\Framework\Exception('msg_empty_origin_layout'); } $oLayoutModel = getModel('layout'); @@ -731,7 +731,7 @@ class layoutAdminController extends layout if(!is_array($sourceArgs->title) || count($sourceArgs->title) == 0) { - return $this->stop('msg_empty_target_layout'); + throw new Rhymix\Framework\Exception('msg_empty_target_layout'); } $output = $oLayoutModel->getLayoutRawData($sourceArgs->layout_srl, array('extra_vars')); diff --git a/modules/layout/layout.admin.model.php b/modules/layout/layout.admin.model.php index 7d6de7f67..004879a12 100644 --- a/modules/layout/layout.admin.model.php +++ b/modules/layout/layout.admin.model.php @@ -67,7 +67,7 @@ class layoutAdminModel extends layout // Error appears if there is no layout information is registered if(!$layout_info) { - return $this->stop('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } // Get a menu list diff --git a/modules/layout/layout.admin.view.php b/modules/layout/layout.admin.view.php index 42df0dcf1..9dc793a9b 100644 --- a/modules/layout/layout.admin.view.php +++ b/modules/layout/layout.admin.view.php @@ -140,11 +140,11 @@ class layoutAdminView extends layout $layout = Context::get('layout'); if(!in_array($type, array('P', 'M'))) $type = 'P'; - if(!$layout) return $this->stop('msg_invalid_request'); + if(!$layout) throw new Rhymix\Framework\Exceptions\InvalidRequest; $oLayoutModel = getModel('layout'); $layout_info = $oLayoutModel->getLayoutInfo($layout, null, $type); - if(!$layout_info) return $this->stop('msg_invalid_request'); + if(!$layout_info) throw new Rhymix\Framework\Exceptions\InvalidRequest; Context::set('layout_info', $layout_info); @@ -175,10 +175,10 @@ class layoutAdminView extends layout // Get layout info $layout = Context::get('layout'); - if($layout == 'faceoff') return $this->stop('not supported'); + if($layout == 'faceoff') throw new Rhymix\Framework\Exception('not supported'); $layout_info = $oModel->getLayoutInfo($layout, null, $type); - if(!$layout_info) return $this->stop('msg_invalid_request'); + if(!$layout_info) throw new Rhymix\Framework\Exceptions\InvalidRequest; // get Menu list $oMenuAdminModel = getAdminModel('menu'); @@ -295,11 +295,11 @@ class layoutAdminView extends layout $layout_srl = Context::get('layout_srl'); $code = Context::get('code'); $code_css = Context::get('code_css'); - if(!$layout_srl || !$code) return $this->setError('msg_invalid_request'); + if(!$layout_srl || !$code) throw new Rhymix\Framework\Exceptions\InvalidRequest; // Get the layout information $oLayoutModel = getModel('layout'); $layout_info = $oLayoutModel->getLayout($layout_srl); - if(!$layout_info) return $this->setError('msg_invalid_request'); + if(!$layout_info) throw new Rhymix\Framework\Exceptions\InvalidRequest; // Separately handle the layout if its type is faceoff if($layout_info && $layout_info->type == 'faceoff') $oLayoutModel->doActivateFaceOff($layout_info); // Apply CSS directly diff --git a/modules/layout/layout.view.php b/modules/layout/layout.view.php index ec8730e93..3c2d714f2 100644 --- a/modules/layout/layout.view.php +++ b/modules/layout/layout.view.php @@ -55,7 +55,7 @@ class layoutView extends layout $logged_info = Context::get('logged_info'); if($logged_info->is_admin != 'Y') { - throw new Exception(lang('msg_invalid_request')); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } // if module is 'ARTiCLE' and from site design setting, make content directly @@ -253,13 +253,13 @@ class layoutView extends layout $output = executeQuery('layout.getOneModuleInstanceByModuleName', $args); if(!$output->toBool()) { - throw new Exception($output->getMessage()); + throw new Rhymix\Framework\Exception($output->getMessage()); } // if there is no module instance, error... if(!$output->data) { - throw new Exception(lang('msg_unabled_preview')); + throw new Rhymix\Framework\Exception(lang('msg_unabled_preview')); } $mid = current($output->data)->mid; @@ -301,7 +301,7 @@ class layoutView extends layout $oModule = $oModuleHandler->procModule(); if(!$oModule->toBool()) { - throw new Exception(lang('not_support_layout_preview')); + throw new Rhymix\Framework\Exception(lang('not_support_layout_preview')); } // get module html @@ -318,23 +318,23 @@ class layoutView extends layout { if(!checkCSRF()) { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } // admin check // this act is admin view but in normal view because do not load admin css/js files $logged_info = Context::get('logged_info'); - if($logged_info->is_admin != 'Y') return $this->stop('msg_invalid_request'); + if($logged_info->is_admin != 'Y') throw new Rhymix\Framework\Exceptions\InvalidRequest; $layout_srl = Context::get('layout_srl'); $code = Context::get('code'); $code_css = Context::get('code_css'); - if(!$layout_srl || !$code) return $this->setError('msg_invalid_request'); + if(!$layout_srl || !$code) throw new Rhymix\Framework\Exceptions\InvalidRequest; // Get the layout information $oLayoutModel = getModel('layout'); $layout_info = $oLayoutModel->getLayout($layout_srl); - if(!$layout_info) return $this->setError('msg_invalid_request'); + if(!$layout_info) throw new Rhymix\Framework\Exceptions\InvalidRequest; // Separately handle the layout if its type is faceoff if($layout_info && $layout_info->type == 'faceoff') $oLayoutModel->doActivateFaceOff($layout_info); // Apply CSS directly diff --git a/modules/member/member.admin.controller.php b/modules/member/member.admin.controller.php index 0d08a6ca1..c3e06f488 100644 --- a/modules/member/member.admin.controller.php +++ b/modules/member/member.admin.controller.php @@ -26,7 +26,7 @@ class memberAdminController extends member $logged_info = Context::get('logged_info'); if($logged_info->is_admin != 'Y' || !checkCSRF()) { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } $args = Context::gets('member_srl','email_address','find_account_answer', 'allow_mailing','allow_message','denied','is_admin','description','group_srl_list','limit_date'); @@ -741,7 +741,7 @@ class memberAdminController extends member // Check ID duplicated if (Context::isReservedWord($args->column_name)) { - return $this->setError('msg_column_id_not_available'); + throw new Rhymix\Framework\Exception('msg_column_id_not_available'); } $oMemberModel = getModel('member'); $config = $oMemberModel->getMemberConfig(); @@ -750,7 +750,7 @@ class memberAdminController extends member if($item->name == $args->column_name) { if($args->member_join_form_srl && $args->member_join_form_srl == $item->member_join_form_srl) continue; - return $this->setError('msg_column_id_not_available'); + throw new Rhymix\Framework\Exception('msg_column_id_not_available'); } } // Fix if member_join_form_srl exists. Add if not exists. @@ -961,7 +961,7 @@ class memberAdminController extends member function procMemberAdminDeleteMembers() { $target_member_srls = Context::get('target_member_srls'); - if(!$target_member_srls) return $this->setError('msg_invalid_request'); + if(!$target_member_srls) throw new Rhymix\Framework\Exceptions\InvalidRequest; $member_srls = explode(',', $target_member_srls); $oMemberController = getController('member'); @@ -985,7 +985,7 @@ class memberAdminController extends member function procMemberAdminUpdateMembersGroup() { $member_srl = Context::get('member_srl'); - if(!$member_srl) return $this->setError('msg_invalid_request'); + if(!$member_srl) throw new Rhymix\Framework\Exceptions\InvalidRequest; $member_srls = explode(',',$member_srl); $group_srl = Context::get('group_srls'); @@ -1258,7 +1258,7 @@ class memberAdminController extends member function updateGroup($args) { if(!$args->site_srl) $args->site_srl = 0; - if(!$args->group_srl) return $this->setError('lang->msg_not_founded'); + if(!$args->group_srl) throw new Rhymix\Framework\Exceptions\TargetNotFound; // Call trigger (before) $trigger_output = ModuleHandler::triggerCall('member.updateGroup', 'before', $args); @@ -1302,8 +1302,8 @@ class memberAdminController extends member $columnList = array('group_srl', 'is_default'); $group_info = $oMemberModel->getGroup($group_srl, $columnList); - if(!$group_info) return $this->setError('lang->msg_not_founded'); - if($group_info->is_default == 'Y') return $this->setError('msg_not_delete_default'); + if(!$group_info) throw new Rhymix\Framework\Exceptions\TargetNotFound; + if($group_info->is_default == 'Y') throw new Rhymix\Framework\Exception('msg_not_delete_default'); // Call trigger (before) $trigger_output = ModuleHandler::triggerCall('member.deleteGroup', 'before', $group_info); diff --git a/modules/member/member.controller.php b/modules/member/member.controller.php index aef2d38d5..6007a54e7 100644 --- a/modules/member/member.controller.php +++ b/modules/member/member.controller.php @@ -30,7 +30,7 @@ class memberController extends member if(!$user_id && !$password && Context::getRequestMethod() == 'GET') { $this->setRedirectUrl(getNotEncodedUrl('')); - return $this->setError('null_user_id'); + throw new Rhymix\Framework\Exception('null_user_id'); } // Variables @@ -42,8 +42,8 @@ class memberController extends member if(!$keep_signed) $keep_signed = Context::get('keep_signed'); // Return an error when id and password doesn't exist - if(!$user_id) return $this->setError('null_user_id'); - if(!$password) return $this->setError('null_password'); + if(!$user_id) throw new Rhymix\Framework\Exception('null_user_id'); + if(!$password) throw new Rhymix\Framework\Exception('null_password'); $output = $this->doLogin($user_id, $password, $keep_signed=='Y'?true:false); if (!$output->toBool()) return $output; @@ -122,7 +122,7 @@ class memberController extends member $document_srl = (int) (Context::get('document_srl') ?: Context::get('target_srl')); if(!$document_srl) { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } $oDocumentModel = getModel('document'); @@ -131,7 +131,7 @@ class memberController extends member // Check document if(!$oDocument->isAccessible()) { - return $this->setError('msg_is_secret'); + throw new Rhymix\Framework\Exception('msg_is_secret'); } $oModuleModel = getModel('module'); @@ -143,19 +143,19 @@ class memberController extends member // Check access to module of the document if(!$grant->access) { - return $this->setError('msg_not_permitted'); + throw new Rhymix\Framework\Exceptions\NotPermitted; } // Check grant to module of the document if(isset($grant->list) && isset($grant->view) && (!$grant->list || !$grant->view)) { - return $this->setError('msg_not_permitted'); + throw new Rhymix\Framework\Exceptions\NotPermitted; } // Check consultation option if(isset($grant->consultation_read) && $module_info->consultation == 'Y' && !$grant->consultation_read && !$oDocument->isGranted()) { - return $this->setError('msg_not_permitted'); + throw new Rhymix\Framework\Exceptions\NotPermitted; } // Find default scrap folder @@ -187,7 +187,7 @@ class memberController extends member $output = executeQuery('member.getScrapDocument', $args); if($output->data->count) { - return $this->setError('msg_alreay_scrapped'); + throw new Rhymix\Framework\Exception('msg_alreay_scrapped'); } // Insert @@ -206,11 +206,12 @@ class memberController extends member function procMemberDeleteScrap() { // Check login information - if(!Context::get('is_logged')) return $this->setError('msg_not_logged'); + if(!Context::get('is_logged')) throw new Rhymix\Framework\Exceptions\MustLogin; $logged_info = Context::get('logged_info'); $document_srl = (int)Context::get('document_srl'); - if(!$document_srl) return $this->setError('msg_invalid_request'); + if(!$document_srl) throw new Rhymix\Framework\Exceptions\InvalidRequest; + // Variables $args = new stdClass; $args->member_srl = $logged_info->member_srl; @@ -226,14 +227,14 @@ class memberController extends member function procMemberMoveScrapFolder() { // Check login information - if(!Context::get('is_logged')) return $this->setError('msg_not_logged'); + if(!Context::get('is_logged')) throw new Rhymix\Framework\Exceptions\MustLogin; $logged_info = Context::get('logged_info'); $document_srl = (int)Context::get('document_srl'); $folder_srl = (int)Context::get('folder_srl'); if(!$document_srl || !$folder_srl) { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } // Check that the target folder exists and belongs to member @@ -243,7 +244,7 @@ class memberController extends member $output = executeQueryArray('member.getScrapFolderList', $args); if(!count($output->data)) { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } // Move @@ -262,7 +263,7 @@ class memberController extends member function procMemberInsertScrapFolder() { // Check login information - if(!Context::get('is_logged')) return $this->setError('msg_not_logged'); + if(!Context::get('is_logged')) throw new Rhymix\Framework\Exceptions\MustLogin; $logged_info = Context::get('logged_info'); // Get new folder name @@ -270,7 +271,7 @@ class memberController extends member $folder_name = escape(trim(utf8_normalize_spaces($folder_name))); if(!$folder_name) { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } // Check existing folder with same name @@ -280,7 +281,7 @@ class memberController extends member $output = executeQueryArray('member.getScrapFolderList', $args); if(count($output->data) || $folder_name === lang('default_folder')) { - return $this->setError('msg_folder_alreay_exists'); + throw new Rhymix\Framework\Exception('msg_folder_alreay_exists'); } // Create folder @@ -301,7 +302,7 @@ class memberController extends member function procMemberRenameScrapFolder() { // Check login information - if(!Context::get('is_logged')) return $this->setError('msg_not_logged'); + if(!Context::get('is_logged')) throw new Rhymix\Framework\Exceptions\MustLogin; $logged_info = Context::get('logged_info'); // Get new folder name @@ -310,7 +311,7 @@ class memberController extends member $folder_name = escape(trim(utf8_normalize_spaces($folder_name))); if(!$folder_srl || !$folder_name) { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } // Check that the original folder exists and belongs to member @@ -320,11 +321,11 @@ class memberController extends member $output = executeQueryArray('member.getScrapFolderList', $args); if(!count($output->data)) { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } if(array_first($output->data)->name === '/DEFAULT/') { - return $this->setError('msg_folder_is_default'); + throw new Rhymix\Framework\Exception('msg_folder_is_default'); } // Check existing folder with same name @@ -335,7 +336,7 @@ class memberController extends member $output = executeQueryArray('member.getScrapFolderList', $args); if(count($output->data) || $folder_name === lang('default_folder')) { - return $this->setError('msg_folder_alreay_exists'); + throw new Rhymix\Framework\Exception('msg_folder_alreay_exists'); } // Rename folder @@ -353,14 +354,14 @@ class memberController extends member function procMemberDeleteScrapFolder() { // Check login information - if(!Context::get('is_logged')) return $this->setError('msg_not_logged'); + if(!Context::get('is_logged')) throw new Rhymix\Framework\Exceptions\MustLogin; $logged_info = Context::get('logged_info'); // Get folder_srl to delete $folder_srl = intval(Context::get('folder_srl')); if(!$folder_srl) { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } // Check that the folder exists and belongs to member @@ -370,11 +371,11 @@ class memberController extends member $output = executeQueryArray('member.getScrapFolderList', $args); if(!count($output->data)) { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } if(array_first($output->data)->name === '/DEFAULT/') { - return $this->setError('msg_folder_is_default'); + throw new Rhymix\Framework\Exception('msg_folder_is_default'); } // Check that the folder is empty @@ -384,7 +385,7 @@ class memberController extends member $output = executeQueryArray('member.getScrapDocumentList', $args); if(count($output->data)) { - return $this->setError('msg_folder_not_empty'); + throw new Rhymix\Framework\Exception('msg_folder_not_empty'); } // Delete folder @@ -436,22 +437,22 @@ class memberController extends member function procMemberDeleteSavedDocument() { // Check login information - if(!Context::get('is_logged')) return $this->setError('msg_not_logged'); + if(!Context::get('is_logged')) throw new Rhymix\Framework\Exceptions\MustLogin; $logged_info = Context::get('logged_info'); $document_srl = (int)Context::get('document_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); if ($oDocument->get('member_srl') != $logged_info->member_srl) { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } $configStatusList = $oDocumentModel->getStatusList(); if ($oDocument->get('status') != $configStatusList['temp']) { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } // Variables @@ -465,14 +466,14 @@ class memberController extends member function procMemberDeleteAutologin() { // Check login information - if(!Context::get('is_logged')) return $this->setError('msg_not_logged'); + if(!Context::get('is_logged')) throw new Rhymix\Framework\Exceptions\MustLogin; $logged_info = Context::get('logged_info'); $autologin_id = intval(Context::get('autologin_id')); $autologin_key = Context::get('autologin_key'); if (!$autologin_id || !$autologin_key) { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } $args = new stdClass; @@ -575,7 +576,11 @@ class memberController extends member */ function procMemberInsert() { - if (Context::getRequestMethod () == "GET") return new BaseObject (-1, "msg_invalid_request"); + if (Context::getRequestMethod() == 'GET') + { + throw new Rhymix\Framework\Exceptions\SecurityViolation; + } + $oMemberModel = &getModel ('member'); $config = $oMemberModel->getMemberConfig(); @@ -583,7 +588,7 @@ class memberController extends member $trigger_output = ModuleHandler::triggerCall ('member.procMemberInsert', 'before', $config); if(!$trigger_output->toBool ()) return $trigger_output; // Check if an administrator allows a membership - if($config->enable_join != 'Y') return $this->stop ('msg_signup_disabled'); + if($config->enable_join != 'Y') throw new Rhymix\Framework\Exceptions\FeatureDisabled('msg_signup_disabled'); // Check if the user accept the license terms (only if terms exist) $accept_agreement = Context::get('accept_agreement'); @@ -591,7 +596,7 @@ class memberController extends member { if($agreement->type === 'required' && $accept_agreement !== 'Y' && $accept_agreement[$i] !== 'Y') { - return $this->setError('msg_accept_agreement'); + throw new Rhymix\Framework\Exception('msg_accept_agreement'); } } @@ -646,7 +651,7 @@ class memberController extends member if(!$oMemberModel->checkPasswordStrength($args->password, $config->password_strength)) { $message = lang('about_password_strength'); - return $this->setError($message[$config->password_strength]); + throw new Rhymix\Framework\Exception($message[$config->password_strength]); } // Remove some unnecessary variables from all the vars @@ -779,19 +784,19 @@ class memberController extends member { if($_SESSION['rechecked_password_step'] != 'INPUT_PASSWORD') { - return $this->stop('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } if(!Context::get('is_logged')) { - return $this->stop('msg_not_logged'); + throw new Rhymix\Framework\Exceptions\MustLogin; } $password = Context::get('password'); if(!$password) { - return $this->stop('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } $oMemberModel = getModel('member'); @@ -805,7 +810,7 @@ class memberController extends member // Verify the current password if(!$oMemberModel->isValidPassword($member_info->password, $password)) { - return $this->setError('invalid_password'); + throw new Rhymix\Framework\Exception('invalid_password'); } $_SESSION['rechecked_password_step'] = 'VALIDATE_PASSWORD'; @@ -830,12 +835,12 @@ class memberController extends member { if(!Context::get('is_logged')) { - return $this->stop('msg_not_logged'); + throw new Rhymix\Framework\Exceptions\MustLogin; } if($_SESSION['rechecked_password_step'] != 'INPUT_DATA') { - return $this->stop('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } unset($_SESSION['rechecked_password_step']); @@ -969,7 +974,7 @@ class memberController extends member */ function procMemberModifyPassword() { - if(!Context::get('is_logged')) return $this->stop('msg_not_logged'); + if(!Context::get('is_logged')) throw new Rhymix\Framework\Exceptions\MustLogin; // Extract the necessary information in advance $current_password = trim(Context::get('current_password')); $password = trim(Context::get('password1')); @@ -983,10 +988,10 @@ class memberController extends member $member_info = $oMemberModel->getMemberInfoByMemberSrl($member_srl, 0, $columnList); // Verify the cuttent password - if(!$oMemberModel->isValidPassword($member_info->password, $current_password, $member_srl)) return $this->setError('invalid_password'); + if(!$oMemberModel->isValidPassword($member_info->password, $current_password, $member_srl)) throw new Rhymix\Framework\Exception('invalid_password'); // Check if a new password is as same as the previous password - if($current_password == $password) return $this->setError('invalid_new_password'); + if($current_password == $password) throw new Rhymix\Framework\Exception('invalid_new_password'); // Execute insert or update depending on the value of member_srl $args = new stdClass; @@ -1017,7 +1022,7 @@ class memberController extends member */ function procMemberLeave() { - if(!Context::get('is_logged')) return $this->stop('msg_not_logged'); + if(!Context::get('is_logged')) throw new Rhymix\Framework\Exceptions\MustLogin; // Extract the necessary information in advance $password = trim(Context::get('password')); // Get information of logged-in user @@ -1029,7 +1034,7 @@ class memberController extends member $columnList = array('member_srl', 'password'); $member_info = $oMemberModel->getMemberInfoByMemberSrl($member_srl, 0, $columnList); // Verify the cuttent password - if(!$oMemberModel->isValidPassword($member_info->password, $password)) return $this->setError('invalid_password'); + if(!$oMemberModel->isValidPassword($member_info->password, $password)) throw new Rhymix\Framework\Exception('invalid_password'); $output = $this->deleteMember($member_srl); if(!$output->toBool()) return $output; @@ -1052,17 +1057,17 @@ class memberController extends member { // Check if the file is successfully uploaded $file = $_FILES['profile_image']; - if(!is_uploaded_file($file['tmp_name'])) return $this->stop('msg_not_uploaded_profile_image'); + if(!is_uploaded_file($file['tmp_name'])) throw new Rhymix\Framework\Exception('msg_not_uploaded_profile_image'); // Ignore if member_srl is invalid or doesn't exist. $member_srl = Context::get('member_srl'); - if(!$member_srl) return $this->stop('msg_not_uploaded_profile_image'); + if(!$member_srl) throw new Rhymix\Framework\Exception('msg_not_uploaded_profile_image'); $logged_info = Context::get('logged_info'); - if($logged_info->is_admin != 'Y' && $logged_info->member_srl != $member_srl) return $this->stop('msg_not_uploaded_profile_image'); + if($logged_info->is_admin != 'Y' && $logged_info->member_srl != $member_srl) throw new Rhymix\Framework\Exception('msg_not_uploaded_profile_image'); // Return if member module is set not to use an image name or the user is not an administrator ; $oMemberModel = getModel('member'); $config = $oMemberModel->getMemberConfig(); - if($logged_info->is_admin != 'Y' && $config->profile_image != 'Y') return $this->stop('msg_not_uploaded_profile_image'); + if($logged_info->is_admin != 'Y' && $config->profile_image != 'Y') throw new Rhymix\Framework\Exception('msg_not_uploaded_profile_image'); $output = $this->insertProfileImage($member_srl, $file['tmp_name']); if(!$output->toBool()) return $output; @@ -1099,7 +1104,7 @@ class memberController extends member elseif(IMAGETYPE_GIF == $type) $ext = 'gif'; else { - return $this->stop('msg_not_uploaded_profile_image'); + throw new Rhymix\Framework\Exception('msg_not_uploaded_profile_image'); } $target_path = sprintf('files/member_extra_info/profile_image/%s', getNumberingPath($member_srl)); @@ -1118,7 +1123,7 @@ class memberController extends member if($max_filesize && $filesize > ($max_filesize * 1024)) { FileHandler::removeFile($temp_filename); - return $this->stop(implode(' ' , array( + throw new Rhymix\Framework\Exception(implode(' ' , array( Context::getLang('msg_not_uploaded_profile_image'), Context::getLang('msg_exceeds_limit_size') ))); @@ -1134,7 +1139,7 @@ class memberController extends member $filesize = filesize($target_file); if($max_filesize && $filesize > ($max_filesize * 1024)) { - return $this->stop(implode(' ' , array( + throw new Rhymix\Framework\Exception(implode(' ' , array( Context::getLang('msg_not_uploaded_profile_image'), Context::getLang('msg_exceeds_limit_size') ))); @@ -1157,17 +1162,17 @@ class memberController extends member { // Check if the file is successfully uploaded $file = $_FILES['image_name']; - if(!is_uploaded_file($file['tmp_name'])) return $this->stop('msg_not_uploaded_image_name'); + if(!is_uploaded_file($file['tmp_name'])) throw new Rhymix\Framework\Exception('msg_not_uploaded_image_name'); // Ignore if member_srl is invalid or doesn't exist. $member_srl = Context::get('member_srl'); - if(!$member_srl) return $this->stop('msg_not_uploaded_image_name'); + if(!$member_srl) throw new Rhymix\Framework\Exception('msg_not_uploaded_image_name'); $logged_info = Context::get('logged_info'); - if($logged_info->is_admin != 'Y' && $logged_info->member_srl != $member_srl) return $this->stop('msg_not_uploaded_image_name'); + if($logged_info->is_admin != 'Y' && $logged_info->member_srl != $member_srl) throw new Rhymix\Framework\Exception('msg_not_uploaded_image_name'); // Return if member module is set not to use an image name or the user is not an administrator ; $oMemberModel = getModel('member'); $config = $oMemberModel->getMemberConfig(); - if($logged_info->is_admin != 'Y' && $config->image_name != 'Y') return $this->stop('msg_not_uploaded_image_name'); + if($logged_info->is_admin != 'Y' && $config->image_name != 'Y') throw new Rhymix\Framework\Exception('msg_not_uploaded_image_name'); $output = $this->insertImageName($member_srl, $file['tmp_name']); if(!$output->toBool()) return $output; @@ -1218,7 +1223,7 @@ class memberController extends member if($max_filesize && $filesize > ($max_filesize * 1024)) { FileHandler::removeFile($temp_filename); - return $this->stop(implode(' ' , array( + throw new Rhymix\Framework\Exception(implode(' ' , array( Context::getLang('msg_not_uploaded_image_name'), Context::getLang('msg_exceeds_limit_size') ))); @@ -1234,7 +1239,7 @@ class memberController extends member $filesize = filesize($target_file); if($max_filesize && $filesize > ($max_filesize * 1024)) { - return $this->stop(implode(' ' , array( + throw new Rhymix\Framework\Exception(implode(' ' , array( Context::getLang('msg_not_uploaded_image_name'), Context::getLang('msg_exceeds_limit_size') ))); @@ -1308,17 +1313,17 @@ class memberController extends member { // Check if the file is successfully uploaded $file = $_FILES['image_mark']; - if(!is_uploaded_file($file['tmp_name'])) return $this->stop('msg_not_uploaded_image_mark'); + if(!is_uploaded_file($file['tmp_name'])) throw new Rhymix\Framework\Exception('msg_not_uploaded_image_mark'); // Ignore if member_srl is invalid or doesn't exist. $member_srl = Context::get('member_srl'); - if(!$member_srl) return $this->stop('msg_not_uploaded_image_mark'); + if(!$member_srl) throw new Rhymix\Framework\Exception('msg_not_uploaded_image_mark'); $logged_info = Context::get('logged_info'); - if($logged_info->is_admin != 'Y' && $logged_info->member_srl != $member_srl) return $this->stop('msg_not_uploaded_image_mark'); + if($logged_info->is_admin != 'Y' && $logged_info->member_srl != $member_srl) throw new Rhymix\Framework\Exception('msg_not_uploaded_image_mark'); // Membership in the images mark the module using the ban was set by an administrator or return; $oMemberModel = getModel('member'); $config = $oMemberModel->getMemberConfig(); - if($logged_info->is_admin != 'Y' && $config->image_mark != 'Y') return $this->stop('msg_not_uploaded_image_mark'); + if($logged_info->is_admin != 'Y' && $config->image_mark != 'Y') throw new Rhymix\Framework\Exception('msg_not_uploaded_image_mark'); $this->insertImageMark($member_srl, $file['tmp_name']); if(!$output->toBool()) return $output; @@ -1365,7 +1370,7 @@ class memberController extends member if($max_filesize && $filesize > ($max_filesize * 1024)) { FileHandler::removeFile($temp_filename); - return $this->stop(implode(' ' , array( + throw new Rhymix\Framework\Exception(implode(' ' , array( Context::getLang('msg_not_uploaded_group_image_mark'), Context::getLang('msg_exceeds_limit_size') ))); @@ -1381,7 +1386,7 @@ class memberController extends member if($max_filesize && $filesize > ($max_filesize * 1024)) { FileHandler::removeFile($target_file); - return $this->stop(implode(' ' , array( + throw new Rhymix\Framework\Exception(implode(' ' , array( Context::getLang('msg_not_uploaded_group_image_mark'), Context::getLang('msg_exceeds_limit_size') ))); @@ -1428,14 +1433,14 @@ class memberController extends member function procMemberFindAccount() { $email_address = Context::get('email_address'); - if(!$email_address) return $this->setError('msg_invalid_request'); + if(!$email_address) throw new Rhymix\Framework\Exceptions\InvalidRequest; $oMemberModel = getModel('member'); $oModuleModel = getModel('module'); // Check if a member having the same email address exists $member_srl = $oMemberModel->getMemberSrlByEmailAddress($email_address); - if(!$member_srl) return $this->setError('msg_email_not_exists'); + if(!$member_srl) throw new Rhymix\Framework\Exception('msg_email_not_exists'); // Get information of the member $columnList = array('denied', 'member_srl', 'user_id', 'user_name', 'email_address', 'nick_name'); @@ -1447,7 +1452,7 @@ class memberController extends member $chk_args = new stdClass; $chk_args->member_srl = $member_info->member_srl; $output = executeQuery('member.chkAuthMail', $chk_args); - if($output->toBool() && $output->data->count != '0') return $this->setError('msg_user_not_confirmed'); + if($output->toBool() && $output->data->count != '0') throw new Rhymix\Framework\Exception('msg_user_not_confirmed'); } // Insert data into the authentication DB @@ -1528,7 +1533,7 @@ class memberController extends member */ function procMemberFindAccountByQuestion() { - return $this->setError('msg_question_not_allowed'); + throw new Rhymix\Framework\Exception('msg_question_not_allowed'); } /** @@ -1547,7 +1552,7 @@ class memberController extends member if(!$member_srl || !$auth_key) { - return $this->stop('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } // Call a trigger (before) @@ -1557,7 +1562,7 @@ class memberController extends member $trigger_output = ModuleHandler::triggerCall('member.procMemberAuthAccount', 'before', $trigger_obj); if(!$trigger_output->toBool()) { - return $this->stop($trigger_output->getMessage()); + return $trigger_output; } // Test logs for finding password by user_id and authkey @@ -1569,13 +1574,13 @@ class memberController extends member if(!$output->toBool() || $output->data->auth_key !== $auth_key) { executeQuery('member.deleteAuthMail', $args); - return $this->stop('msg_invalid_auth_key'); + throw new Rhymix\Framework\Exception('msg_invalid_auth_key'); } if(ztime($output->data->regdate) < time() - (86400 * 3)) { executeQuery('member.deleteAuthMail', $args); - return $this->stop('msg_expired_auth_key'); + throw new Rhymix\Framework\Exception('msg_expired_auth_key'); } // Back up the value of $output->data->is_register @@ -1594,7 +1599,7 @@ class memberController extends member $output = executeQuery('member.updateMemberPassword', $args); if(!$output->toBool()) { - return $this->stop($output->getMessage()); + return $output; } // Remove all values having the member_srl from authentication table @@ -1621,14 +1626,14 @@ class memberController extends member { // Get an email_address $email_address = Context::get('email_address'); - if(!$email_address) return $this->setError('msg_invalid_request'); + if(!$email_address) throw new Rhymix\Framework\Exceptions\InvalidRequest; // Log test by using email_address $oMemberModel = getModel('member'); $args = new stdClass; $args->email_address = $email_address; $memberSrl = $oMemberModel->getMemberSrlByEmailAddress($email_address); - if(!$memberSrl) return $this->setError('msg_not_exists_member'); + if(!$memberSrl) throw new Rhymix\Framework\Exception('msg_not_exists_member'); $columnList = array('member_srl', 'user_id', 'user_name', 'nick_name', 'email_address'); $member_info = $oMemberModel->getMemberInfoByMemberSrl($memberSrl, 0, $columnList); @@ -1642,12 +1647,12 @@ class memberController extends member $chk_args = new stdClass; $chk_args->member_srl = $member_info->member_srl; $output = executeQuery('member.chkAuthMail', $chk_args); - if($output->toBool() && $output->data->count == '0') return $this->setError('msg_invalid_request'); + if($output->toBool() && $output->data->count == '0') throw new Rhymix\Framework\Exceptions\InvalidRequest; $auth_args = new stdClass; $auth_args->member_srl = $member_info->member_srl; $output = executeQueryArray('member.getAuthMailInfo', $auth_args); - if(!$output->data || !$output->data[0]->auth_key) return $this->setError('msg_invalid_request'); + if(!$output->data || !$output->data[0]->auth_key) throw new Rhymix\Framework\Exceptions\InvalidRequest; $auth_info = $output->data[0]; // Update the regdate of authmail entry @@ -1711,21 +1716,21 @@ class memberController extends member if(!$memberInfo) { - return $this->stop('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } $newEmail = Context::get('email_address'); if(!$newEmail) { - return $this->stop('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } $oMemberModel = getModel('member'); $member_srl = $oMemberModel->getMemberSrlByEmailAddress($newEmail); if($member_srl) { - return $this->setError('msg_exists_email_address'); + throw new Rhymix\Framework\Exception('msg_exists_email_address'); } // remove all key by member_srl @@ -1745,7 +1750,7 @@ class memberController extends member $output = executeQuery('member.updateMemberEmailAddress', $args); if(!$output->toBool()) { - return $this->stop($output->getMessage()); + return $output; } $this->_clearMemberCache($args->member_srl); @@ -1840,7 +1845,7 @@ class memberController extends member { $site_module_info = Context::get('site_module_info'); $logged_info = Context::get('logged_info'); - if(!$site_module_info->site_srl || !Context::get('is_logged') || count($logged_info->group_srl_list) ) return $this->setError('msg_invalid_request'); + if(!$site_module_info->site_srl || !Context::get('is_logged') || count($logged_info->group_srl_list) ) throw new Rhymix\Framework\Exceptions\InvalidRequest; $oMemberModel = getModel('member'); $columnList = array('site_srl', 'group_srl', 'title'); @@ -1859,7 +1864,7 @@ class memberController extends member { $site_module_info = Context::get('site_module_info'); $logged_info = Context::get('logged_info'); - if(!$site_module_info->site_srl || !Context::get('is_logged') || count($logged_info->group_srl_list) ) return $this->setError('msg_invalid_request'); + if(!$site_module_info->site_srl || !Context::get('is_logged') || count($logged_info->group_srl_list) ) throw new Rhymix\Framework\Exceptions\InvalidRequest; $args = new stdClass; $args->site_srl= $site_module_info->site_srl; @@ -2624,7 +2629,7 @@ class memberController extends member unset($args->denied); if($logged_info->member_srl != $args->member_srl && $is_admin == false) { - return $this->stop('msg_invalid_request'); + return new BaseObject(-1, 'msg_invalid_request'); } } @@ -3041,12 +3046,12 @@ class memberController extends member function procMemberModifyEmailAddress() { - if(!Context::get('is_logged')) return $this->setError('msg_not_logged'); + if(!Context::get('is_logged')) throw new Rhymix\Framework\Exceptions\MustLogin; $member_info = Context::get('logged_info'); $newEmail = Context::get('email_address'); - if(!$newEmail) return $this->setError('msg_invalid_request'); + if(!$newEmail) throw new Rhymix\Framework\Exceptions\InvalidRequest; $oMemberModel = getModel('member'); // Check managed Email Host @@ -3062,16 +3067,16 @@ class memberController extends member $hosts[] = $host->email_host; } $message = sprintf($managed_email_host[$emailhost_check],implode(', ',$hosts),'id@'.implode(', id@',$hosts)); - return $this->setError($message); + throw new Rhymix\Framework\Exception($message); } // Check if the e-mail address is already registered $member_srl = $oMemberModel->getMemberSrlByEmailAddress($newEmail); - if($member_srl) return $this->setError('msg_exists_email_address'); + if($member_srl) throw new Rhymix\Framework\Exception('msg_exists_email_address'); if($_SESSION['rechecked_password_step'] != 'INPUT_DATA') { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } unset($_SESSION['rechecked_password_step']); @@ -3129,7 +3134,7 @@ class memberController extends member { $member_srl = Context::get('member_srl'); $auth_key = Context::get('auth_key'); - if(!$member_srl || !$auth_key) return $this->stop('msg_invalid_request'); + if(!$member_srl || !$auth_key) throw new Rhymix\Framework\Exceptions\InvalidRequest; // Test logs for finding password by user_id and authkey $args = new stdClass; @@ -3139,7 +3144,7 @@ class memberController extends member if(!$output->toBool() || $output->data->auth_key != $auth_key) { if(strlen($output->data->auth_key) !== strlen($auth_key)) executeQuery('member.deleteAuthChangeEmailAddress', $args); - return $this->stop('msg_invalid_modify_email_auth_key'); + throw new Rhymix\Framework\Exception('msg_invalid_modify_email_auth_key'); } $newEmail = $output->data->user_id; @@ -3147,7 +3152,7 @@ class memberController extends member list($args->email_id, $args->email_host) = explode('@', $newEmail); $output = executeQuery('member.updateMemberEmailAddress', $args); - if(!$output->toBool()) return $this->stop($output->getMessage()); + if(!$output->toBool()) return $output; // Remove all values having the member_srl and new_password equal to 'XE_change_emaill_address' from authentication table executeQuery('member.deleteAuthChangeEmailAddress',$args); @@ -3227,7 +3232,7 @@ class memberController extends member **/ function procMemberSpammerManage() { - if(!Context::get('is_logged')) return $this->setError('msg_not_permitted'); + if(!Context::get('is_logged')) throw new Rhymix\Framework\Exceptions\NotPermitted; $logged_info = Context::get('logged_info'); $member_srl = Context::get('member_srl'); @@ -3244,7 +3249,7 @@ class memberController extends member $module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl, $columnList); $grant = $oModuleModel->getGrant($module_info, $logged_info); - if(!$grant->manager) return $this->setError('msg_not_permitted'); + if(!$grant->manager) throw new Rhymix\Framework\Exceptions\NotPermitted; $proc_msg = ""; diff --git a/modules/member/member.view.php b/modules/member/member.view.php index 16170a60b..b0010ad7d 100644 --- a/modules/member/member.view.php +++ b/modules/member/member.view.php @@ -63,7 +63,7 @@ class memberView extends member $oMemberModel = getModel('member'); $logged_info = Context::get('logged_info'); // Don't display member info to non-logged user - if(!$logged_info->member_srl) return $this->stop('msg_not_permitted'); + if(!$logged_info->member_srl) throw new Rhymix\Framework\Exceptions\MustLogin; $member_srl = Context::get('member_srl'); if(!$member_srl && Context::get('is_logged')) @@ -198,12 +198,12 @@ class memberView extends member $oMemberModel = getModel('member'); // Get the member information if logged-in - if($oMemberModel->isLogged()) return $this->stop('msg_already_logged'); + if($oMemberModel->isLogged()) throw new Rhymix\Framework\Exception('msg_already_logged'); // call a trigger (before) $trigger_output = ModuleHandler::triggerCall('member.dispMemberSignUpForm', 'before', $member_config); if(!$trigger_output->toBool()) return $trigger_output; // Error appears if the member is not allowed to join - if($member_config->enable_join != 'Y') return $this->stop('msg_signup_disabled'); + if($member_config->enable_join != 'Y') throw new Rhymix\Framework\Exceptions\FeatureDisabled('msg_signup_disabled'); $formTags = getAdminView('member')->_getMemberInputTag(); Context::set('formTags', $formTags); @@ -251,7 +251,7 @@ class memberView extends member $oMemberModel = getModel('member'); if(!$oMemberModel->isLogged() || empty($logged_info)) { - return $this->stop('msg_not_logged'); + throw new Rhymix\Framework\Exceptions\MustLogin; } $_SESSION['rechecked_password_step'] = 'INPUT_PASSWORD'; @@ -294,7 +294,7 @@ class memberView extends member $oMemberModel = getModel('member'); // A message appears if the user is not logged-in - if(!$oMemberModel->isLogged()) return $this->stop('msg_not_logged'); + if(!$oMemberModel->isLogged()) throw new Rhymix\Framework\Exceptions\MustLogin; $logged_info = Context::get('logged_info'); $member_srl = $logged_info->member_srl; @@ -351,13 +351,13 @@ class memberView extends member { if ($this->member_config->features['my_documents'] === false) { - return $this->stop('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\FeatureDisabled; } // A message appears if the user is not logged-in if(!Context::get('is_logged')) { - return $this->setError('msg_not_logged'); + throw new Rhymix\Framework\Exceptions\MustLogin; } $logged_info = Context::get('logged_info'); @@ -385,12 +385,12 @@ class memberView extends member { if ($this->member_config->features['my_comments'] === false) { - return $this->stop('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\FeatureDisabled; } $oMemberModel = getModel('member'); // A message appears if the user is not logged-in - if(!$oMemberModel->isLogged()) return $this->stop('msg_not_logged'); + if(!$oMemberModel->isLogged()) throw new Rhymix\Framework\Exceptions\MustLogin; $logged_info = Context::get('logged_info'); $member_srl = $logged_info->member_srl; @@ -417,12 +417,12 @@ class memberView extends member { if ($this->member_config->features['scrapped_documents'] === false) { - return $this->stop('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\FeatureDisabled; } $oMemberModel = getModel('member'); // A message appears if the user is not logged-in - if(!$oMemberModel->isLogged()) return $this->stop('msg_not_logged'); + if(!$oMemberModel->isLogged()) throw new Rhymix\Framework\Exceptions\MustLogin; $logged_info = Context::get('logged_info'); @@ -447,7 +447,7 @@ class memberView extends member $folder_srl = (int)Context::get('folder_srl'); if($folder_srl && !array_filter($folders, function($folder) use($folder_srl) { return $folder->folder_srl == $folder_srl; })) { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } if(!$folder_srl && count($folders)) { @@ -493,12 +493,12 @@ class memberView extends member { if ($this->member_config->features['saved_documents'] === false) { - return $this->stop('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\FeatureDisabled; } $oMemberModel = getModel('member'); // A message appears if the user is not logged-in - if(!$oMemberModel->isLogged()) return $this->stop('msg_not_logged'); + if(!$oMemberModel->isLogged()) throw new Rhymix\Framework\Exceptions\MustLogin; // Get the saved document(module_srl is set to member_srl instead) $logged_info = Context::get('logged_info'); $args = new stdClass(); @@ -524,13 +524,13 @@ class memberView extends member { if ($this->member_config->features['active_logins'] === false) { - return $this->stop('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\FeatureDisabled; } $logged_info = Context::get('logged_info'); if (!$logged_info->member_srl) { - return $this->stop('msg_not_logged'); + throw new Rhymix\Framework\Exceptions\MustLogin; } $args = new stdClass(); @@ -583,7 +583,7 @@ class memberView extends member { $oMemberModel = getModel('member'); // A message appears if the user is not logged-in - if(!$oMemberModel->isLogged()) return $this->stop('msg_not_logged'); + if(!$oMemberModel->isLogged()) throw new Rhymix\Framework\Exceptions\MustLogin; $memberConfig = $this->member_config; @@ -615,7 +615,7 @@ class memberView extends member { $oMemberModel = getModel('member'); // A message appears if the user is not logged-in - if(!$oMemberModel->isLogged()) return $this->stop('msg_not_logged'); + if(!$oMemberModel->isLogged()) throw new Rhymix\Framework\Exceptions\MustLogin; $memberConfig = $this->member_config; @@ -668,7 +668,10 @@ class memberView extends member */ function dispMemberFindAccount() { - if(Context::get('is_logged')) return $this->stop('already_logged'); + if(Context::get('is_logged')) + { + throw new Rhymix\Framework\Exception('already_logged'); + } $config = $this->member_config; @@ -688,7 +691,7 @@ class memberView extends member if(Context::get('is_logged')) { - return $this->stop('already_logged'); + throw new Rhymix\Framework\Exception('already_logged'); } if($authMemberSrl) @@ -765,7 +768,7 @@ class memberView extends member **/ function dispMemberSpammer() { - if(!Context::get('is_logged')) return $this->setError('msg_not_permitted'); + if(!Context::get('is_logged')) throw new Rhymix\Framework\Exceptions\NotPermitted; $member_srl = Context::get('member_srl'); $module_srl = Context::get('module_srl'); @@ -776,7 +779,7 @@ class memberView extends member $module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl, $columnList); $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; $oMemberModel = getModel('member'); @@ -800,7 +803,7 @@ class memberView extends member { if ($this->member_config->features['nickname_log'] === false || $this->member_config->update_nickname_log != 'Y') { - return $this->stop('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\FeatureDisabled; } $member_srl = Context::get('member_srl'); @@ -813,7 +816,7 @@ class memberView extends member { if($logged_info->is_admin != 'Y') { - return $this->setError('msg_not_permitted'); + throw new Rhymix\Framework\Exceptions\NotPermitted; } } diff --git a/modules/menu/menu.admin.controller.php b/modules/menu/menu.admin.controller.php index dad867187..d7ef3a697 100644 --- a/modules/menu/menu.admin.controller.php +++ b/modules/menu/menu.admin.controller.php @@ -170,7 +170,7 @@ class menuAdminController extends menu { if(!$moduleInfos || !is_array($moduleInfos) || count($moduleInfos) == 0 || $menuSrl == 0) { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } foreach($moduleInfos as $moduleInfo) @@ -252,7 +252,7 @@ class menuAdminController extends menu $oAdmin = getClass('admin'); if($menuInfo->title == $oAdmin->getAdminMenuName()) - return $this->setError('msg_adminmenu_cannot_delete'); + throw new Rhymix\Framework\Exception('msg_adminmenu_cannot_delete'); // get menu properies with child menu $phpFile = sprintf("./files/cache/menu/%s.php", $menu_srl); @@ -283,13 +283,13 @@ class menuAdminController extends menu if($isStartmenuInclude) { - return $this->setError('msg_cannot_delete_homemenu'); + throw new Rhymix\Framework\Exception('msg_cannot_delete_homemenu'); } $output = $this->deleteMenu($menu_srl); if(!$output->toBool()) { - return $this->setError($output->message); + throw new Rhymix\Framework\Exception($output->message); } $this->setMessage('success_deleted', 'info'); @@ -389,13 +389,13 @@ class menuAdminController extends menu if(!$request->parent_srl || !$request->menu_name) { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } $this->_setMenuSrl($request->parent_srl, $request->menu_srl); if(!$request->menu_srl) { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } if($request->is_shortcut == 'Y') @@ -475,7 +475,7 @@ class menuAdminController extends menu $itemInfo = $oMenuAdminModel->getMenuItemInfo($request->shortcut_target); if(!$itemInfo->menu_item_srl) { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } unset($itemInfo->normal_btn, $itemInfo->hover_btn, $itemInfo->active_btn); @@ -540,7 +540,7 @@ class menuAdminController extends menu if($request->module_id && strncasecmp('http', $request->module_id, 4) === 0) { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } // when menu copy, module already copied @@ -549,7 +549,7 @@ class menuAdminController extends menu $result = $this->_insertModule($request, $args); if(!$result->toBool()) { - return $this->setError($result->message); + throw new Rhymix\Framework\Exception($result->message); } } @@ -560,7 +560,7 @@ class menuAdminController extends menu if(!$request->module_id) { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } $args->url = $request->module_id; @@ -625,7 +625,7 @@ class menuAdminController extends menu $output = $oModuleModel->getModuleInfoByMid($request->module_id); if($output->module_srl) { - return $this->setError('msg_module_name_exists'); + throw new Rhymix\Framework\Exception('msg_module_name_exists'); } $oModuleController = getController('module'); @@ -644,7 +644,7 @@ class menuAdminController extends menu if(!$request->menu_item_srl || !$request->menu_name) { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } // variables set @@ -671,7 +671,7 @@ class menuAdminController extends menu $newItemInfo = $oMenuAdminModel->getMenuItemInfo($request->shortcut_target); if(!$newItemInfo->menu_item_srl) { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } $args->url = $newItemInfo->url; @@ -691,7 +691,7 @@ class menuAdminController extends menu $output = $oModuleModel->getModuleInfoByMid($request->module_id); if($output->module_srl) { - return $this->setError('msg_module_name_exists'); + throw new Rhymix\Framework\Exception('msg_module_name_exists'); } } @@ -699,7 +699,7 @@ class menuAdminController extends menu $moduleInfo = $oModuleModel->getModuleInfoByMid($itemInfo->url); if(!$moduleInfo) { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } $moduleInfo->mid = $request->module_id; @@ -867,7 +867,7 @@ class menuAdminController extends menu $oAdmin = getClass('admin'); if($menu_title == $oAdmin->getAdminMenuName() && $itemInfo->parent_srl == 0) { - return $this->stop('msg_cannot_delete_for_admin_topmenu'); + return new BaseObject(-1002, 'msg_cannot_delete_for_admin_topmenu'); } if($itemInfo->parent_srl) $parent_srl = $itemInfo->parent_srl; @@ -892,7 +892,7 @@ class menuAdminController extends menu $this->_checkHomeMenuInOriginMenu($originMenu, $siteInfo->mid, $isStartmenuInclude); if($isStartmenuInclude) { - return $this->setError('msg_cannot_delete_homemenu'); + return new BaseObject(-1003, 'msg_cannot_delete_homemenu'); } $oDB = DB::getInstance(); @@ -990,7 +990,7 @@ class menuAdminController extends menu $output = $this->_deleteMenuItem($oDB, $menuInfo, $node); if(!$output->toBool()) { - return $this->setError($output->message); + throw new Rhymix\Framework\Exception($output->message); } if(is_array($node['list'])) @@ -1013,7 +1013,7 @@ class menuAdminController extends menu $source_srl = Context::get('source_srl'); // Same hierarchy's menu item serial number $target_srl = Context::get('target_srl'); // Self menu item serial number - if(!$mode || !$parent_srl || !$target_srl) return $this->setError('msg_invalid_request'); + if(!$mode || !$parent_srl || !$target_srl) throw new Rhymix\Framework\Exceptions\InvalidRequest; $oMenuAdminModel = getAdminModel('menu'); @@ -1023,7 +1023,7 @@ class menuAdminController extends menu $targetMenuItemInfo = $oMenuAdminModel->getMenuItemInfo($target_srl); if(!$originalItemInfo->menu_item_srl || (!$targetMenuInfo->menu_srl && !$targetMenuItemInfo->menu_item_srl)) { - return $this->setError('msg_empty_menu_item'); + throw new Rhymix\Framework\Exception('msg_empty_menu_item'); } // get menu properies with child menu @@ -1407,7 +1407,7 @@ class menuAdminController extends menu $oMenuAdminModel = getAdminModel('menu'); $target_item = $oMenuAdminModel->getMenuItemInfo($target_srl); - if($target_item->menu_item_srl != $target_srl) return $this->setError('msg_invalid_request'); + if($target_item->menu_item_srl != $target_srl) throw new Rhymix\Framework\Exceptions\InvalidRequest; // Move the menu location(change the order menu appears) if($mode == 'move') { @@ -1418,7 +1418,7 @@ class menuAdminController extends menu if($source_srl) { $source_item = $oMenuAdminModel->getMenuItemInfo($source_srl); - if($source_item->menu_item_srl != $source_srl) return $this->setError('msg_invalid_request'); + if($source_item->menu_item_srl != $source_srl) throw new Rhymix\Framework\Exceptions\InvalidRequest; $args->listorder = $source_item->listorder-1; } else diff --git a/modules/menu/menu.admin.model.php b/modules/menu/menu.admin.model.php index eaeb96206..0de6c60e5 100644 --- a/modules/menu/menu.admin.model.php +++ b/modules/menu/menu.admin.model.php @@ -614,7 +614,7 @@ class menuAdminModel extends menu $menuItemSrl = Context::get('menu_item_srl'); if(!$menuItemSrl) { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } $menuItemInfo = $this->getMenuItemInfo($menuItemSrl); @@ -622,7 +622,7 @@ class menuAdminModel extends menu // if menu is shortcut if($menuItemInfo->is_shortcut == 'Y') { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } // get module info diff --git a/modules/module/module.admin.controller.php b/modules/module/module.admin.controller.php index 6c4cd0cf0..60f7c8052 100644 --- a/modules/module/module.admin.controller.php +++ b/modules/module/module.admin.controller.php @@ -108,7 +108,7 @@ class moduleAdminController extends module { $mid = trim($args->{"mid_".$i}); if(!$mid) continue; - if(!preg_match("/^[a-zA-Z]([a-zA-Z0-9_]*)$/i", $mid)) return $this->setError('msg_limit_mid'); + if(!preg_match("/^[a-zA-Z]([a-zA-Z0-9_]*)$/i", $mid)) throw new Rhymix\Framework\Exception('msg_limit_mid'); $browser_title = $args->{"browser_title_".$i}; if(!$mid) continue; if($mid && !$browser_title) $browser_title = $mid; @@ -282,7 +282,7 @@ class moduleAdminController extends module // Get information of the module $columnList = array('module_srl', 'module'); $module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl, $columnList); - if(!$module_info) return $this->setError('msg_invalid_request'); + if(!$module_info) throw new Rhymix\Framework\Exceptions\InvalidRequest; // Register Admin ID $oModuleController->deleteAdminId($module_srl); $admin_member = Context::get('admin_member'); @@ -509,10 +509,10 @@ class moduleAdminController extends module { $vars = Context::getRequestVars(); - if(!$vars->module_srls) return $this->setError('msg_invalid_request'); + if(!$vars->module_srls) throw new Rhymix\Framework\Exceptions\InvalidRequest; $module_srls = explode(',',$vars->module_srls); - if(count($module_srls) < 1) return $this->setError('msg_invalid_request'); + if(count($module_srls) < 1) throw new Rhymix\Framework\Exceptions\InvalidRequest; $oModuleModel = getModel('module'); $oModuleController= getController('module'); @@ -564,10 +564,10 @@ class moduleAdminController extends module function procModuleAdminModuleGrantSetup() { $module_srls = Context::get('module_srls'); - if(!$module_srls) return $this->setError('msg_invalid_request'); + if(!$module_srls) throw new Rhymix\Framework\Exceptions\InvalidRequest; $modules = explode(',',$module_srls); - if(count($modules) < 1) return $this->setError('msg_invalid_request'); + if(count($modules) < 1) throw new Rhymix\Framework\Exceptions\InvalidRequest; $oModuleController = getController('module'); $oModuleModel = getModel('module'); @@ -676,7 +676,7 @@ class moduleAdminController extends module // if args->name is empty, random generate for user define language if(empty($args->name)) $args->name = 'userLang'.date('YmdHis').''.sprintf('%03d', mt_rand(0, 100)); - if(!$args->name) return $this->setError('msg_invalid_request'); + if(!$args->name) throw new Rhymix\Framework\Exceptions\InvalidRequest; // Check whether a language code exists $output = executeQueryArray('module.getLang', $args); if(!$output->toBool()) return $output; @@ -723,7 +723,7 @@ class moduleAdminController extends module $args->name = str_replace(' ','_',Context::get('name')); $args->lang_name = str_replace(' ','_',Context::get('lang_name')); if(!empty($args->lang_name)) $args->name = $args->lang_name; - if(!$args->name) return $this->setError('msg_invalid_request'); + if(!$args->name) throw new Rhymix\Framework\Exceptions\InvalidRequest; $output = executeQuery('module.deleteLang', $args); if(!$output->toBool()) return $output; @@ -737,7 +737,7 @@ class moduleAdminController extends module function procModuleAdminGetList() { - if(!Context::get('is_logged')) return $this->setError('msg_not_permitted'); + if(!Context::get('is_logged')) throw new Rhymix\Framework\Exceptions\NotPermitted; $oModuleController = getController('module'); $oModuleModel = getModel('module'); @@ -939,7 +939,7 @@ class moduleAdminController extends module { if(!$moduleSrl && !$mid) { - return $this->stop(-1, 'msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } $oModuleModel = getModel('module'); @@ -955,7 +955,7 @@ class moduleAdminController extends module if(!$moduleInfo) { - return $this->stop(-1, 'msg_module_not_exists'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } $skinTargetValue = ($skinType == 'M') ? 'mskin' : 'skin'; @@ -1004,7 +1004,7 @@ class moduleAdminController extends module if(!$menuItemSrl) { - return $this->stop(-1, 'msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\InvalidRequest; } $oModuleModel = getModel('module'); diff --git a/modules/module/module.admin.view.php b/modules/module/module.admin.view.php index 4af61b9a0..9f7bc3dbb 100644 --- a/modules/module/module.admin.view.php +++ b/modules/module/module.admin.view.php @@ -165,7 +165,7 @@ class moduleAdminView extends module $module_srls = Context::get('module_srls'); $modules = explode(',',$module_srls); - if(!count($modules)) if(!$module_srls) return $this->setError('msg_invalid_request'); + if(!count($modules)) if(!$module_srls) throw new Rhymix\Framework\Exceptions\InvalidRequest; $oModuleModel = getModel('module'); $columnList = array('module_srl', 'module'); @@ -201,7 +201,7 @@ class moduleAdminView extends module $module_srls = Context::get('module_srls'); $modules = explode(',',$module_srls); - if(!count($modules)) if(!$module_srls) return $this->setError('msg_invalid_request'); + if(!count($modules)) if(!$module_srls) throw new Rhymix\Framework\Exceptions\InvalidRequest; // pre-define variables because you can get contents from other module (call by reference) $content = ''; // Call a trigger for additional settings @@ -224,7 +224,7 @@ class moduleAdminView extends module $module_srls = Context::get('module_srls'); $modules = explode(',',$module_srls); - if(!count($modules)) if(!$module_srls) return $this->setError('msg_invalid_request'); + if(!count($modules)) if(!$module_srls) throw new Rhymix\Framework\Exceptions\InvalidRequest; $oModuleModel = getModel('module'); $columnList = array('module_srl', 'module', 'site_srl'); diff --git a/modules/module/module.controller.php b/modules/module/module.controller.php index f899ff223..6f24c72dd 100644 --- a/modules/module/module.controller.php +++ b/modules/module/module.controller.php @@ -1078,7 +1078,10 @@ class moduleController extends module if ($ajax) Context::setRequestMethod('JSON'); $logged_info = Context::get('logged_info'); - if($logged_info->is_admin !='Y' && !$logged_info->is_site_admin) return $this->setError('msg_not_permitted'); + if($logged_info->is_admin !='Y' && !$logged_info->is_site_admin) + { + throw new Rhymix\Framework\Exceptions\NotPermitted; + } $vars = Context::gets('addfile','filter'); $attributeNames = Context::get('attribute_name'); @@ -1107,7 +1110,7 @@ class moduleController extends module $filter = array_map('trim', explode(',',$vars->filter)); if (!in_array($ext, $filter)) { - return $this->setError('msg_error_occured'); + throw new Rhymix\Framework\Exception('msg_error_occured'); } } @@ -1122,10 +1125,10 @@ class moduleController extends module // insert else { - if(!Context::isUploaded()) return $this->setError('msg_error_occured'); + if(!Context::isUploaded()) throw new Rhymix\Framework\Exception('msg_error_occured'); $addfile = Context::get('addfile'); - if(!is_uploaded_file($addfile['tmp_name'])) return $this->setError('msg_error_occured'); - if($vars->addfile['error'] != 0) return $this->setError('msg_error_occured'); + if(!is_uploaded_file($addfile['tmp_name'])) throw new Rhymix\Framework\Exception('msg_error_occured'); + if($vars->addfile['error'] != 0) throw new Rhymix\Framework\Exception('msg_error_occured'); $output = $this->insertModuleFileBox($vars); } @@ -1224,10 +1227,17 @@ class moduleController extends module function procModuleFileBoxDelete() { $logged_info = Context::get('logged_info'); - if($logged_info->is_admin !='Y' && !$logged_info->is_site_admin) return $this->setError('msg_not_permitted'); + if($logged_info->is_admin !='Y' && !$logged_info->is_site_admin) + { + throw new Rhymix\Framework\Exceptions\NotPermitted; + } $module_filebox_srl = Context::get('module_filebox_srl'); - if(!$module_filebox_srl) return $this->setError('msg_invalid_request'); + if(!$module_filebox_srl) + { + throw new Rhymix\Framework\Exceptions\InvalidRequest; + } + $vars = new stdClass(); $vars->module_filebox_srl = $module_filebox_srl; $output = $this->deleteModuleFileBox($vars); diff --git a/modules/module/module.model.php b/modules/module/module.model.php index 38dd1ff90..f6ca24970 100644 --- a/modules/module/module.model.php +++ b/modules/module/module.model.php @@ -267,8 +267,7 @@ class moduleModel extends module if(!$menuItemSrl) { - $this->stop(-1, 'msg_invalid_request'); - return; + return new BaseObject(-1, 'msg_invalid_request'); } $args = new stdClass(); diff --git a/modules/module/module.view.php b/modules/module/module.view.php index 686846be5..3247a6b8e 100644 --- a/modules/module/module.view.php +++ b/modules/module/module.view.php @@ -25,10 +25,10 @@ class moduleView extends module $skin = Context::get('skin'); // Get modules/skin information $module_path = sprintf("./modules/%s/", $selected_module); - if(!is_dir($module_path)) $this->stop("msg_invalid_request"); + if(!is_dir($module_path)) throw new Rhymix\Framework\Exceptions\InvalidRequest; $skin_info_xml = sprintf("%sskins/%s/skin.xml", $module_path, $skin); - if(!file_exists($skin_info_xml)) $this->stop("msg_invalid_request"); + if(!file_exists($skin_info_xml)) throw new Rhymix\Framework\Exceptions\InvalidRequest; $oModuleModel = getModel('module'); $skin_info = $oModuleModel->loadSkinInfo($module_path, $skin); @@ -123,15 +123,16 @@ class moduleView extends module function dispModuleFileBox() { $logged_info = Context::get('logged_info'); - if($logged_info->is_admin !='Y' && !$logged_info->is_site_admin) return $this->setError('msg_not_permitted'); - - $input_name = Context::get('input'); - if(!preg_match('/^[a-z0-9_]+$/i', $input_name)) + if($logged_info->is_admin !='Y' && !$logged_info->is_site_admin) { - return $this->setError('msg_invalid_request'); + throw new Rhymix\Framework\Exceptions\NotPermitted; } - if(!$input_name) return $this->setError('msg_not_permitted'); + $input_name = Context::get('input'); + if(!$input_name || !preg_match('/^[a-z0-9_]+$/i', $input_name)) + { + throw new Rhymix\Framework\Exceptions\InvalidRequest; + } $addscript = sprintf('