summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorINOPIAE <inopiae@cacert.org>2014-10-28 11:27:43 +0100
committerBenny Baumann <BenBE@geshi.org>2014-10-28 21:43:11 +0100
commite9c243beb7bcff2bd3ccf8c10d08b76aa6274228 (patch)
tree4439d3197812a55e81a36ce359431ac8d71b5767
parentfb720bf477205d505c37a47eb29b965a4dcc2b04 (diff)
downloadcacert-devel-e9c243beb7bcff2bd3ccf8c10d08b76aa6274228.tar.gz
cacert-devel-e9c243beb7bcff2bd3ccf8c10d08b76aa6274228.tar.xz
cacert-devel-e9c243beb7bcff2bd3ccf8c10d08b76aa6274228.zip
bug 1316: added new function revoke assurance
-rw-r--r--includes/notary.inc.php47
1 files changed, 47 insertions, 0 deletions
diff --git a/includes/notary.inc.php b/includes/notary.inc.php
index 3b8e736..722308a 100644
--- a/includes/notary.inc.php
+++ b/includes/notary.inc.php
@@ -2138,3 +2138,50 @@ 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 = "select * from `notary` where `id` = '$assuranceid'";
+
+ $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);
+ }
+ }
+ }
+ fix_assurer_flag($toid);
+}