From: Matteo Nastasi (mop) Date: Mon, 10 Oct 2016 06:10:02 +0000 (+0200) Subject: full 'listen' prefs management completed and partial 'comps' prefs implemented X-Git-Url: https://mop.ddnsfree.com/gitweb/?p=brisk.git;a=commitdiff_plain;h=89023025985f8c0b07bb4e4500c787bfe23d999e full 'listen' prefs management completed and partial 'comps' prefs implemented --- diff --git a/web/Obj/brisk.phh b/web/Obj/brisk.phh index 29ec0e8..2c83a01 100644 --- a/web/Obj/brisk.phh +++ b/web/Obj/brisk.phh @@ -1417,13 +1417,26 @@ class Brisk $ret = sprintf('gst.st = %d; ', $user_step); 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")))); - - $ret .= sprintf('g_prefsf.fields_descr_set(JSON.parse(\'%s\'));', $model); + $model = array('listen' => array('__type' => 'radio')); + $content = array('listen' => array('val' => ($user->flags_db & USER_FLAG_ISOLAUTH ? "2" : + ($user->flags_db & USER_FLAG_LISTAUTH ? "1" : "0")), + 'cur' => ($user->flags & USER_FLAG_ISOLAUTH ? "2" : + ($user->flags & USER_FLAG_LISTAUTH ? "1" : "0")))); + if ($user->is_supp_custom()) { + $comps = $user->rec->supp_comp_get_array(); + $model['fg'] = array('__type' => 'fields', 'r' => array('__type' => 'value'), + 'g' => array('__type' => 'value'), 'b' => array('__type' => 'value')); + $model['bg'] = array('__type' => 'fields', 'r' => array('__type' => 'value'), + 'g' => array('__type' => 'value'), 'b' => array('__type' => 'value')); + $content['fg'] = array('r' => array('val' => $comps['fg']['r'], 'cur' => $comps['fg']['r']), + 'g' => array('val' => $comps['fg']['g'], 'cur' => $comps['fg']['g']), + 'b' => array('val' => $comps['fg']['b'], 'cur' => $comps['fg']['b'])); + $content['bg'] = array('r' => array('val' => $comps['bg']['r'], 'cur' => $comps['bg']['r']), + 'g' => array('val' => $comps['bg']['g'], 'cur' => $comps['bg']['g']), + 'b' => array('val' => $comps['bg']['b'], 'cur' => $comps['bg']['b'])); + } + + $ret .= sprintf('g_prefsf.fields_descr_set(JSON.parse(\'%s\'));', json_encode($model)); $ret .= sprintf('g_prefsf.json2dom(JSON.parse(\'%s\'));', json_encode($content)); } @@ -2551,11 +2564,11 @@ class Brisk $this->user[$idx]->ip = $ip; $this->user[$idx]->rec = $authenticate; - $this->user[$idx]->flags = $user_type; - $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; + $this->user[$idx]->flags_db = $user_type; + $this->user[$idx]->flags_db |= ($authenticate != FALSE ? USER_FLAG_AUTH : 0x00); + $this->user[$idx]->flags_db |= ( ($pass != FALSE && $bdb == FALSE) ? USER_FLAG_DBFAILED : 0x00); + log_auth("XXX", sprintf("FLAGS: [%x]", $this->user[$idx]->flags_db)); + $this->user[$idx]->flags = $this->user[$idx]->flags_db; if ($authenticate != FALSE) { $this->user[$idx]->code = $authenticate->code_get(); } diff --git a/web/Obj/dbase_base.phh b/web/Obj/dbase_base.phh index 25c36d5..d7d8068 100644 --- a/web/Obj/dbase_base.phh +++ b/web/Obj/dbase_base.phh @@ -116,6 +116,20 @@ class LoginDBItem { return ($ret_arr); } + function supp_comp_set_array($supp_comp_in) + { + $group_id = array("fg", "bg"); + $comp_id = array("r", "g", "b"); + $supp_comp = ""; + + for ($i = 0 ; $i < 2 ; $i++) { + for ($e = 0 ; $e < 3 ; $e++) { + $supp_comp += sprintf("%02x", $supp_comp_in[$group_id[$i]][$comp_id[$e]]); + } + } + $this->supp_comp = $supp_comp; + } + function supp_comp_set($supp_comp) { $this->supp_comp = $supp_comp; diff --git a/web/Obj/user.phh b/web/Obj/user.phh index ad402b8..1d693d5 100644 --- a/web/Obj/user.phh +++ b/web/Obj/user.phh @@ -209,8 +209,8 @@ class User { $thiz->handpt = -1; $thiz->exitislock = TRUE; + $thiz->flags_db = 0x00; $thiz->flags = 0x00; - $thiz->flags_cur = 0x00; $thiz->rec = FALSE; $thiz->chattime = array_fill(0, CHAT_N, 0); @@ -259,8 +259,8 @@ class User { $this->handpt = $from->handpt; $this->exitislock = $from->exitislock; + $this->flags_db = $from->flags_db; $this->flags = $from->flags; - $this->flags_cur = $from->flags_cur; $this->rec = $from->rec; $this->chattime = array(); @@ -328,8 +328,8 @@ class User { $thiz->exitislock = $from->exitislock; $thiz->the_end = $from->the_end; + $thiz->flags_db = $from->flags_db; $thiz->flags = $from->flags; - $thiz->flags_cur = $from->flags_cur; $thiz->rec = $from->rec; $thiz->chattime = array_fill(0, CHAT_N, 0); @@ -375,20 +375,30 @@ class User { return FALSE; } - function flags_set($flags, $mask) + function flags_db_get($mask) { - $flags_old = $this->flags & (~$mask); - $this->flags = ($flags_old | ($flags & $mask)); + return ($this->flags_db & $mask); + } - return ($flags_old); + function flags_db_set($flags_db, $mask) + { + $flags_db_old = $this->flags_db & (~$mask); + $this->flags_db = ($flags_db_old | ($flags_db & $mask)); + + return ($flags_db_old); } - function flags_cur_set($flags_cur, $mask) + function flags_get($mask) { - $flags_cur_old = $this->flags_cur & (~$mask); - $this->flags_cur = ($flags_cur_old | ($flags_cur & $mask)); + return ($this->flags & $mask); + } - return ($flags_cur_old); + function flags_set($flags, $mask) + { + $flags_old = $this->flags & (~$mask); + $this->flags = ($flags_old | ($flags & $mask)); + + return ($flags_old); } function prefs_store() @@ -396,7 +406,11 @@ class User { if (($bdb = BriskDB::create()) == FALSE) { return FALSE; } - return ($bdb->user_prefs_update($this->code, ($this->flags & (USER_FLAG_TY_ALL | USER_FLAG_MAP_AUTH)), + if ($this->flags_db == $this->flags) + return TRUE; + + $this->flags_db = $this->flags; + return ($bdb->user_prefs_update($this->code, ($this->flags_db & (USER_FLAG_TY_ALL | USER_FLAG_MAP_AUTH)), $this->rec->supp_comp_get())); } @@ -410,10 +424,11 @@ class User { function state_store() { - if (($bdb = BriskDB::create()) == FALSE) { + if (($bdb = BriskDB::create()) == FALSE) { return FALSE; } - return ($bdb->user_state_update($this->code, ($this->flags & (USER_FLAG_TY_ALL | USER_FLAG_MAP_AUTH)), + $this->flags_db = $this->flags; + return ($bdb->user_state_update($this->code, ($this->flags_db & (USER_FLAG_TY_ALL | USER_FLAG_MAP_AUTH)), $this->rec->disa_reas_get())); } diff --git a/web/commons.js b/web/commons.js index 28e6aae..462ce2e 100644 --- a/web/commons.js +++ b/web/commons.js @@ -54,6 +54,8 @@ var mlang_commons = { 'imgload_a' : { 'it' : 'Immagini caricate ', function $(id) { return document.getElementById(id); } +function $C(cls) { return document.getElementsByClassName(cls); } + function dec2hex(d, padding) { var hex = Number(d).toString(16); diff --git a/web/index.php b/web/index.php index 878c2a5..b2d853f 100644 --- a/web/index.php +++ b/web/index.php @@ -1563,7 +1563,7 @@ type="submit" class="button" onclick="this.form.elements['realsub'].value = 'chi - + @@ -1637,15 +1637,15 @@ type="submit" class="button" onclick="this.form.elements['realsub'].value = 'chi : - - - @@ -1653,15 +1653,15 @@ title=""> : - - - diff --git a/web/index_wr.php b/web/index_wr.php index cf41230..001b51f 100644 --- a/web/index_wr.php +++ b/web/index_wr.php @@ -391,17 +391,26 @@ function index_wr_main(&$brisk, $remote_addr_full, $get, $post, $cookie) [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; + if ($post['F_act'] == 'update' || $post['F_act'] == 'store') { + $cont = json_decode($post['json']); + $leaf = ($post['F_act'] == 'update' ? 'cur' : 'val'); + + $listen_flags = (($cont->listen->$leaf == '1' ? USER_FLAG_LISTAUTH : 0) | + ($cont->listen->$leaf == '2' ? USER_FLAG_ISOLAUTH : 0)); + $user->flags_set($listen_flags, USER_FLAG_MAP_AUTH); + if ($post['F_act'] == 'store' + && $user->flags_db_get(USER_FLAG_MAP_AUTH) != $user->flags_get(USER_FLAG_MAP_AUTH)) { + $user->prefs_store(); + } + } + if ($user->stat == 'room' && $user->subst == 'standup') { + $brisk->standup_update($user); } - else if ($cont->listen->cur == '2') { - $new_flags_cur |= USER_FLAG_ISOLAUTH; + else if ($user->stat == 'room' && $user->subst == 'sitdown') { + $brisk->table_update($user); } - $user->flags_cur = $new_flags_cur; - fprintf(STDERR, "INFO: prefsf postset [%x]\n", $user->flags_cur); + echo "1"; + return TRUE; } } else if ($argz[0] == 'prefs') { diff --git a/web/prefs.js b/web/prefs.js index e2c32ba..639c055 100644 --- a/web/prefs.js +++ b/web/prefs.js @@ -490,6 +490,27 @@ function g_prefsf_listen_cb(item) } } +function g_prefsf_comps_cb(item) +{ + console.log(item); + console.log(g_prefsf); + + var col, ct = 0, s = ""; + var col_arr = [ 'fg', 'bg' ]; + var cmp_arr = [ 'r', 'g', 'b' ]; + for (col in col_arr) { + for (cmp in cmp_arr) { + console.log(g_prefsf.bsk_comps[col_arr[col]][cmp_arr[cmp]].value); + var val_s = g_prefsf.bsk_comps[col_arr[col]][cmp_arr[cmp]].value; + if (parseInt(val_s) < 0 || parseInt(val_s) > 255 || isNaN(parseInt(val_s))) + return false; + s += dec2hex(parseInt(val_s), 2); + } + console.log("sub: [" + s + "]"); + } + $('s_img').src = 'suprend.php?comp=' + s; +} + function prefsf_status_cb(st) { // console.log('status_show HERE ' + st); @@ -506,10 +527,20 @@ function prefsf_status_cb(st) } } - - function prefsf_initialize() { - clie_cb = { 'listen': { cb: g_prefsf_listen_cb, type: "fast" } }; + clie_cb = { 'listen': { cb: g_prefsf_listen_cb, type: "fast" }, + 'fg': { 'r': { cb: g_prefsf_comps_cb, type: "fast"}, + 'g': { cb: g_prefsf_comps_cb, type: "fast"}, + 'b': { cb: g_prefsf_comps_cb, type: "fast"}}, + 'bg': { 'r': { cb: g_prefsf_comps_cb, type: "fast"}, + 'g': { cb: g_prefsf_comps_cb, type: "fast"}, + 'b': { cb: g_prefsf_comps_cb, type: "fast"}}}; g_prefsf = new Fieldify(null, null, null, clie_cb, "prefsf", [$("prefsf")], prefsf_status_cb); + g_prefsf.bsk_comps = { 'bg': { 'r': $C('bg_r') != undefined ? $C('bg_r')[0] : null, + 'g': $C('bg_g') != undefined ? $C('bg_g')[0] : null, + 'b': $C('bg_b') != undefined ? $C('bg_b')[0] : null }, + 'fg': { 'r': $C('fg_r') != undefined ? $C('fg_r')[0] : null, + 'g': $C('fg_g') != undefined ? $C('fg_g')[0] : null, + 'b': $C('fg_b') != undefined ? $C('fg_b')[0] : null} }; }