From f7068bc71e92a6290b6efcd8c10771aab8bc3449 Mon Sep 17 00:00:00 2001 From: "Matteo Nastasi (mop)" Date: Wed, 17 Feb 2016 07:29:59 +0100 Subject: [PATCH] prefs refactoring: partial implementation (wip) --- web/Obj/brisk.phh | 20 ++++- web/Obj/dbase_base.phh | 19 +++++ web/Obj/user.phh | 24 ++++++ web/index.php | 125 ++++++++++++---------------- web/index_wr.php | 32 ++++++++ web/info.js | 3 +- web/prefs.js | 181 +++++++++++++++++++++++++++++++++++++++-- 7 files changed, 321 insertions(+), 83 deletions(-) diff --git a/web/Obj/brisk.phh b/web/Obj/brisk.phh index e3abaa9..7262ef4 100644 --- a/web/Obj/brisk.phh +++ b/web/Obj/brisk.phh @@ -1416,9 +1416,9 @@ 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()) { + $ret .= sprintf('g_prefsn.load(\'%s\');', json_encode($user->prefsn_get())); + } if(false) { if ($user->flags & USER_FLAG_ISOLAUTH) { $ret .= 'list_set(\'isolation\', false, \''.$mlang_brisk['tit_onisol'][$G_lang].'\' ); '; @@ -2152,6 +2152,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"); diff --git a/web/Obj/dbase_base.phh b/web/Obj/dbase_base.phh index 66c998f..d2cebbc 100644 --- a/web/Obj/dbase_base.phh +++ b/web/Obj/dbase_base.phh @@ -98,6 +98,25 @@ class LoginDBItem { { return $this->supp_comp; } + function supp_comp_get_array() + { + $ret = array(); + $group_id = array("fg", "bg"); + $comp_id = array("r", "g", "b"); + $ret_arr = array(); + $supp_comp = $this->supp_comp; + + for ($i = 0 ; $i < 2 ; $i++) { + $group_cur = $group_id[$i]; + $ret_arr[$group_cur] = array(); + for ($e = 0 ; $e < 3 ; $e++) { + $ret_arr[$group_cur][$comp_id[$e]] = base_convert(substr($supp_comp, $i*3 + $e, 2), 16, 10); + } + } + + return ($ret_arr); + } + function supp_comp_set($supp_comp) { $this->supp_comp = $supp_comp; diff --git a/web/Obj/user.phh b/web/Obj/user.phh index a1bc74d..3d09ceb 100644 --- a/web/Obj/user.phh +++ b/web/Obj/user.phh @@ -920,6 +920,30 @@ function chunked_fini() return sprintf("0\r\n"); } +function prefsn_get() +{ + GLOBAL $G_lang, $mlang_brisk, $G_base; + + $mesg = ""; + $user_code = -1; + + $listen = ($this->flags & USER_FLAG_MAP_AUTH) >> 2; + if ($this->rec != FALSE) { + $ret = $this->rec->supp_comp_get_array(); + } + else { + $ret = array( + "fg" => array("r" => 0, "g" => 0, "b" => 0), + "bg" => array("r" => 0, "g" => 0, "b" => 0) + ); + } + + return (array("ret" => 0, + "listen" => $listen, + "fg" => $ret["fg"], + "bg" => $ret["bg"])); +} + } // end class User diff --git a/web/index.php b/web/index.php index 14b7961..5d1a92e 100644 --- a/web/index.php +++ b/web/index.php @@ -956,7 +956,7 @@ google_color_url = "000000"; ' + onmouseover="menu_hide(0,1);" onclick="g_prefsn.show(); menu_over(-1,this);">' // MLANG garantisci .$mlang_room['tit_prefs'][$G_lang].'
' : '').' @@ -1039,6 +1039,7 @@ var g_tables_appr_n = ; var g_tables_auth_n = ; var g_tables_cert_n = ; var g_prefs, g_prefs_new = null; +var g_prefsn, g_prefsn_old = null; var g_listen; var g_withflash = false; var g_is_spawn = 0; @@ -1054,8 +1055,6 @@ window.onload = function() { // alert(window.onbeforeunload); g_brow = get_browser_agent(); - g_prefs = new client_prefs(null); - spo_slide = new sideslide($('spon_caro'), 80, 20); sup_slide = new sideslide($('supp_caro'), 80, 20); @@ -1209,6 +1208,7 @@ cookie_law(null); var g_tables_auth_n = ; var g_tables_cert_n = ; var g_prefs, g_prefs_new = null; + var g_prefsn, g_prefsn_old = null; var g_listen; var g_is_spawn = 0; var g_withflash = false; @@ -1228,6 +1228,7 @@ cookie_law(null); g_brow = get_browser_agent(); g_prefs = new client_prefs(null); + g_prefsn = new Prefsn($('prefsn')); spo_slide = new sideslide($('spon_caro'), 80, 20); sup_slide = new sideslide($('supp_caro'), 80, 20); @@ -1488,6 +1489,9 @@ type="submit" class="button" onclick="this.form.elements['realsub'].value = 'chi + + +