]> source.dussan.org Git - nextcloud-server.git/commitdiff
update to comply with the OCS spec (lookup by application name too)
authorMartin Sandsmark <martin.sandsmark@kde.org>
Mon, 2 Aug 2010 18:39:14 +0000 (20:39 +0200)
committerMartin Sandsmark <martin.sandsmark@kde.org>
Mon, 2 Aug 2010 18:39:14 +0000 (20:39 +0200)
db_structure.xml
inc/lib_ocs.php

index 51ab9210933ea8314a963dd5afe4f1beecf5d5d2..6eea47fec4f32ca07f3e00973feee7b2f6233a44 100644 (file)
        <notnull>true</notnull>
        <length>64</length>
      </field>
+     <field>
+       <name>app</name>
+       <type>text</type>
+       <default></default>
+       <notnull>true</notnull>
+       <length>64</length>
+     </field>
      <field>
        <name>value</name>
        <type>text</type>
        <notnull>true</notnull>
      </field>
      <index>
-       <name>timestamp</name>
-       <unique>false</unique>
-       <field>
-         <name>timestamp</name>
-         <sorting>ascending</sorting>
-       </field>
+      <name>appkey</name>
+      <unique>true</unique>
+      <field>
+       <name>key</name>
+       <sorting>ascending</sorting>
+      </field>
+      <field>
+       <name>app</name>
+       <sorting>ascending</sorting>
+      </field>
      </index>
    </declaration>
  </table>
index 3a675b64d8a0faa487c517189cbcb98b33811138..a4c51f7c62d258e154a0bfbb65939305e4968fcd 100644 (file)
@@ -145,11 +145,12 @@ class OC_OCS {
       OC_OCS::privateDataGet($format, $key);
 
     // set - POST DATA
-    }elseif(($method=='post') and (strtolower($ex[$paracount-5])=='v1.php')and (strtolower($ex[$paracount-3])=='setattribute')){
+    }elseif(($method=='post') and (strtolower($ex[$paracount-6])=='v1.php')and (strtolower($ex[$paracount-4])=='setattribute')){
       $format=OC_OCS::readdata('format','text');
       $key=$ex[$paracount-2];
+      $app=$ex[$paracount-3];
       $value=OC_OCS::readdata('value','text');
-      OC_OCS::privatedataset($format, $key, $value);
+      OC_OCS::privatedataset($format, $app, $key, $value);
 
     }else{
       $format=OC_OCS::readdata('format','text');
@@ -472,19 +473,19 @@ class OC_OCS {
    * @param string $value
    * @return string xml/json
    */
-  private static function privateDataSet($format, $key, $value) {
+  private static function privateDataSet($format, $app, $key, $value) {
        global $CONFIG_DBTABLEPREFIX;
 
     //TODO: prepared statements, locking tables, fancy stuff, error checking/handling
     $user=OC_OCS::checkpassword();
 
-    $result=OC_DB::select("select count(*) as co from {$CONFIG_DBTABLEPREFIX}privatedata where key = '".addslashes($key)."'");
+    $result=OC_DB::select("select count(*) as co from {$CONFIG_DBTABLEPREFIX}privatedata where key = '".addslashes($key)."' and app = '".addslashes($app)."'");
     $totalcount=$result[0]['co'];
 
     if ($totalcount != 0) {
-        $result = OC_DB::query("update {$CONFIG_DBTABLEPREFIX}privatedata set value='".addslashes($value)."', timestamp = datetime('now') where key = '".addslashes($key)."'");
+        $result = OC_DB::query("update {$CONFIG_DBTABLEPREFIX}privatedata set value='".addslashes($value)."', timestamp = datetime('now') where key = '".addslashes($key)."' and app = '".addslashes($app)."'");
     } else {
-        $result = OC_DB::query("insert into {$CONFIG_DBTABLEPREFIX}privatedata(key, value, timestamp) values('".addslashes($key)."', '".addslashes($value)."', datetime('now'))");
+        $result = OC_DB::query("insert into {$CONFIG_DBTABLEPREFIX}privatedata(app, key, value, timestamp) values('".addslashes($app)."', '".addslashes($key)."', '".addslashes($value)."', datetime('now'))");
     }
 
     echo(OC_OCS::generatexml($format,'ok',100,''));