From: Roland Haeder Date: Fri, 17 Apr 2015 20:09:20 +0000 (+0200) Subject: Added new stuff for founding first city (unfinished). X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=a18210ed2a9311a8828f0b2965a1a5fb9962f38e;p=city.git Added new stuff for founding first city (unfinished). Signed-off-by: Roland Haeder --- diff --git a/application/city/config.php b/application/city/config.php index 66a9390..29ed1ad 100644 --- a/application/city/config.php +++ b/application/city/config.php @@ -89,6 +89,9 @@ $cfg->setConfigEntry('news_reader_login_area_status_problem_class', 'DefaultNews // CFG: NEWS-READER-LOGIN-AREA-CITY-MAP-CLASS $cfg->setConfigEntry('news_reader_login_area_city_map_class', 'DefaultNewsReader'); +// CFG: NEWS-READER-LOGIN-AREA-GOVERNMENT-CLASS +$cfg->setConfigEntry('news_reader_login_area_government_class', 'DefaultNewsReader'); + // CFG: NEWS-HOME-LIMIT $cfg->setConfigEntry('news_home_limit', 10); @@ -224,6 +227,9 @@ $cfg->setConfigEntry('city_government_startup_captcha_class', 'GraphicalCodeCapt // CFG: CITY-GOVERNMENT-TRAINING-CAPTCHA-CLASS $cfg->setConfigEntry('city_government_training_captcha_class', 'GraphicalCodeCaptcha'); +// CFG: CITY-MAP-CAPTCHA-SECURED +$cfg->setConfigEntry('city_map_captcha_secured', 'N'); + // CFG: CAPTCHA-STRING-LENGTH $cfg->setConfigEntry('captcha_string_length', 5); @@ -278,6 +284,9 @@ $cfg->setConfigEntry('birthday_register_verifier_filter', 'BirthdayVerifierFilte // CFG: BIRTHDAY-PROFILE-VERIFIER-FILTER $cfg->setConfigEntry('birthday_profile_verifier_filter', 'BirthdayVerifierFilter'); +// CFG: USER-STATUS-FILTER +$cfg->setConfigEntry('user_status_filter', 'UserStatusVerifierFilter'); + // CFG: CITY-HTML-CMD-DO-FORM-RESOLVER-CLASS $cfg->setConfigEntry('city_html_cmd_do_form_resolver_class', 'HtmlCommandResolver'); @@ -443,6 +452,9 @@ $cfg->setConfigEntry('login_enabled', 'Y'); // CFG: LOGIN-TYPE (username, email, both) $cfg->setConfigEntry('login_type', 'username'); +// CFG: CITY-MANAGER-CLASS +$cfg->setConfigEntry('city_manager_class', 'CityManager'); + /****************************************************************************** * Console client * ******************************************************************************/ diff --git a/application/city/interfaces/manager/.htaccess b/application/city/interfaces/manager/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/interfaces/manager/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/interfaces/manager/city/.htaccess b/application/city/interfaces/manager/city/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/interfaces/manager/city/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/interfaces/manager/city/class_ManageableCity.php b/application/city/interfaces/manager/city/class_ManageableCity.php new file mode 100644 index 0000000..18d5f19 --- /dev/null +++ b/application/city/interfaces/manager/city/class_ManageableCity.php @@ -0,0 +1,34 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2015 City Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.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 ManageableCity extends FrameworkInterface { + /** + * Checks whether the current user has already founded a city + * + * @return $isFounded Whether the current user has already founded a city + */ + function isCityAlreadyFounded (); +} + +// [EOF] +?> diff --git a/application/city/main/actions/html/class_HtmlCityLoginGovernmentAction.php b/application/city/main/actions/html/class_HtmlCityLoginGovernmentAction.php new file mode 100644 index 0000000..4dfbc09 --- /dev/null +++ b/application/city/main/actions/html/class_HtmlCityLoginGovernmentAction.php @@ -0,0 +1,79 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2015 City Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.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 HtmlCityLoginGovernmentAction extends BaseCityAction implements Commandable, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this action + * + * @param $resolverInstance An instance of an action resolver + * @return $actionInstance An instance of this action class + */ + public static final function createHtmlCityLoginGovernmentAction (ActionResolver $resolverInstance) { + // Get a new instance + $actionInstance = new HtmlCityLoginGovernmentAction(); + + // Set the resolver instance + $actionInstance->setResolverInstance($resolverInstance); + + // Return the instance + return $actionInstance; + } + + /** + * Executes the command 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 Maybe add more here? + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Call parent execute method + parent::execute($requestInstance, $responseInstance); + } + + /** + * Adds extra filters to the given controller instance + * + * @param $controllerInstance A controller instance + * @param $requestInstance An instance of a class with an Requestable interface + * @return void + * @todo Add some filters here + */ + public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) { + // Unfinished method + } +} + +// [EOF] +?> diff --git a/application/city/main/commands/html/class_HtmlCityMapCommand.php b/application/city/main/commands/html/class_HtmlCityMapCommand.php new file mode 100644 index 0000000..48a048e --- /dev/null +++ b/application/city/main/commands/html/class_HtmlCityMapCommand.php @@ -0,0 +1,98 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2015 City Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.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 HtmlCityMapCommand extends BaseCommand implements Commandable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this command and sets the resolver instance + * + * @param $resolverInstance An instance of a command resolver + * @return $commandInstance The created command instance + */ + public static final function createHtmlCityMapCommand (CommandResolver $resolverInstance) { + // Get a new instance + $commandInstance = new HtmlCityMapCommand(); + + // Set the resolver instance + $commandInstance->setResolverInstance($resolverInstance); + + // Return the prepared instance + return $commandInstance; + } + + /** + * Executes the command 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 + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // First get a UserRegistration instance + $managerInstance = ObjectFactory::createObjectByConfiguredName('city_manager_class'); + + // First set request and response instance + $managerInstance->setRequestInstance($requestInstance); + $managerInstance->setResponseInstance($responseInstance); + + // Do things before adding city + $managerInstance->doPreAddCity(); + + // Add new city + $managerInstance->addNewCity(); + + // Redirect or login after registration + $managerInstance->doPostAction(); + } + + /** + * Adds extra filters to the given controller instance + * + * @param $controllerInstance A controller instance + * @param $requestInstance An instance of a class with an Requestable interface + * @return void + * @todo Add some more pre/post filters to the controller + */ + public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) { + // Add user auth filter (we don't need an update of the user here because it will be redirected) + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_auth_filter')); + + // Validate user status ('confirmed' no guest) + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_status_filter')); + + // Validate ... + //$controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('email_validator_filter')); + } +} + +// [EOF] +?> diff --git a/application/city/main/controller/html/form/class_CityHtmlDoFormController.php b/application/city/main/controller/html/form/class_CityHtmlDoFormController.php index be5c413..aef6eb5 100644 --- a/application/city/main/controller/html/form/class_CityHtmlDoFormController.php +++ b/application/city/main/controller/html/form/class_CityHtmlDoFormController.php @@ -30,6 +30,11 @@ class CityHtmlDoFormController extends BaseController implements Controller { protected function __construct () { // Call parent constructor parent::__construct(__CLASS__); + + // Init additional filter chains + foreach (array('shutdown') as $filterChain) { + $this->initFilterChain($filterChain); + } // END - foreach } /** diff --git a/application/city/main/database/frontend/city/class_CityInformationDatabaseWrapper.php b/application/city/main/database/frontend/city/class_CityInformationDatabaseWrapper.php index 641e763..0fea306 100644 --- a/application/city/main/database/frontend/city/class_CityInformationDatabaseWrapper.php +++ b/application/city/main/database/frontend/city/class_CityInformationDatabaseWrapper.php @@ -29,6 +29,7 @@ class CityInformationDatabaseWrapper extends BaseDatabaseWrapper implements City const DB_COLUMN_CITY_NR = 'city_nr'; const DB_COLUMN_CITY_ID = 'city_id'; const DB_COLUMN_CITY_MODE = 'city_mode'; + const DB_COLUMN_CITY_NAME = 'city_name'; /** * Protected constructor diff --git a/application/city/main/login/class_CityUserLogin.php b/application/city/main/login/class_CityUserLogin.php index f02a615..0957e71 100644 --- a/application/city/main/login/class_CityUserLogin.php +++ b/application/city/main/login/class_CityUserLogin.php @@ -65,10 +65,6 @@ class CityUserLogin extends BaseFrameworkSystem implements LoginableUser { * @todo user account. */ public function doLogin (Requestable $requestInstance, Responseable $responseInstance) { - // By default no method is selected - $method = null; - $data = ""; - // Get member class $userClass = $this->getConfigInstance()->getConfigEntry('user_class'); @@ -84,10 +80,13 @@ class CityUserLogin extends BaseFrameworkSystem implements LoginableUser { throw new UserPasswordMismatchException(array($this, $userInstance), BaseUser::EXCEPTION_USER_PASS_MISMATCH); } // END - if - // ToDo place + // @TODO What else? + + /* + * Now do the real login. This can be cookie- or session-based login + * which depends on the admins setting then on the user's taste. + */ - // Now do the real login. This can be cookie- or session-based login - // which depends on the admins setting then on the user's taste. // 1) Get a login helper instance $helperInstance = ObjectFactory::createObjectByConfiguredName('login_helper_class', array($requestInstance)); diff --git a/application/city/main/manager/.htaccess b/application/city/main/manager/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/main/manager/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/main/manager/city/.htaccess b/application/city/main/manager/city/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/city/main/manager/city/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/city/main/manager/city/class_CityManager.php b/application/city/main/manager/city/class_CityManager.php new file mode 100644 index 0000000..cc6924c --- /dev/null +++ b/application/city/main/manager/city/class_CityManager.php @@ -0,0 +1,69 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2015 City Developer Team + * @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 CityManager extends BaseFrameworkSystem implements ManageableCity { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $managerInstance An instance of a ManageableCity class + */ + public final static function createCityManager () { + // Get new instance + $managerInstance = new CityManager(); + + // Get database wrapper + $wrapperInstance = ObjectFactory::createObjectByConfiguredName('city_info_db_wrapper_class'); + + // And set it here + $managerInstance->setWrapperInstance($wrapperInstance); + + // Return the prepared instance + return $managerInstance; + } + + /** + * Checks whether the current user has already founded a city + * + * @return $isFounded Whether the current user has already founded a city + */ + public function isCityAlreadyFounded () { + // Default is not found + $isFounded = FALSE; + + // Return result + return $isFounded; + } +} + +// [EOF] +?> diff --git a/application/city/main/manager/class_ b/application/city/main/manager/class_ new file mode 100644 index 0000000..e302a4b --- /dev/null +++ b/application/city/main/manager/class_ @@ -0,0 +1,50 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2015 City Developer Team + * @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 ???Manager extends BaseFrameworkSystem implements Manageable??? { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $managerInstance An instance of a Manageable??? class + */ + public final static function create???Manager () { + // Get new instance + $managerInstance = new ???Manager(); + + // Return the prepared instance + return $managerInstance; + } +} + +// [EOF] +?> diff --git a/application/city/main/manager/class_BaseManager.php b/application/city/main/manager/class_BaseManager.php new file mode 100644 index 0000000..408edef --- /dev/null +++ b/application/city/main/manager/class_BaseManager.php @@ -0,0 +1,38 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2015 City Developer Team + * @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 BaseManager extends BaseCitySystem { + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } +} + +// [EOF] +?> diff --git a/application/city/templates/de/code/action_city_login_city_map.ctp b/application/city/templates/de/code/action_city_login_city_map.ctp new file mode 100644 index 0000000..03db31c --- /dev/null +++ b/application/city/templates/de/code/action_city_login_city_map.ctp @@ -0,0 +1,56 @@ +prefetchValueInstance('user', 'city_manager'); + +// Get manager instance +$managerInstance = ObjectFactory::createObjectByConfiguredName('city_manager_class'); + +// Get user instance +$userInstance = Registry::getRegistry()->getInstance('user'); + +// Is a city already founded? +if ($userInstance->isGuest()) { + // Guests are not allowed to found cities + $helperInstance->addFormNote('guest', "Du musst dich beim Spiel {?app_full_name?} anmelden, dann kannst du erst Städte gründen."); +} elseif (!$managerInstance->isCityAlreadyFounded()) { + // No, then generate form: + // Add group for personal data + $helperInstance->addFormGroup('city_create', "Gründe deine erste Stadt."); + + // Login with user name only + $helperInstance->addFormSubGroup('city_name', "Bitte gebe den Namen der Stadt ein."); + $helperInstance->addFieldText('city_name', "Dein Stadtname:"); + $helperInstance->addInputTextField('city_name'); + + // CAPTCHA enabled? + if ($helperInstance->ifFormSecuredWithCaptcha()) { + $helperInstance->addFormGroup('captcha_user', "Die virtuelle Beantragung von Starthilfe ist durch ein CAPTCHA geschützt. Bitte wiederhole den angezeigten Code, damit du die Starthilfe beantragen kannst."); + $helperInstance->addCaptcha(); + } // END - if + + // Final notices + $helperInstance->addFormGroup('buttons', "Soll so die Stadt angelegt werden?"); + $helperInstance->addInputResetButton("Alles nochmal eingeben"); + $helperInstance->addInputSubmitButton("Stadt anlegen"); + $helperInstance->addFormNote('more_cities', "Du kannst später auch weitere Städte anlegen, fange aber erstmal klein an."); + + // Flush the finished form + $helperInstance->flushContent(); +} else { + // City has already been created +} + +// [EOC] +?> +
+
+ Stadtkarte +
+ +
+ {?city_map?} +
+
diff --git a/db/city_data/.htaccess b/db/city_data/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/db/city_data/.htaccess @@ -0,0 +1 @@ +Deny from all