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

@ -657,18 +657,18 @@ class boardView extends board
$document_srl = Context::get('document_srl');
if(!$document_srl)
{
return new BaseObject(-1, "msg_invalid_request");
return $this->setError("msg_invalid_request");
}
if($this->grant->view == false || ($this->module_info->consultation == 'Y' && !$this->grant->manager && !$this->grant->consultation_read))
{
return new BaseObject(-1, "msg_not_permitted");
return $this->setError("msg_not_permitted");
}
$oDocument = getModel('document')->getDocument($document_srl);
if(!$oDocument->isExists())
{
return new BaseObject(-1, "msg_invalid_request");
return $this->setError("msg_invalid_request");
}
Context::set('oDocument', $oDocument);
@ -765,20 +765,20 @@ class boardView extends board
{
$format = lang('msg_protect_regdate_document');
$massage = sprintf($format, $this->module_info->protect_document_regdate);
return new BaseObject(-1, $massage);
return $this->setError($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 new BaseObject(-1, 'msg_protect_update_content');
return $this->setError('msg_protect_update_content');
}
}
}
if($member_info->is_admin == 'Y' && $logged_info->is_admin != 'Y')
{
return new BaseObject(-1, 'msg_admin_document_no_modify');
return $this->setError('msg_admin_document_no_modify');
}
// if the document is not granted, then back to the password input form
@ -892,7 +892,7 @@ class boardView extends board
{
$format = lang('msg_protect_regdate_document');
$massage = sprintf($format, $this->module_info->protect_document_regdate);
return new BaseObject(-1, $massage);
return $this->setError($massage);
}
}
@ -900,7 +900,7 @@ class boardView extends board
{
if($oDocument->get('comment_count')>0 && $this->grant->manager == false)
{
return new BaseObject(-1,'msg_protect_delete_content');
return $this->setError('msg_protect_delete_content');
}
}
@ -977,7 +977,7 @@ class boardView extends board
// if the parent comment is not existed
if(!$parent_srl)
{
return new BaseObject(-1, 'msg_invalid_request');
return $this->setError('msg_invalid_request');
}
// get the comment
@ -1039,7 +1039,7 @@ class boardView extends board
// if the comment is not existed
if(!$comment_srl)
{
return new BaseObject(-1, 'msg_invalid_request');
return $this->setError('msg_invalid_request');
}
// get comment information
@ -1054,7 +1054,7 @@ class boardView extends board
{
$format = lang('msg_protect_regdate_comment');
$massage = sprintf($format, $this->module_info->protect_document_regdate);
return new BaseObject(-1, $massage);
return $this->setError($massage);
}
}
if($this->module_info->protect_update_comment === 'Y' && $this->grant->manager == false)
@ -1062,13 +1062,13 @@ class boardView extends board
$childs = $oCommentModel->getChildComments($comment_srl);
if(count($childs) > 0)
{
return new BaseObject(-1, 'msg_board_update_protect_comment');
return $this->setError('msg_board_update_protect_comment');
}
}
if($member_info->is_admin == 'Y' && $logged_info->is_admin != 'Y')
{
return new BaseObject(-1, 'msg_admin_comment_no_modify');
return $this->setError('msg_admin_comment_no_modify');
}
// if the comment is not exited, alert an error message
@ -1122,7 +1122,7 @@ class boardView extends board
{
$format = lang('msg_protect_regdate_comment');
$massage = sprintf($format, $this->module_info->protect_document_regdate);
return new BaseObject(-1, $massage);
return $this->setError($massage);
}
}
@ -1132,7 +1132,7 @@ class boardView extends board
$childs = $oCommentModel->getChildComments($comment_srl);
if(count($childs) > 0)
{
return new BaseObject(-1, 'msg_board_delete_protect_comment');
return $this->setError('msg_board_delete_protect_comment');
}
}
@ -1212,7 +1212,7 @@ class boardView extends board
if($this->grant->update_view !== true)
{
return new BaseObject(-1, 'msg_not_permitted');
return $this->setError('msg_not_permitted');
}
$updatelog = $oDocumentModel->getDocumentUpdateLog($document_srl);
@ -1232,7 +1232,7 @@ class boardView extends board
if($this->grant->update_view !== true)
{
return new BaseObject(-1, 'msg_not_permitted');
return $this->setError('msg_not_permitted');
}
$update_log = $oDocumentModel->getUpdateLog($update_id);
@ -1268,7 +1268,7 @@ class boardView extends board
{
iF($this->grant->vote_log_view !== true)
{
return new BaseObject(-1, 'msg_not_permitted');
return $this->setError('msg_not_permitted');
}
$oMemberModel = getModel('member');
@ -1289,7 +1289,7 @@ class boardView extends board
}
else
{
return new BaseObject(-1, 'msg_not_target');
return $this->setError('msg_not_target');
}
$output = executeQueryArray($queryId, $args);