server/php/basic/resources/library/renkanFunctions.php
changeset 540 5eaf3bd2cd90
parent 444 19f0b7803aed
--- a/server/php/basic/resources/library/renkanFunctions.php	Sat Sep 19 13:43:17 2015 +0200
+++ b/server/php/basic/resources/library/renkanFunctions.php	Tue Sep 22 00:03:37 2015 +0200
@@ -1,60 +1,62 @@
 <?php
 
-    require_once("utilsFunctions.php");
-    require_once("dbFunctions.php");
+require_once("constants.php");
+require_once("utilsFunctions.php");
+require_once("dbFunctions.php");
 
-    function getRenkan($renkanId) {
+function getRenkan($renkanId) {
+
+    $resRenkan = selectProject($renkanId);
 
-        $resRenkan = selectProject($renkanId);
+    header('Content-Type: application/json');
+    echo($resRenkan[0]['renkan']);
+    die();
+
+}
 
-        header('Content-Type: application/json');
-        echo($resRenkan[0]['renkan']);
-        die();
+function saveRenkan($renkanId, $renkanStr) {
 
+    $renkanJson = json_decode($renkanStr, true);
+    if(array_key_exists("title", $renkanJson)) {
+        $title = $renkanJson["title"];
+    }
+    else {
+        $title = "";
     }
 
-    function saveRenkan($renkanId, $renkanStr) {
-
-        $renkanJson = json_decode($renkanStr, true);
-        if(array_key_exists("title", $renkanJson)) {
-            $title = $renkanJson["title"];
-        }
-        else {
-            $title = "";
-        }
-
-        $res = updateProject($renkanId, $title, $renkanStr);
+    $res = updateProject($renkanId, $title, $renkanStr);
 
 
-        //TODO: return error when fail.
-        http_response_code(200);
-        echo("RES:");
-        print_r($res);
-        die();
+    //TODO: return error when fail.
+    http_response_code(200);
+    echo("RES:");
+    print_r($res);
+    die();
 
+}
+
+function emptyRenkan($title, $description, $renkanId = NULL) {
+    if(is_null($renkanId) || trim($renkanId) === '' ) {
+        $renkanId = genUuid4();
     }
 
-    function emptyRenkan($title, $description, $renkanId = NULL) {
-        if(is_null($renkanId) || trim($renkanId) === '' ) {
-            $renkanId = genUuid4();
-        }
-
-        $now = new DateTime('NOW');
+    $now = new DateTime('NOW');
 
-        $renkan_array = [
-            'id' => $renkanId,
-            'title' => $title,
-            'description' => $description,
-            'uri' => NULL,
-            'color' => NULL,
-            'created' => $now->format("c"),
-            'updated' => $now->format("c"),
-            'nodes' => [],
-            'edges' => [],
-            'users' => [],
-            'views' => []
-        ];
+    $renkan_array = [
+        'id' => $renkanId,
+        'title' => $title,
+        'description' => $description,
+        'uri' => NULL,
+        'color' => NULL,
+        'created' => $now->format("c"),
+        'updated' => $now->format("c"),
+        'schema_version' => RENKAN_SCHEMA_VERSION,
+        'nodes' => [],
+        'edges' => [],
+        'users' => [],
+        'views' => []
+    ];
 
-        return json_encode($renkan_array);
+    return json_encode($renkan_array);
 
-    }
+}