summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Tänzer <neo@nhng.de>2014-04-22 00:17:12 +0200
committerMichael Tänzer <neo@nhng.de>2014-04-22 00:17:12 +0200
commitbb16f087e8921f9fc9b247791810f3e70a84daac (patch)
tree2affb903bea8306abb1bf928640e6e9aa1c86a30
parenta5876e5a860e0e855b5e8a0e3895af7d8b891224 (diff)
downloadcacert-devel-bb16f087e8921f9fc9b247791810f3e70a84daac.tar.gz
cacert-devel-bb16f087e8921f9fc9b247791810f3e70a84daac.tar.xz
cacert-devel-bb16f087e8921f9fc9b247791810f3e70a84daac.zip
bug 1221: Put the assurance method independent logic in one place
Signed-off-by: Michael Tänzer <neo@nhng.de>
-rw-r--r--includes/notary.inc.php15
1 files changed, 8 insertions, 7 deletions
diff --git a/includes/notary.inc.php b/includes/notary.inc.php
index a8ec208..49dc09d 100644
--- a/includes/notary.inc.php
+++ b/includes/notary.inc.php
@@ -124,11 +124,13 @@
*/
function calc_awarded($row)
{
- $awarded = intval($row['awarded']);
- if (intval($row['points']) < $awarded)
- $points = $awarded; // if 'sum of added points' > 100, awarded shows correct value
- else
- $points = intval($row['points']); // on very old assurances, awarded is '0' instead of correct value
+ // Back in the old days there was no `awarded` column => is now zero,
+ // there the `points` column contained that data
+ $points = max(intval($row['awarded']), intval($row['points']));
+
+ // Set negative points to zero, yes there are such things in the database
+ $points = max($points, 0);
+
switch ($row['method'])
{
case 'Thawte Points Transfer': // revoke all Thawte-points (as per arbitration)
@@ -150,8 +152,7 @@
default: // should never happen ... ;-)
$points = 0;
}
- if ($points < 0) // ignore negative points (bug needs to be fixed)
- $points = 0;
+
return $points;
}