From: Roland Häder Date: Sun, 21 Dec 2008 04:13:06 +0000 (+0000) Subject: Refill page now books points (unfinished, need redirect!) X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=7a44bb20ca579fb79bba71d65f5f7a834665f80f;p=shipsimu.git Refill page now books points (unfinished, need redirect!) --- diff --git a/.gitattributes b/.gitattributes index 8ab3108..5d5dff6 100644 --- a/.gitattributes +++ b/.gitattributes @@ -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 diff --git a/application/ship-simu/config.php b/application/ship-simu/config.php index 3a33a65..00973d7 100644 --- a/application/ship-simu/config.php +++ b/application/ship-simu/config.php @@ -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 index 0000000..c8733bf --- /dev/null +++ b/application/ship-simu/interfaces/class_BookableAccount.php @@ -0,0 +1,36 @@ + + * @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 . + */ +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] +?> diff --git a/application/ship-simu/main/commands/web/class_WebShipsimuRefillCommand.php b/application/ship-simu/main/commands/web/class_WebShipsimuRefillCommand.php index fb7bd40..fa7aff5 100644 --- a/application/ship-simu/main/commands/web/class_WebShipsimuRefillCommand.php +++ b/application/ship-simu/main/commands/web/class_WebShipsimuRefillCommand.php @@ -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 index 7101a82..0000000 --- a/application/ship-simu/main/filter/book/class_RefillRequestCurrencyBookFilter.php +++ /dev/null @@ -1,65 +0,0 @@ - - * @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 . - */ -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 index 0000000..3a42882 --- /dev/null +++ b/application/ship-simu/main/filter/book/refill/.htaccess @@ -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 index 0000000..f910f41 --- /dev/null +++ b/application/ship-simu/main/filter/book/refill/class_RefillRequestCurrencyTestBookFilter.php @@ -0,0 +1,72 @@ + + * @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 . + */ +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] +?> diff --git a/application/ship-simu/main/user/class_ShipSimuBaseUser.php b/application/ship-simu/main/user/class_ShipSimuBaseUser.php index e12dfdd..87032df 100644 --- a/application/ship-simu/main/user/class_ShipSimuBaseUser.php +++ b/application/ship-simu/main/user/class_ShipSimuBaseUser.php @@ -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); diff --git a/application/ship-simu/main/user/extended/class_ShipSimuMember.php b/application/ship-simu/main/user/extended/class_ShipSimuMember.php index 98e7a2a..ea8132a 100644 --- a/application/ship-simu/main/user/extended/class_ShipSimuMember.php +++ b/application/ship-simu/main/user/extended/class_ShipSimuMember.php @@ -21,7 +21,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -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 *