]> git.mxchange.org Git - city.git/commitdiff
Added new stuff for founding first city (unfinished).
authorRoland Haeder <roland@mxchange.org>
Fri, 17 Apr 2015 20:09:20 +0000 (22:09 +0200)
committerRoland Haeder <roland@mxchange.org>
Fri, 17 Apr 2015 20:09:20 +0000 (22:09 +0200)
Signed-off-by: Roland Haeder <roland@mxchange.org>
16 files changed:
application/city/config.php
application/city/interfaces/manager/.htaccess [new file with mode: 0644]
application/city/interfaces/manager/city/.htaccess [new file with mode: 0644]
application/city/interfaces/manager/city/class_ManageableCity.php [new file with mode: 0644]
application/city/main/actions/html/class_HtmlCityLoginGovernmentAction.php [new file with mode: 0644]
application/city/main/commands/html/class_HtmlCityMapCommand.php [new file with mode: 0644]
application/city/main/controller/html/form/class_CityHtmlDoFormController.php
application/city/main/database/frontend/city/class_CityInformationDatabaseWrapper.php
application/city/main/login/class_CityUserLogin.php
application/city/main/manager/.htaccess [new file with mode: 0644]
application/city/main/manager/city/.htaccess [new file with mode: 0644]
application/city/main/manager/city/class_CityManager.php [new file with mode: 0644]
application/city/main/manager/class_ [new file with mode: 0644]
application/city/main/manager/class_BaseManager.php [new file with mode: 0644]
application/city/templates/de/code/action_city_login_city_map.ctp [new file with mode: 0644]
db/city_data/.htaccess [new file with mode: 0644]

index 66a93902a16763212751d55108b7176193dca972..29ed1ad6f57a96a7fb616e556d87cc1e2c1daf24 100644 (file)
@@ -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 (file)
index 0000000..3a42882
--- /dev/null
@@ -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 (file)
index 0000000..3a42882
--- /dev/null
@@ -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 (file)
index 0000000..18d5f19
--- /dev/null
@@ -0,0 +1,34 @@
+<?php
+/**
+ * An interface city manager
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+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 (file)
index 0000000..4dfbc09
--- /dev/null
@@ -0,0 +1,79 @@
+<?php
+/**
+ * An action for the government page
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+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 (file)
index 0000000..48a048e
--- /dev/null
@@ -0,0 +1,98 @@
+<?php
+/**
+ * A command for adding cities
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+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]
+?>
index be5c413177307feb22331b49153d59c0e883eb94..aef6eb51248295837374ad0ab57b2442cdedccd1 100644 (file)
@@ -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
        }
 
        /**
index 641e763d88bdbe1212ae7ddf7b3285986632a1f1..0fea306d70038218a75b01222e92ee88bbf0d671 100644 (file)
@@ -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
index f02a615ee1e79e605c69159dc5e3b4ae3a415b72..0957e71784161bb643b8eecf4e332a54c1b69901 100644 (file)
@@ -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 (file)
index 0000000..3a42882
--- /dev/null
@@ -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 (file)
index 0000000..3a42882
--- /dev/null
@@ -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 (file)
index 0000000..cc6924c
--- /dev/null
@@ -0,0 +1,69 @@
+<?php
+/**
+ * A City manager
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+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 (file)
index 0000000..e302a4b
--- /dev/null
@@ -0,0 +1,50 @@
+<?php
+/**
+ * A ??? manager
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+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 (file)
index 0000000..408edef
--- /dev/null
@@ -0,0 +1,38 @@
+<?php
+/**
+ * A general Manager class
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+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 (file)
index 0000000..03db31c
--- /dev/null
@@ -0,0 +1,56 @@
+<?php
+// Get form helper instance
+$helperInstance = ObjectFactory::createObjectByConfiguredName('html_form_helper_class', array($this, 'city_map'));
+
+// Prefetch user instance
+$helperInstance->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&auml;dte gr&uuml;nden.");
+} elseif (!$managerInstance->isCityAlreadyFounded()) {
+       // No, then generate form:
+       // Add group for personal data
+       $helperInstance->addFormGroup('city_create', "Gr&uuml;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&uuml;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&auml;ter auch weitere St&auml;dte anlegen, fange aber erstmal klein an.");
+
+       // Flush the finished form
+       $helperInstance->flushContent();
+} else {
+       // City has already been created
+}
+
+// [EOC]
+?>
+<div id="government_frame">
+       <div id="government_header">
+               Stadtkarte
+       </div>
+
+       <div id="government_form">
+               {?city_map?}
+       </div>
+</div>
diff --git a/db/city_data/.htaccess b/db/city_data/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all