version updated
[brisk.git] / web / Obj / brisk.phh
index 4c9c26e..8118b8c 100644 (file)
@@ -141,12 +141,12 @@ $mlang_brisk = array( 'btn_backstand'=> array( 'it' => 'torna in piedi',
 $G_lng = langtolng($G_lang);
 
 $G_all_points = array( 11,10,4,3,2, 0,0,0,0,0 );
-$G_brisk_version = "4.6.0";
+$G_brisk_version = "4.7.2";
 
 /* MLANG: ALL THE INFO STRINGS IN brisk.phh */
-$root_wellarr = array( 'it' => array ( 'Brisk (Ver. '.$G_brisk_version.'), <b>NOVITA\'</b>: aggiunti script di avvio automatico, gestione dei segnali e logging dell\' ultima connessione.',
+$root_wellarr = array( 'it' => array ( 'Brisk (Ver. '.$G_brisk_version.'), <b>NOVITA\'</b>: prova il nuovo azioni->preferenze.',
                                        'Se vuoi iscriverti alla <a target="_blank" href="mailto:ml-briscola+subscribe@milug.org">Mailing List</a>, cliccala!' ),
-                       'en' => array ( 'Brisk (Ver. '.$G_brisk_version.'), <b>NEWS</b>: usage of reader/writer locking instead of generic exclusive locking.',
+                       'en' => array ( 'Brisk (Ver. '.$G_brisk_version.'), <b>NEWS</b>: server-side infrastructure to manage user preferences added and S customization added.',
                                        'If you want to subscribe our <a target="_blank" href="ml-briscola+subscribe@milug.org">Mailing List</a>, click it!' ) );
 
 $G_room_help = array( 'it' => '
@@ -716,6 +716,7 @@ class Client_prefs {
     {
         $thiz = new Client_prefs();
         if ($thiz->json_load($json) == FALSE) {
+            unset($thiz);
             return (FALSE);
         }
 
@@ -726,24 +727,48 @@ class Client_prefs {
     {
         fprintf(STDERR, "QQ %s: %x\n", __FUNCTION__, $user->flags);
         $this->listen = ($user->flags & USER_FLAG_MAP_AUTH) >> 2;
-        $this->supp_comp = $user->rec->supp_comp;
+        if ($user->rec != FALSE) {
+            $this->supp_comp = $user->rec->supp_comp;
+        }
+        else {
+            $this->supp_comp = "000000000000";
+        }
 
         fprintf(STDERR, "QQ %s: LISTEN: %d\n", __FUNCTION__, $this->listen);
     }
 
     function json_load($json_s)
     {
-        if (gettype($json_s) == "string") {
-            if (($json = json_decode($json_s)) == FALSE)
-                return FALSE;
-        }
-        else {
-            $json = $json_s;
-        }
-        $this->listen    = $json->listen;
-        $this->supp_comp = $json->supp_comp;
+        $ret = FALSE;
+
+        do {
+            if (gettype($json_s) == "string") {
+                if (($json = json_decode($json_s)) == FALSE)
+                    break;
+            }
+            else {
+                $json = $json_s;
+            }
+            if ($this->listen < 0 || $this->listen > 2)
+                break;
+            $this->listen = $json->listen;
+
+            if (mb_strlen($json->supp_comp, "ASCII") != 12)
+                break;
 
-        return TRUE;
+            for ($i = 0, $idx = 0 ; $i < 12 ; $i++) {
+                if (($json->supp_comp[$i] >= '0' && $json->supp_comp[$i] <= '9') ||
+                    ($json->supp_comp[$i] >= 'a' && $json->supp_comp[$i] <= 'f'))
+                    continue;
+                break;
+            }
+            if ($i < 12)
+                break;
+            $this->supp_comp = $json->supp_comp;
+            $ret = TRUE;
+        } while (FALSE);
+
+        return ($ret);
     }
 
     function store($user, $is_save)
@@ -754,7 +779,9 @@ class Client_prefs {
         $user->flags_set(($this->listen << 2), USER_FLAG_MAP_AUTH);
         fprintf(STDERR, "QQ %s::%s %x\n", __CLASS__, __FUNCTION__,
                 $user->flags);
-        $user->rec->supp_comp = $this->supp_comp;
+        if ($user->is_supp_custom()) {
+            $user->rec->supp_comp = $this->supp_comp;
+        }
         if ($is_save)
             $user->store_set();
     }
@@ -2196,18 +2223,28 @@ class Room
     
     $content = ' j_stand_cont( [ ';
 
+    $user_cur_id = $user->idx_get();
     for ($i = 0 , $ct = 0 ; $i < MAX_PLAYERS ; $i++) {
       if ($this->user[$i]->sess == "" || $this->user[$i]->stat != "room" || $this->user[$i]->name == "")
         continue;
       
       $flags = $this->user[$i]->flags;
-      
+
+      // sql record exists AND last donate > 2013-01-01
+      if ($this->user[$i]->is_supp_custom()) {
+          $supp_comp_s = sprintf(', "%s"', $this->user[$i]->rec->supp_comp);
+      }
+      else {
+          $supp_comp_s = '';
+      }
+
       if ($this->user[$i]->subst == "standup") {
-          if ($user->idx_get() == $i) { 
+          if ($user_cur_id == $i) {
               $flags |= 1;
           }
           
-          $content .= sprintf('%s[ %d, "%s" ]',($ct > 0 ? ', ' : ''), $flags, xcape($this->user[$i]->name));
+          $content .= sprintf('%s[ %d, "%s"%s ]',($ct > 0 ? ', ' : ''), $flags,
+                              xcape($this->user[$i]->name), $supp_comp_s);
           $ct++;
       }
     }
@@ -2231,18 +2268,24 @@ class Room
     if ($user->stat != 'room')
       return;
     
+    $user_cur_id = $user->idx_get();
     $content = "[ ";
     for ($i = 0 ; $i < $table->player_n ; $i++) {
         $user_cur = $this->user[$table->player[$i]];
         
         $flags = $user_cur->flags;
         
-        if ($user->idx_get() == $table->player[$i]) 
+        if ($user_cur_id == $table->player[$i])
             $flags |= 1;
         
         log_main($user_cur->name. sprintf(" IN TABLE [%d]", $table_idx));
-        
-        $content .= sprintf('%s[ %d, "%s" ]',($i == 0 ? '' : ', '), $flags, xcape($user_cur->name));
+        if ($user_cur->is_supp_custom())
+            $supp_comp_s = sprintf(', "%s"', $user_cur->rec->supp_comp);
+        else
+            $supp_comp_s = '';
+
+        $content .= sprintf('%s[ %d, "%s"%s ]',($i == 0 ? '' : ', '), $flags,
+                            xcape($user_cur->name), $supp_comp_s);
     }
 
     $content .= ' ]';