Show 'my points' in reverse order (newest points count, not oldest ones)
authorroot <root@cacert1.(none)>
Mon, 26 Apr 2010 08:57:00 +0000 (10:57 +0200)
committerMichael Tänzer <neo@nhng.de>
Tue, 30 Nov 2010 20:10:04 +0000 (21:10 +0100)
Needed for revoke of TTP-Assurances in November 2010
(cherry picked from commit 0bee978a0e84aedff45115e3f4e42af152cdfc4d)

pages/wot/10.php

index 51ed019..4a6afac 100644 (file)
     <td class="DataTD"><b><?=_("Method")?></b></td>
   </tr>
 <?
-       $query = "select * from `notary` where `to`='".intval($_SESSION['profile']['id'])."'";
+        $points = 0;
+        $query = "select sum(points) as apoints from `notary` where `from`='".intval($_SESSION['profile']['id'])."' and `from`=`to` ";
+        $res = mysql_query($query);
+       $row = mysql_fetch_assoc($res);
+
+       $maxpoints=intval($_SESSION['profile']['points'])-$row['apoints'];
+
+       $points = 0;
+       $query = "select * from `notary` where `to`='".intval($_SESSION['profile']['id'])."' order by `id` desc ";
        $res = mysql_query($query);
        while($row = mysql_fetch_assoc($res))
        {
+               $awarded = $row['awarded'];
+               if ($points+$awarded > $maxpoints)
+                       $awarded = $maxpoints-$points;
+               $points = $points + $awarded;
                $fromuser = mysql_fetch_assoc(mysql_query("select * from `users` where `id`='".intval($row['from'])."'"));
 ?>
   <tr>
     <td class="DataTD"><?=$row['id']?></td>
     <td class="DataTD"><?=$row['date']?></td>
     <td class="DataTD"><a href="wot.php?id=9&amp;userid=<?=intval($row['from'])?>"><?=$fromuser['fname']." ".$fromuser['lname']?></td>
-    <td class="DataTD"><?=$row['points']?></td>
+    <td class="DataTD"><?=$awarded?></td>
     <td class="DataTD"><?=$row['location']?></td>
     <td class="DataTD"><?=_(sprintf("%s", $row['method']))?></td>
   </tr>
   </tr>
 <?
        $points = 0;
-       $query = "select * from `notary` where `from`='".intval($_SESSION['profile']['id'])."' and `to`!='".intval($_SESSION['profile']['id'])."'";
+       $query = "select * from `notary` where `from`='".intval($_SESSION['profile']['id'])."' and `to`!='".intval($_SESSION['profile']['id'])."' order by `id` desc";
        $res = mysql_query($query);
        while($row = mysql_fetch_assoc($res))
        {
                $fromuser = mysql_fetch_assoc(mysql_query("select * from `users` where `id`='".intval($row['to'])."'"));
-               $points += $row['points'];
+               $points += $row['awarded'];
                $name = trim($fromuser['fname']." ".$fromuser['lname']);
                if($name == "")
                        $name = _("Deleted before Verification");
     <td class="DataTD"><?=intval($row['id'])?></td>
     <td class="DataTD"><?=$row['date']?></td>
     <td class="DataTD"><?=$name?></td>
-    <td class="DataTD"><?=intval($row['points'])?></td>
+    <td class="DataTD"><?=intval($row['awarded'])?></td>
     <td class="DataTD"><?=$row['location']?></td>
     <td class="DataTD"><?=$row['method']==""?"":_(sprintf("%s", $row['method']))?></td>
   </tr>