// 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);
// 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);
// 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');
// CFG: LOGIN-TYPE (username, email, both)
$cfg->setConfigEntry('login_type', 'username');
+// CFG: CITY-MANAGER-CLASS
+$cfg->setConfigEntry('city_manager_class', 'CityManager');
+
/******************************************************************************
* Console client *
******************************************************************************/
--- /dev/null
+Deny from all
--- /dev/null
+Deny from all
--- /dev/null
+<?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]
+?>
--- /dev/null
+<?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]
+?>
--- /dev/null
+<?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]
+?>
protected function __construct () {
// Call parent constructor
parent::__construct(__CLASS__);
+
+ // Init additional filter chains
+ foreach (array('shutdown') as $filterChain) {
+ $this->initFilterChain($filterChain);
+ } // END - foreach
}
/**
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
* @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');
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));
--- /dev/null
+Deny from all
--- /dev/null
+Deny from all
--- /dev/null
+<?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]
+?>
--- /dev/null
+<?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]
+?>
--- /dev/null
+<?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]
+?>
--- /dev/null
+<?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ä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]
+?>
+<div id="government_frame">
+ <div id="government_header">
+ Stadtkarte
+ </div>
+
+ <div id="government_form">
+ {?city_map?}
+ </div>
+</div>
--- /dev/null
+Deny from all