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

@ -102,7 +102,7 @@ class pollController extends poll
}
}
if(!count($args->poll)) return new BaseObject(-1, 'cmd_null_item');
if(!count($args->poll)) return $this->setError('cmd_null_item');
$args->stop_date = $stop_date;
@ -178,12 +178,12 @@ class pollController extends poll
$poll_index_srl = (int) Context::get('index_srl');
$poll_item_title = Context::get('title');
if($poll_item_title=='') return new BaseObject(-1,"msg_item_title_cannot_empty");
if($poll_item_title=='') return $this->setError("msg_item_title_cannot_empty");
$logged_info = Context::get('logged_info');
if(!$logged_info) return new BaseObject(-1,"msg_cannot_add_item");
if(!$logged_info) return $this->setError("msg_cannot_add_item");
if(!$poll_srl || !$poll_index_srl) return new BaseObject(-1,"msg_invalid_request");
if(!$poll_srl || !$poll_index_srl) return $this->setError("msg_invalid_request");
$args = new stdClass();
$args->poll_srl = $poll_srl;
@ -191,10 +191,10 @@ class pollController extends poll
// Get the information related to the survey
$columnList = array('poll_type');
$output = executeQuery('poll.getPoll', $args, $columnList);
if(!$output->data) return new BaseObject(-1,"poll_no_poll_or_deleted_poll");
if(!$output->data) return $this->setError("poll_no_poll_or_deleted_poll");
$type = $output->data->poll_type;
if(!$this->isAbletoAddItem($type)) return new BaseObject(-1,"msg_cannot_add_item");
if(!$this->isAbletoAddItem($type)) return $this->setError("msg_cannot_add_item");
if($logged_info->is_admin != 'Y')
{
@ -227,9 +227,9 @@ class pollController extends poll
$poll_item_srl = Context::get('item_srl');
$logged_info = Context::get('logged_info');
if(!$logged_info) return new BaseObject(-1,"msg_cannot_delete_item");
if(!$logged_info) return $this->setError("msg_cannot_delete_item");
if(!$poll_srl || !$poll_index_srl || !$poll_item_srl) return new BaseObject(-1,"msg_invalid_request");
if(!$poll_srl || !$poll_index_srl || !$poll_item_srl) return $this->setError("msg_invalid_request");
$args = new stdClass();
$args->poll_srl = $poll_srl;
@ -245,11 +245,11 @@ class pollController extends poll
// Get the information related to the survey
$columnList = array('member_srl');
$output = executeQuery('poll.getPoll', $args, $columnList);
if(!$output->data) return new BaseObject(-1,"poll_no_poll_or_deleted_poll");
if(!$output->data) return $this->setError("poll_no_poll_or_deleted_poll");
$poll_member_srl = $output->data->member_srl;
if($add_user_srl!=$logged_info->member_srl && $poll_member_srl!=$logged_info->member_srl) return new BaseObject(-1,"msg_cannot_delete_item");
if($poll_count>0) return new BaseObject(-1,"msg_cannot_delete_item_poll_exist");
if($add_user_srl!=$logged_info->member_srl && $poll_member_srl!=$logged_info->member_srl) return $this->setError("msg_cannot_delete_item");
if($poll_count>0) return $this->setError("msg_cannot_delete_item_poll_exist");
$oDB = &DB::getInstance();
$oDB->begin();
@ -280,9 +280,9 @@ class pollController extends poll
// Get the information related to the survey
$columnList = array('poll_count', 'stop_date','poll_type');
$output = executeQuery('poll.getPoll', $args, $columnList);
if(!$output->data) return new BaseObject(-1,"poll_no_poll_or_deleted_poll");
if(!$output->data) return $this->setError("poll_no_poll_or_deleted_poll");
if($output->data->stop_date < date("Ymd")) return new BaseObject(-1,"msg_cannot_vote");
if($output->data->stop_date < date("Ymd")) return $this->setError("msg_cannot_vote");
$columnList = array('checkcount');
$output = executeQuery('poll.getPollTitle', $args, $columnList);
@ -290,7 +290,7 @@ class pollController extends poll
$poll_srl_indexes = Context::get('poll_srl_indexes');
$tmp_item_srls = explode(',',$poll_srl_indexes);
//if(count($tmp_item_srls)-1>(int)$output->data->checkcount) return new BaseObject(-1,"msg_exceed_max_select");
//if(count($tmp_item_srls)-1>(int)$output->data->checkcount) return $this->setError("msg_exceed_max_select");
for($i=0;$i<count($tmp_item_srls);$i++)
{
$srl = (int)trim($tmp_item_srls[$i]);
@ -299,10 +299,10 @@ class pollController extends poll
}
// If there is no response item, display an error
if(!count($item_srls)) return new BaseObject(-1, 'msg_check_poll_item');
if(!count($item_srls)) return $this->setError('msg_check_poll_item');
// Make sure is the poll has already been taken
$oPollModel = getModel('poll');
if($oPollModel->isPolled($poll_srl)) return new BaseObject(-1, 'msg_already_poll');
if($oPollModel->isPolled($poll_srl)) return $this->setError('msg_already_poll');
$oDB = &DB::getInstance();
$oDB->begin();
@ -382,7 +382,7 @@ class pollController extends poll
*/
function procPollGetList()
{
if(!Context::get('is_logged')) return new BaseObject(-1,'msg_not_permitted');
if(!Context::get('is_logged')) return $this->setError('msg_not_permitted');
$pollSrls = Context::get('poll_srls');
if($pollSrls) $pollSrlList = explode(',', $pollSrls);
@ -419,7 +419,6 @@ class pollController extends poll
function triggerInsertDocumentPoll(&$obj)
{
$this->syncPoll($obj->document_srl, $obj->content);
return new BaseObject();
}
/**
@ -428,7 +427,6 @@ class pollController extends poll
function triggerInsertCommentPoll(&$obj)
{
$this->syncPoll($obj->comment_srl, $obj->content);
return new BaseObject();
}
/**
@ -437,7 +435,6 @@ class pollController extends poll
function triggerUpdateDocumentPoll(&$obj)
{
$this->syncPoll($obj->document_srl, $obj->content);
return new BaseObject();
}
/**
@ -446,7 +443,6 @@ class pollController extends poll
function triggerUpdateCommentPoll(&$obj)
{
$this->syncPoll($obj->comment_srl, $obj->content);
return new BaseObject();
}
/**
@ -455,15 +451,15 @@ class pollController extends poll
function triggerDeleteDocumentPoll(&$obj)
{
$document_srl = $obj->document_srl;
if(!$document_srl) return new BaseObject();
if(!$document_srl) return;
// Get the poll
$args = new stdClass();
$args->upload_target_srl = $document_srl;
$output = executeQuery('poll.getPollByTargetSrl', $args);
if(!$output->data) return new BaseObject();
if(!$output->data) return;
$poll_srl = $output->data->poll_srl;
if(!$poll_srl) return new BaseObject();
if(!$poll_srl) return;
$args->poll_srl = $poll_srl;
@ -478,8 +474,6 @@ class pollController extends poll
$output = executeQuery('poll.deletePollLog', $args);
if(!$output->toBool()) return $output;
return new BaseObject();
}
/**
@ -488,15 +482,15 @@ class pollController extends poll
function triggerDeleteCommentPoll(&$obj)
{
$comment_srl = $obj->comment_srl;
if(!$comment_srl) return new BaseObject();
if(!$comment_srl) return;
// Get the poll
$args = new stdClass();
$args->upload_target_srl = $comment_srl;
$output = executeQuery('poll.getPollByTargetSrl', $args);
if(!$output->data) return new BaseObject();
if(!$output->data) return;
$poll_srl = $output->data->poll_srl;
if(!$poll_srl) return new BaseObject();
if(!$poll_srl) return;
$args->poll_srl = $poll_srl;
@ -511,8 +505,6 @@ class pollController extends poll
$output = executeQuery('poll.deletePollLog', $args);
if(!$output->toBool()) return $output;
return new BaseObject();
}
/**