summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenny Baumann <BenBE@geshi.org>2014-10-29 08:44:06 +0100
committerBenny Baumann <BenBE@geshi.org>2014-10-29 09:02:45 +0100
commit06bad1b1fcded843b28a5c67b090fde49933fa13 (patch)
tree40f07fc71a06075280c8062ebd877f15df31853f
parentb6266ccd4d4abe39b698e60fc0e7ae3ad4791455 (diff)
downloadcacert-devel-06bad1b1fcded843b28a5c67b090fde49933fa13.tar.gz
cacert-devel-06bad1b1fcded843b28a5c67b090fde49933fa13.tar.xz
cacert-devel-06bad1b1fcded843b28a5c67b090fde49933fa13.zip
bug 1316: Shorten the code even more and make it much more readable
-rw-r--r--includes/notary.inc.php25
1 files changed, 8 insertions, 17 deletions
diff --git a/includes/notary.inc.php b/includes/notary.inc.php
index fbaa6d5..32167f9 100644
--- a/includes/notary.inc.php
+++ b/includes/notary.inc.php
@@ -2141,7 +2141,7 @@ function output_gpg_certs($row, $support=0, $readonly=true){
/**
* revoke_assurance()
- * revokes an assurance and adjusts the old point calculation
+ * revokes an assurance and adjusts the old point calculation
* @param mixed $assuranceid - id of the assurance
* @param mixed $toid - id of the assuree
* @return
@@ -2154,25 +2154,16 @@ function revoke_assurance($assuranceid, $toid){
$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`";
+ $query = "select * from `notary` where `to` = '$toid' and `method` != 'Administrative Increase' and `deleted` = 0 order by `when`";
$res = mysql_query($query);
while($row = mysql_fetch_assoc($res)){
- 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'];
- }
+ $maxToAward = max(100 - $points, 0);
+ $newpoints = min($row['awarded'], $maxToAward);
- if ($points >= 100) {
- break;
- }
+ $points += $row['points'];
+
+ $query = "update `notary` set `points` = '". (int)$newpoints ."' where `id`='" . (int)$row['id'] . "' LIMIT 1";
+ mysql_query($query);
}
fix_assurer_flag($toid);