From b45d86b1a08e04f516bca2887126fcedeb2abc24 Mon Sep 17 00:00:00 2001 From: "Matteo Nastasi (mop)" Date: Thu, 10 Dec 2015 07:42:31 +0100 Subject: [PATCH] add widefriend and narrowfriend exposition to client (wip) --- web/Obj/brisk.phh | 14 ++++++++--- web/Obj/dbase_base.phh | 15 ++++++++---- web/Obj/dbase_pgsql.phh | 54 +++++++++++++++++++++++++++++++++++------ web/Obj/sac-a-push.phh | 2 +- web/index.php | 30 +++++++++++++++++------ web/room.css | 2 +- 6 files changed, 92 insertions(+), 25 deletions(-) diff --git a/web/Obj/brisk.phh b/web/Obj/brisk.phh index d543267..0c1e5c9 100644 --- a/web/Obj/brisk.phh +++ b/web/Obj/brisk.phh @@ -1693,8 +1693,13 @@ class Brisk } $user_tos_vers = $user_item->tos_vers_get(); - if (($usersnet_item = $bdb->usersnet_bycode($user->code, $user_item->code)) == FALSE) { - $usersnet_item = $bdb->usersnet_default($user->code, $user_item->code); + $widefriend = $bdb->usersnet_widefriend($user->code, $user_item->code); + $narrowfriend = $bdb->usersnet_narrowfriend($user->code, $user_item->code); + + if (($usersnet_item = $bdb->usersnet_bycode($user->code, $user_item->code, + $widefriend, $narrowfriend)) == FALSE) { + $usersnet_item = $bdb->usersnet_default($user->code, $user_item->code, + $widefriend, $narrowfriend); } if (versions_cmp($user_tos_vers, "1.2") < 0) { @@ -1728,7 +1733,10 @@ class Brisk "game" => (versions_cmp($user_tos_vers, "1.4") < 0 ? "non autorizzato" : $user_item->game_cnt), "friend" => usersnet_friend_getlabel($usersnet_item->friend), "skill" => $usersnet_item->skill, - "trust" => $usersnet_item->trust)); + "trust" => $usersnet_item->trust, + "widefriend" => $usersnet_item->widefriend, + "narrowfriend" => $usersnet_item->narrowfriend + )); } return $jret; diff --git a/web/Obj/dbase_base.phh b/web/Obj/dbase_base.phh index dddd592..85d9315 100644 --- a/web/Obj/dbase_base.phh +++ b/web/Obj/dbase_base.phh @@ -194,29 +194,34 @@ class UsersNetItem { var $from_db; - function UsersNetItem($owner, $target, $friend, $skill, $trust, $from_db) + function UsersNetItem($owner, $target, $friend, $skill, $trust, + $widefriend, $narrowfriend, $from_db) { $this->owner = $owner; $this->target = $target; $this->friend = $friend; $this->skill = $skill; $this->trust = $trust; + $this->widefriend = $widefriend; + $this->narrowfriend = $narrowfriend; $this->from_db = $from_db; } - static function UsersNetItemFromRecord($rec) + static function UsersNetItemFromRecord($rec, $widefriend, $narrowfriend) { $ret = new UsersNetItem($rec->owner, $rec->target, $rec->friend, - $rec->skill, $rec->trust, TRUE); + $rec->skill, $rec->trust, + $widefriend, $narrowfriend, TRUE); return ($ret); } - static function UsersNetItemDefaults($owner, $target) + static function UsersNetItemDefaults($owner, $target, $widefriend, $narrowfriend) { $ret = new UsersNetItem($owner, $target, USERSNET_FRIEND, - USERSNET_SKILL, USERSNET_TRUST, FALSE); + USERSNET_SKILL, USERSNET_TRUST, + $widefriend, $narrowfriend, FALSE); return ($ret); } diff --git a/web/Obj/dbase_pgsql.phh b/web/Obj/dbase_pgsql.phh index 911b2b6..91ca210 100644 --- a/web/Obj/dbase_pgsql.phh +++ b/web/Obj/dbase_pgsql.phh @@ -856,28 +856,68 @@ INSERT INTO %smails (code, ucode, type, tstamp, subj, body_txt, body_htm, hash) return (TRUE); } - function usersnet_bycode($owner, $target) + function usersnet_widefriend($owner, $target) + { + GLOBAL $G_dbpfx; + + $widefriend = array(1 => "//", 2 => "//", 3 => "//", 4 => "//", 5 => "//"); + + $wfri_sql = sprintf("SELECT * FROM %susersnet_widefriend WHERE owner = %d AND target = %d;", + $G_dbpfx, $owner, $target); + if (($wfri_pg = $this->query($wfri_sql)) == FALSE) { + return ($widefriend); + } + + for ($i = 0 ; $i < pg_numrows($wfri_pg) ; $i++) { + $wfri_obj = pg_fetch_object($wfri_pg, $i); + $widefriend[intval($wfri_obj->friend)] = $wfri_obj->count; + } + + return ($widefriend); + } + + function usersnet_narrowfriend($owner, $target) + { + GLOBAL $G_dbpfx; + + $narrowfriend = array(1 => "//", 2 => "//", 3 => "//", 4 => "//", 5 => "//"); + + $nfri_sql = sprintf("SELECT * FROM %susersnet_narrowfriend WHERE owner = %d AND target = %d;", + $G_dbpfx, $owner, $target); + if (($nfri_pg = $this->query($nfri_sql)) == FALSE) { + return $narrowfriend; + } + + for ($i = 0 ; $i < pg_numrows($nfri_pg) ; $i++) { + $nfri_obj = pg_fetch_object($nfri_pg, $i); + $narrowfriend[intval($nfri_obj->friend)] = $nfri_obj->count; + } + return ($narrowfriend); + } + + function usersnet_bycode($owner, $target, $widefriend, $narrowfriend) { GLOBAL $G_dbpfx; $ret = FALSE; $net_sql = sprintf("SELECT * FROM %susersnet WHERE owner = %d AND target = %d;", - $G_dbpfx, $owner, $target); - if (($net_pg = $this->query($net_sql)) == FALSE) { + $G_dbpfx, $owner, $target); + if (($net_pg = $this->query($net_sql)) == FALSE) return FALSE; - } + if (pg_numrows($net_pg) != 1) return FALSE; $net_obj = pg_fetch_object($net_pg, 0); - return (UsersNetItem::UsersNetItemFromRecord($net_obj)); + return (UsersNetItem::UsersNetItemFromRecord($net_obj, $widefriend, $narrowfriend)); } - function usersnet_default($owner, $target) + function usersnet_default($owner, $target, $widefriend, $narrowfriend) { - return (UsersNetItem::UsersNetItemDefaults($owner, $target)); + return (UsersNetItem::UsersNetItemDefaults($owner, $target, $widefriend, $narrowfriend)); } + function usersnet_save($owner_id, $json) { GLOBAL $G_dbpfx; diff --git a/web/Obj/sac-a-push.phh b/web/Obj/sac-a-push.phh index 80db1f4..62eb860 100644 --- a/web/Obj/sac-a-push.phh +++ b/web/Obj/sac-a-push.phh @@ -40,7 +40,7 @@ function global_dump() GLOBAL $G_splash_h, $G_splash_idx, $G_splash_interval, $G_splash_timeout; GLOBAL $G_splash_w, $G_topbanner, $G_with_donors, $G_with_poll; GLOBAL $G_with_splash, $G_sidebanner, $G_sidebanner_idx; - GLOBAL $G_with_topbanner, $G_selfreg_tout; + GLOBAL $G_with_topbanner, $G_selfreg_tout, $G_selfreg_mask; fprintf(STDERR, "G_alarm_passwd = [%s]\n", print_r($G_alarm_passwd, TRUE)); fprintf(STDERR, "G_ban_list = [%s]\n", print_r($G_ban_list, TRUE)); diff --git a/web/index.php b/web/index.php index 162e142..3178264 100644 --- a/web/index.php +++ b/web/index.php @@ -234,9 +234,9 @@ $mlang_room = array( 'userpassuse' => array('it' => 'Il tuo nickname è g 'en' => 'State:'), 'info_guar' => array('it' => 'Garante:', 'en' => 'Guarantee:'), - 'info_match' => array('it' => 'Partite:', + 'info_match' => array('it' => 'Partite:', 'en' => 'Matches:'), - 'info_game' => array('it' => 'Mani:', + 'info_game' => array('it' => 'Mani:', 'en' => 'Hands:'), 'info_frie' => array('it' => 'Conoscenza:', 'en' => 'Friendship:'), @@ -1380,12 +1380,24 @@ type="submit" class="button" onclick="this.form.elements['realsub'].value = 'chi