Refill page now books points (unfinished, need redirect!)
authorRoland Häder <roland@mxchange.org>
Sun, 21 Dec 2008 04:13:06 +0000 (04:13 +0000)
committerRoland Häder <roland@mxchange.org>
Sun, 21 Dec 2008 04:13:06 +0000 (04:13 +0000)
.gitattributes
application/ship-simu/config.php
application/ship-simu/interfaces/class_BookableAccount.php [new file with mode: 0644]
application/ship-simu/main/commands/web/class_WebShipsimuRefillCommand.php
application/ship-simu/main/filter/book/class_RefillRequestCurrencyBookFilter.php [deleted file]
application/ship-simu/main/filter/book/refill/.htaccess [new file with mode: 0644]
application/ship-simu/main/filter/book/refill/class_RefillRequestCurrencyTestBookFilter.php [new file with mode: 0644]
application/ship-simu/main/user/class_ShipSimuBaseUser.php
application/ship-simu/main/user/extended/class_ShipSimuMember.php

index 8ab3108ef551ce66a84566bcf4574fce4fa16648..5d5dff67d6aacb3b5d12290776c678469fc550b3 100644 (file)
@@ -51,6 +51,7 @@ application/ship-simu/exceptions/class_UnsupportedLimitationPartException.php -t
 application/ship-simu/exceptions/class_WrongGenderSpecifiedException.php -text
 application/ship-simu/init.php -text
 application/ship-simu/interfaces/.htaccess -text
+application/ship-simu/interfaces/class_BookableAccount.php -text
 application/ship-simu/interfaces/class_ConstructableShip.php -text
 application/ship-simu/interfaces/class_ConstructableShipPart.php -text
 application/ship-simu/interfaces/class_ContractPartner.php -text
@@ -117,7 +118,8 @@ application/ship-simu/main/factories/.htaccess -text
 application/ship-simu/main/factories/class_ShipSimuWebNewsFactory.php -text
 application/ship-simu/main/filter/.htaccess -text
 application/ship-simu/main/filter/book/.htaccess -text
-application/ship-simu/main/filter/book/class_RefillRequestCurrencyBookFilter.php -text
+application/ship-simu/main/filter/book/refill/.htaccess -text
+application/ship-simu/main/filter/book/refill/class_RefillRequestCurrencyTestBookFilter.php -text
 application/ship-simu/main/filter/class_ -text
 application/ship-simu/main/filter/class_BaseShipSimuFilter.php -text
 application/ship-simu/main/filter/government/.htaccess -text
