From 4c853fd49e21d5d3ae7a3c0c2822c788643375c7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Thu, 13 Nov 2008 20:32:23 +0000 Subject: [PATCH] Again, a commit! ;-) - Maximum count of startup helps the goverment is willing to pay added - User id partly added (stub message) - Some other minor rewrites --- .gitattributes | 3 +- application/ship-simu/config.php | 3 + .../class_RefillRequestValidatorFilter.php | 4 +- .../goverment/class_SimplifiedGoverment.php | 43 ++++- .../main/user/class_ShipSimuBaseUser.php | 47 ++++- .../main/user/class_ShipSimuGuest.php | 111 ----------- .../main/user/class_ShipSimuMember.php | 178 ------------------ .../user/extended/class_ShipSimuMember.php | 6 + .../code/action_ship_simu_login_company.ctp | 13 +- ...ship_simu_login_goverment_startup_help.ctp | 20 ++ .../main/class_GetterNotFoundException.php | 5 +- .../databases/class_LocalFileDatabase.php | 23 ++- .../wrapper/class_UserDatabaseWrapper.php | 1 + .../filter/change/class_EmailChangeFilter.php | 9 +- inc/classes/main/user/class_BaseUser.php | 48 ++++- tests/old/contract-test.php | 128 ++++++------- tests/old/loader-test.php | 52 ++--- tests/old/personell-test.php | 52 ++--- 18 files changed, 296 insertions(+), 450 deletions(-) delete mode 100644 application/ship-simu/main/user/class_ShipSimuGuest.php delete mode 100644 application/ship-simu/main/user/class_ShipSimuMember.php create mode 100644 application/ship-simu/templates/de/code/action_ship_simu_login_goverment_startup_help.ctp diff --git a/.gitattributes b/.gitattributes index 0850929..57f3ab7 100644 --- a/.gitattributes +++ b/.gitattributes @@ -251,8 +251,6 @@ application/ship-simu/main/structures/extended/upper/.htaccess -text application/ship-simu/main/structures/extended/upper/class_Bridge.php -text application/ship-simu/main/user/.htaccess -text application/ship-simu/main/user/class_ShipSimuBaseUser.php -text -application/ship-simu/main/user/class_ShipSimuGuest.php -text -application/ship-simu/main/user/class_ShipSimuMember.php -text application/ship-simu/main/user/extended/.htaccess -text application/ship-simu/main/user/extended/class_ShipSimuGuest.php -text application/ship-simu/main/user/extended/class_ShipSimuMember.php -text @@ -263,6 +261,7 @@ application/ship-simu/starter.php -text application/ship-simu/templates/.htaccess -text application/ship-simu/templates/de/.htaccess -text application/ship-simu/templates/de/code/action_ship_simu_login_company.ctp -text +application/ship-simu/templates/de/code/action_ship_simu_login_goverment_startup_help.ctp -text application/ship-simu/templates/de/code/action_ship_simu_login_logout.ctp -text application/ship-simu/templates/de/code/action_ship_simu_login_profile.ctp -text application/ship-simu/templates/de/code/action_ship_simu_login_refill.ctp -text diff --git a/application/ship-simu/config.php b/application/ship-simu/config.php index dd52a7b..b2f3f32 100644 --- a/application/ship-simu/config.php +++ b/application/ship-simu/config.php @@ -310,5 +310,8 @@ $cfg->setConfigEntry('refill_page_min_currency_amount', 1000); // CFG: SHIP-SIMU-LOGIN-FILL-PAYMENT-DISCOVERY $cfg->setConfigEntry('ship_simu_login_refill_payment_discovery', "LocalPaymentDiscovery"); +// CFG: GOVERMENT-STARTUP-HELP-LIMIT +$cfg->setConfigEntry('goverment_startup_help_limit', 3); + // [EOF] ?> diff --git a/application/ship-simu/main/filter/validator/class_RefillRequestValidatorFilter.php b/application/ship-simu/main/filter/validator/class_RefillRequestValidatorFilter.php index 02833a4..76fe612 100644 --- a/application/ship-simu/main/filter/validator/class_RefillRequestValidatorFilter.php +++ b/application/ship-simu/main/filter/validator/class_RefillRequestValidatorFilter.php @@ -69,7 +69,9 @@ class RefillRequestValidatorFilter extends BaseFrameworkSystem implements Filter // Abort here return false; } // END - if - die("OK!"); + + // Unfinised part + $this->partialStub("Unfinished method."); } } diff --git a/application/ship-simu/main/goverment/class_SimplifiedGoverment.php b/application/ship-simu/main/goverment/class_SimplifiedGoverment.php index ccdc373..7f122d4 100644 --- a/application/ship-simu/main/goverment/class_SimplifiedGoverment.php +++ b/application/ship-simu/main/goverment/class_SimplifiedGoverment.php @@ -58,18 +58,18 @@ class SimplifiedGoverment extends BaseFrameworkSystem implements Registerable { } /** - * Checks wether the goverment has already payed a startup help to the + * Checks wether the goverment has already payed a training course for te * current user * * @return $alreadyPayed Wether the goverment has already payed */ - public function ifGovermentAlreadyPayedStartupHelp () { + public function ifGovermentAlreadyPayedTraining () { // Default is not payed $alreadyPayed = false; // Now get a search criteria and set the user's name as criteria $criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); - $criteriaInstance->addCriteria("gov_uid", $this->getUserInstance()->getUserName()); + $criteriaInstance->addCriteria("gov_uid", $this->getUserInstance()->getUserId()); $criteriaInstance->addCriteria("gov_activity_status", self::STATUS_STARTER_HELP); $criteriaInstance->setLimit(1); @@ -81,13 +81,48 @@ class SimplifiedGoverment extends BaseFrameworkSystem implements Registerable { // Was the query fine? if ($resultInstance->getAffectedRows() === 1) { - // Entry found! + // Entry was found so the goverment can no more pay a training $alreadyPayed = true; } // END - if // Return the result return $alreadyPayed; } + + /** + * Checks wether the goverment has payed maximum of startup helps to the + * current user + * + * @return $maximumPayed Wether the goverment has already payed + */ + public function ifGovermentPayedMaxmimumStartupHelp () { + // Default is not payed + $maximumPayed = false; + + // Cache startup help limit + $helpLimit = $this->getConfigInstance()->readConfig('goverment_startup_help_limit'); + + // Now get a search criteria and set the user's name as criteria + $criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); + $criteriaInstance->addCriteria("gov_uid", $this->getUserInstance()->getUserId()); + $criteriaInstance->addCriteria("gov_activity_status", self::STATUS_STARTER_HELP); + $criteriaInstance->setLimit($helpLimit); + + // Get a wrapper instance + $wrapperInstance = ObjectFactory::createObjectByConfiguredName('user_gov_wrapper_class'); + + // Get result back + $resultInstance = $wrapperInstance->doSelectByCriteria($criteriaInstance); + + // Was the query fine? + if ($resultInstance->getAffectedRows() === $helpLimit) { + // Entry found, so lets have a look if this goverment wants to again... + $maximumPayed = true; + } // END - if + + // Return the result + return $maximumPayed; + } } // [EOF] diff --git a/application/ship-simu/main/user/class_ShipSimuBaseUser.php b/application/ship-simu/main/user/class_ShipSimuBaseUser.php index 22ccc55..61feb28 100644 --- a/application/ship-simu/main/user/class_ShipSimuBaseUser.php +++ b/application/ship-simu/main/user/class_ShipSimuBaseUser.php @@ -89,14 +89,45 @@ class ShipSimuBaseUser extends BaseUser implements Registerable, Updateable { return $hasRequired; } + /** + * Determines if the goverment can still pay a "virtual training course" in general + * + * @return $ifGovHelps Wether if the goverment helps the user with a virtual training course + */ + public function ifGovermentPaysTraining () { + // By default they want to help. + $ifGovHelps = true; + + // First get a goverment instance from registry + $govermentInstance = Registry::getRegistry()->getInstance('goverment'); + + // Is it there? + if (is_null($govermentInstance)) { + // Then create a new one + $govermentInstance = ObjectFactory::createObjectByConfiguredName('goverment_class', array($this)); + + // Store it in registry + Registry::getRegistry()->addInstance('goverment', $govermentInstance); + } // END - if + + // Then ask the goverment if they want to pay a "startup help" to the user + if ($govermentInstance->ifGovermentAlreadyPayedTraining()) { + // Training already given! + $ifGovHelps = false; + } // END - if + + // Return result here + return $ifGovHelps; + } + /** * Determines if the goverment can still pay a "startup help" to the user * - * @return $ifGovHelped Wether if the goverment has helped the user with startup + * @return $ifGovHelps Wether if the goverment helps the user with some startup money */ public function ifGovermentPaysStartupHelp () { - // By default they have not payed, which is indeed good. ;-) - $ifGovHelped = false; + // By default they want to help. + $ifGovHelps = true; // First get a goverment instance from registry $govermentInstance = Registry::getRegistry()->getInstance('goverment'); @@ -111,20 +142,20 @@ class ShipSimuBaseUser extends BaseUser implements Registerable, Updateable { } // END - if // Then ask the goverment if they want to pay a "startup help" to the user - if ($govermentInstance->ifGovermentAlreadyPayedStartupHelp()) { + if ($govermentInstance->ifGovermentPayedMaxmimumStartupHelp()) { // They can't pay anymore to the user (excited amount) - $ifGovHelped = true; + $ifGovHelps = false; } // END - if // Return result here - return $ifGovHelped; + return $ifGovHelps; } /** * Checks wether the user can take points from the money bank * * @return $bankLends Wether the money bank is able to lend money - * @todo Need to check the bank if they can generally lend money to the user + * @todo Need to implement MoneyBank::ifBankLendsMoreMoney() */ public function ifUserAllowedTakeCreditsFromMoneyBank () { // Per default the money bank cannot pay @@ -143,7 +174,7 @@ class ShipSimuBaseUser extends BaseUser implements Registerable, Updateable { } // END - if // Does the money bank lend more money? - /** UNFINISHED PART! + /* UNFINISED: if ($bankInstance->ifBankLendsMoreMoney()) { // Okay, that they will do $bankLends = true; diff --git a/application/ship-simu/main/user/class_ShipSimuGuest.php b/application/ship-simu/main/user/class_ShipSimuGuest.php deleted file mode 100644 index e4edbc5..0000000 --- a/application/ship-simu/main/user/class_ShipSimuGuest.php +++ /dev/null @@ -1,111 +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 ShipSimuGuest extends ShipSimuBaseUser implements ManageableGuest, Registerable { - // Exceptions - const EXCEPTION_USERNAME_NOT_FOUND = 0x170; - const EXCEPTION_USER_EMAIL_NOT_FOUND = 0x171; - const EXCEPTION_USER_PASS_MISMATCH = 0x172; - - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className = "") { - // Is the class name empty? Then this is not a specialized user class - if (empty($className)) $className = __CLASS__; - - // Call parent constructor - parent::__construct($className); - } - - /** - * Creates an instance of this user class by a provided username. This - * factory method will check if the username is already taken and if not - * so it will throw an exception. - * - * @param $userName Username we need a class instance for - * @return $userInstance An instance of this user class - * @throws UsernameMissingException If the username does not exist - */ - public final static function createGuestByUsername ($userName) { - // Get a new instance - $userInstance = new ShipSimuGuest(); - - // Set the username - $userInstance->setUserName($userName); - - // Check if the username exists - if (!$userInstance->ifUsernameExists()) { - // Throw an exception here - throw new UsernameMissingException(array($userInstance, $userName), self::EXCEPTION_USERNAME_NOT_FOUND); - } - - // Return the instance - return $userInstance; - } - - /** - * Creates an instance of this user class by a provided email address. This - * factory method will not check if the email address is there. - * - * @param $email Email address of the user - * @return $userInstance An instance of this user class - */ - public final static function createGuestByEmail ($email) { - // Get a new instance - $userInstance = new ShipSimuGuest(); - - // Set the username - $userInstance->setEmail($email); - - // Return the instance - return $userInstance; - } - - /** - * Updates the last activity timestamp and last performed action in the - * database result. You should call flushPendingUpdates() to flush these updates - * to the database layer. - * - * @param $requestInstance A requestable class instance - * @return void - */ - public function updateLastActivity (Requestable $requestInstance) { - // No activity will be logged for guest accounts - } - - /** - * Flushs all pending updates to the database layer - * - * @return void - */ - public function flushPendingUpdates () { - // No updates will be flushed to database! - } -} - -// [EOF] -?> diff --git a/application/ship-simu/main/user/class_ShipSimuMember.php b/application/ship-simu/main/user/class_ShipSimuMember.php deleted file mode 100644 index 2f72868..0000000 --- a/application/ship-simu/main/user/class_ShipSimuMember.php +++ /dev/null @@ -1,178 +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 ShipSimuMember extends ShipSimuBaseUser implements ManageableMember, Registerable, Updateable { - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className = "") { - // Is the class name empty? Then this is not a specialized user class - if (empty($className)) $className = __CLASS__; - - // Call parent constructor - parent::__construct($className); - } - - /** - * Destructor to always flush updates - * - * @return void - */ - public function __destruct () { - // Flush any updated entries to the database - $this->flushPendingUpdates(); - - // Call parent destructor - parent::__destruct(); - } - - /** - * Creates an instance of this user class by a provided username. This - * factory method will check if the username is already taken and if not - * so it will throw an exception. - * - * @param $userName Username we need a class instance for - * @return $userInstance An instance of this user class - * @throws UsernameMissingException If the username does not exist - */ - public final static function createMemberByUsername ($userName) { - // Get a new instance - $userInstance = new ShipSimuMember(); - - // Set the username - $userInstance->setUserName($userName); - - // Check if the username exists - if (!$userInstance->ifUsernameExists()) { - // Throw an exception here - throw new UsernameMissingException(array($userInstance, $userName), self::EXCEPTION_USERNAME_NOT_FOUND); - } - - // Return the instance - return $userInstance; - } - - /** - * Creates an instance of this user class by a provided email address. This - * factory method will not check if the email address is there. - * - * @param $email Email address of the user - * @return $userInstance An instance of this user class - */ - public final static function createMemberByEmail ($email) { - // Get a new instance - $userInstance = new ShipSimuMember(); - - // Set the username - $userInstance->setEmail($email); - - // Return the instance - return $userInstance; - } - - /** - * Creates a user by a given request instance - * - * @param $requestInstance An instance of a Requestable class - * @return $userInstance An instance of this user class - */ - public final static function createMemberByRequest (Requestable $requestInstance) { - // Determine if by email or username - if (!is_null($requestInstance->getRequestElement('username'))) { - // Username supplied - $userInstance = self::createMemberByUserName($requestInstance->getRequestElement('username')); - } elseif (!is_null($requestInstance->getRequestElement('email'))) { - // Email supplied - $userInstance = self::createMemberByEmail($requestInstance->getRequestElement('email')); - } else { - // Unsupported mode - $userInstance = new ShipSimuMember(); - $userInstance->partialStub("We need to add more ways of creating user classes here."); - $userInstance->debugBackTrace(); - exit(); - } - - // Return the prepared instance - return $userInstance; - } - - /** - * Updates the last activity timestamp and last performed action in the - * database result. You should call flushPendingUpdates() to flush these updates - * to the database layer. - * - * @param $requestInstance A requestable class instance - * @return void - */ - public function updateLastActivity (Requestable $requestInstance) { - // Set last action - $lastAction = $requestInstance->getRequestElement('action'); - - // If there is no action use the default on - if (is_null($lastAction)) { - $lastAction = $this->getConfigInstance()->readConfig('login_default_action'); - } // END - if - - // Get a critieria instance - $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); - - // Add search criteria - $searchInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_USERNAME, $this->getUserName()); - $searchInstance->setLimit(1); - - // Now get another criteria - $updateInstance = ObjectFactory::createObjectByConfiguredName('update_criteria_class'); - - // And add our both entries - $updateInstance->addCriteria('last_activity', date("Y-m-d H:i:s", time())); - $updateInstance->addCriteria('last_action', $lastAction); - - // Add the search criteria for searching for the right entry - $updateInstance->setSearchInstance($searchInstance); - - // Remember the update in database result - $this->getResultInstance()->add2UpdateQueue($updateInstance); - } - - /** - * Flushs all pending updates to the database layer - * - * @return void - */ - public function flushPendingUpdates () { - // Do we have data to update? - if ($this->getResultInstance()->ifDataNeedsFlush()) { - // Get a database wrapper - $wrapperInstance = ObjectFactory::createObjectByConfiguredName('user_db_wrapper_class'); - - // Yes, then send the whole result to the database layer - $wrapperInstance->doUpdateByResult($this->getResultInstance()); - } // END - if - } -} - -// [EOF] -?> diff --git a/application/ship-simu/main/user/extended/class_ShipSimuMember.php b/application/ship-simu/main/user/extended/class_ShipSimuMember.php index f2caaa8..ed2673a 100644 --- a/application/ship-simu/main/user/extended/class_ShipSimuMember.php +++ b/application/ship-simu/main/user/extended/class_ShipSimuMember.php @@ -161,6 +161,12 @@ class ShipSimuMember extends ShipSimuBaseUser implements ManageableMember { * @return void */ public function flushPendingUpdates () { + // Is the object valid? + if (!$this->getResultInstance() instanceof SearchableResult) { + // Abort here + return; + } // END - if + // Do we have data to update? if ($this->getResultInstance()->ifDataNeedsFlush()) { // Get a database wrapper diff --git a/application/ship-simu/templates/de/code/action_ship_simu_login_company.ctp b/application/ship-simu/templates/de/code/action_ship_simu_login_company.ctp index 63285af..2722364 100644 --- a/application/ship-simu/templates/de/code/action_ship_simu_login_company.ctp +++ b/application/ship-simu/templates/de/code/action_ship_simu_login_company.ctp @@ -19,7 +19,7 @@ if ($linkInstance->getValueInstance()->ifUserCreatedMaximumAllowedCompanies()) { // No more money left for founding company so place link here to refill page/money bank if ($linkInstance->getValueInstance()->ifUserAllowedTakeCreditsFromMoneyBank()) { // Display link to money bank page - $linkInstance->addActionLink('moneybank', "Jetzt deinen Kredit tilgen."); + $linkInstance->addActionLink('moneybank', "Jetzt zur Bank gehen und mehr {?currency?} leihen."); } elseif ($linkInstance->getValueInstance()->ifUserHasMaximumCreditsWithMoneyBank()) { // Maximum credits reached which a money bank can lent $linkInstance->addLinkNote("Die Bank kann dir kein Geld mehr leihen, bitte zahle es auch wieder zurück."); @@ -31,14 +31,17 @@ if ($linkInstance->getValueInstance()->ifUserCreatedMaximumAllowedCompanies()) { } // Add link group for goverment -$linkInstance->addLinkGroup('goverment', "Bewerbe dich bei anderen Firmen und hole dir eine Starthilfe vom Staat ab wenn du nicht flüssig bist!"); +$linkInstance->addLinkGroup('goverment', "Bewerbe dich bei anderen Firmen und hole dir eine Starthilfe vom virtuellen Staat ab wenn du nicht flüssig bist!"); if ($linkInstance->getValueInstance()->ifUserHasRequiredPoints('write_applications')) { // Enough money to write applications to other companies $linkInstance->addActionLink('company_list', "Alle Firmen auflisten zum Bewerben."); +} elseif ($linkInstance->getValueInstance()->ifGovermentPaysTraining()) { + // Goverment is able to pay a training in general + $linkInstance->addActionLink('goverment_training', "Jetzt zur virtuellen Kurswelt und ein Training auswählen."); } elseif ($linkInstance->getValueInstance()->ifGovermentPaysStartupHelp()) { // Display link to goverment for startup help - $linkInstance->addActionLink('goverment&sub=request&request=startup_help', "Direkt zum Antragsformular für deine Starthilfe."); + $linkInstance->addActionLink('goverment_startup_help', "Direkt zum Antragsformular für deine Starthilfe."); } else { // Even goverment cannot help the gamer here $linkInstance->addLinkNote("Leider kann dir der Staat nicht mehr weiterhelfen, dich zu bewerben, da du zu oft Starthilfen erhalten hast. Hier muss aber noch weiter am Spiel gearbeitet werden. :-)"); @@ -49,11 +52,11 @@ $linkInstance->addLinkGroup('moneybank', "Leihe dir zu günstigen Zinsen vir if ($linkInstance->getValueInstance()->ifUserAllowedTakeCreditsFromMoneyBank()) { // Display link to money bank page - $linkInstance->addActionLink('moneybank', "Jetzt deinen Kredit tilgen."); + $linkInstance->addActionLink('moneybank', "Jetzt zur virtuellen Bank gehen."); } elseif ($linkInstance->getValueInstance()->ifUserHasMaximumCreditsWithMoneyBank()) { // Maximum credits reached which a money bank can lent $linkInstance->addLinkNote("Die Bank kann dir kein Geld mehr leihen, bitte zahle es auch wieder zurück."); - $linkInstance->addActionLink('moneybank&sub=payback_credits', "Jetzt deinen Kredit tilgen."); + $linkInstance->addActionLink('moneybank_payback_credits', "Jetzt deinen Kredit tilgen."); } else { // Money bank is closed! $linkInstance->addLinkNote("Die Bank hat derzeit geschlossen. Bitte später nochmal versuchen."); diff --git a/application/ship-simu/templates/de/code/action_ship_simu_login_goverment_startup_help.ctp b/application/ship-simu/templates/de/code/action_ship_simu_login_goverment_startup_help.ctp new file mode 100644 index 0000000..3c15204 --- /dev/null +++ b/application/ship-simu/templates/de/code/action_ship_simu_login_goverment_startup_help.ctp @@ -0,0 +1,20 @@ +addFormNote('reality_warning', "WARNUNG: Bitte dieses Formular nicht mit echten Angaben ausfüllen!"); + +// Flush the finished form +$helper->flushContent(); + +?> +
+
+ Virtuelle Beantragung von Startuphilfe +
+ +
+ {?shipsimu_startup_form?} +
+
diff --git a/inc/classes/exceptions/main/class_GetterNotFoundException.php b/inc/classes/exceptions/main/class_GetterNotFoundException.php index a632dcd..0020169 100644 --- a/inc/classes/exceptions/main/class_GetterNotFoundException.php +++ b/inc/classes/exceptions/main/class_GetterNotFoundException.php @@ -29,10 +29,7 @@ class GetterNotFoundException extends FrameworkException { * @param $code Code number for the exception * @return void */ - public function __construct ($dataArray, $code) { - // Cast the array - $dataArray = (array) $dataArray; - + public function __construct (array $dataArray, $code) { // Add a message around the missing class $message = sprintf("[%s:%d] Getter-Methode für Attribut %s nicht gefunden.", $dataArray[0]->__toString(), diff --git a/inc/classes/main/database/databases/class_LocalFileDatabase.php b/inc/classes/main/database/databases/class_LocalFileDatabase.php index 25cf938..96b5c22 100644 --- a/inc/classes/main/database/databases/class_LocalFileDatabase.php +++ b/inc/classes/main/database/databases/class_LocalFileDatabase.php @@ -153,13 +153,12 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend /** * Setter for the last read file * - * @param $fqfn The FQFN of the last read file + * @param $fqfn The FQFN of the last read file * @return void */ private final function setLastFile ($fqfn) { - // Cast string - $fqfn = (string) $fqfn; - $this->lastFile = $fqfn; + // Cast string and set it + $this->lastFile = (string) $fqfn; } /** @@ -188,9 +187,8 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend * @param $contents An array with header and data elements * @return void */ - private final function setLastFileContents ($contents) { - // Cast array - $contents = (array) $contents; + private final function setLastFileContents (array $contents) { + // Set array $this->lastContents = $contents; } @@ -370,6 +368,7 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend // Initialize limit/skip $limitFound = 0; $skipFound = 0; + $idx = 1; // Read the directory with some exceptions while (($dataFile = $directoryInstance->readDirectoryExcept(array(".", "..", ".htaccess", ".svn", "info." . $this->getFileExtension()))) && ($limitFound < $criteriaInstance->getLimit())) { @@ -377,7 +376,7 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend if (substr($dataFile, -(strlen($this->getFileExtension()))) !== $this->getFileExtension()) { // Skip this file! continue; - } + } // END - if // Read the file $dataArray = $this->getDataArrayFromFile($pathName . $dataFile); @@ -402,8 +401,13 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend } // END - if } // END - if + // Set id number + $dataArray['__idx'] = $idx; + // Entry found! $resultData['rows'][] = $dataArray; + + // Count found entries up $limitFound++; break; } // END - if @@ -412,6 +416,9 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend // Throw an exception here throw new SqlException(array($this, sprintf("File '%s' contains invalid data.", $dataFile), self::DB_CODE_DATA_FILE_CORRUPT), self::EXCEPTION_SQL_QUERY); } + + // Count entry up + $idx++; } // END - while // Close directory and throw the instance away diff --git a/inc/classes/main/database/wrapper/class_UserDatabaseWrapper.php b/inc/classes/main/database/wrapper/class_UserDatabaseWrapper.php index 1bbbf03..0406bb2 100644 --- a/inc/classes/main/database/wrapper/class_UserDatabaseWrapper.php +++ b/inc/classes/main/database/wrapper/class_UserDatabaseWrapper.php @@ -26,6 +26,7 @@ class UserDatabaseWrapper extends BaseDatabaseWrapper { const EXCEPTION_CLIENT_USERNAME_NOT_FOUND = 0x180; // Constants for database columns + const DB_COLUMN_USERID = "userid"; const DB_COLUMN_USERNAME = "username"; const DB_COLUMN_EMAIL = "email"; const DB_COLUMN_CONFIRM_HASH = "confirm_hash"; diff --git a/inc/classes/main/filter/change/class_EmailChangeFilter.php b/inc/classes/main/filter/change/class_EmailChangeFilter.php index 4e75421..0991492 100644 --- a/inc/classes/main/filter/change/class_EmailChangeFilter.php +++ b/inc/classes/main/filter/change/class_EmailChangeFilter.php @@ -101,10 +101,13 @@ class EmailChangeFilter extends BaseFrameworkSystem implements Filterable { $userEmail = $userInstance->getField('email'); // Are they different? - if ($userEmail != $email1) { - // Update the "new_email" field - $this->partialStub("Unfinished part."); + if ($userEmail == $email1) { + // Nothing has been changed is fine... + return true; } // END - if + + // Update the "new_email" field + $this->partialStub("Unfinished part."); } } diff --git a/inc/classes/main/user/class_BaseUser.php b/inc/classes/main/user/class_BaseUser.php index 0a3432d..b3fc24d 100644 --- a/inc/classes/main/user/class_BaseUser.php +++ b/inc/classes/main/user/class_BaseUser.php @@ -32,6 +32,11 @@ class BaseUser extends BaseFrameworkSystem { */ private $userName = ""; + /** + * User id of current user + */ + private $userId = 0; + /** * Email of current user */ @@ -59,26 +64,46 @@ class BaseUser extends BaseFrameworkSystem { * @return void */ public final function setUserName ($userName) { - $this->userName = $userName; + $this->userName = (string) $userName; } /** - * Setter for email + * Getter for username * - * @param $email The email to set + * @return $userName The username to get + */ + public final function getUserName () { + return $this->userName; + } + + /** + * Setter for user id + * + * @param $userId The user id to set * @return void + * @todo Find a way of casting here. "(int)" might destroy the user id > 32766 */ - protected final function setEmail ($email) { - $this->email = $email; + public final function setUserId ($userId) { + $this->userId = $userId; } /** - * Getter for username + * Getter for user id * - * @return $userName The username to get + * @return $userId The user id to get */ - public final function getUsername () { - return $this->userName; + public final function getUserId () { + return $this->userId; + } + + /** + * Setter for email + * + * @param $email The email to set + * @return void + */ + protected final function setEmail ($email) { + $this->email = (string) $email; } /** @@ -108,7 +133,8 @@ class BaseUser extends BaseFrameworkSystem { $criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); // Add the username as a criteria and set limit to one entry - $criteriaInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_USERNAME, $this->getUsername()); + $criteriaInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_USERNAME, $this->getUserName()); + $criteriaInstance->setIndexSolution(UserDatabaseWrapper::DB_COLUMN_USERID, array($this, 'setUserId')); $criteriaInstance->setLimit(1); // Get a search result @@ -147,6 +173,7 @@ class BaseUser extends BaseFrameworkSystem { // Add the username as a criteria and set limit to one entry $criteriaInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_EMAIL, $this->getEmail()); + $criteriaInstance->setIndexSolution(UserDatabaseWrapper::DB_COLUMN_USERID, array($this, 'setUserId')); $criteriaInstance->setLimit(1); // Get a search resultInstance @@ -194,6 +221,7 @@ class BaseUser extends BaseFrameworkSystem { // Add the username as a criteria and set limit to one entry $criteriaInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_USERNAME, $this->getUserName()); + $criteriaInstance->setIndexSolution(UserDatabaseWrapper::DB_COLUMN_USERID, array($this, 'setUserId')); $criteriaInstance->setLimit(1); // Get a search resultInstance diff --git a/tests/old/contract-test.php b/tests/old/contract-test.php index 3e9cd2b..fd44cdf 100644 --- a/tests/old/contract-test.php +++ b/tests/old/contract-test.php @@ -32,63 +32,63 @@ require($cfg->readConfig('base_path') . 'application/ship-simu/loader.php'); try { $personell = SimulatorPersonell::createSimulatorPersonellByID('SimulatorPersonell@829292aeca3f6bf78c16e25fc4f75c98'); } catch (InvalidIDFormatException $e) { - die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", $e->getMessage() )); } catch (InvalidArrayCountException $e) { - die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", $e->getMessage() )); } catch (NullPointerException $e) { - die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", $e->getMessage() )); } catch (NoObjectException $e) { - die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", $e->getMessage() )); } catch (MissingMethodException $e) { - die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", $e->getMessage() )); } catch (FileIsEmptyException $e) { - die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", $e->getMessage() )); } catch (FilePointerNotOpenedException $e) { - die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", $e->getMessage() )); } catch (InvalidArrayCountException $e) { - die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", $e->getMessage() )); } catch (InvalidMD5ChecksumException $e) { - die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", $e->getMessage() )); } catch (InvalidDataLengthException $e) { - die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", $e->getMessage() )); } catch (InvalidSimulatorIDException $e) { - die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", $e->getMessage() )); } catch (MismatchingCompressorsException $e) { - die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", $e->getMessage() )); } catch (ContainerItemIsNullException $e) { - die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", $e->getMessage() )); } catch (ContainerItemIsNoArrayException $e) { - die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", $e->getMessage() )); } catch (ContainerMaybeDamagedException $e) { - die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", $e->getMessage() )); } @@ -105,13 +105,13 @@ if (defined('DEBUG_PERSONELL_OBJ')) { $harbor = Harbor::createHarbor("Hamburger Hafen"); // Name ausgeben -DebugMiddleware::getInstance()->output(sprintf("Der %s ist gegründet worden.
\n", +DebugMiddleware::getInstance()->output(sprintf("Der %s ist gegründet worden.
\n", $harbor->getHarborName() )); // Hafen-Objekt debuggen if (defined('DEBUG_HARBOR_OBJ')) { - DebugMiddleware::getInstance()->output(sprintf("Der %s sieht wie folgt aus:
+ DebugMiddleware::getInstance()->output(sprintf("Der %s sieht wie folgt aus:
%s
\n", $harbor->getHarborName(), print_r($harbor, true) @@ -225,7 +225,7 @@ foreach ($einbauten['parts'] as $key=>$part) { $item .= sprintf("%f, ", $subPart); } else { // Unsupport part found - die(sprintf("[Main:] Unsupported sub-array element on pos %d in array %s found: %s", $idx2, $idx, $subPart)); + die(sprintf("[Main:] Unsupported sub-array element on pos %d in array %s found: %s", $idx2, $idx, $subPart)); } } @@ -264,7 +264,7 @@ foreach ($einbauten['parts'] as $key=>$part) { // Run the constructed command eval($eval); } catch (ItemNotTradeableException $e) { - die(sprintf("[Main:] Die Preisliste des Händlers %s kann nicht befüllt werden. Grund: %s
\n", + die(sprintf("[Main:] Die Preisliste des Händlers %s kann nicht befüllt werden. Grund: %s
\n", $merchant->getMerchantName(), $e->getMessage() )); @@ -273,7 +273,7 @@ foreach ($einbauten['parts'] as $key=>$part) { // Haendler-Objekt debuggen if (defined('DEBUG_MERCHANT_OBJ')) { - DebugMiddleware::getInstance()->output(sprintf("Der Händler %s sieht wie folgt aus:
+ DebugMiddleware::getInstance()->output(sprintf("Der Händler %s sieht wie folgt aus:
%s
\n", $merchant->getMerchantName(), print_r($merchant, true) @@ -287,13 +287,13 @@ $shipping = ShippingCompany::createShippingCompany("Hanseatic Travel Company", $ try { $shipping->setCompanyFounder(CompanyEmployee::createCompanyEmployee("Roland", "Häder", "M", 1977, 9, 26, true, 2000)); } catch (BirthdayInvalidException $e) { - die(sprintf("[Main:] Reederei-Gründer konnte nicht gesetzt werden. Grund: %s
\n", + die(sprintf("[Main:] Reederei-Gründer konnte nicht gesetzt werden. Grund: %s
\n", $e->getMessage() )); } // Dann mal ausgeben... -DebugMiddleware::getInstance()->output(sprintf("Die Reederei %s ist von %s %s gegründet worden.
\n", +DebugMiddleware::getInstance()->output(sprintf("Die Reederei %s ist von %s %s gegründet worden.
\n", $shipping->getCompanyName(), $shipping->getFounderInstance()->getSurname(), $shipping->getFounderInstance()->getFamily() @@ -303,19 +303,19 @@ DebugMiddleware::getInstance()->output(sprintf("Die Reederei %s try { $shipping->recruitRandomEmployees(10, $personell); } catch (ToMuchEmployeesException $e) { - die(sprintf("[Main:] Die Reederei %s konnte kein Personal einstellen. Grund: %s
\n", + die(sprintf("[Main:] Die Reederei %s konnte kein Personal einstellen. Grund: %s
\n", $shipping->getCompanyName(), $e->getMessage() )); } catch (OutOfBoundsException $e) { - die(sprintf("[Main:] Die Reederei %s konnte kein Personal einstellen. Grund: %s
\n", + die(sprintf("[Main:] Die Reederei %s konnte kein Personal einstellen. Grund: %s
\n", $shipping->getCompanyName(), $e->getMessage() )); } // Anzahl Personal ausgeben -DebugMiddleware::getInstance()->output(sprintf("Die Reederei %s hat nun %d weitere Mitarbeiter.
\n", +DebugMiddleware::getInstance()->output(sprintf("Die Reederei %s hat nun %d weitere Mitarbeiter.
\n", $shipping->getCompanyName(), $shipping->getTotalEmployee() )); @@ -329,17 +329,17 @@ $shipping->createShipyardInHarbor("Werft 3", $harbor); try { $shipping->addShipTypeToAllShipyards("PassengerShip"); } catch (ClassNotFoundException $e) { - die(sprintf("[Main:] Die Reederei %s kann ihre Werften nicht beschäftigen. Grund: %s
\n", + die(sprintf("[Main:] Die Reederei %s kann ihre Werften nicht beschäftigen. Grund: %s
\n", $shipping->getCompanyName(), $e->getMessage() )); } catch (ClassMismatchException $e) { - die(sprintf("[Main:] Die Reederei %s kann ihre Werften nicht beschäftigen. Grund: %s
\n", + die(sprintf("[Main:] Die Reederei %s kann ihre Werften nicht beschäftigen. Grund: %s
\n", $shipping->getCompanyName(), $e->getMessage() )); } catch (NoObjectException $e) { - die(sprintf("[Main:] Die Reederei %s kann ihre Werften nicht beschäftigen. Grund: %s
\n", + die(sprintf("[Main:] Die Reederei %s kann ihre Werften nicht beschäftigen. Grund: %s
\n", $shipping->getCompanyName(), $e->getMessage() )); @@ -349,29 +349,29 @@ try { try { $shipping->distributeAllPersonellOnShipyards(); } catch (NoShipyardsConstructedException $e) { - die(sprintf("[Main:] Die Reederei %s konnte kein Personal den Werften zuteilen. Grund: %s
\n", + die(sprintf("[Main:] Die Reederei %s konnte kein Personal den Werften zuteilen. Grund: %s
\n", $shipping->getCompanyName(), $e->getMessage() )); } catch (ClassMismatchException $e) { - die(sprintf("[Main:] Die Reederei %s konnte kein Personal den Werften zuteilen. Grund: %s
\n", + die(sprintf("[Main:] Die Reederei %s konnte kein Personal den Werften zuteilen. Grund: %s
\n", $shipping->getCompanyName(), $e->getMessage() )); } catch (NullPointerException $e) { - die(sprintf("[Main:] Die Reederei %s konnte kein Personal den Werften zuteilen. Grund: %s
\n", + die(sprintf("[Main:] Die Reederei %s konnte kein Personal den Werften zuteilen. Grund: %s
\n", $shipping->getCompanyName(), $e->getMessage() )); } catch (NoObjectException $e) { - die(sprintf("[Main:] Die Reederei %s konnte kein Personal den Werften zuteilen. Grund: %s
\n", + die(sprintf("[Main:] Die Reederei %s konnte kein Personal den Werften zuteilen. Grund: %s
\n", $shipping->getCompanyName(), $e->getMessage() )); } // Normale Meldung ausgeben -DebugMiddleware::getInstance()->output(sprintf("Die Reederei %s beschäftigt nun ihre %d Mitarbeiter in %d Werft(en):
\n", +DebugMiddleware::getInstance()->output(sprintf("Die Reederei %s beschäftigt nun ihre %d Mitarbeiter in %d Werft(en):
\n", $shipping->getCompanyName(), $shipping->getTotalEmployee(), $shipping->getTotalShipyards() @@ -382,23 +382,23 @@ DebugMiddleware::getInstance()->output(sprintf("Die Reederei %s try { $shipping->addNewWorksContract(WorksContract::createWorksContract("PassengerShip", "M/S Poseidon", $shipping)); } catch (ClassNotFoundException $e) { - die(sprintf("[Main:] Der Bauauftrag konnte nicht erstellt werden. Grund: %s
\n", + die(sprintf("[Main:] Der Bauauftrag konnte nicht erstellt werden. Grund: %s
\n", $e->getMessage() )); } catch (NullPointerException $e) { - die(sprintf("[Main:] Der Bauauftrag konnte nicht erstellt werden. Grund: %s
\n", + die(sprintf("[Main:] Der Bauauftrag konnte nicht erstellt werden. Grund: %s
\n", $e->getMessage() )); } catch (NoObjectException $e) { - die(sprintf("[Main:] Der Bauauftrag konnte nicht erstellt werden. Grund: %s
\n", + die(sprintf("[Main:] Der Bauauftrag konnte nicht erstellt werden. Grund: %s
\n", $e->getMessage() )); } catch (MissingMethodException $e) { - die(sprintf("[Main:] Der Bauauftrag konnte nicht erstellt werden. Grund: %s
\n", + die(sprintf("[Main:] Der Bauauftrag konnte nicht erstellt werden. Grund: %s
\n", $e->getMessage() )); } catch (EmptyStructuresListException $e) { - die(sprintf("[Main:] Der Bauauftrag konnte nicht erstellt werden. Grund: %s
\n", + die(sprintf("[Main:] Der Bauauftrag konnte nicht erstellt werden. Grund: %s
\n", $e->getMessage() )); } @@ -410,17 +410,17 @@ $contract = $shipping->getLastContractInstance(); try { $shipping->setMerchantInstance($merchant); } catch (NullPointerException $e) { - die(sprintf("[Main:] Der Händler %s konnte nicht ausgewählt werden. Grund: %s
\n", + die(sprintf("[Main:] Der Händler %s konnte nicht ausgewählt werden. Grund: %s
\n", $merchant->getMerchantName(), $e->getMessage() )); } catch (NoObjectException $e) { - die(sprintf("[Main:] Der Händler %s konnte nicht ausgewählt werden. Grund: %s
\n", + die(sprintf("[Main:] Der Händler %s konnte nicht ausgewählt werden. Grund: %s
\n", $merchant->getMerchantName(), $e->getMessage() )); } catch (ClassMismatchException $e) { - die(sprintf("[Main:] Der Händler %s konnte nicht ausgewählt werden. Grund: %s
\n", + die(sprintf("[Main:] Der Händler %s konnte nicht ausgewählt werden. Grund: %s
\n", $merchant->getMerchantName(), $e->getMessage() )); @@ -430,12 +430,12 @@ try { try { $typeValid = $shipping->validateWorksContractShipType($contract); } catch (NullPointerException $e) { - die(sprintf("[Main:] Die Reederei %s konnte den Bauauftrag nicht validieren. Grund: %s
\n", + die(sprintf("[Main:] Die Reederei %s konnte den Bauauftrag nicht validieren. Grund: %s
\n", $shipping->getCompanyName(), $e->getMessage() )); } catch (NoObjectException $e) { - die(sprintf("[Main:] Die Reederei %s konnte den Bauauftrag nicht validieren. Grund: %s
\n", + die(sprintf("[Main:] Die Reederei %s konnte den Bauauftrag nicht validieren. Grund: %s
\n", $shipping->getCompanyName(), $e->getMessage() )); @@ -443,12 +443,12 @@ try { // Kann gebaut werden? if ($typeValid) { - DebugMiddleware::getInstance()->output(sprintf("Die Reederei %s kann Schiffe vom Typ %s bauen.
\n", + DebugMiddleware::getInstance()->output(sprintf("Die Reederei %s kann Schiffe vom Typ %s bauen.
\n", $shipping->getCompanyName(), $contract->getShipInstance()->getObjectDescription() )); } else { - DebugMiddleware::getInstance()->output(sprintf("Die Reederei %s kann keine Schiffe vom Typ %s bauen!
\n", + DebugMiddleware::getInstance()->output(sprintf("Die Reederei %s kann keine Schiffe vom Typ %s bauen!
\n", $shipping->getCompanyName(), $contract->getShipInstance()->getObjectDescription() )); @@ -466,12 +466,12 @@ foreach ($einbauten['parts'] as $key=>$part) { // Output message die($e->getMessage()); } catch (ItemNotInPriceListException $e) { - die(sprintf("[Main:] Der Artikel %s konnte nicht in der Preisliste gefunden werden. Grund: %s
\n", + die(sprintf("[Main:] Der Artikel %s konnte nicht in der Preisliste gefunden werden. Grund: %s
\n", $key, $e->getMessage() )); } catch (InvalidArrayCountException $e) { - die(sprintf("[Main:] Der Artikel %s konnte nicht in der Preisliste gefunden werden. Grund: %s
\n", + die(sprintf("[Main:] Der Artikel %s konnte nicht in der Preisliste gefunden werden. Grund: %s
\n", $key, $e->getMessage() )); @@ -480,7 +480,7 @@ foreach ($einbauten['parts'] as $key=>$part) { // Reederei-Objekt ausgeben if (defined('DEBUG_COMPANY_OBJ')) { - DebugMiddleware::getInstance()->output(sprintf("Die Reederei %s sieht wie folgt aus:
+ DebugMiddleware::getInstance()->output(sprintf("Die Reederei %s sieht wie folgt aus:
%s
\n", $shipping->getCompanyName(), print_r($shipping, true) @@ -499,29 +499,29 @@ unset($typeValid); try { $totalValue = $contract->getTotalPrice(); } catch (NullPointerException $e) { - die(sprintf("[Main:] Gesamtbestellwert nicht ermittelbar. Grund: %s
\n", + die(sprintf("[Main:] Gesamtbestellwert nicht ermittelbar. Grund: %s
\n", $e->getMessage() )); } catch (NoObjectException $e) { - die(sprintf("[Main:] Gesamtbestellwert nicht ermittelbar. Grund: %s
\n", + die(sprintf("[Main:] Gesamtbestellwert nicht ermittelbar. Grund: %s
\n", $e->getMessage() )); } catch (MissingMethodException $e) { - die(sprintf("[Main:] Gesamtbestellwert nicht ermittelbar. Grund: %s
\n", + die(sprintf("[Main:] Gesamtbestellwert nicht ermittelbar. Grund: %s
\n", $e->getMessage() )); } catch (EmptyStructuresListException $e) { - die(sprintf("[Main:] Gesamtbestellwert nicht ermittelbar. Grund: %s
\n", + die(sprintf("[Main:] Gesamtbestellwert nicht ermittelbar. Grund: %s
\n", $e->getMessage() )); } catch (TotalPriceNotCalculatedException $e) { - die(sprintf("[Main:] Gesamtbestellwert nicht ermittelbar. Grund: %s
\n", + die(sprintf("[Main:] Gesamtbestellwert nicht ermittelbar. Grund: %s
\n", $e->getMessage() )); } // Wert ausgeben -DebugMiddleware::getInstance()->output(sprintf("Der Bau der %s wird der Reederei %s voraussichtlich %s kosten.
\n", +DebugMiddleware::getInstance()->output(sprintf("Der Bau der %s wird der Reederei %s voraussichtlich %s kosten.
\n", $contract->getShipInstance()->getShipName(), $shipping->getCompanyName(), $contract->formatCurrency($totalValue) @@ -534,32 +534,32 @@ unset($totalValue); try { $shipping->signContract($contract, $shipping); } catch (NullPointerException $e) { - die(sprintf("[Main:] The shipping company %s was not able to sign the contract for the following reason: %s
\n", + die(sprintf("[Main:] The shipping company %s was not able to sign the contract for the following reason: %s
\n", $shipping->getCompanyName(), $e->getMessage() )); } catch (NoObjectException $e) { - die(sprintf("[Main:] The shipping company %s was not able to sign the contract for the following reason: %s
\n", + die(sprintf("[Main:] The shipping company %s was not able to sign the contract for the following reason: %s
\n", $shipping->getCompanyName(), $e->getMessage() )); } catch (MissingMethodException $e) { - die(sprintf("[Main:] The shipping company %s was not able to sign the contract for the following reason: %s
\n", + die(sprintf("[Main:] The shipping company %s was not able to sign the contract for the following reason: %s
\n", $shipping->getCompanyName(), $e->getMessage() )); } catch (InvalidContractPartnerException $e) { - die(sprintf("[Main:] The shipping company %s was not able to sign the contract for the following reason: %s
\n", + die(sprintf("[Main:] The shipping company %s was not able to sign the contract for the following reason: %s
\n", $shipping->getCompanyName(), $e->getMessage() )); } catch (ContractAllreadySignedException $e) { - die(sprintf("[Main:] The shipping company %s was not able to sign the contract for the following reason: %s
\n", + die(sprintf("[Main:] The shipping company %s was not able to sign the contract for the following reason: %s
\n", $shipping->getCompanyName(), $e->getMessage() )); } catch (WrongContractPartnerException $e) { - die(sprintf("[Main:] The shipping company %s was not able to sign the contract for the following reason: %s
\n", + die(sprintf("[Main:] The shipping company %s was not able to sign the contract for the following reason: %s
\n", $shipping->getCompanyName(), $e->getMessage() )); @@ -567,12 +567,12 @@ try { // Meldung ausgeben if ($contract->isSigned()) { - DebugMiddleware::getInstance()->output(sprintf("Die Reederei %s hat den Bau der %s zugestimmt.
\n", + DebugMiddleware::getInstance()->output(sprintf("Die Reederei %s hat den Bau der %s zugestimmt.
\n", $shipping->getCompanyName(), $contract->getShipInstance()->getShipName() )); } else { - DebugMiddleware::getInstance()->output(sprintf("Die Reederei %s hat den Bau der %s abgelehnt.
\n", + DebugMiddleware::getInstance()->output(sprintf("Die Reederei %s hat den Bau der %s abgelehnt.
\n", $shipping->getCompanyName(), $contract->getShipInstance()->getShipName() )); @@ -594,11 +594,11 @@ if (defined('DEBUG_CONTRACT_OBJ')) { try { $totalBeds = $contract->getShipInstance()->calcTotalBeds(); } catch (StructuresOutOfBoundsException $e) { - die(sprintf("[Main:] Anzahl Betten konnten nicht ermittelt werden. Grund: %s
\n", + die(sprintf("[Main:] Anzahl Betten konnten nicht ermittelt werden. Grund: %s
\n", $e->getMessage() )); } catch (EmptyStructuresListException $e) { - die(sprintf("[Main:] Anzahl Betten konnten nicht ermittelt werden. Grund: %s
\n", + die(sprintf("[Main:] Anzahl Betten konnten nicht ermittelt werden. Grund: %s
\n", $e->getMessage() )); } diff --git a/tests/old/loader-test.php b/tests/old/loader-test.php index 6d885ab..1b9dc3a 100644 --- a/tests/old/loader-test.php +++ b/tests/old/loader-test.php @@ -32,63 +32,63 @@ require($cfg->readConfig('base_path') . 'application/ship-simu/loader.php'); try { $personell = SimulatorPersonell::createSimulatorPersonellByID('SimulatorPersonell@829292aeca3f6bf78c16e25fc4f75c98'); } catch (InvalidIDFormatException $e) { - die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", $e->getMessage() )); } catch (InvalidArrayCountException $e) { - die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", $e->getMessage() )); } catch (NullPointerException $e) { - die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", $e->getMessage() )); } catch (NoObjectException $e) { - die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", $e->getMessage() )); } catch (MissingMethodException $e) { - die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", $e->getMessage() )); } catch (FileIsEmptyException $e) { - die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", $e->getMessage() )); } catch (FilePointerNotOpenedException $e) { - die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", $e->getMessage() )); } catch (InvalidArrayCountException $e) { - die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", $e->getMessage() )); } catch (InvalidMD5ChecksumException $e) { - die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", $e->getMessage() )); } catch (InvalidDataLengthException $e) { - die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", $e->getMessage() )); } catch (InvalidSimulatorIDException $e) { - die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", $e->getMessage() )); } catch (MismatchingCompressorsException $e) { - die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", $e->getMessage() )); } catch (ContainerItemIsNullException $e) { - die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", $e->getMessage() )); } catch (ContainerItemIsNoArrayException $e) { - die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", $e->getMessage() )); } catch (ContainerMaybeDamagedException $e) { - die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", $e->getMessage() )); } @@ -108,15 +108,15 @@ exit(); try { $personell = SimulatorPersonell::createSimulatorPersonell(20); } catch (NullPointerException $e) { - die(sprintf("[Main:] Personal list not created for following reason: %s
\n", + die(sprintf("[Main:] Personal list not created for following reason: %s
\n", $e->getMessage() )); } catch (NoObjectException $e) { - die(sprintf("[Main:] Personal list not created for following reason: %s
\n", + die(sprintf("[Main:] Personal list not created for following reason: %s
\n", $e->getMessage() )); } catch (MissingMethodException $e) { - die(sprintf("[Main:] Personal list not created for following reason: %s
\n", + die(sprintf("[Main:] Personal list not created for following reason: %s
\n", $e->getMessage() )); } @@ -133,35 +133,35 @@ if (defined('DEBUG_PERSONELL_OBJ')) { try { $personell->saveObjectToDatabase(); } catch (NullPointerException $e) { - die(sprintf("[Main:] Object not saved for following reason: %s
\n", + die(sprintf("[Main:] Object not saved for following reason: %s
\n", $e->getMessage() )); } catch (NoObjectException $e) { - die(sprintf("[Main:] Object not saved for following reason: %s
\n", + die(sprintf("[Main:] Object not saved for following reason: %s
\n", $e->getMessage() )); } catch (InvalidObjectException $e) { - die(sprintf("[Main:] Object not saved for following reason: %s
\n", + die(sprintf("[Main:] Object not saved for following reason: %s
\n", $e->getMessage() )); } catch (MissingMethodException $e) { - die(sprintf("[Main:] Object not saved for following reason: %s
\n", + die(sprintf("[Main:] Object not saved for following reason: %s
\n", $e->getMessage() )); } catch (UnsupportedLimitationPartException $e) { - die(sprintf("[Main:] Object not saved for following reason: %s
\n", + die(sprintf("[Main:] Object not saved for following reason: %s
\n", $e->getMessage() )); } catch (GetterNotFoundException $e) { - die(sprintf("[Main:] Object not saved for following reason: %s
\n", + die(sprintf("[Main:] Object not saved for following reason: %s
\n", $e->getMessage() )); } catch (NoArrayCreatedException $e) { - die(sprintf("[Main:] Object not saved for following reason: %s
\n", + die(sprintf("[Main:] Object not saved for following reason: %s
\n", $e->getMessage() )); } catch (InvalidArrayCountException $e) { - die(sprintf("[Main:] Object not saved for following reason: %s
\n", + die(sprintf("[Main:] Object not saved for following reason: %s
\n", $e->getMessage() )); } diff --git a/tests/old/personell-test.php b/tests/old/personell-test.php index 67dea21..3a67420 100644 --- a/tests/old/personell-test.php +++ b/tests/old/personell-test.php @@ -32,63 +32,63 @@ require($cfg->readConfig('base_path') . 'application/ship-simu/loader.php'); try { $personell = SimulatorPersonell::createSimulatorPersonellByID('SimulatorPersonell@829292aeca3f6bf78c16e25fc4f75c98'); } catch (InvalidIDFormatException $e) { - die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", $e->getMessage() )); } catch (InvalidArrayCountException $e) { - die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", $e->getMessage() )); } catch (NullPointerException $e) { - die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", $e->getMessage() )); } catch (NoObjectException $e) { - die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", $e->getMessage() )); } catch (MissingMethodException $e) { - die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", $e->getMessage() )); } catch (FileIsEmptyException $e) { - die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", $e->getMessage() )); } catch (FilePointerNotOpenedException $e) { - die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", $e->getMessage() )); } catch (InvalidArrayCountException $e) { - die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", $e->getMessage() )); } catch (InvalidMD5ChecksumException $e) { - die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", $e->getMessage() )); } catch (InvalidDataLengthException $e) { - die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", $e->getMessage() )); } catch (InvalidSimulatorIDException $e) { - die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", $e->getMessage() )); } catch (MismatchingCompressorsException $e) { - die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", $e->getMessage() )); } catch (ContainerItemIsNullException $e) { - die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", $e->getMessage() )); } catch (ContainerItemIsNoArrayException $e) { - die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", $e->getMessage() )); } catch (ContainerMaybeDamagedException $e) { - die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", + die(sprintf("[Main:] Could not create personal list for follwing reason: %s
\n", $e->getMessage() )); } @@ -108,15 +108,15 @@ exit(); try { $personell = SimulatorPersonell::createSimulatorPersonell(20); } catch (NullPointerException $e) { - die(sprintf("[Main:] Personal list not created for following reason: %s
\n", + die(sprintf("[Main:] Personal list not created for following reason: %s
\n", $e->getMessage() )); } catch (NoObjectException $e) { - die(sprintf("[Main:] Personal list not created for following reason: %s
\n", + die(sprintf("[Main:] Personal list not created for following reason: %s
\n", $e->getMessage() )); } catch (MissingMethodException $e) { - die(sprintf("[Main:] Personal list not created for following reason: %s
\n", + die(sprintf("[Main:] Personal list not created for following reason: %s
\n", $e->getMessage() )); } @@ -133,35 +133,35 @@ if (defined('DEBUG_PERSONELL_OBJ')) { try { $personell->saveObjectToDatabase(); } catch (NullPointerException $e) { - die(sprintf("[Main:] Object not saved for following reason: %s
\n", + die(sprintf("[Main:] Object not saved for following reason: %s
\n", $e->getMessage() )); } catch (NoObjectException $e) { - die(sprintf("[Main:] Object not saved for following reason: %s
\n", + die(sprintf("[Main:] Object not saved for following reason: %s
\n", $e->getMessage() )); } catch (InvalidObjectException $e) { - die(sprintf("[Main:] Object not saved for following reason: %s
\n", + die(sprintf("[Main:] Object not saved for following reason: %s
\n", $e->getMessage() )); } catch (MissingMethodException $e) { - die(sprintf("[Main:] Object not saved for following reason: %s
\n", + die(sprintf("[Main:] Object not saved for following reason: %s
\n", $e->getMessage() )); } catch (UnsupportedLimitationPartException $e) { - die(sprintf("[Main:] Object not saved for following reason: %s
\n", + die(sprintf("[Main:] Object not saved for following reason: %s
\n", $e->getMessage() )); } catch (GetterNotFoundException $e) { - die(sprintf("[Main:] Object not saved for following reason: %s
\n", + die(sprintf("[Main:] Object not saved for following reason: %s
\n", $e->getMessage() )); } catch (NoArrayCreatedException $e) { - die(sprintf("[Main:] Object not saved for following reason: %s
\n", + die(sprintf("[Main:] Object not saved for following reason: %s
\n", $e->getMessage() )); } catch (InvalidArrayCountException $e) { - die(sprintf("[Main:] Object not saved for following reason: %s
\n", + die(sprintf("[Main:] Object not saved for following reason: %s
\n", $e->getMessage() )); } -- 2.39.2