summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenny Baumann <BenBE@geshi.org>2014-10-29 09:03:06 +0100
committerBenny Baumann <BenBE@geshi.org>2014-10-29 09:03:06 +0100
commit52dfc5b3a270bc14f8ffa0710815695e447274b7 (patch)
tree509c8439b86c939f6a7d561ece92c50926ebf838
parent8190047643b449c3ce6f85516aec73f9da3a9468 (diff)
parent06bad1b1fcded843b28a5c67b090fde49933fa13 (diff)
downloadcacert-devel-52dfc5b3a270bc14f8ffa0710815695e447274b7.tar.gz
cacert-devel-52dfc5b3a270bc14f8ffa0710815695e447274b7.tar.xz
cacert-devel-52dfc5b3a270bc14f8ffa0710815695e447274b7.zip
Merge branch 'bug-1316' into testserver-stable
-rw-r--r--includes/notary.inc.php37
1 files changed, 10 insertions, 27 deletions
diff --git a/includes/notary.inc.php b/includes/notary.inc.php
index 6486f42..b95214c 100644
--- a/includes/notary.inc.php
+++ b/includes/notary.inc.php
@@ -2308,7 +2308,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
@@ -2318,37 +2318,20 @@ 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 `method` != 'Administrative Increase' and `deleted` = 0 order by `when`";
$res = mysql_query($query);
while($row = mysql_fetch_assoc($res)){
- $points = $row['points'];
- }
+ $maxToAward = max(100 - $points, 0);
+ $newpoints = min($row['awarded'], $maxToAward);
- $query = "update `notary` set `deleted` = NOW() where `id` = '$assuranceid'";
- mysql_query($query);
+ $points += $row['points'];
- 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);
- }
- }
+ $query = "update `notary` set `points` = '". (int)$newpoints ."' where `id`='" . (int)$row['id'] . "' LIMIT 1";
+ mysql_query($query);
}
+
fix_assurer_flag($toid);
}