index 3a33a658b8db4a9bac8ade2a5004f6ae3b128f23..00973d7769efce22fb6f8e0c63ad1dc25069291c 100644 (file)
@@ -209,7 +209,7 @@ $cfg->setConfigEntry('birthday_profile_verifier_filter', "BirthdayVerifierFilter
 $cfg->setConfigEntry('refill_page_filter', "RefillPageFilter");
 
 // CFG: REFILL-REQUEST-CURRENCY-BOOK-FILTER
-$cfg->setConfigEntry('refill_request_currency_book_filter', "RefillRequestCurrencyBookFilter");
+$cfg->setConfigEntry('refill_request_currency_test_book_filter', "RefillRequestCurrencyTestBookFilter");
 
 // CFG: PAYMENT-DISCOVERY-FILTER
 $cfg->setConfigEntry('payment_discovery_filter', "PaymentDiscoveryFilter");
@@ -362,7 +362,7 @@ $cfg->setConfigEntry('found_new_company_action_points', 1000000);
 $cfg->setConfigEntry('write_applications_action_points', 10000);
 
 // CFG: USER-POINTS-CLASS
-$cfg->setConfigEntry('user_ppints_class', "UserPoints");
+$cfg->setConfigEntry('user_points_class', "UserPoints");
 
 // CFG: GOVERNMENT-CLASS
 $cfg->setConfigEntry('government_class', "SimplifiedGovernment");
@@ -394,5 +394,8 @@ $cfg->setConfigEntry('web_link_helper', "WebLinkHelper");
 // CFG: WEB-CMD-GOVERNMENT-FAILED-RESOLVER-CLASS
 $cfg->setConfigEntry('web_cmd_government_failed_resolver_class', "WebGovernmentFailedCommandResolver");
 
+// CFG: REFILL-REQUEST-CURRENCY-PAYMENT-TYPE
+$cfg->setConfigEntry('refill_request_currency_payment_type', "test");
+
 // [EOF]
 ?>
diff --git a/application/ship-simu/interfaces/class_BookableAccount.php b/application/ship-simu/interfaces/class_BookableAccount.php
new file mode 100644 (file)
index 0000000..c8733bf
--- /dev/null
@@ -0,0 +1,36 @@
+<?php
+/**
+ * An interface for bookable user accounts
+ *
+ * @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/>.
+ */
+interface BookableAccount extends FrameworkInterface {
+       /**
+        * Books the given 'amount' in the request instance on the users "points
+        * account"
+        *
+        * @param       $requestInstance        An instance of a Requestable class
+        * @return      void
+        */
+       function bookAmountDirectly (Requestable $requestInstance);
+}
+
+// [EOF]
+?>
index fb7bd40c8e71a3d88bf94ad467573bbdf7b64fa5..fa7aff5322642ec7f0e8db382426c9709d896b04 100644 (file)
@@ -91,8 +91,14 @@ class WebShipsimuRefillCommand extends BaseCommand implements Commandable {
                // Verify refill request
                $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('refill_request_validator_filter'));
 
+               // Construct config entry for wether automatic payment from API or waiting for approval
+               $paymentTypeConfig = sprintf("refill_request_%s_payment_type", $requestInstance->getRequestElement('type'));
+
                // Prepare a filter based on the requested type we shall refill
-               $filterName = sprintf("refill_request_%s_book_filter", $requestInstance->getRequestElement('type'));
+               $filterName = sprintf("refill_request_%s_%s_book_filter",
+                       $requestInstance->getRequestElement('type'),
+                       $this->getConfigInstance()->readConfig($paymentTypeConfig)
+               );
 
                // Now, try to load that filter
                $controllerInstance->addPostFilter(ObjectFactory::createObjectByConfiguredName($filterName));
diff --git a/application/ship-simu/main/filter/book/class_RefillRequestCurrencyBookFilter.php b/application/ship-simu/main/filter/book/class_RefillRequestCurrencyBookFilter.php
deleted file mode 100644 (file)
index 7101a82..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-<?php
-/**
- * A filter for currency booking in refill requests
- *
- * @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 RefillRequestCurrencyBookFilter extends BaseShipSimuFilter implements Filterable {
-       /**
-        * Protected constructor
-        *
-        * @return      void
-        */
-       protected function __construct () {
-               // Call parent constructor
-               parent::__construct(__CLASS__);
-       }
-
-       /**
-        * Creates an instance of this filter class
-        *
-        * @return      $filterInstance         An instance of this filter class
-        */
-       public final static function createRefillRequestCurrencyBookFilter () {
-               // Get a new instance
-               $filterInstance = new RefillRequestCurrencyBookFilter();
-
-               // Return the instance
-               return $filterInstance;
-       }
-
-       /**
-        * Executes the filter with given request and response objects
-        *
-        * @param       $requestInstance        An instance of a class with an Requestable interface
-        * @param       $responseInstance       An instance of a class with an Responseable interface
-        * @return      void
-        * @todo        Add code being executed in this filter
-        */
-       public function execute (Requestable $requestInstance, Responseable $responseInstance) {
-               // Execute the parent execute method
-               parent::execute($requestInstance, $responseInstance);
-
-               $this->partialStub("Add code here for your specific filter.");
-       }
-}
-
-// [EOF]
-?>
diff --git a/application/ship-simu/main/filter/book/refill/.htaccess b/application/ship-simu/main/filter/book/refill/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/ship-simu/main/filter/book/refill/class_RefillRequestCurrencyTestBookFilter.php b/application/ship-simu/main/filter/book/refill/class_RefillRequestCurrencyTestBookFilter.php
new file mode 100644 (file)
index 0000000..f910f41
--- /dev/null
@@ -0,0 +1,72 @@
+<?php
+/**
+ * A filter for currency booking in refill requests. This filter shall "book" the
+ * requested amount of points directly on the users account. This filter is for
+ * testing/developing only and was needed for the first developement stage of the
+ * game. You should not really use this filter on your "live-system".
+ *
+ * @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 RefillRequestCurrencyTestBookFilter extends BaseShipSimuFilter implements Filterable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this filter class
+        *
+        * @return      $filterInstance         An instance of this filter class
+        */
+       public final static function createRefillRequestCurrencyTestBookFilter () {
+               // Get a new instance
+               $filterInstance = new RefillRequestCurrencyTestBookFilter();
+
+               // Return the instance
+               return $filterInstance;
+       }
+
+       /**
+        * Executes the filter with given request and response objects
+        *
+        * @param       $requestInstance        An instance of a class with an Requestable interface
+        * @param       $responseInstance       An instance of a class with an Responseable interface
+        * @return      void
+        * @todo        Add code being executed in this filter
+        */
+       public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+               // Execute the parent execute method
+               parent::execute($requestInstance, $responseInstance);
+
+               // Get the user instance from registry
+               $userInstance = Registry::getRegistry()->getInstance('user');
+
+               // Run the update
+               $userInstance->bookAmountDirectly($requestInstance);
+       }
+}
+
+// [EOF]
+?>
index e12dfddadfc0a050c575bab4bddcd7ba12ee47ef..87032dfcd0f2d978129265064fbbc271d8287d16 100644 (file)
@@ -76,7 +76,7 @@ class ShipSimuBaseUser extends BaseUser implements Registerable, Updateable {
                // Is there an instance?
                if (is_null($pointsInstance)) {
                        // Then create one
-                       $pointsInstance = ObjectFactory::createObjectByConfiguredName('user_ppints_class', array($this));
+                       $pointsInstance = ObjectFactory::createObjectByConfiguredName('user_points_class', array($this));
 
                        // And store it in registry
                        Registry::getRegistry()->addInstance('points', $pointsInstance);
index 98e7a2a5976168cd04757126bd56e8386a8a3f0f..ea8132a01a1766491560607acc54fe82d947241c 100644 (file)
@@ -21,7 +21,7 @@
  * 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 ShipSimuMember extends ShipSimuBaseUser implements ManageableMember {
+class ShipSimuMember extends ShipSimuBaseUser implements ManageableMember, BookableAccount {
        /**
         * Protected constructor
         *
@@ -151,10 +151,40 @@ class ShipSimuMember extends ShipSimuBaseUser implements ManageableMember {
                // Add the search criteria for searching for the right entry
                $updateInstance->setSearchInstance($searchInstance);
 
+               // Set wrapper class name
+               $updateInstance->setWrapperConfigEntry('user_db_wrapper_class');
+
                // Remember the update in database result
                $this->getResultInstance()->add2UpdateQueue($updateInstance);
        }
 
+       /**
+        * Books the given 'amount' in the request instance on the users "points
+        * account"
+        *
+        * @param       $requestInstance        An instance of a Requestable class
+        * @return      void
+        */
+       public function bookAmountDirectly (Requestable $requestInstance) {
+               // Get the points class from registry
+               $pointsInstance = Registry::getRegistry()->getInstance('points');
+
+               // Is the points instance null?
+               if (is_null($pointsInstance)) {
+                       // Then get a new one
+                       $pointsInstance = ObjectFactory::createObjectByConfiguredName('user_points_class', array($this));
+
+                       // And store it in registry
+                       Registry::getRegistry()->addInstance('points', $pointsInstance);
+               } // END - if
+
+               // Get the amount
+               $amount = $requestInstance->getRequestElement('amount');
+
+               // Call the method for booking points
+               $pointsInstance->bookPointsDirectly($amount);
+       }
+
        /**
         * Flushs all pending updates to the database layer
         *