/** * Set all fieldsets and fields */ public function setFieldsetsAndFields() { $Data = AccountHandler::getDataForId(SessionAccountHandler::getId()); FormularInput::setStandardSize(FormularInput::$SIZE_MIDDLE); $UsernameField = new FormularInput('name', __('Username'), $Data['username']); $UsernameField->setDisabled(); $MailField = new FormularInput('name', __('Email address'), $Data['mail']); $MailField->setDisabled(); $NameField = new FormularInput('name', __('Name'), $Data['name']); $LanguageField = new FormularSelectBox('language', __('Language'), $Data['language']); foreach (Language::availableLanguages() as $klang => $lang) { $LanguageField->addOption($klang, $lang[0]); } $SinceField = new FormularInput('name', __('Registered since'), date('d.m.Y H:i', $Data['registerdate'])); $SinceField->setDisabled(); $LastLoginField = new FormularInput('name', __('Last Login'), date('d.m.Y H:i', $Data['lastlogin'])); $LastLoginField->setDisabled(); $Account = new FormularFieldset(__('Your account')); $Account->addField($UsernameField); $Account->addField($MailField); $Account->addField($NameField); $Account->addField($LanguageField); $Account->addField($SinceField); $Account->addField($LastLoginField); $AllowMailsField = new FormularSelectBox('allow_mails', __('Email me'), $Data['allow_mails']); $AllowMailsField->addOption('1', __('Yes')); $AllowMailsField->addOption('0', __('No')); $Notifications = new FormularFieldset(__('Notifications')); $Notifications->addInfo(__('At irregular intervals we are sending mails to you. We will never send you spam or advertisement.')); $Notifications->addField($AllowMailsField); $Password = new FormularFieldset(__('Change your password')); if (empty($_POST['old_pw']) && empty($_POST['new_pw']) && empty($_POST['new_pw_repeat'])) { $Password->setCollapsed(); } else { // Don't show passwords as 'value="..."' $_POST['old_pw'] = ''; $_POST['new_pw'] = ''; $_POST['new_pw_repeat'] = ''; } $Password->addField(new FormularInputPassword('old_pw', __('Old password'))); $Password->addField(new FormularInputPassword('new_pw', __('New password'))); $Password->addField(new FormularInputPassword('new_pw_repeat', __('Repeat new password'))); $Backup = new FormularFieldset(__('Backup your data')); $Backup->setCollapsed(); $Factory = new PluginFactory(); if ($Factory->isInstalled('RunalyzePluginTool_DbBackup')) { $Plugin = $Factory->newInstance('RunalyzePluginTool_DbBackup'); $Backup->addInfo(__('Please use the plugin') . ' \'<strong>' . $Plugin->getWindowLink() . '</strong>\'.'); } else { $Backup->addInfo(__('The backup of all your data is not manually possible yet.<br>' . 'In important individual cases write us an e-mail to mail@runalyze.de and and we will take care of it right away!')); } $DeleteLink = Ajax::window('<a href="call/window.delete.php"><strong>' . __('Delete your account') . ' »</strong></a>') . '<br><br>' . __('You\'ll receive an email with a link to confirm the deletion.<br>' . 'The deletion is permanent and cannot be reversed. ' . 'Therefore, you should backup your data.'); $Delete = new FormularFieldset(__('Delete your account')); $Delete->setCollapsed(); $Delete->addWarning($DeleteLink); $this->Formular->addFieldset($Account); $this->Formular->addFieldset($Notifications); $this->Formular->addFieldset($Password); $this->Formular->addFieldset($Backup); $this->Formular->addFieldset($Delete); $this->Formular->setLayoutForFields(FormularFieldset::$LAYOUT_FIELD_W100); }
/** * Get fieldset for settings * @return \FormularFieldset */ private function getSettingsFieldset() { FormularInput::setStandardSize(FormularInput::$SIZE_MIDDLE); $Fieldset = new FormularFieldset(__('Settings')); $Fieldset->addField(new FormularCheckbox('RUNALYZE_DEBUG', __('Debug mode'))); $Fieldset->addField(new FormularCheckbox('USER_CANT_LOGIN', __('Maintenance mode'))); $Fieldset->addField(new FormularCheckbox('USER_CAN_REGISTER', __('Users can register'))); $Fieldset->addField(new FormularInput('GARMIN_API_KEY', Ajax::tooltip(__('Garmin API-key'), __('Needed for any online-version of the Garmin Communicator<br>see http://developer.garmin.com/web-device/garmin-communicator-plugin/get-your-site-key/')))); $Fieldset->addField(new FormularInput('PERL_PATH', __('Perl Path'))); $Fieldset->addField(new FormularInput('TTBIN_PATH', __('TTBIN Converter Path'))); $Fieldset->addField(new FormularInput('MAIL_SENDER', __('Sender e-mail'))); $Fieldset->addField(new FormularInput('MAIL_NAME', __('Sender e-mail name'))); $Fieldset->addField(new FormularInput('SMTP_HOST', __('SMTP: host'))); $Fieldset->addField(new FormularInput('SMTP_PORT', __('SMTP: port'))); $Fieldset->addField(new FormularInput('SMTP_SECURITY', __('SMTP: encryption'))); $Fieldset->addField(new FormularInput('SMTP_USERNAME', __('SMTP: username'))); $Fieldset->addField(new FormularInputPassword('SMTP_PASSWORD', __('SMTP: password'))); $Fieldset->addField(new FormularInput('OPENWEATHERMAP_API_KEY', Ajax::tooltip(__('OpenWeatherMap API-Key'), __('Loading weather data requires an api key, see openweathermap.org/appid')))); $Fieldset->addField(new FormularInput('NOKIA_HERE_APPID', Ajax::tooltip(__('Nokia/Here App-ID'), __('Nokia maps require an app-id/-token, see developer.here.com')))); $Fieldset->addField(new FormularInput('NOKIA_HERE_TOKEN', Ajax::tooltip(__('Nokia/Here Token'), __('Nokia maps require an app-id/-token, see developer.here.com')))); $Fieldset->addField(new FormularSubmit(__('Save'), '')); $Fieldset->setLayoutForFields(FormularFieldset::$LAYOUT_FIELD_W100); if (!is_writable(FRONTEND_PATH . '../data/config.php')) { $Fieldset->addError(__('<strong>data/config.php</strong> is not writable') . ', <em>(chmod = ' . substr(decoct(fileperms(FRONTEND_PATH . '../data/config.php')), 1) . ')</em> ' . __('Changes can\'t be saved.')); } return $Fieldset; }
if (!USER_CAN_REGISTER) { echo HTML::error(__('Registrations are currently disabled.')); } else { if (isset($_POST['new_username'])) { $Errors = AccountHandler::tryToRegisterNewUser(); if (is_array($Errors)) { foreach ($Errors as $Error) { if (is_array($Error)) { foreach (array_keys($Error) as $FieldName) { FormularField::setKeyAsFailed($FieldName); } } } } } FormularInput::setStandardSize(FormularInput::$SIZE_MIDDLE); $Field = new FormularInput('new_username', __('Username')); $Field->setLayout(FormularFieldset::$LAYOUT_FIELD_W100); $Field->setUnit(FormularUnit::$USER); $Field->display(); $Field = new FormularInput('name', __('Name')); $Field->setLayout(FormularFieldset::$LAYOUT_FIELD_W100); $Field->setUnit(FormularUnit::$USER); $Field->display(); $Field = new FormularInput('email', __('Email')); $Field->setLayout(FormularFieldset::$LAYOUT_FIELD_W100); $Field->setUnit(FormularUnit::$MAIL); $Field->display(); $Field = new FormularInputPassword('password', __('Password')); $Field->setLayout(FormularFieldset::$LAYOUT_FIELD_W100); $Field->setUnit(FormularUnit::$PASS);