private function updateSettings() { //update prefs $asErrorsPrefs = array(); try { $sLang = AnwEnv::_POST("lang", ""); AnwCurrentSession::setLang($sLang); $nTimezone = AnwEnv::_POST("timezone", 0); AnwCurrentSession::setTimezone($nTimezone); } catch (AnwBadLangException $e) { $asErrorsPrefs[] = $this->g_("err_badlang"); } catch (AnwBadTimezoneException $e) { $asErrorsPrefs[] = $this->g_("err_badtimezone"); } catch (AnwException $e) { $asErrorsPrefs[] = $this->g_("err_unkn"); } $asErrorsAccount = array(); if (AnwCurrentSession::isLoggedIn() && AnwUsers::isDriverInternal()) { //update account try { //displayname change requested ? if (self::globalCfgUsersChangeDisplayname()) { $sDisplayname = AnwEnv::_POST("displayname", ""); if (AnwCurrentSession::getUser()->getDisplayName() != $sDisplayname) { AnwCurrentSession::getUser()->changeDisplayName($sDisplayname); } } //email change requested ? $sEmail = AnwEnv::_POST("email", ""); if (AnwCurrentSession::getUser()->getEmail() != $sEmail) { AnwCurrentSession::getUser()->changeEmail($sEmail); } //password change requested ? $sNewPassword = AnwEnv::_POST("newpassword"); $sNewPasswordRepeat = AnwEnv::_POST("newpassword_repeat"); $sCurrentPassword = AnwEnv::_POST("currentpassword", ""); if ($sNewPassword) { if ($sNewPassword == $sNewPasswordRepeat) { try { //authenticate with current password AnwCurrentSession::getUser()->authenticate($sCurrentPassword); //authentication ok, change the password try { AnwCurrentSession::getUser()->changePassword($sNewPassword); } catch (AnwBadPasswordException $e) { $asErrorsAccount[] = $this->t_("err_badnewpassword"); } } catch (AnwBadPasswordException $e) { $asErrorsAccount[] = $this->g_("err_incorrectpassword"); } catch (AnwAuthException $e) { $asErrorsAccount[] = $this->g_("err_incorrectpassword"); } } else { $asErrorsAccount[] = $this->g_("err_passwordsmatch"); } } } catch (AnwDisplayNameAlreadyTakenException $e) { $asErrorsAccount[] = $this->g_("err_displaynamealreadytaken"); } catch (AnwBadDisplayNameException $e) { $asErrorsAccount[] = $this->g_("err_baddisplayname"); } catch (AnwEmailAlreadyTakenException $e) { $asErrorsAccount[] = $this->g_("err_emailalreadytaken"); } catch (AnwBadEmailException $e) { $asErrorsAccount[] = $this->g_("err_bademail"); } catch (AnwException $e) { $asErrorsAccount[] = $this->g_("err_unkn"); } } if (count($asErrorsPrefs) > 0 || count($asErrorsAccount) > 0) { $this->formSettings(false, $asErrorsPrefs, $asErrorsAccount); } else { AnwUtils::redirect($this->linkMe(array("done" => 1))); } }
function needsCaptcha() { return AnwCurrentSession::isLoggedIn() ? false : true; }
function output($bEmergencyError = false) { AnwDebug::startbench("output", true); //render head $this->renderHeadForOutput(); //global actions /*$asAllGlobalActions = array("lastchanges", "sitemap", "untranslated", "management"); $asAvailableGlobalActions = array(); foreach ($asAllGlobalActions as $sAction) { if (AnwCurrentSession::isActionGlobalAllowed($sAction)) { $asAvailableGlobalActions[] = array( 'action' => $sAction, 'link' => AnwUtils::alink($sAction), 'translation' => self::g_("action_".$sAction) ); } }*/ if (!$bEmergencyError) { //session nav if (AnwCurrentSession::isLoggedIn()) { $sLinkProfile = AnwUsers::isDriverInternal() ? AnwUtils::alink("profile") : AnwUsers::getLinkProfile(AnwCurrentSession::getUser()); $sLinkSettings = AnwUtils::aLink("settings"); $sLinkLogout = AnwSessions::isDriverInternal() ? AnwUtils::alink("logout") : AnwSessions::getLogoutLink(); $sessionnav = $this->tpl()->sessionNavLoggedin(AnwCurrentSession::getUser()->getDisplayName(), $sLinkProfile, $sLinkSettings, $sLinkLogout); } else { $sLinkSettings = AnwUtils::aLink("settings"); $sLinkLogin = AnwSessions::isDriverInternal() ? AnwUtils::alink("login") : AnwSessions::getLoginLink(); if (self::globalCfgUsersRegisterEnabled()) { $sLinkRegister = AnwUsers::isDriverInternal() ? AnwUtils::alink("register") : AnwUsers::getRegisterLink(); } else { $sLinkRegister = false; } $sessionnav = $this->tpl()->sessionNavGuest($sLinkSettings, $sLinkLogin, $sLinkRegister); } $aoAllowedGlobalNavEntries = $this->getGlobalNavEntriesAllowed(); if (count($aoAllowedGlobalNavEntries) > 0) { $globalnav = $this->tpl()->globalNav($aoAllowedGlobalNavEntries); } else { $globalnav = ""; } } else { $sessionnav = ""; $globalnav = ""; } $this->out = $this->tpl()->globalBody($sessionnav, $globalnav, $this->out); $this->out = $this->tpl()->globalHtml(self::g_("local_html_lang", array(), self::getActionLang()), self::g_("local_html_dir", array(), self::getActionLang()), $this->title, $this->head, $this->out); AnwDebug::stopbench("output"); $this->printOutput(); }