A new Assurer has to be selected for every single assurance
authorMichael Tänzer <neo@nhng.de>
Thu, 29 Apr 2010 19:21:47 +0000 (21:21 +0200)
committerMichael Tänzer <neo@nhng.de>
Thu, 29 Apr 2010 19:21:47 +0000 (21:21 +0200)
Signed-off-by: Michael Tänzer <neo@nhng.de>
manager/application/controllers/AddPointsController.php

index 86557f3..891ee5d 100644 (file)
@@ -57,10 +57,6 @@ class AddPointsController extends Zend_Controller_Action
         $user['id'] = $row['id'];
         
         
-        // Get the first assurer who didn't already assure the user
-        $assurer = $this->getNewAssurer($user['id']);
-        
-        
         // Get current points of the user
         $query = 'select sum(`points`) as `total` from `notary` where `to` = :user';
         $query_params['user'] = $user['id'];
@@ -71,7 +67,6 @@ class AddPointsController extends Zend_Controller_Action
         
         // Do the actual assurances
         $assurance = array(); // Make sure the array is empty
-        $assurance['from'] = $assurer;
         $assurance['to'] = $user['id'];
         $assurance['location'] = $values['location'];
         $assurance['date'] = $values['date'];
@@ -89,6 +84,9 @@ class AddPointsController extends Zend_Controller_Action
                 $quantity = 0;
             }
             
+            // Get the assurer for this assurance
+            $assurance['from'] = $this->getNewAssurer($user['id']);
+            
             // only assign points whithin the limit
             if ($user['points'] + $assurance['awarded'] > self::MAX_ASSURANCE_POINTS){
                 $assurance['points'] = self::MAX_ASSURANCE_POINTS - $user['points'];