diff --git a/application/core/APIv1_Controller.php b/application/core/APIv1_Controller.php index 50b5e1f52..fe2bbe212 100644 --- a/application/core/APIv1_Controller.php +++ b/application/core/APIv1_Controller.php @@ -7,10 +7,30 @@ class APIv1_Controller extends REST_Controller function __construct() { parent::__construct(); - //$this->load->library('session'); // -> autoload - //$this->load->library('database'); -> autoload + $this->load->helper('Message'); } + /** --------------------------------------------------------------- + * Success + * + * @param mixed $retval + * @return array + */ + protected function _success($retval, $message = null) + { + return success($retval, $message); + } + + /** --------------------------------------------------------------- + * General Error + * + * @return array + */ + protected function _error($retval, $message = null) + { + return error($retval, $message); + } + /** * * @param type $data diff --git a/application/core/FHC_Model.php b/application/core/FHC_Model.php index 14b50a109..485678c94 100644 --- a/application/core/FHC_Model.php +++ b/application/core/FHC_Model.php @@ -10,6 +10,7 @@ class FHC_Model extends CI_Model $this->load->helper('language'); $this->lang->load('fhc_model'); $this->lang->load('fhcomplete'); + $this->load->helper('Message'); $uid = null; @@ -46,14 +47,9 @@ class FHC_Model extends CI_Model * @param mixed $retval * @return array */ - protected function _success($retval, $message = FHC_SUCCESS) + protected function _success($retval, $message = null) { - $return = new stdClass(); - $return->error = EXIT_SUCCESS; - $return->fhcCode = $message; - $return->msg = lang('fhc_' . $message); - $return->retval = $retval; - return $return; + return success($retval, $message); } /** --------------------------------------------------------------- @@ -61,13 +57,8 @@ class FHC_Model extends CI_Model * * @return array */ - protected function _error($retval = '', $message = FHC_MODEL_ERROR) + protected function _error($retval, $message = null) { - $return = new stdClass(); - $return->error = EXIT_MODEL; - $return->fhcCode = $message; - $return->msg = lang('fhc_' . $message); - $return->retval = $retval; - return $return; + return error($retval, $message); } -} +} \ No newline at end of file diff --git a/application/helpers/message_helper.php b/application/helpers/message_helper.php new file mode 100644 index 000000000..0a70a1015 --- /dev/null +++ b/application/helpers/message_helper.php @@ -0,0 +1,31 @@ +error = EXIT_SUCCESS; + $return->fhcCode = $message; + $return->msg = lang('fhc_' . $message); + $return->retval = $retval; + return $return; +} + +/** --------------------------------------------------------------- + * General Error + * + * @return array + */ +function error($retval = '', $message = FHC_MODEL_ERROR) +{ + $return = new stdClass(); + $return->error = EXIT_MODEL; + $return->fhcCode = $message; + $return->msg = lang('fhc_' . $message); + $return->retval = $retval; + return $return; +} \ No newline at end of file