+++ /dev/null
-<?php
-/**
- * A class for handling user points which can be real or Internet currency
- *
- * @author Roland Haeder <webmaster@ship-simu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.ship-simu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class UserPoints extends BaseFrameworkSystem implements Registerable {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
-
- // Clean up a little
- $this->removeNumberFormaters();
- $this->removeSystemArray();
- }
-
- /**
- * Creates an instance of this points class
- *
- * @param $userInstance An instance of a user class
- * @return $pointsInstance An instance of this class
- */
- public final static function createUserPoints (ManageableAccount $userInstance) {
- // Get a new instance
- $pointsInstance = new UserPoints();
-
- // Set user instance
- $pointsInstance->setUserInstance($userInstance);
-
- // Return instance
- return $pointsInstance;
- }
-
- /**
- * Checks wether the user has the required amount of points left for the specified action
- *
- * @param $action The action or configuration entry plus prefix the user wants to perform
- * @return $hasRequired Wether the user has the required points
- * @todo Finish loading part of points
- */
- public function ifUserHasRequiredPoints ($action) {
- // Default is that everyone is poor... ;-)
- $hasRequired = false;
-
- // Get the required points entry
- $requiredPoints = $this->getConfigInstance()->readConfig($action . '_action_points');
-
- // Get a wrapper instance
- $wrapperInstance = ObjectFactory::createObjectByConfiguredName('user_points_db_wrapper_class');
-
- // Now get a search criteria and set the user's name as criteria
- $criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
- $criteriaInstance->addCriteria("points_uid", $this->getUserInstance()->getUserName());
- $criteriaInstance->setLimit(1);
-
- // Get result back
- $resultInstance = $wrapperInstance->doSelectByCriteria($criteriaInstance);
-
- // Do we have an entry?
- if ($resultInstance->next()) {
- // @TODO Load points here
- $this->partialStub("Load points here for comparison.");
- } // END - if
-
- // Return the result
- return $hasRequired;
- }
-}
-
-// [EOF]
-?>