From: Matteo Nastasi (mop) Date: Fri, 6 Nov 2015 08:28:53 +0000 (+0100) Subject: enable 'usersnet' table with indexes and reading info from it X-Git-Tag: v5.3.0~59 X-Git-Url: http://mop.ddnsfree.com/gitweb/?a=commitdiff_plain;h=7f9618888f9963c4a7daebeb9e3d14ef0a56b968;p=brisk.git enable 'usersnet' table with indexes and reading info from it --- diff --git a/web/Obj/brisk.phh b/web/Obj/brisk.phh index 760e377..7d82d56 100644 --- a/web/Obj/brisk.phh +++ b/web/Obj/brisk.phh @@ -1677,8 +1677,8 @@ class Brisk } $user_tos_vers = $user_item->tos_vers_get(); - if (($usernet_item = $bdb->usernet_bycode($user->code, $user_item->code)) == FALSE) { - $usernet_item = $bdb->usernet_default($user->code, $user_item->code); + if (($usersnet_item = $bdb->usersnet_bycode($user->code, $user_item->code)) == FALSE) { + $usersnet_item = $bdb->usersnet_default($user->code, $user_item->code); } if (versions_cmp($user_tos_vers, "1.2") < 0) { @@ -1710,7 +1710,9 @@ class Brisk "" : $guar_login), "match" => (versions_cmp($user_tos_vers, "1.4") < 0 ? "non autorizzato" : $user_item->match_cnt) , "game" => (versions_cmp($user_tos_vers, "1.4") < 0 ? "non autorizzato" : $user_item->game_cnt), - "friend" => "unknown")); + "friend" => usersnet_friend_getlabel($usersnet_item->friend), + "skill" => $usersnet_item->skill, + "trust" => $usersnet_item->trust)); } return $jret; diff --git a/web/Obj/dbase_base.phh b/web/Obj/dbase_base.phh index 5e65ec8..dddd592 100644 --- a/web/Obj/dbase_base.phh +++ b/web/Obj/dbase_base.phh @@ -182,41 +182,41 @@ class MailDBItem { } } -define('USERNET_FRIEND', 0); -define('USERNET_CLEVER', 1); -define('USERNET_TRUST', 2); -class UserNetItem { +define('USERSNET_FRIEND', 1); +define('USERSNET_SKILL', 1); +define('USERSNET_TRUST', 2); +class UsersNetItem { var $owner; var $target; var $friend; - var $clever; + var $skill; var $trust; var $from_db; - function UserNetItem($owner, $target, $friend, $clever, $trust, $from_db) + function UsersNetItem($owner, $target, $friend, $skill, $trust, $from_db) { $this->owner = $owner; $this->target = $target; $this->friend = $friend; - $this->clever = $clever; + $this->skill = $skill; $this->trust = $trust; $this->from_db = $from_db; } - static function UserNetItemFromRecord($rec) + static function UsersNetItemFromRecord($rec) { - $ret = new UserNetItem($rec->owner, $rec->target, $rec->friend, - $rec->clever, $rec->trust, TRUE); + $ret = new UsersNetItem($rec->owner, $rec->target, $rec->friend, + $rec->skill, $rec->trust, TRUE); return ($ret); } - static function UserNetItemDefaults($owner, $target) + static function UsersNetItemDefaults($owner, $target) { - $ret = new UserNetItem($owner, $target, USERNET_FRIEND, - USERNET_CLEVER, USERNET_TRUST, FALSE); + $ret = new UsersNetItem($owner, $target, USERSNET_FRIEND, + USERSNET_SKILL, USERSNET_TRUST, FALSE); return ($ret); } diff --git a/web/Obj/dbase_pgsql.phh b/web/Obj/dbase_pgsql.phh index e3e1551..5c187aa 100644 --- a/web/Obj/dbase_pgsql.phh +++ b/web/Obj/dbase_pgsql.phh @@ -855,12 +855,12 @@ INSERT INTO %smails (code, ucode, type, tstamp, subj, body_txt, body_htm, hash) return (TRUE); } - function usernet_bycode($owner, $target) + function usersnet_bycode($owner, $target) { GLOBAL $G_dbpfx; $ret = FALSE; - $net_sql = sprintf("SELECT * FROM %susers_net WHERE owner = %d AND target = %d;", + $net_sql = sprintf("SELECT * FROM %susersnet WHERE owner = %d AND target = %d;", $G_dbpfx, $owner, $target); if (($net_pg = $this->query($net_sql)) == FALSE) { return FALSE; @@ -870,12 +870,12 @@ INSERT INTO %smails (code, ucode, type, tstamp, subj, body_txt, body_htm, hash) $net_obj = pg_fetch_object($net_pg, 0); - return (UserNetItem::UserNetItemFromRecord($net_obj)); + return (UsersNetItem::UsersNetItemFromRecord($net_obj)); } - function usernet_default($owner, $target) + function usersnet_default($owner, $target) { - return (UserNetItem::UserNetItemDefaults($owner, $target)); + return (UsersNetItem::UsersNetItemDefaults($owner, $target)); } } // End class BriskDB diff --git a/web/Obj/user.phh b/web/Obj/user.phh index 361acda..99952e4 100644 --- a/web/Obj/user.phh +++ b/web/Obj/user.phh @@ -923,5 +923,19 @@ function chunked_fini() } // end class User +if (!isset($__usersnet_friend_map)) { + $__usersnet_friend_map = array("black", "unknown", "test", "friend", "bff"); +} + +function usersnet_friend_getlabel($id) +{ + GLOBAL $__usersnet_friend_map; + + $id_i = intval($id); + if ($id_i < 0 || $id_i >= count($__usersnet_friend_map)) { + return FALSE; + } + return ($__usersnet_friend_map[$id_i]); +} ?> diff --git a/web/fieldify.js b/web/fieldify.js index 254dd0d..5be1dea 100644 --- a/web/fieldify.js +++ b/web/fieldify.js @@ -3,7 +3,7 @@ function Fieldify(ancestor, fieldsdescr) { this.ancestor = ancestor; - + this.field = new Array(); for (k in fieldsdescr) { this.field[k] = fieldsdescr[k]; @@ -13,7 +13,7 @@ function Fieldify(ancestor, fieldsdescr) Fieldify.prototype = { ancestor: null, field: null, - + visible: function(is_visible) { this.ancestor.style.visibility = (is_visible ? "visible" : "hidden" ); }, @@ -33,20 +33,17 @@ Fieldify.prototype = { fld_value_set: function(name, value) { - console.log(name + "=" + value); this.ancestor.getElementsByClassName(name + '_id')[0].innerHTML = value; }, - + fld_radio_set: function(name, value) { var arr = this.ancestor.getElementsByClassName(name + '_id'); - console.log(name + "=" + value); - for (k in arr) { if (arr[k].value == value) arr[k].checked = true; - else + else arr[k].checked = false; } }, diff --git a/web/index.php b/web/index.php index d68f270..43e1b0c 100644 --- a/web/index.php +++ b/web/index.php @@ -1410,11 +1410,11 @@ type="submit" class="button" onclick="this.form.elements['realsub'].value = 'chi 3 4 5 - - - - - + + + + + diff --git a/web/room.js b/web/room.js index f6d6d24..a8230db 100644 --- a/web/room.js +++ b/web/room.js @@ -451,7 +451,10 @@ function info_show(username) guar: { type: 'value' }, match: { type: 'value' }, game: { type: 'value' }, - friend: { type: 'radio' } }; + friend: { type: 'radio' }, + skill: { type: 'radio' }, + trust: { type: 'radio' } + }; info = new Fieldify($('info'), fields); info.populate(info_in);