1
0
mirror of https://github.com/owncloud/bookmarks.git synced 2024-12-01 05:24:11 +01:00

Use OC_JSON for json responses

Create OC_JSON class, for single point of creating json responses.
No real logic change, this just cleans up the code a bit.
This commit is contained in:
Bart Visscher 2011-09-23 22:22:59 +02:00
parent a36d38f2e4
commit ceb4b25166
6 changed files with 10 additions and 44 deletions

View File

@ -26,14 +26,8 @@ $RUNTIME_NOSETUPFS=true;
require_once('../../../lib/base.php');
// We send json data
header( "Content-Type: application/jsonrequest" );
// Check if we are a user
if( !OC_User::isLoggedIn()){
echo json_encode( array( "status" => "error", "data" => array( "message" => "Authentication error" )));
exit();
}
OC_JSON::checkLoggedIn();
$CONFIG_DBTYPE = OC_Config::getValue( "dbtype", "sqlite" );
if( $CONFIG_DBTYPE == 'sqlite' or $CONFIG_DBTYPE == 'sqlite3' ){
@ -76,6 +70,6 @@ if($b_id !== false) {
$query->execute($params);
}
echo json_encode( array( 'status' => 'success', 'data' => $b_id));
OC_JSON::success(array('data' => $b_id));
}

View File

@ -26,14 +26,8 @@ $RUNTIME_NOSETUPFS=true;
require_once('../../../lib/base.php');
// We send json data
header( "Content-Type: application/jsonrequest" );
// Check if we are a user
if( !OC_User::isLoggedIn()){
echo json_encode( array( "status" => "error", "data" => array( "message" => "Authentication error" )));
exit();
}
OC_JSON::checkLoggedIn();
$params=array(
htmlspecialchars_decode($_GET["url"]),
@ -64,4 +58,4 @@ $query = OC_DB::prepare("
$result = $query->execute();
// var_dump($params);
echo json_encode( array( "status" => "success", "data" => array()));
OC_JSON::success(array('data' => array()));

View File

@ -26,14 +26,8 @@ $RUNTIME_NOSETUPFS=true;
require_once('../../../lib/base.php');
// We send json data
header( 'Content-Type: application/jsonrequest' );
// Check if we are a user
if( !OC_User::isLoggedIn()){
echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => 'Authentication error' )));
exit();
}
OC_JSON::checkLoggedIn();
$CONFIG_DBTYPE = OC_Config::getValue( "dbtype", "sqlite" );
if( $CONFIG_DBTYPE == 'sqlite' or $CONFIG_DBTYPE == 'sqlite3' ){

View File

@ -26,14 +26,8 @@ $RUNTIME_NOSETUPFS=true;
require_once('../../../lib/base.php');
// We send json data
header( 'Content-Type: application/jsonrequest' );
// Check if we are a user
if( !OC_User::isLoggedIn()){
echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => 'Authentication error' )));
exit();
}
OC_JSON::checkLoggedIn();
// $metadata = array();
@ -41,4 +35,4 @@ require '../bookmarksHelper.php';
$metadata = getURLMetadata(htmlspecialchars_decode($_GET["url"]));
echo json_encode( array( 'status' => 'success', 'data' => $metadata));
OC_JSON::success(array('data' => $metadata));

View File

@ -27,11 +27,7 @@ $RUNTIME_NOSETUPFS=true;
require_once('../../../lib/base.php');
// Check if we are a user
if( !OC_User::isLoggedIn()){
header( "Content-Type: application/jsonrequest" );
echo json_encode( array( "status" => "error", "data" => array( "message" => "Authentication error" )));
exit();
}
OC_JSON::checkLoggedIn();
$query = OC_DB::prepare("
UPDATE *PREFIX*bookmarks

View File

@ -26,14 +26,8 @@ $RUNTIME_NOSETUPFS=true;
require_once('../../../lib/base.php');
// We send json data
header( 'Content-Type: application/jsonrequest' );
// Check if we are a user
if( !OC_User::isLoggedIn()){
echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => 'Authentication error' )));
exit();
}
OC_JSON::checkLoggedIn();
$params=array(OC_User::getUser());
$CONFIG_DBTYPE = OC_Config::getValue( 'dbtype', 'sqlite' );
@ -85,4 +79,4 @@ $query = OC_DB::prepare('
$bookmarks = $query->execute($params)->fetchAll();
echo json_encode( array( 'status' => 'success', 'data' => $bookmarks));
OC_JSON::success(array('data' => $bookmarks));