summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenny Baumann <BenBE@geshi.org>2014-10-28 21:44:05 +0100
committerBenny Baumann <BenBE@geshi.org>2014-10-28 21:44:05 +0100
commit0ffc97cbe1e0c4796022ea69f7dbbb1a8f02336b (patch)
tree087a0e55a08c9c50c0df0741650d66498ac7c97a
parent350a2f0df6d80e2667a7698ffd1fc613229fab54 (diff)
parent20a5109644ca501f8a1e501af37416c8409a5ba8 (diff)
downloadcacert-devel-0ffc97cbe1e0c4796022ea69f7dbbb1a8f02336b.tar.gz
cacert-devel-0ffc97cbe1e0c4796022ea69f7dbbb1a8f02336b.tar.xz
cacert-devel-0ffc97cbe1e0c4796022ea69f7dbbb1a8f02336b.zip
Merge branch 'bug-1316' into testserver-stable
-rw-r--r--includes/notary.inc.php47
-rw-r--r--pages/account/43.php3
2 files changed, 48 insertions, 2 deletions
diff --git a/includes/notary.inc.php b/includes/notary.inc.php
index f8577b7..6486f42 100644
--- a/includes/notary.inc.php
+++ b/includes/notary.inc.php
@@ -2305,3 +2305,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);
+}
diff --git a/pages/account/43.php b/pages/account/43.php
index 4fc67a0..b876330 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']);
}
}
}