[Mapbender-commits] r6746 - branches/banjo_dev/mapbender/http/rest

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Tue Aug 10 12:32:12 EDT 2010


Author: banjo
Date: 2010-08-10 16:32:12 +0000 (Tue, 10 Aug 2010)
New Revision: 6746

Added:
   branches/banjo_dev/mapbender/http/rest/user.php
Log:
Adding user.php file - this file handles the resource "user"


Added: branches/banjo_dev/mapbender/http/rest/user.php
===================================================================
--- branches/banjo_dev/mapbender/http/rest/user.php	                        (rev 0)
+++ branches/banjo_dev/mapbender/http/rest/user.php	2010-08-10 16:32:12 UTC (rev 6746)
@@ -0,0 +1,51 @@
+<?php
+require_once("db_connect.php");
+require_once("http_auth.php");
+require_once("rest_response.php");
+
+$request_method = strtolower($_SERVER['REQUEST_METHOD']);
+$request_parameter_string = $_SERVER['PATH_INFO'];
+$request_parameters = explode("/", $request_parameter_string);
+
+switch($request_method)
+{
+  case 'get':
+    $userID = $request_parameters[1];
+    $responseFormat = strtolower($request_parameters[2]);
+    if((strcmp($responseFormat, "xml") != 0) && (strcmp($responseFormat, "json") != 0))
+    {
+      die(send_rest_response(400));
+    }
+    send_get_response($userID, $responseFormat);
+    break;
+  case 'post':
+    break;
+  case 'put':
+    break;
+}
+
+function send_get_response($userID, $responseFormat)
+{
+  $sql = "SELECT * FROM mb_user where mb_user_id=$userID";
+  $res = db_query($sql);
+
+  //If there is no such userID
+  if(!($row = db_fetch_array($res)))
+  {
+    die(send_rest_response(404));
+  }
+
+  //Prepare the response body according to responseFormat
+  if(strcmp($responseFormat, "xml") == 0)
+  {
+    //send xml response
+  }
+  else
+  {
+    //send json response
+  }
+}
+
+
+
+



More information about the Mapbender_commits mailing list