application/ship-simu/main/actions/.htaccess -text
application/ship-simu/main/actions/class_ShipSimuLoginAction.php -text
application/ship-simu/main/actions/class_ShipSimuLogoutAction.php -text
+application/ship-simu/main/actions/class_ShipSimuProfileAction.php -text
application/ship-simu/main/class_ -text
application/ship-simu/main/class_BasePersonell.php -text
application/ship-simu/main/class_BaseSimulator.php -text
application/ship-simu/templates/de/code/login_form.ctp -text
application/ship-simu/templates/de/code/login_logout.ctp -text
application/ship-simu/templates/de/code/login_main.ctp -text
+application/ship-simu/templates/de/code/login_profile.ctp -text
application/ship-simu/templates/de/code/login_welcome.ctp -text
application/ship-simu/templates/de/code/logout_done.ctp -text
application/ship-simu/templates/de/code/register_form.ctp -text
// CFG: GUEST-LOGIN-ALLOWED
$cfg->setConfigEntry('guest_login_allowed', "Y");
+// CFG: EMAIL-CHANGE-CONFIRMATION
+$cfg->setConfigEntry('email_change_confirmation', "Y");
+
+// CFG: EMAIL-CHANGE-ALLOWED
+$cfg->setConfigEntry('email_change_allowed', "Y");
+
// CFG: GUEST-LOGIN-USERNAME
$cfg->setConfigEntry('guest_login_username', "guest");
// CFG: LOGIN-LOGOUT-ACTION-CLASS
$cfg->setConfigEntry('login_logout_action_class', "ShipSimuLogoutAction");
+// CFG: LOGIN-PROFILE-ACTION-CLASS
+$cfg->setConfigEntry('login_profile_action_class', "ShipSimuProfileAction");
+
// CFG: LOGOUT-IMMEDIATE
$cfg->setConfigEntry('logout_immediate', "N");
--- /dev/null
+<?php
+/**
+ * An action class for the profile page
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+class ShipSimuProfileAction extends BaseAction implements Commandable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set description
+ $this->setObjectDescription("Profile action");
+
+ // Generate unique key
+ $this->generateUniqueId();
+ }
+
+ /**
+ * Creates an instance of this action
+ *
+ * @return $actionInstance An instance of this action class
+ */
+ public final static function createShipSimuProfileAction () {
+ // Get a new instance
+ $actionInstance = new ShipSimuProfileAction();
+
+ // 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
+ */
+ public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+ /* @TODO Maybe we need to do something later here */
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+// Get helper instance for web forms. This will add the opening form-tag to
+// the helper's render cache which is simply a small variable in the class
+// BaseHelper.
+$helper = WebFormHelper::createWebFormHelper($this, "shipsimu_profile");
+
+// Pre-fetch field data with a given registry key
+$helper->prefetchFieldValues('user');
+
+// Password can only be changed when the old one is entered and new one twice!
+$helper->addFormGroup("pass", "Neues Passwort einrichten:");
+$helper->addFormSubGroup("password", "Bitte gebe zum Ändern deines Passwortes zweimal das gewünschte neue Passwort ein.");
+$helper->addFieldText("pass1", "Neues Passwort:");
+$helper->addInputPasswordField("pass1");
+$helper->addFieldText("pass2", "Neues Passwort, Wiederholung:");
+$helper->addInputPasswordField("pass2");
+
+// Display current email
+$helper->addFormNote("Derzeitige Email-Adresse: <span id=\"displayed_field\">".$helper->getField("email")."</span>");
+
+// Only for changing email address
+if ($helper->ifEmailChangeAllowed()) {
+ $helper->addFormGroup("email", "Änderung deiner Email-Addresse:");
+ $helper->addFormSubGroup("email", "Gebe nur deine Email-Adresse zweimal ein, wenn du diese ändern möchtest!");
+ $helper->addFieldText("email1", "Email-Adresse:");
+ $helper->addInputTextField("email1");
+ $helper->addFieldText("email2", "Wiederholung Email-Adresse:");
+ $helper->addInputTextField("email2");
+
+ if ($helper->ifEmailMustBeUnique()) {
+ $helper->addFormNote("Die von dir eingegebene Email-Adresse darf nur einmal im Spiel verwendet worden sein.");
+ } // END - Unique email addresses
+
+ if ($helper->ifEmailChangeRequireConfirmation()) {
+ $helper->addFormNote("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
+
+$helper->addFormGroup("profile", "Hier kannst du deine Profildaten ändern.");
+
+// Persoenliche Daten mit in der Anmeldung abfragen?
+if ($helper->ifRegisterIncludesPersonaData()) {
+ $helper->addFormSubGroup("persona", "Wenn du magst, dann vervollständige deine komplette Adresse mit deinem Namen.");
+ $helper->addFieldText("surname", "Dein Vorname:");
+ $helper->addInputTextFieldWithDefault("surname");
+ $helper->addFieldText("family", "Dein Nachname:");
+ $helper->addInputTextFieldWithDefault("family");
+ $helper->addFieldText("street", "Strasse und Hausnummer:");
+ $helper->addInputTextFieldWithDefault("street");
+ $helper->addFieldText("city", "Wohnort:");
+ $helper->addInputTextFieldWithDefault("city");
+} // END - Persona data
+
+$helper->addFormSubGroup("zip", "Magst du uns auch deine Postleitzahl verraten?");
+$helper->addFieldText("zip", "Postleitzahl:");
+$helper->addInputTextFieldWithDefault("zip");
+
+$helper->addFormSubGroup("chat", "Gebe hier deine Nicknames bzw. Nummern an:");
+
+if ($helper->ifChatEnabled("icq")) {
+ $helper->addFieldText("icq", "ICQ-Nummer:");
+ $helper->addInputTextFieldWithDefault("icq");
+} // END - if
+
+if ($helper->ifChatEnabled("jabber")) {
+ $helper->addFieldText("jabber", "Jabber:");
+ $helper->addInputTextFieldWithDefault("jabber");
+} // END - if
+
+if ($helper->ifChatEnabled("yahoo")) {
+ $helper->addFieldText("yahoo", "Yahoo!:");
+ $helper->addInputTextFieldWithDefault("yahoo");
+} // END - if
+
+if ($helper->ifChatEnabled("aol")) {
+ $helper->addFieldText("aol", "AOL-Screenname:");
+ $helper->addInputTextFieldWithDefault("aol");
+} // END - if
+
+if ($helper->ifChatEnabled("msn")) {
+ $helper->addFieldText("msn", "MSN:");
+ $helper->addInputTextFieldWithDefault("msn");
+} // END - if
+
+if (!$helper->ifRegisterRequiresEmailVerification()) {
+ $helper->addFormExtraNote(1, "Die Benachrichtigungen per sind im Loginbereich verfeinerbar, welche du genau haben willst.");
+} // END - Extra note
+
+// Rules already accepted?
+if ($helper->ifRulesHaveChanged()) {
+ $helper->addFormGroup("rules", "Bitte lese dir die Spieleregeln gut durch und kreuze dann "Ja, ich akzeptiere die aktuellen Spielregeln" an.");
+ $helper->addFieldText("rules", "Ja, ich akzeptiere die aktuellen Spielregeln:");
+ $helper->addInputCheckboxField("rules", false);
+} else {
+ $helper->addFormNote("Du hast die aktuellen Spielregeln akzeptiert. Vielen Dank!");
+ $helper->addInputHiddenField("rules", "1");
+}
+
+// Ask again for current account password
+$helper->addFormGroup("pass_old", "Bitte gebe zur Bestätigung der Änderungen dein derzeiges Passwort ein.");
+$helper->addFieldText("pass_old", "Altes Passwort:");
+$helper->addInputPasswordField("pass_old");
+
+// Abschliessender Hinweis und Abschluss des Formulars
+$helper->addFormGroup("buttons", "Sind alle Daten nun korrekt eingegeben? Dann sende sie mit einem Klick einfach ab!");
+$helper->addInputResetButton("Alles nochmal eingeben");
+$helper->addInputSubmitButton("Accountdaten aktualisieren");
+$helper->addFormNote("Deine Daten werden nach den gültigen Datenschutzgesetzten gespeichert und werden nicht an Dritte weitergegeben. Weiteres dazu siehe Link "Datenschutz".");
+$helper->addFormTag();
+$helper->flushContent();
+?>
+<div id="content_header">
+ Ihre Profildaten bearbeiten
+</div>
+
+<div id="profile_box">
+ {?shipsimu_profile?}
+</div>
// BaseHelper.
$helper = WebFormHelper::createWebFormHelper($this, "shipsimu_register");
-// Nickname und Passwort sollten immer abgefragt werden, die Email als Loginname
-// wuerde aber auch gehen.
+// Always ask at least for nickname and password
$helper->addFormGroup("login", "Bitte gebe hier gewünschten Nickname und dein Zugangspasswort ein.");
$helper->addFormSubGroup("username", "Dein Nickname wird erst nach Absenden des Formulares geprüft. Später bauen wir dann einen automatischen Test ein, der dir sofort zeigt, ob der Nickname bereits vergeben ist.");
$helper->addFieldText("username", "Nickname im Spiel:");
$helper->addInputTextField("email1");
$helper->addFieldText("email2", "Wiederholung Email-Adresse:");
$helper->addInputTextField("email2");
+
if ($helper->ifEmailMustBeUnique()) {
$helper->addFormNote("Die von dir eingegebene Email-Adresse darf nur einmal im Spiel verwendet worden sein.");
} // END - Unique email addresses
+
} // END - email verification
if ($helper->ifRegisterIncludesProfile()) {
$helper->addFormGroup("profile", "Hier kannst du zusätzlich deine Profildaten vorweg eingeben, du kannst sie aber auch nach dem Login vervollständigen!");
+
if (!$helper->ifRegisterRequiresEmailVerification()) {
$helper->addFormSubGroup("email", "Die Angabe deiner Email-Adresse ist nur dann nötig, wenn du auch Email-Benachrichtigungen (<span id=\"add_note\">*1</span>) haben möchtest.");
$helper->addFieldText("email1", "Email-Adresse:");
$helper->addInputTextField("zip");
$helper->addFormSubGroup("chat", "Gebe hier deine Nicknames bzw. Nummern an:");
+
if ($helper->ifChatEnabled("icq")) {
$helper->addFieldText("icq", "ICQ-Nummer:");
$helper->addInputTextField("icq");
- }
+ } // END - if
+
if ($helper->ifChatEnabled("jabber")) {
$helper->addFieldText("jabber", "Jabber:");
$helper->addInputTextField("jabber");
- }
+ } // END - if
+
if ($helper->ifChatEnabled("yahoo")) {
$helper->addFieldText("yahoo", "Yahoo!:");
$helper->addInputTextField("yahoo");
- }
+ } // END - if
+
if ($helper->ifChatEnabled("aol")) {
$helper->addFieldText("aol", "AOL-Screenname:");
$helper->addInputTextField("aol");
- }
+ } // END - if
+
if ($helper->ifChatEnabled("msn")) {
$helper->addFieldText("msn", "MSN:");
$helper->addInputTextField("msn");
- }
+ } // END - if
if (!$helper->ifRegisterRequiresEmailVerification()) {
$helper->addFormExtraNote(1, "Die Benachrichtigungen per sind im Loginbereich verfeinerbar, welche du genau haben willst.");
} // END - Extra note
+
} // END - ask profile data
// Spielregeln abfragen
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
class WebFormHelper extends BaseHelper {
+ /**
+ * Instance to the class which provides field values
+ */
+ private $valueInstance = null;
+
/**
* Wether the form tag is opened (keep at false or else your forms will
* never work!)
return $helperInstance;
}
+ /**
+ * Pre-fetches field default values from the given registry key instance into this class
+ *
+ * @param $registryKey
+ * @return void
+ * @throws NullPointerException If an instance from registry is null
+ */
+ public function prefetchFieldValues ($registryKey) {
+ // Get the required instance
+ $this->valueInstance = Registry::getRegistry()->getInstance($registryKey);
+
+ // Is the instance valid?
+ if (is_null($this->valueInstance)) {
+ // Throw an exception
+ throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
+ } // END - if
+ }
+
/**
* Add the form tag or close it an already opened form tag
*
* Add a text input tag to the form or throw an exception if it is not yet
* opened. The field's name will be set as id.
*
- * @param $fieldName Input field name
- * @param $fieldValue Input default value (default: empty)
+ * @param $fieldName Input field name
+ * @param $fieldValue Input default value (default: empty)
* @return void
* @throws FormClosedException If the form is not yet opened
*/
$this->addContent($inputContent);
}
+ /**
+ * Add a text input tag to the form with pre-loaded default value
+ *
+ * @param $fieldName Input field name
+ * @return void
+ */
+ public function addInputTextFieldWithDefault ($fieldName) {
+ // Get the value from instance
+ $fieldValue = call_user_func_array(array($this->valueInstance, "getField"), array($fieldName));
+ //* DEBUG: */ echo __METHOD__.":".$fieldName."=".$fieldValue."<br />\n";
+
+ // Add the text field
+ $this->addInputTextField($fieldName, $fieldValue);
+ }
+
/**
* Add a password input tag to the form or throw an exception if it is not
* yet opened. The field's name will be set as id.
return $isAllowed;
}
+ /**
+ * Checks wether the email address change must be confirmed
+ *
+ * @return $requireConfirm Wether email change must be confirmed
+ */
+ public function ifEmailChangeRequireConfirmation () {
+ $requireConfirm = ($this->getConfigInstance()->readConfig('email_change_confirmation') == "Y");
+ return $requireConfirm;
+ }
+
+ /**
+ * Checks wether the rules has been updated
+ *
+ * @return $rulesUpdated Wether rules has been updated
+ */
+ public function ifRulesHaveChanged () {
+ /* @TODO Implement check if rules have been changed */
+ return false;
+ }
+
+ /**
+ * Checks wether email change is allowed
+ *
+ * @return $emailChange Wether changing email address is allowed
+ */
+ public function ifEmailChangeAllowed () {
+ $emailChange = ($this->getConfigInstance()->readConfig('email_change_allowed') == "Y");
+ return $emailChange;
+ }
+
/**
* Flushs the content out (not yet secured against open forms, etc.!) or
* throw an exception if it is not yet closed
// Send content to template engine
$this->getTemplateInstance()->assignVariable($this->formName, $this->getContent());
}
+
+ /**
+ * Getter for direct field values
+ *
+ * @param $fieldName Name of the field we shall fetch
+ * @return $fieldValue Value from field
+ */
+ public function getField ($fieldName) {
+ // Get the field value
+ $fieldValue = call_user_func_array(array($this->valueInstance, "getField"), array($fieldName));
+
+ // Return it
+ return $fieldValue;
+ }
}
// [EOF]
$wrapperInstance->doUpdateByResult($this->resultInstance);
} // END - if
}
+
+ /**
+ * Getter for field name
+ *
+ * @param $fieldName Field name which we shall get
+ * @return $fieldValue Field value from the user
+ */
+ public function getField ($fieldName) {
+ // Default field value
+ $fieldValue = null;
+
+ // Get current array
+ $fieldArray = $this->resultInstance->current();
+
+ // Does the field exist?
+ if (isset($fieldArray[$fieldName])) {
+ // Get it
+ $fieldValue = $fieldArray[$fieldName];
+ } // END - if
+
+ // Return it
+ return $fieldValue;
+ }
}
// [EOF]