From a53bab3c7b384a95a807ddd64fe93a6564be5504 Mon Sep 17 00:00:00 2001 From: "Matteo Nastasi (mop)" Date: Tue, 15 Jul 2014 19:05:47 +0200 Subject: [PATCH] add new type of tables (certified only) and new type of user (certified) --- web/Obj/brisk.phh | 63 +++++++++++++++++++++++++---------------------- web/brisk.css | 22 +++++++++++++++-- web/commons.js | 7 +++--- web/index_wr.php | 11 +++++++-- web/room.js | 13 +++++++--- 5 files changed, 77 insertions(+), 39 deletions(-) diff --git a/web/Obj/brisk.phh b/web/Obj/brisk.phh index 711e16b..cbe89a6 100644 --- a/web/Obj/brisk.phh +++ b/web/Obj/brisk.phh @@ -622,12 +622,17 @@ class Vect { } } +define('TABLE_AUTH_TY_PUBL', 0); +define('TABLE_AUTH_TY_AUTH', 1); +define('TABLE_AUTH_TY_CERT', 2); + + class Table { var $idx; var $player; var $player_n; - var $auth_only; // se tavolo riservato o libero + var $auth_type; // required authorization to sit down var $wag_own; var $wag_com; @@ -650,7 +655,13 @@ class Table { $thiz->idx = $idx; $thiz->player = array(); $thiz->player_n = 0; - $thiz->auth_only = FALSE; + + if ($idx < TABLES_CERT_N) + $thiz->auth_type = TABLE_AUTH_TY_CERT; + else if ($idx < TABLES_AUTH_N) + $thiz->auth_type = TABLE_AUTH_TY_AUTH; + else + $thiz->auth_type = TABLE_AUTH_TY_PUBL; $thiz->wag_own = -1; $thiz->wag_com = ""; @@ -674,7 +685,7 @@ class Table { log_main("PLAYER_N - parent::copy.".$this->player_n); - $this->auth_only = $from->auth_only; + $this->auth_type = $from->auth_type; $this->wag_own = $from->wag_own; $this->wag_com = $from->wag_com; @@ -707,7 +718,7 @@ class Table { $thiz->player[$i] = $i; $thiz->player_n = $from->player_n; - $thiz->auth_only = $from->auth_only; + $thiz->auth_type = $from->auth_type; $thiz->wag_own = $from->wag_own; $thiz->wag_com = $from->wag_com; @@ -778,7 +789,7 @@ class Table { } } - // function act_content($isstanding, $sitted, $table, $cur_table, $allowed) + // Table->act_content - return 'id' of type of output required for table button function act_content($user) { $ret = ""; @@ -790,15 +801,23 @@ class Table { if ($isstanding) { if ($sitted < PLAYERS_N) { - if ($this->auth_only) { - if ($user->flags & USER_FLAG_AUTH) - $act = "sitreser"; - else - $act = 'reserved'; - } - else { - $act = 'sit'; - } + switch ($this->auth_type) { + case TABLE_AUTH_TY_CERT: + if ($user->flags & USER_FLAG_AUTH && $user->flags & USER_FLAG_TY_CERT) + $act = "sitcert"; + else + $act = 'resercert'; + break; + case TABLE_AUTH_TY_AUTH: + if ($user->flags & USER_FLAG_AUTH) + $act = "sitreser"; + else + $act = 'reserved'; + break; + default: + $act = 'sit'; + break; + } } else { $act = 'none'; @@ -1019,20 +1038,6 @@ class Brisk for ($i = 0 ; $i < TABLES_N ; $i++) { $thiz->table[$i] = Table::create($i); - /* OLD METHOD - if ($i < 12) { - $row = ( (((int)($i / 4)) % 2) == 0 ); - $col = ($i % 2 == 0); - $thiz->table[$i]->auth_only = (($row && $col) || (!$row && !$col)); - } - else { - $thiz->table[$i]->auth_only = FALSE; - } - */ - if ($i < TABLES_AUTH_N) - $thiz->table[$i]->auth_only = TRUE; - else - $thiz->table[$i]->auth_only = FALSE; } $thiz->garbage_timeout = 0; $thiz->shm_sz = SHM_DIMS_MIN; @@ -1881,7 +1886,7 @@ class Brisk 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_only == FALSE) + ($user->subst != 'standup' && $this->table[$user->table]->auth_type == TABLE_AUTH_TY_PUBL) ) ) { $user->flags &= ~(USER_FLAG_AUTH | USER_FLAG_TY_ALL); // Remove auth if name changed diff --git a/web/brisk.css b/web/brisk.css index 6f375ab..1e247cf 100644 --- a/web/brisk.css +++ b/web/brisk.css @@ -253,13 +253,31 @@ span.au1 { span.au2 { font-style: italic; -/* text-decoration: underline; */ background-color: #bafcba; } span.au3 { font-weight: bold; font-style: italic; -/* text-decoration: underline; */ background-color: #bafcba; } + +span.au4 { + background-color: #ffd780; +} + +span.au5 { + font-weight: bold; + background-color: #ffd780; +} + +span.au6 { + font-style: italic; + background-color: #ffd780; +} + +span.au7 { + font-weight: bold; + font-style: italic; + background-color: #ffd780; +} diff --git a/web/commons.js b/web/commons.js index 9d07b5d..b95519b 100644 --- a/web/commons.js +++ b/web/commons.js @@ -1027,9 +1027,10 @@ var CHATT_MAXLINES = 40; function user_decorator(user) { var name; - var flags = user[0]; - if ((flags & 0x03) != 0) - name = ""+user[1]+""; + var flags = user[0] & 0x03 | ((user[0] & 0x040000) >> 16); + + if (flags != 0) + name = ""+user[1]+""; else name = user[1]; diff --git a/web/index_wr.php b/web/index_wr.php index 6d5484b..14a8b19 100644 --- a/web/index_wr.php +++ b/web/index_wr.php @@ -41,7 +41,9 @@ $mlang_indwr = array( 'btn_backtotab' => array( 'it' => 'Torna ai tavoli.', 'shutmsg' => array( 'it' => 'Il server sta per essere riavviato, non possono avere inizio nuove partite.', 'en' => 'The server is going to be rebooted, new games are not allowed.'), 'mustauth' => array( 'it' => 'Il tavolo a cui volevi sederti richiede autentifica.', - 'en' => 'the table where you want to sit require authentication'), + 'en' => 'The table where you want to sit require authentication'), + 'mustcert' => array( 'it' => 'Il tavolo a cui volevi sederti richiede autentifica e certificazione.', + 'en' => 'The table where you want to sit require authentication and certification'), 'tabwait_a'=> array( 'it' => 'Il tavolo si è appena liberato, ci si potrà sedere tra ', 'en' => 'The table is only just opened, you will sit down in '), // FIXME 'tabwait_b'=> array( 'it' => ' secondi.', @@ -700,7 +702,12 @@ function index_wr_main(&$brisk, $remote_addr_full, $get, $post, $cookie) $dt, NICKSERV, $mlang_indwr['tabwait_a'][$G_lang], $table->wakeup_time - $curtime, $mlang_indwr['tabwait_b'][$G_lang]); } - else if ($table->auth_only && (($user->flags & USER_FLAG_AUTH) == 0)) { + else if ($table->auth_type == TABLE_AUTH_TY_CERT + && ( (($user->flags & USER_FLAG_AUTH) == 0) || (($user->flags & USER_FLAG_TY_CERT) == 0) ) ) { + $not_allowed_msg = sprintf('chatt_sub("%s", [2, "%s"],"%s");', + $dt, NICKSERV, $mlang_indwr['mustcert'][$G_lang]); + } + else if ($table->auth_type == TABLE_AUTH_TY_AUTH && (($user->flags & USER_FLAG_AUTH) == 0)) { $not_allowed_msg = sprintf('chatt_sub("%s", [2, "%s"],"%s");', $dt, NICKSERV, $mlang_indwr['mustauth'][$G_lang]); } diff --git a/web/room.js b/web/room.js index 85ea699..59117c9 100644 --- a/web/room.js +++ b/web/room.js @@ -1,7 +1,7 @@ /* * brisk - room.js * - * Copyright (C) 2006-2012 Matteo Nastasi + * Copyright (C) 2006-2014 Matteo Nastasi * mailto: nastasi@alternativeoutput.it * matteo.nastasi@milug.org * web: http://www.alternativeoutput.it @@ -460,14 +460,21 @@ function j_tab_act_cont(idx, act) $("table_act"+idx).innerHTML = ''; } else if (act == 'sitreser') { - // // MLANG 1 - $("table_act"+idx).innerHTML = ''; + $("table_act"+idx).innerHTML = ''; + } + else if (act == 'sitcert') { + // MLANG 1 + $("table_act"+idx).innerHTML = ''; } else if (act == 'wake') { // MLANG 1 $("table_act"+idx).innerHTML = ''; } + else if (act == 'resercert') { + // MLANG 1 + $("table_act"+idx).innerHTML = ''; + } else if (act == 'reserved') { // MLANG 1 $("table_act"+idx).innerHTML = ''; -- 2.17.1