bug 1047: removing old points calculation from www/index.php and using the notary...
authorFelix Dörre <felix@dogcraft.de>
Wed, 1 Apr 2015 23:49:37 +0000 (01:49 +0200)
committerFelix Dörre <felix@dogcraft.de>
Tue, 21 Apr 2015 19:32:03 +0000 (21:32 +0200)
includes/notary.inc.php
www/index.php

index 3b8e736..c68e7f2 100644 (file)
@@ -322,6 +322,39 @@ define('THAWTE_REVOCATION_DATETIME', '2010-11-16 00:00:00');
                $rank_of_assuree = get_top_assuree_position($num_of_assurees);
        }
 
+       /**
+        * Helper function to sum all assurance points received by the user
+        * @param int  $userid
+        */
+       function get_received_assurance_points($userid)
+       {
+               $sum_points = 0;
+               $sum_experience = 0;
+               $res = get_received_assurances(intval($userid), $log);
+               while($row = mysql_fetch_assoc($res))
+               {
+                       $fromuser = get_user(intval($row['from']));
+                       calc_assurances($row, $sum_points, $sum_experience);
+               }
+               return $sum_points;
+       }
+
+       /**
+        * Helper function to sum all assurance points received by the user
+        * @param int  $userid
+        */
+       function get_received_experience_points($userid)
+       {
+               $sum_points = 0;
+               $sum_experience = 0;
+               $res = get_received_assurances(intval($userid), $log);
+               while($row = mysql_fetch_assoc($res))
+               {
+                       $fromuser = get_user(intval($row['from']));
+                       calc_assurances($row, $sum_points, $sum_experience);
+               }
+               return $sum_experience;
+       }
 
 // ************* html table definitions ******************
 
@@ -585,7 +618,7 @@ define('THAWTE_REVOCATION_DATETIME', '2010-11-16 00:00:00');
                        $log)
        {
                $sum_points = 0;
-               $sumexperience = 0;
+               $sum_experience = 0;
                $res = get_given_assurances(intval($userid), $log);
                while($row = mysql_fetch_assoc($res))
                {
@@ -615,7 +648,7 @@ define('THAWTE_REVOCATION_DATETIME', '2010-11-16 00:00:00');
                        $log)
        {
                $sum_points = 0;
-               $sumexperience = 0;
+               $sum_experience = 0;
                $res = get_received_assurances(intval($userid), $log);
                while($row = mysql_fetch_assoc($res))
                {
index 8c5560c..6c1eca4 100644 (file)
@@ -210,10 +210,7 @@ require_once('../includes/notary.inc.php');
                                L10n::set_translation($_SESSION['profile']['language']);
                                L10n::init_gettext();
                        }
-                       $query = "select sum(`points`) as `total` from `notary` where `to`='".intval($_SESSION['profile']['id'])."' and `deleted`=0 group by `to`";
-                       $res = mysql_query($query);
-                       $row = mysql_fetch_assoc($res);
-                       $_SESSION['profile']['points'] = $row['total'];
+                       $_SESSION['profile']['points'] = get_received_assurance_points($_SESSION['profile']['id']);
                        $_SESSION['profile']['loggedin'] = 1;
                        if($_SESSION['profile']['Q1'] == "" || $_SESSION['profile']['Q2'] == "" ||
                                $_SESSION['profile']['Q3'] == "" || $_SESSION['profile']['Q4'] == "" ||