summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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);
+}