add widefriend and narrowfriend exposition to client (wip)
authorMatteo Nastasi (mop) <nastasi@alternativeoutput.it>
Thu, 10 Dec 2015 06:42:31 +0000 (07:42 +0100)
committerMatteo Nastasi (mop) <nastasi@alternativeoutput.it>
Thu, 10 Dec 2015 06:42:31 +0000 (07:42 +0100)
web/Obj/brisk.phh
web/Obj/dbase_base.phh
web/Obj/dbase_pgsql.phh
web/Obj/sac-a-push.phh
web/index.php
web/room.css

index d543267..0c1e5c9 100644 (file)
@@ -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;
index dddd592..85d9315 100644 (file)
@@ -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);
     }
index 911b2b6..91ca210 100644 (file)
@@ -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;
index 80db1f4..62eb860 100644 (file)
@@ -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));
index 162e142..3178264 100644 (file)
@@ -234,9 +234,9 @@ $mlang_room = array( 'userpassuse'  => array('it' => 'Il tuo nickname &egrave; g
                                           'en' => 'State:'),
                      'info_guar' => array('it' => 'Garante:',
                                           'en' => 'Guarantee:'),
-                     'info_match' => array('it' => 'Partite:',
+                     'info_match' => array('it' => '<span title="Partite giocate ai tavoli riservati.">Partite:</span>',
                                            'en' => 'Matches:'),
-                     'info_game' => array('it' => 'Mani:',
+                     'info_game' => array('it' => '<span title="Mani giocate ai tavoli riservati.">Mani:</span>',
                                           'en' => 'Hands:'),
                      'info_frie' => array('it' => 'Conoscenza:',
                                           'en' => 'Friendship:'),
@@ -1380,12 +1380,24 @@ type="submit" class="button" onclick="this.form.elements['realsub'].value = 'chi
 
 <div id="info" class="notify" style="z-index: 200; width: 400px; margin-left: -200px; height: 340px; top: 150px; visibility: hidden;">
 <table class="info">
-<tr><td class="le"><b><?php echo $mlang_room['info_login'][$G_lang]; ?></b></td><td class="ri"><span class="login_id"></span></td></tr>
-<tr><td class="le"><b><?php echo $mlang_room['info_state'][$G_lang]; ?></b></td><td class="ri"><span class="state_id"></span></td></tr>
-<tr><td class="le"><b><?php echo $mlang_room['info_guar'][$G_lang]; ?></b></td><td class="ri"><span class="guar_id"></span></td></tr>
-<tr><td class="le"><b><?php echo $mlang_room['info_match'][$G_lang]; ?></b></td><td class="ri"><span class="match_id"></span></td></tr>
-<tr><td class="le"><b><?php echo $mlang_room['info_game'][$G_lang]; ?></b></td><td class="ri"><span class="game_id"></span></td></tr>
-<tr><td colspan="2" style="background-color: pink;">di seguito le opzioni che verranno attivate successivamente:</td></tr>
+<tr><td><b><?php echo $mlang_room['info_login'][$G_lang]; ?></b></td><td class="ri"><span class="login_id"></span></td>
+<td><b><?php echo $mlang_room['info_state'][$G_lang]; ?></b></td><td class="ri"><span class="state_id"></span></td></tr>
+<tr><td><b><?php echo $mlang_room['info_guar'][$G_lang]; ?></b></td><td class="ri"><span class="guar_id"></span></td><td></td><td></td></tr>
+<tr><td><b><?php echo $mlang_room['info_match'][$G_lang]; ?></b></td><td class="ri"><span class="match_id"></span></td>
+<td><b><?php echo $mlang_room['info_game'][$G_lang]; ?></b></td><td class="ri"><span class="game_id"></span></td></tr>
+<tr><td colspan="4"><b>Cosa ne pensano gli amici.</b></td></tr>
+
+<tr><td class="le info-opt">Da evitare:<span class="frie_black"></span></td>
+<td class="le info-opt">In prova:<span class="frie_test"></span></td>
+<td class="le info-opt">Amico:<span class="frie_friend"></span></td>
+<td class="le info-opt">Amico fidato:<span class="frie_bff"></span></td></tr>
+
+<tr><td colspan="4"><b>Cosa ne pensano gli amici fidati:</b></td></tr>
+<tr><td class="le info-opt">Da evitare:<span class="frie_black"></span></td>
+<td class="le info-opt">In prova:<span class="frie_test"></span></td>
+<td class="le info-opt">Amico:<span class="frie_friend"></span></td>
+<td class="le info-opt">Amico fidato:<span class="frie_bff"></span></td></tr>
+<!-- 
 <tr><td class="le ri" colspan="2"><b><?php echo $mlang_room['info_frie'][$G_lang]; ?></b></td></tr>
 <tr><td class="le info-opt"><input type="radio" name="friend" class="friend_id" value="black">Da evitare</td>
     <td class="ri info-opt"><input type="radio" name="friend" class="friend_id" value="friend">Amico</td></tr>
@@ -1422,6 +1434,8 @@ type="submit" class="button" onclick="this.form.elements['realsub'].value = 'chi
        </tr>
     </table>
 </td></tr>
+-->
+<tr><td colspan="4" style="background-color: pink;">di seguito le opzioni che verranno attivate successivamente:</td></tr>
 </table>
 <div style="position: absolute; bottom: 8px; margin: auto; width: 100%;">
 <input type="submit" class="input_sub" style="bottom: 4px;" onclick="$('info').style.visibility = 'hidden';" value="<?php echo $mlang_room['btn_close'][$G_lang]; ?>"/>
index ab78151..5eef67e 100644 (file)
@@ -511,7 +511,7 @@ table.info {
 table.info td {
     border-top: 1px solid grey;
     padding: 4px;
-    width: 50%;
+    width: 25%;
 }