Registry rewritten, exception added #2
[core.git] / inc / classes / main / points / class_UserPoints.php
index a76cf3ca6fd59f0bd58eded26f1d412a4b677cad..efbd9c82e4f4892636dbc4349499604f47aca967 100644 (file)
@@ -4,7 +4,7 @@
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009, 2010 Core Developer Team
  * @license            GNU GPL 3.0 or any newer version
  * @link               http://www.ship-simu.org
  *
@@ -63,8 +63,11 @@ class UserPoints extends BaseFrameworkSystem implements Registerable, BookablePo
                // Get result back
                $resultInstance = $wrapperInstance->doSelectByCriteria($searchInstance);
 
+               // Advance to first entry by default
+               $resultInstance->next();
+
                // Set it in this instance
-               $pointsInstance->setResultInstance();
+               $pointsInstance->setResultInstance($resultInstance);
 
                // Return instance
                return $pointsInstance;
@@ -103,6 +106,9 @@ class UserPoints extends BaseFrameworkSystem implements Registerable, BookablePo
                // Get the required points entry
                $requiredPoints = $this->getConfigInstance()->getConfigEntry($action . '_action_points');
 
+               // Rewind always
+               $this->getResultInstance()->rewind();
+
                // Do we have an entry?
                if ($this->getResultInstance()->next()) {
                        // Get the entry
@@ -123,6 +129,9 @@ class UserPoints extends BaseFrameworkSystem implements Registerable, BookablePo
         * @return      void
         */
        function bookPointsDirectly ($amount) {
+               // Rewind always
+               $this->getResultInstance()->rewind();
+
                // Do we have an entry?
                if ($this->getResultInstance()->next()) {
                        // Get the entry