From d0fec7e5d36612e80b0cf5cbc9af08909664bb0c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sat, 15 Nov 2008 21:08:05 +0000 Subject: [PATCH] More improvements and fixes: - CAPTCHA added to profile page - Action for profile page added - User status re-fixed... - Form for training payed by goverment added (unfinished) - Web link/form/base helper fixed/improved --- .gitattributes | 1 + application/ship-simu/config.php | 9 +++ .../main/actions/web/class_WebShipSimuLogin | 3 +- .../class_WebShipSimuLoginLogoutAction.php | 2 + .../class_WebShipSimuLoginProfileAction.php | 79 +++++++++++++++++++ .../web/class_WebShipsimuProfileCommand.php | 3 + ...ion_ship_simu_login_goverment_training.ctp | 19 +++++ .../code/action_ship_simu_login_profile.ctp | 26 +++--- .../filter/change/class_EmailChangeFilter.php | 6 ++ .../change/class_PasswordChangeFilter.php | 6 ++ .../helper/web/forms/class_WebFormHelper.php | 6 -- .../helper/web/links/class_WebLinkHelper.php | 15 ++++ 12 files changed, 159 insertions(+), 16 deletions(-) create mode 100644 application/ship-simu/main/actions/web/class_WebShipSimuLoginProfileAction.php diff --git a/.gitattributes b/.gitattributes index 878445b..01097e3 100644 --- a/.gitattributes +++ b/.gitattributes @@ -167,6 +167,7 @@ application/ship-simu/main/actions/web/class_WebShipSimuLogin -text application/ship-simu/main/actions/web/class_WebShipSimuLoginCompanyAction.php -text application/ship-simu/main/actions/web/class_WebShipSimuLoginGovermentTrainingAction.php -text application/ship-simu/main/actions/web/class_WebShipSimuLoginLogoutAction.php -text +application/ship-simu/main/actions/web/class_WebShipSimuLoginProfileAction.php -text application/ship-simu/main/actions/web/class_WebShipSimuLoginRefillAction.php -text application/ship-simu/main/actions/web/class_WebShipSimuLoginWelcomeAction.php -text application/ship-simu/main/bank/.htaccess -text diff --git a/application/ship-simu/config.php b/application/ship-simu/config.php index ce4b96f..058397f 100644 --- a/application/ship-simu/config.php +++ b/application/ship-simu/config.php @@ -160,6 +160,9 @@ $cfg->setConfigEntry('captcha_register_verifier_filter', "GraphicalCodeCaptchaVe // CFG: CAPTCHA-REFILL-VERFIER-FILTER $cfg->setConfigEntry('captcha_refill_verifier_filter', "GraphicalCodeCaptchaVerifierFilter"); +// CFG: CAPTCHA-PROFILE-VERFIER-FILTER +$cfg->setConfigEntry('captcha_profile_verifier_filter', "GraphicalCodeCaptchaVerifierFilter"); + // CFG: CONFIRM-CODE-VERIFIER-FILTER $cfg->setConfigEntry('confirm_code_verifier_filter', "ConfirmCodeVerifierFilter"); @@ -226,6 +229,9 @@ $cfg->setConfigEntry('shipsimu_user_login_captcha', "GraphicalCodeCaptcha"); // CFG: SHIPSIMU-GUEST-LOGIN-CAPTCHA $cfg->setConfigEntry('shipsimu_guest_login_captcha', "GraphicalCodeCaptcha"); +// CFG: SHIPSIMU-PROFILE-CAPTCHA +$cfg->setConfigEntry('shipsimu_profile_captcha', "GraphicalCodeCaptcha"); + // CFG: REFILL-FORM-CAPTCHA $cfg->setConfigEntry('refill_form_captcha', "GraphicalCodeCaptcha"); @@ -247,6 +253,9 @@ $cfg->setConfigEntry('shipsimu_user_login_captcha_secured', "Y"); // CFG: SHIPSIMU-GUEST-LOGIN-CAPTCHA-SECURED $cfg->setConfigEntry('shipsimu_guest_login_captcha_secured', "Y"); +// CFG: SHIPSIMU-PROFILE-CAPTCHA-SECURED +$cfg->setConfigEntry('shipsimu_profile_captcha_secured', "Y"); + // CFG: REFILL-FORM-CAPTCHA-SECURED $cfg->setConfigEntry('refill_form_captcha_secured', "Y"); diff --git a/application/ship-simu/main/actions/web/class_WebShipSimuLogin b/application/ship-simu/main/actions/web/class_WebShipSimuLogin index 99b2e56..ad2f1cc 100644 --- a/application/ship-simu/main/actions/web/class_WebShipSimuLogin +++ b/application/ship-simu/main/actions/web/class_WebShipSimuLogin @@ -70,7 +70,8 @@ class WebShipSimuLogin???Action extends BaseAction implements Commandable, Regis * @todo Add some filters here */ public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) { - // Unfinished method + // Check for user status by default + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_status_filter')); } } diff --git a/application/ship-simu/main/actions/web/class_WebShipSimuLoginLogoutAction.php b/application/ship-simu/main/actions/web/class_WebShipSimuLoginLogoutAction.php index fed0d1d..31464c8 100644 --- a/application/ship-simu/main/actions/web/class_WebShipSimuLoginLogoutAction.php +++ b/application/ship-simu/main/actions/web/class_WebShipSimuLoginLogoutAction.php @@ -69,6 +69,8 @@ class WebShipSimuLoginLogoutAction extends BaseAction implements Commandable, Re * @return void */ public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) { + // Check for user status by default + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_status_filter')); } } diff --git a/application/ship-simu/main/actions/web/class_WebShipSimuLoginProfileAction.php b/application/ship-simu/main/actions/web/class_WebShipSimuLoginProfileAction.php new file mode 100644 index 0000000..532e47e --- /dev/null +++ b/application/ship-simu/main/actions/web/class_WebShipSimuLoginProfileAction.php @@ -0,0 +1,79 @@ + + * @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 WebShipSimuLoginProfileAction extends BaseAction 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 final static function createWebShipSimuLoginProfileAction (ActionResolver $resolverInstance) { + // Get a new instance + $actionInstance = new WebShipSimuLoginProfileAction(); + + // 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 0% done + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Unfinished method + } + + /** + * 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) { + // Check for user status by default + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_status_filter')); + } +} + +// [EOF] +?> diff --git a/application/ship-simu/main/commands/web/class_WebShipsimuProfileCommand.php b/application/ship-simu/main/commands/web/class_WebShipsimuProfileCommand.php index a9c652e..e8aff7d 100644 --- a/application/ship-simu/main/commands/web/class_WebShipsimuProfileCommand.php +++ b/application/ship-simu/main/commands/web/class_WebShipsimuProfileCommand.php @@ -133,6 +133,9 @@ class WebShipsimuProfileCommand extends BaseCommand implements Commandable { // Account password validation $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('account_password_filter')); + // Validate CAPTCHA input + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('captcha_profile_verifier_filter')); + // Email changed $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('email_change_filter')); diff --git a/application/ship-simu/templates/de/code/action_ship_simu_login_goverment_training.ctp b/application/ship-simu/templates/de/code/action_ship_simu_login_goverment_training.ctp index 3e60274..e168ef9 100644 --- a/application/ship-simu/templates/de/code/action_ship_simu_login_goverment_training.ctp +++ b/application/ship-simu/templates/de/code/action_ship_simu_login_goverment_training.ctp @@ -8,9 +8,28 @@ $helperInstance->prefetchValueInstance('user'); // Add main form group $helperInstance->addFormNote('reality_warning', "WARNUNG: Bitte dieses Formular nicht mit echten Angaben ausfüllen!"); +// Add group for personal data +$helperInstance->addFormGroup('persona_data', "Deine persönliche Daten, die für die Kursusteilnahme nötig sind:"); + +// Display email, surname and family name +$helperInstance->addFormNote('name', "Dein Name: ".$helperInstance->getValueField('surname')." ".$helperInstance->getValueField('family').""); +$helperInstance->addFormNote('email', "Email-Adresse: ".$helperInstance->getValueField('email').""); + +// Add link placeholder for profile page +$helperInstance->addFormNote('profile', "Stimmen die Daten noch? {?shipsimu_profile_link?}"); + // Flush the finished form $helperInstance->flushContent(); +// Get link helper for profile link +$linkInstance = WebLinkHelper::createWebLinkHelper($this, 'shipsimu_profile_link', 'index.php?app={?app_short_name?}&page=login_area'); + +// Add action +$linkInstance->addActionLinkById('profile', 'goto_profile_link'); + +// Flush the finished form +$linkInstance->flushContent(); + ?>
diff --git a/application/ship-simu/templates/de/code/action_ship_simu_login_profile.ctp b/application/ship-simu/templates/de/code/action_ship_simu_login_profile.ctp index 866489d..b97e27f 100644 --- a/application/ship-simu/templates/de/code/action_ship_simu_login_profile.ctp +++ b/application/ship-simu/templates/de/code/action_ship_simu_login_profile.ctp @@ -16,7 +16,7 @@ $helperInstance->addFieldText('pass2', "Neues Passwort, Wiederholung:"); $helperInstance->addInputPasswordField('pass2'); // Display current email -$helperInstance->addFormNote('current_email', "Derzeitige Email-Adresse: ".$helperInstance->getValueField('email').""); +$helperInstance->addFormNote('current_email', "Derzeitige Email-Adresse: ".$helperInstance->getValueField('email').""); // Only for changing email address if ($helperInstance->ifEmailChangeAllowed()) { @@ -29,12 +29,12 @@ if ($helperInstance->ifEmailChangeAllowed()) { if ($helperInstance->ifEmailMustBeUnique()) { $helperInstance->addFormNote('email', "Die von dir eingegebene Email-Adresse darf nur einmal im Spiel verwendet worden sein."); - } // END - Unique email addresses + } // END - if if ($helperInstance->ifEmailChangeRequireConfirmation()) { $helperInstance->addFormNote('confirm_link', "Es wird ein Bestätigungslink an deine neue Email-Adresse gesendet. Bitte klicke diesen dann möglichst schnell an."); - } // END - Change requires confirmation -} // END - email change allowed + } // END - if +} // END - if // Add form group for user profile $helperInstance->addFormGroup('profile', "Hier kannst du deine Profildaten ändern."); @@ -50,9 +50,9 @@ if ($helperInstance->ifRegisterIncludesPersonaData()) { $helperInstance->addInputTextFieldWithDefault('street'); $helperInstance->addFieldText('city', "Wohnort:"); $helperInstance->addInputTextFieldWithDefault('city'); -} // END - Persona data +} // END - if -// Add su group for zip code +// Add sub group for zip code $helperInstance->addFormSubGroup('zip', "Magst du uns auch deine Postleitzahl verraten?"); $helperInstance->addFieldText('zip', "Postleitzahl:"); $helperInstance->addInputTextFieldWithDefault('zip'); @@ -91,8 +91,8 @@ if ($helperInstance->ifChatEnabled('msn')) { } // END - if if (!$helperInstance->ifRegisterRequiresEmailVerification()) { - $helperInstance->addFormExtraNote(1, "Die Benachrichtigungen per sind im Loginbereich verfeinerbar, welche du genau haben willst."); -} // END - Extra note + $helperInstance->addFormExtraNote(1, "Die Benachrichtigungen per Email sind im Loginbereich verfeinerbar, welche du genau haben willst."); +} // END - if // Rules already accepted? if ($helperInstance->ifRulesHaveChanged()) { @@ -104,16 +104,24 @@ if ($helperInstance->ifRulesHaveChanged()) { $helperInstance->addInputHiddenField('rules', "1"); } +// CAPTCHA enabled? +if ($helperInstance->ifFormSecuredWithCaptcha()) { + $helperInstance->addFormGroup('captcha_user', "Unser Benuzter-Login ist durch ein CAPTCHA geschützt. Bitte wiederhole den angezeigten Code, damit du dich einloggen kannst."); + $helperInstance->addCaptcha(); +} // END - if + // Ask again for current account password $helperInstance->addFormGroup('pass_old', "Bitte gebe zur Bestätigung der Änderungen dein derzeitiges Passwort ein."); $helperInstance->addFieldText('pass_old', "Derzeitiges Passwort:"); $helperInstance->addInputPasswordField('pass_old'); -// Abschliessender Hinweis und Abschluss des Formulars +// Final notices $helperInstance->addFormGroup('buttons', "Sind alle Daten nun korrekt eingegeben? Dann sende sie mit einem Klick einfach ab!"); $helperInstance->addInputResetButton("Alles nochmal eingeben"); $helperInstance->addInputSubmitButton("Accountdaten aktualisieren"); $helperInstance->addFormNote('data_protection', "Deine Daten werden nach den gültigen Datenschutzgesetzten gespeichert und werden nicht an Dritte weitergegeben. Weiteres dazu siehe Link "Datenschutz"."); + +// Flush finished form $helperInstance->flushContent(); ?>
diff --git a/inc/classes/main/filter/change/class_EmailChangeFilter.php b/inc/classes/main/filter/change/class_EmailChangeFilter.php index 0991492..d213a22 100644 --- a/inc/classes/main/filter/change/class_EmailChangeFilter.php +++ b/inc/classes/main/filter/change/class_EmailChangeFilter.php @@ -94,6 +94,12 @@ class EmailChangeFilter extends BaseFrameworkSystem implements Filterable { return false; } // END - if + // Are email and confirmation empty? + if ((empty($email1)) && (empty($email2))) { + // No email change required! + return true; + } // END - if + // Now, get a user instance for comparison $userInstance = Registry::getRegistry()->getInstance('user'); diff --git a/inc/classes/main/filter/change/class_PasswordChangeFilter.php b/inc/classes/main/filter/change/class_PasswordChangeFilter.php index 078d294..5a604fd 100644 --- a/inc/classes/main/filter/change/class_PasswordChangeFilter.php +++ b/inc/classes/main/filter/change/class_PasswordChangeFilter.php @@ -82,6 +82,12 @@ class PasswordChangeFilter extends BaseFrameworkSystem implements Filterable { return false; } // END - if + // Are password and confirmation empty? + if ((empty($pass1)) && (empty($pass2))) { + // Don't change password here + return true; + } // END - if + // Do both match? if ($pass1 != $pass2) { // Request is invalid! diff --git a/inc/classes/main/helper/web/forms/class_WebFormHelper.php b/inc/classes/main/helper/web/forms/class_WebFormHelper.php index acb419a..539f025 100644 --- a/inc/classes/main/helper/web/forms/class_WebFormHelper.php +++ b/inc/classes/main/helper/web/forms/class_WebFormHelper.php @@ -552,12 +552,6 @@ class WebFormHelper extends BaseWebHelper implements HelpableTemplate { throw new FormClosedException (array($this, "form_notes"), self::EXCEPTION_CLOSED_FORM); } // END - if - // Is a group open? - if ($this->ifGroupOpenedPreviously()) { - // Then automatically close it here - $this->addFormGroup(); - } // END - if - // Generate the content $inputContent = sprintf("
%s diff --git a/inc/classes/main/helper/web/links/class_WebLinkHelper.php b/inc/classes/main/helper/web/links/class_WebLinkHelper.php index 540cf80..1a238a6 100644 --- a/inc/classes/main/helper/web/links/class_WebLinkHelper.php +++ b/inc/classes/main/helper/web/links/class_WebLinkHelper.php @@ -251,6 +251,21 @@ class WebLinkHelper extends BaseWebHelper implements HelpableTemplate { $this->addContentToPreviousGroup($linkContent); } + /** + * Adds a link to the previously opened group with a text from language system + * + * @param $linkAction Action (action=xxx) value for the link + * @param $languageId Language id string to use + * @return void + */ + public function addActionLinkById ($linkAction, $languageId) { + // Resolve the language string + $languageResolved = $this->getLanguageInstance()->getMessage($languageId); + + // Add the action link + $this->addActionLink($linkAction, $languageResolved); + } + /** * Adds a default link (no extra parameters) to the content with specified * language id string. -- 2.30.2