From 84ce2c6ce0eb1b4f2f32c4ae0d7e08f3571f5018 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Wed, 14 Aug 2013 17:06:07 +0200 Subject: Provide json output for api functions Signed-off-by: Florian Pritz --- application/helpers/filebin_helper.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'application/helpers') diff --git a/application/helpers/filebin_helper.php b/application/helpers/filebin_helper.php index 57f7bdc65..9b124506f 100644 --- a/application/helpers/filebin_helper.php +++ b/application/helpers/filebin_helper.php @@ -330,11 +330,26 @@ function user_logged_in() return $CI->muser->logged_in(); } -function send_json_reply($array) +function send_json_reply($array, $status = "success") { + $reply = array(); + $reply["status"] = $status; + $reply["data"] = $array; + $CI =& get_instance(); $CI->output->set_content_type('application/json'); - $CI->output->set_output(json_encode($array)); + $CI->output->set_output(json_encode($reply)); +} + +function request_type($set_type = null) +{ + static $type = null; + + if ($set_type !== null) { + $type = $set_type; + } + + return $type; } # vim: set noet: -- cgit v1.2.3-24-g4f1b