From 97a6d096a5e248061cbc7d1769f2ad866a7b9bcd Mon Sep 17 00:00:00 2001 From: "Matteo Nastasi (mop)" Date: Mon, 3 Oct 2016 18:50:07 +0200 Subject: [PATCH 1/1] prefs via fieldify partial works --- INSTALL.sh | 1 + web/Obj/brisk.phh | 34 +++++++--------------------------- web/Obj/user.phh | 11 +++++++++++ web/index_wr.php | 27 ++++++++++++++++++++++++--- 4 files changed, 43 insertions(+), 30 deletions(-) diff --git a/INSTALL.sh b/INSTALL.sh index 83884f6..175893e 100755 --- a/INSTALL.sh +++ b/INSTALL.sh @@ -1,5 +1,6 @@ #!/bin/bash # set -x +set -e # # Defaults # diff --git a/web/Obj/brisk.phh b/web/Obj/brisk.phh index a903589..9368916 100644 --- a/web/Obj/brisk.phh +++ b/web/Obj/brisk.phh @@ -1418,11 +1418,13 @@ class Brisk if ($user->is_auth()) { $model = '{ "listen": { "__type": "radio" } }'; - $content = '{ "listen": {"val": "' . ($user->flags & USER_FLAG_ISOLAUTH ? "2" : - ($user->flags & USER_FLAG_LISTAUTH ? "1" : "0")) . - '" } }'; + $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")))); + $ret .= sprintf('g_prefsf.fields_descr_set(JSON.parse(\'%s\'));', $model); - $ret .= sprintf('g_prefsf.json2dom(JSON.parse(\'%s\'));', $content); + $ret .= sprintf('g_prefsf.json2dom(JSON.parse(\'%s\'));', json_encode($content)); } if ($user->subst == 'standup') @@ -2553,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) { diff --git a/web/Obj/user.phh b/web/Obj/user.phh index 3d09ceb..ad402b8 100644 --- a/web/Obj/user.phh +++ b/web/Obj/user.phh @@ -210,6 +210,7 @@ class User { $thiz->exitislock = TRUE; $thiz->flags = 0x00; + $thiz->flags_cur = 0x00; $thiz->rec = FALSE; $thiz->chattime = array_fill(0, CHAT_N, 0); @@ -259,6 +260,7 @@ class User { $this->exitislock = $from->exitislock; $this->flags = $from->flags; + $this->flags_cur = $from->flags_cur; $this->rec = $from->rec; $this->chattime = array(); @@ -327,6 +329,7 @@ class User { $thiz->the_end = $from->the_end; $thiz->flags = $from->flags; + $thiz->flags_cur = $from->flags_cur; $thiz->rec = $from->rec; $thiz->chattime = array_fill(0, CHAT_N, 0); @@ -380,6 +383,14 @@ class User { return ($flags_old); } + function flags_cur_set($flags_cur, $mask) + { + $flags_cur_old = $this->flags_cur & (~$mask); + $this->flags_cur = ($flags_cur_old | ($flags_cur & $mask)); + + return ($flags_cur_old); + } + function prefs_store() { if (($bdb = BriskDB::create()) == FALSE) { diff --git a/web/index_wr.php b/web/index_wr.php index bed3c89..cf41230 100644 --- a/web/index_wr.php +++ b/web/index_wr.php @@ -381,7 +381,28 @@ function index_wr_main(&$brisk, $remote_addr_full, $get, $post, $cookie) } } else if ($argz[0] == 'prefsf') { - fprintf(STDERR, "INFO: prefsf case\n"); + fprintf(STDERR, "INFO: prefsf case [%s]\n", $post['F_act']); + if (!isset($post['model_name']) || !isset($post['json'])) + return FALSE; + + /* [F_act] => update + [model_name] => prefsf + [counter] => 1 + [json] => {"listen":{"act":"1"}} + */ + if ($post['model_name'] == 'prefsf') { + fprintf(STDERR, "INFO: prefsf preset [%x]\n", $user->flags_cur); + $cont = json_decode($post['json']); + $new_flags_cur = $user->flags_cur & ~(USER_FLAG_ISOLAUTH | USER_FLAG_LISTAUTH); + if ($cont->listen->cur == '1') { + $new_flags_cur |= USER_FLAG_LISTAUTH; + } + else if ($cont->listen->cur == '2') { + $new_flags_cur |= USER_FLAG_ISOLAUTH; + } + $user->flags_cur = $new_flags_cur; + fprintf(STDERR, "INFO: prefsf postset [%x]\n", $user->flags_cur); + } } else if ($argz[0] == 'prefs') { if ($argz[1] == 'save') { @@ -398,8 +419,8 @@ function index_wr_main(&$brisk, $remote_addr_full, $get, $post, $cookie) $prefs = Client_prefs::from_user($user); } $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; "; - $user->comm[$user->step % COMM_N] .= sprintf('prefs_load(\'%s\', true, %s);', json_encode($prefs), - 'false'); + $user->comm[$user->step % COMM_N] .= sprintf('prefs_load(\'%s\', true, %s);', json_encode($prefs), + 'false'); $user->step_inc(); if ($argz[1] == 'save') { -- 2.17.1