supp_comp_get_array function fixed
[brisk.git] / web / Obj / brisk.phh
index f971277..29ec0e8 100644 (file)
@@ -1416,19 +1416,15 @@ class Brisk
 
     $ret = sprintf('gst.st = %d; ',  $user_step);
 
-    $prefs = Client_prefs::from_user($user);
-    $ret .= sprintf('prefs_load(\'%s\', false, false);', json_encode($prefs));
+    if ($user->is_auth()) {
+        $model = '{ "listen": { "__type": "radio" } }';
+        $content = array('listen' =>  array('val' => ($user->flags & USER_FLAG_ISOLAUTH ? "2" :
+                                                      ($user->flags & USER_FLAG_LISTAUTH ? "1" : "0")),
+                                            'cur' => ($user->flags_cur & USER_FLAG_ISOLAUTH ? "2" :
+                                                      ($user->flags_cur & USER_FLAG_LISTAUTH ? "1" : "0"))));
 
-    if(false) {
-        if ($user->flags & USER_FLAG_ISOLAUTH) {
-            $ret .= 'list_set(\'isolation\', false, \''.$mlang_brisk['tit_onisol'][$G_lang].'\' ); ';
-        }
-        else if ($user->flags & USER_FLAG_LISTAUTH) {
-            $ret .= 'list_set(\'auth\', false, \''.$mlang_brisk['tit_onauth'][$G_lang].'\' ); ';
-        }
-        else {
-            $ret .= 'list_set(\'all\', false, \'\' ); ';
-        }
+        $ret .= sprintf('g_prefsf.fields_descr_set(JSON.parse(\'%s\'));', $model);
+        $ret .= sprintf('g_prefsf.json2dom(JSON.parse(\'%s\'));', json_encode($content));
     }
 
     if ($user->subst == 'standup')
@@ -2101,7 +2097,7 @@ class Brisk
 
         /* MLANG: "<b>Non puoi cambiare nick a un tavolo per soli autenticati.</b>", "Il nickname <b>\'%s\'</b> &egrave; gi&agrave; registrato, <b>se il suo proprietario si autentificher&agrave; verrai rinominato d\'ufficio come ghost<i>N</i>.</b>" */
         if ($user->is_auth()) {
-          if (strcasecmp($user->name,$name_new) != 0) {
+          if (strcasecmp($user->name, $name_new) != 0) {
              if (( ($user->flags & USER_FLAG_MAP_AUTH) != USER_FLAG_ISOLAUTH) &&
                 ($user->subst == 'standup' ||
                  ($user->subst != 'standup' && $this->table[$user->table]->auth_type == TABLE_AUTH_TY_PUBL)
@@ -2152,6 +2148,20 @@ class Brisk
             echo $this->info_show($user, urldecode($info_user), $dt);
         } while(0);
     }
+    else if (strncmp($msg, "/prefsn", 7) == 0) {
+        do {
+            if (! $user->is_auth()) {
+                if ($mlang_indwr) {
+                    $to_user = nickserv_msg($dt, $mlang_indwr['info_auth'][$G_lang]);
+                }
+                else {
+                    $to_user = nickserv_msg($dt, "error");
+                }
+                break;
+            }
+            echo $this->prefsn_show($user, $dt);
+        } while(0);
+    }
     else if (strncmp($msg, "/st ", 4) == 0) {
       log_main("chatt_send BEGIN");
 
@@ -2545,31 +2555,9 @@ class Brisk
       $this->user[$idx]->flags |= ($authenticate != FALSE ? USER_FLAG_AUTH : 0x00);
       $this->user[$idx]->flags |= ( ($pass != FALSE && $bdb == FALSE) ? USER_FLAG_DBFAILED : 0x00);
       log_auth("XXX", sprintf("FLAGS: [%x]", $this->user[$idx]->flags));
-
+      $this->user[$idx]->flags_cur = $this->user[$idx]->flags;
       if ($authenticate != FALSE) {
           $this->user[$idx]->code = $authenticate->code_get();
-          if (0 == 1) {
-              // all this part is included in the db server
-              $this->user[$idx]->flags |= USER_FLAG_LISTAUTH;
-
-              if (isset($cookie['CO_list'])) {
-                  fprintf(STDERR, "QQ: %s CO_list: [%s]\n", __FUNCTION__, $cookie['CO_list']);
-                  if (strcmp($cookie['CO_list'], "auth") == 0) {
-                      $this->user[$idx]->flags &= ~USER_FLAG_MAP_AUTH;
-                      $this->user[$idx]->flags |= USER_FLAG_LISTAUTH;
-                  }
-                  if (strcmp($cookie['CO_list'], "isolation") == 0) {
-                      $this->user[$idx]->flags &= ~USER_FLAG_MAP_AUTH;
-                      $this->user[$idx]->flags |= USER_FLAG_ISOLAUTH;
-                  }
-                  else {
-                      $this->user[$idx]->flags &= ~USER_FLAG_MAP_AUTH;
-                  }
-              }
-          }
-          else {
-              fprintf(STDERR, "QQ: CO_list not set flags: %x\n", __FUNCTION__, $this->user[$idx]->flags);
-          }
       }
       fprintf(STDERR, "QQ %s: flag %x\n", __FUNCTION__, $this->user[$idx]->flags);
       if ($ghost > -1) {
@@ -3540,6 +3528,9 @@ function carousel_top()
     }
 }
 
+/* function login_consistency:
+       name length must be less or equal than 12 chars,
+       no more than 2 consecutive same character (or generic digits) are allowed */
 function login_consistency($name)
 {
     $old_c = '';
@@ -3550,6 +3541,9 @@ function login_consistency($name)
     for ($i = 0 ; $i < mb_strlen($name) ; $i++) {
         $c = mb_substr($name, $i, 1);
         if (mb_ereg_match ("[a-zA-Z0-9]", $c)) {
+            if (mb_ereg_match ("[0-9]", $c)) {
+                $c = "0";
+            }
             if ($old_c != $c) {
                 $old_c = $c;
                 $old_ct = 1;