summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorINOPIAE <inopiae@cacert.org>2014-10-28 22:46:17 +0100
committerBenny Baumann <BenBE@geshi.org>2014-10-29 08:34:57 +0100
commitb6266ccd4d4abe39b698e60fc0e7ae3ad4791455 (patch)
treec255579314cdcc15b5b4ddae03ec069f819d79fb
parent20a5109644ca501f8a1e501af37416c8409a5ba8 (diff)
downloadcacert-devel-b6266ccd4d4abe39b698e60fc0e7ae3ad4791455.tar.gz
cacert-devel-b6266ccd4d4abe39b698e60fc0e7ae3ad4791455.tar.xz
cacert-devel-b6266ccd4d4abe39b698e60fc0e7ae3ad4791455.zip
bug 1316: rework on calculation
-rw-r--r--includes/notary.inc.php44
1 files changed, 18 insertions, 26 deletions
diff --git a/includes/notary.inc.php b/includes/notary.inc.php
index 722308a..fbaa6d5 100644
--- a/includes/notary.inc.php
+++ b/includes/notary.inc.php
@@ -2151,37 +2151,29 @@ function revoke_assurance($assuranceid, $toid){
$toid = intval($toid);
$points = 0;
- $query = "select * from `notary` where `id` = '$assuranceid'";
+ $query = "update `notary` set `deleted` = NOW() where `id` = '$assuranceid' LIMIT 1";
+ mysql_query($query);
+ $query = "select * from `notary` where `to` = '$toid' and `deleted` = 0 order by `when`";
$res = mysql_query($query);
while($row = mysql_fetch_assoc($res)){
- $points = $row['points'];
- }
-
- $query = "update `notary` set `deleted` = NOW() where `id` = '$assuranceid'";
- mysql_query($query);
-
- if ($points > 0) {
- $query = "select * from `notary` where `to` = '$toid' order by `when`";
- $res = mysql_query($query);
- while($row = mysql_fetch_assoc($res)){
- if ($points == 0) {
- break;
- }
- $diff = 0;
- if ($row['points'] < $row['awarded']) {
- $diff = $row['awarded'] - $row['points'];
- if ($diff <= $points) {
- $newpoints = $diff + $row['points'];
- $points -= $diff;
- } else {
- $newpoints = $points + $row['points'];
- $points = 0 ;
- }
- $query = "update `notary` set `points` = $newpoints where `id`='" . $row['id'] ."'";
- mysql_query($query);
+ if ($row['points'] < $row['awarded'] and $points < 100) {
+ if ($row['awarded'] + $points < 100) {
+ $newpoints = $row['awarded'];
+ } else {
+ $newpoints = 100 -$points;
}
+ $points += $newpoints;
+ $query = "update `notary` set `points` = $newpoints where `id`='" . $row['id'] ."' LIMIT 1";
+ mysql_query($query);
+ } else {
+ $points += $row['points'];
+ }
+
+ if ($points >= 100) {
+ break;
}
}
+
fix_assurer_flag($toid);
}