summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Dörre <felix@dogcraft.de>2015-05-12 22:45:01 +0200
committerFelix Dörre <felix@dogcraft.de>2015-05-12 22:45:01 +0200
commitb47e4b367e4ca0e86cbb314bd51ab82872c50f92 (patch)
treecfbe6a63fc5708ea9367fd6e047c2a0f47616eb0
parent4fa1c66b3a2cb0228b855406dc189019b425b46f (diff)
parente2f72e63808feb0a2380d7e3fea85636b412427d (diff)
downloadcacert-devel-b47e4b367e4ca0e86cbb314bd51ab82872c50f92.tar.gz
cacert-devel-b47e4b367e4ca0e86cbb314bd51ab82872c50f92.tar.xz
cacert-devel-b47e4b367e4ca0e86cbb314bd51ab82872c50f92.zip
Merge branch 'bug-1316' into bug-1050
-rw-r--r--includes/notary.inc.php37
-rw-r--r--pages/account/43.php3
2 files changed, 38 insertions, 2 deletions
diff --git a/includes/notary.inc.php b/includes/notary.inc.php
index da22b4b..af5e781 100644
--- a/includes/notary.inc.php
+++ b/includes/notary.inc.php
@@ -2195,3 +2195,40 @@ function output_gpg_certs($row, $support=0, $readonly=true){
</tr>
<?
}
+
+/**
+ * revoke_assurance()
+ * revokes an assurance and adjusts the old point calculation
+ * @param mixed $assuranceid - id of the assurance
+ * @param mixed $toid - id of the assuree
+ * @return
+ */
+function revoke_assurance($assuranceid, $toid){
+ $assuranceid = intval($assuranceid);
+ $toid = intval($toid);
+ $points = 0;
+
+ $query = "update `notary` set `deleted` = NOW() where `id` = '$assuranceid' LIMIT 1";
+ mysql_query($query);
+ recalculate_old_assurance_points($toid);
+ fix_assurer_flag($toid);
+}
+
+/**
+ * recalculates the old points of an assuree
+ * @param int $toid - id of the assuree
+ */
+function recalculate_old_assurance_points($toid){
+ $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)){
+ $maxToAward = max(100 - $points, 0);
+ $newpoints = min($row['awarded'], $maxToAward);
+
+ $points += $row['awarded'];
+
+ $query = "update `notary` set `points` = '". (int)$newpoints ."' where `id`='" . (int)$row['id'] . "' LIMIT 1";
+ mysql_query($query);
+ }
+
+}
diff --git a/pages/account/43.php b/pages/account/43.php
index c889ce3..7ea782d 100644
--- a/pages/account/43.php
+++ b/pages/account/43.php
@@ -136,8 +136,7 @@ if(intval($_REQUEST['userid']) > 0) {
if ($res) {
$trow = mysql_fetch_assoc($res);
if ($trow) {
- mysql_query("update `notary` set `deleted`=NOW() where `id`='".intval($assurance)."'");
- fix_assurer_flag($trow['to']);
+ revoke_assurance(intval($assurance),$trow['to']);
}
}
}