Remove unnecessary use of BaseObject

- 트리거 등 반환값이 필요하지 않은 곳에서 new BaseObject()를 반환하는 것 삭제
- 모듈 설치, 업데이트 후 무의미한 new BaseObject()를 반환하는 것 삭제
- 사용자에게 에러 메시지를 돌려주는 용도로 new BaseObject(-1, '에러메시지')를
  사용하는 경우는 대부분 $this->setError()로 변경함. 언어 변환과 sprintf()
  처리까지 한 번에 이루어지므로 이쪽이 더 편리함.
This commit is contained in:
Kijin Sung 2017-12-01 00:54:51 +09:00
parent 03d74a984f
commit 84e5542d77
103 changed files with 692 additions and 862 deletions

View file

@ -20,7 +20,7 @@ class installAdminController extends install
function procInstallAdminInstall()
{
$module_name = Context::get('module_name');
if(!$module_name) return new BaseObject(-1, 'invalid_request');
if(!$module_name) return $this->setError('invalid_request');
$oInstallController = getController('install');
$oInstallController->installModule($module_name, './modules/'.$module_name);
@ -35,13 +35,16 @@ class installAdminController extends install
{
@set_time_limit(0);
$module_name = Context::get('module_name');
if(!$module_name) return new BaseObject(-1, 'invalid_request');
if(!$module_name) return $this->setError('invalid_request');
$oModule = getModule($module_name, 'class');
if($oModule) $output = $oModule->moduleUpdate();
else $output = new BaseObject(-1, 'invalid_request');
return $output;
if(!$oModule) return $this->setError('invalid_request');
$output = $oModule->moduleUpdate();
if($output instanceof BaseObject && !$output->toBool())
{
return $output;
}
}
function procInstallAdminRemoveFTPInfo()

View file

@ -12,7 +12,7 @@ class install extends ModuleObject
*/
function moduleInstall()
{
return new BaseObject();
}
/**
@ -28,7 +28,7 @@ class install extends ModuleObject
*/
function moduleUpdate()
{
return new BaseObject();
}
/**

View file

@ -76,7 +76,7 @@ class installController extends install
{
if ($oDB->isTableExists($table_name))
{
return new BaseObject(-1, 'msg_table_already_exists');
return $this->setError('msg_table_already_exists');
}
}
@ -99,7 +99,7 @@ class installController extends install
// Check if it is already installed
if (Context::isInstalled())
{
return new BaseObject(-1, 'msg_already_installed');
return $this->setError('msg_already_installed');
}
// Get install parameters.
@ -227,7 +227,7 @@ class installController extends install
catch(Exception $e)
{
$oDB->rollback();
return new BaseObject(-1, $e->getMessage());
return $this->setError($e->getMessage());
}
// Execute the install script.
@ -411,7 +411,7 @@ class installController extends install
else
{
FileHandler::removeFile($this->flagLicenseAgreement);
return new BaseObject(-1, 'msg_must_accept_license_agreement');
return $this->setError('msg_must_accept_license_agreement');
}
if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON')))

View file

@ -15,13 +15,13 @@ class installModel extends install
$connection = ssh2_connect($ftp_info->ftp_host, $ftp_info->ftp_port);
if(!ssh2_auth_password($connection, $ftp_info->ftp_user, $ftp_info->ftp_password))
{
return new BaseObject(-1,'msg_ftp_invalid_auth_info');
return $this->setError('msg_ftp_invalid_auth_info');
}
$sftp = ssh2_sftp($connection);
$curpwd = "ssh2.sftp://$sftp".$this->pwd;
$dh = @opendir($curpwd);
if(!$dh) return new BaseObject(-1, 'msg_ftp_invalid_path');
if(!$dh) return $this->setError('msg_ftp_invalid_path');
$list = array();
while(($file = readdir($dh)) !== false)
@ -37,7 +37,7 @@ class installModel extends install
{
if(!($ftp_info = Context::getRequestVars()) || !$ftp_info->ftp_user || !$ftp_info->ftp_password)
{
return new BaseObject(-1, 'msg_ftp_invalid_auth_info');
return $this->setError('msg_ftp_invalid_auth_info');
}
$this->pwd = $ftp_info->ftp_root_path;
if(!$ftp_info->ftp_host)
@ -54,11 +54,11 @@ class installModel extends install
if(function_exists('ftp_connect'))
{
$connection = ftp_connect($ftp_info->ftp_host, $ftp_info->ftp_port);
if(!$connection) return new BaseObject(-1, sprintf(lang('msg_ftp_not_connected'), 'host'));
if(!$connection) return $this->setError(sprintf(lang('msg_ftp_not_connected'), 'host'));
if(! @ftp_login($connection, $ftp_info->ftp_user, $ftp_info->ftp_password))
{
ftp_close($connection);
return new BaseObject(-1,'msg_ftp_invalid_auth_info');
return $this->setError('msg_ftp_invalid_auth_info');
}
if($ftp_info->ftp_pasv != "N")
@ -82,7 +82,7 @@ class installModel extends install
else
{
$oFtp->ftp_quit();
return new BaseObject(-1,'msg_ftp_invalid_auth_info');
return $this->setError('msg_ftp_invalid_auth_info');
}
}
}

View file

@ -58,7 +58,6 @@ class installView extends install
else
{
$this->setRedirectUrl(RX_BASEURL);
return new BaseObject();
}
}
}