/** * @covers AccountHandler::usernameExists * @covers AccountHandler::mailExists * @covers AccountHandler::getMailFor * @covers AccountHandler::getDataForId * @covers AccountHandler::getDataFor */ public function testSimpleGetter() { DB::getInstance()->exec('DELETE FROM `runalyze_account` WHERE `id` = 1 OR `id` = 13'); DB::getInstance()->insert('account', array('id', 'username', 'name', 'mail'), array(1, 'Testuser', 'Max Mustermann', '*****@*****.**')); $this->assertEquals(true, AccountHandler::usernameExists('Testuser')); $this->assertEquals(false, AccountHandler::usernameExists('Tester')); $this->assertEquals(true, AccountHandler::mailExists('*****@*****.**')); $this->assertEquals(false, AccountHandler::mailExists('*****@*****.**')); $this->assertEquals('*****@*****.**', AccountHandler::getMailFor('Testuser')); $this->assertEquals(false, AccountHandler::getMailFor('Tester')); $this->assertTrue(is_array(AccountHandler::getDataForId(1))); $this->assertEquals(false, AccountHandler::getDataForId(13)); $this->assertTrue(is_array(AccountHandler::getDataFor('Testuser'))); $this->assertEquals(false, AccountHandler::getDataFor('Tester')); }
/** * Function to display the HTML-Header */ public function displayHeader() { self::$IS_SHOWN = true; self::$IS_IFRAME = Request::param('mode') == 'iframe'; $this->setEncoding(); $this->initTraining(); $UserId = !is_null($this->ActivityContext) ? SessionAccountHandler::getId() : 0; $User = AccountHandler::getDataForId($UserId); if (!Request::isAjax()) { if (self::$IS_IFRAME) { include 'tpl/tpl.FrontendSharedIframe.header.php'; } else { include 'tpl/tpl.FrontendShared.header.php'; } } Error::getInstance()->header_sent = true; }
/** * Display shared menu */ protected function displaySharedMenu() { $User = AccountHandler::getDataForId(SharedLinker::getUserId()); $this->ToolbarLinks = array(); $this->ToolbarLinks[] = SharedLinker::getStandardLinkTo($this->Context->activity()->id(), Icon::$ATTACH); $this->ToolbarLinks[] = '<a href="shared/' . $User['username'] . '/" target="_blank">' . Icon::$TABLE . '</a>'; $this->displayHeaderMenu(); }
/** * Try to set account from request */ public static function setAccountFromRequest() { if (empty(self::$Account)) { self::$Account = AccountHandler::getDataForId(SharedLinker::getUserId()); } }
/** * 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); }