js: add info_save() function
authorMatteo Nastasi (mop) <nastasi@alternativeoutput.it>
Thu, 19 Nov 2015 18:13:25 +0000 (19:13 +0100)
committerMatteo Nastasi (mop) <nastasi@alternativeoutput.it>
Thu, 19 Nov 2015 18:13:25 +0000 (19:13 +0100)
web/Obj/brisk.phh
web/prefs.js

index 5ae7486..3e7870d 100644 (file)
@@ -1724,6 +1724,35 @@ class Brisk
       return $jret;
   }
 
+  function info_save($user, $json_s)
+  {
+      GLOBAL $G_lang, $mlang_brisk, $G_base;
+
+      $mesg = "";
+      $user_code = -1;
+      $ret = 0;
+
+
+      do {
+          if (($json = json_decode($json_s)) == FALSE) {
+              $ret = 1;
+              break;
+          }
+
+          if (($bdb = BriskDB::create()) == FALSE) {
+              $ret = 2;
+              break;
+          }
+
+          if (($user_item = $bdb->usersnet_save($user->code, $json)) == FALSE) {
+              $ret = 4;
+              break;
+          }
+          return (TRUE);
+      } while(0);
+      return (FALSE);
+  }
+
   function room_outstandup($user)
   {
     $this->room_sitdown($user, -1);
index 51b7eba..87d84c8 100644 (file)
@@ -114,8 +114,12 @@ function prefs_save()
 
     ret = server_request('mesg', 'prefs|save','__POST__', 'prefs', JSON.stringify(g_prefs));
 
-    if (ret == 1)
+    if (ret == 1) {
         $('preferences').style.visibility = 'hidden';
+    }
+    else {
+        alert(ret);
+    }
 }
 
 function prefs_reset()