/** * Load and set session vars * * @access protected * @return void */ protected function _sessioncontrol() { Yii::import('application.libraries.Limesurvey_lang'); // From personal settings if (Yii::app()->request->getPost('action') == 'savepersonalsettings') { if (Yii::app()->request->getPost('lang') == 'auto') { $sLanguage = getBrowserLanguage(); } else { $sLanguage = Yii::app()->request->getPost('lang'); } Yii::app()->session['adminlang'] = $sLanguage; } if (empty(Yii::app()->session['adminlang'])) { Yii::app()->session["adminlang"] = Yii::app()->getConfig("defaultlang"); } global $clang; // Needed so EM can localize equation hints until a better solution is found $this->lang = $clang = new Limesurvey_lang(Yii::app()->session['adminlang']); Yii::app()->setLang($this->lang); if (!empty($this->user_id)) { $this->_GetSessionUserRights($this->user_id); } }
/** * Manage user personal settings */ function personalsettings() { // Save Data if (Yii::app()->request->getPost("action")) { $aData = array('lang' => Yii::app()->request->getPost('lang'), 'dateformat' => Yii::app()->request->getPost('dateformat'), 'htmleditormode' => Yii::app()->request->getPost('htmleditormode'), 'questionselectormode' => Yii::app()->request->getPost('questionselectormode'), 'templateeditormode' => Yii::app()->request->getPost('templateeditormode')); $uresult = User::model()->updateByPk(Yii::app()->session['loginID'], $aData); if (Yii::app()->request->getPost('lang') == 'auto') { $sLanguage = getBrowserLanguage(); } else { $sLanguage = Yii::app()->request->getPost('lang'); } Yii::app()->session['adminlang'] = $sLanguage; Yii::app()->lang = new limesurvey_lang($sLanguage); $clang = Yii::app()->lang; Yii::app()->session['htmleditormode'] = Yii::app()->request->getPost('htmleditormode'); Yii::app()->session['questionselectormode'] = Yii::app()->request->getPost('questionselectormode'); Yii::app()->session['templateeditormode'] = Yii::app()->request->getPost('templateeditormode'); Yii::app()->session['dateformat'] = Yii::app()->request->getPost('dateformat'); Yii::app()->session['flashmessage'] = $clang->gT("Your personal settings were successfully saved."); } // Get user lang $user = User::model()->findByPk(Yii::app()->session['loginID']); $aData['sSavedLanguage'] = $user->lang; // Render personal settings view $this->_renderWrappedTemplate('user', 'personalsettings', $aData); }
protected function postLogin() { $user = $this->getUser(); App()->user->login($this); // Check for default password if ($this->password === 'password') { Yii::app()->setFlashMessage(gT("Warning: You are still using the default password ('password'). Please change your password and re-login again."), 'warning'); } if ((int) App()->request->getPost('width', '1280') < 1280) { Yii::app()->setFlashMessage(gT("Your browser screen size is too small to use the administration properly. The minimum size required is 1280*1024 px."), 'error'); } // Do session setup Yii::app()->session['loginID'] = (int) $user->uid; Yii::app()->session['user'] = $user->users_name; Yii::app()->session['full_name'] = $user->full_name; Yii::app()->session['htmleditormode'] = $user->htmleditormode; Yii::app()->session['templateeditormode'] = $user->templateeditormode; Yii::app()->session['questionselectormode'] = $user->questionselectormode; Yii::app()->session['dateformat'] = $user->dateformat; Yii::app()->session['session_hash'] = hash('sha256', getGlobalSetting('SessionName') . $user->users_name . $user->uid); // Perform language settings if (App()->request->getPost('loginlang', 'default') != 'default') { $user->lang = sanitize_languagecode(App()->request->getPost('loginlang')); $user->save(); $sLanguage = $user->lang; } else { if ($user->lang == 'auto' || $user->lang == '') { $sLanguage = getBrowserLanguage(); } else { $sLanguage = $user->lang; } } Yii::app()->session['adminlang'] = $sLanguage; App()->setLanguage($sLanguage); }
protected function postLogin() { $user = $this->getUser(); App()->user->login($this); // Check for default password if ($this->password === 'password') { App()->user->setFlash('pwdnotify', gT('Warning: You are still using the default password (\'password\'). Please change your password and re-login again.')); } // Do session setup Yii::app()->session['loginID'] = (int) $user->uid; Yii::app()->session['user'] = $user->users_name; Yii::app()->session['useremail'] = $user->email; Yii::app()->session['full_name'] = $user->full_name; Yii::app()->session['htmleditormode'] = $user->htmleditormode; Yii::app()->session['templateeditormode'] = $user->templateeditormode; Yii::app()->session['questionselectormode'] = $user->questionselectormode; Yii::app()->session['dateformat'] = $user->dateformat; Yii::app()->session['session_hash'] = hash('sha256', getGlobalSetting('SessionName') . $user->users_name . $user->uid); // Perform language settings if (App()->request->getPost('loginlang', 'default') != 'default') { $user->lang = sanitize_languagecode(App()->request->getPost('loginlang')); $user->save(); $sLanguage = $user->lang; } else { if ($user->lang == 'auto' || $user->lang == '') { $sLanguage = getBrowserLanguage(); } else { $sLanguage = $user->lang; } } Yii::app()->session['adminlang'] = $sLanguage; $lang = new limesurvey_lang($sLanguage); App()->lang = $lang; App()->getController()->lang = $lang; }
/** * Sets the language settings for the user * @param CActiveRecord $user */ private function _setLanguageSettings($user) { if (Yii::app()->request->getPost('loginlang', 'default') != 'default') { $user->lang = sanitize_languagecode(Yii::app()->request->getPost('loginlang')); $user->save(); $sLanguage = $user->lang; } else { if ($user->lang == 'auto' || $user->lang == '') { $sLanguage = getBrowserLanguage(); } else { $sLanguage = $user->lang; } } Yii::app()->session['adminlang'] = $sLanguage; $this->getController()->lang = new limesurvey_lang($sLanguage); }
/** * Load and set session vars * * @access protected * @return void */ protected function _sessioncontrol() { // From personal settings if (Yii::app()->request->getPost('action') == 'savepersonalsettings') { if (Yii::app()->request->getPost('lang') == 'auto') { $sLanguage = getBrowserLanguage(); } else { $sLanguage = sanitize_languagecode(Yii::app()->request->getPost('lang')); } Yii::app()->session['adminlang'] = $sLanguage; } if (empty(Yii::app()->session['adminlang'])) { Yii::app()->session["adminlang"] = Yii::app()->getConfig("defaultlang"); } Yii::app()->setLanguage(Yii::app()->session["adminlang"]); if (!empty($this->user_id)) { $this->_GetSessionUserRights($this->user_id); } }
/** * Manage user personal settings */ public function personalsettings() { // Save Data if (Yii::app()->request->getPost("action")) { $aData = array('lang' => Yii::app()->request->getPost('lang'), 'dateformat' => Yii::app()->request->getPost('dateformat'), 'htmleditormode' => Yii::app()->request->getPost('htmleditormode'), 'questionselectormode' => Yii::app()->request->getPost('questionselectormode'), 'templateeditormode' => Yii::app()->request->getPost('templateeditormode')); $uresult = User::model()->updateByPk(Yii::app()->session['loginID'], $aData); if (Yii::app()->request->getPost('lang') == 'auto') { $sLanguage = getBrowserLanguage(); } else { $sLanguage = Yii::app()->request->getPost('lang'); } Yii::app()->session['adminlang'] = $sLanguage; Yii::app()->setLanguage($sLanguage); Yii::app()->session['htmleditormode'] = Yii::app()->request->getPost('htmleditormode'); Yii::app()->session['questionselectormode'] = Yii::app()->request->getPost('questionselectormode'); Yii::app()->session['templateeditormode'] = Yii::app()->request->getPost('templateeditormode'); Yii::app()->session['dateformat'] = Yii::app()->request->getPost('dateformat'); Yii::app()->session['flashmessage'] = gT("Your personal settings were successfully saved."); if (Yii::app()->request->getPost("saveandclose")) { $this->getController()->redirect(array("admin/survey/sa/index")); } } else { $aData = array(); } // Get user lang $user = User::model()->findByPk(Yii::app()->session['loginID']); $aData['sSavedLanguage'] = $user->lang; $aData['fullpagebar']['savebutton']['form'] = 'personalsettings'; $aData['fullpagebar']['saveandclosebutton']['form'] = 'personalsettings'; $aData['fullpagebar']['closebutton']['url'] = 'admin/survey/sa/index'; // Close button // Render personal settings view if (isset($_POST['saveandclose'])) { $this->getController()->redirect(array("admin/user/sa/index")); } else { $this->_renderWrappedTemplate('user', 'personalsettings', $aData); } }
function getBrowserLanguage() { if (isset($_SERVER["HTTP_ACCEPT_LANGUAGE"])) { $acceptLanguage = $_SERVER["HTTP_ACCEPT_LANGUAGE"]; global $LANGUAGES; $parts = split(";", $acceptLanguage); foreach (split(",", $parts[0]) as $langRegion) { $lang = split("-", $langRegion); if (in_array($lang[0], $LANGUAGES)) { return $lang[0]; } } } return "en"; } $LANGUAGE = getBrowserLanguage(); function loadTranslations($filepattern) { global $LANGUAGE; require_once sprintf($filepattern, "en"); include_once sprintf($filepattern, $LANGUAGE); } // Echo a translated message or log an error. function MSG($message) { global $MESSAGES; global $LANGUAGE; global $HTTP_ACCEPT_LANGUAGE; $translation = $MESSAGES[$LANGUAGE][$message]; if (!isset($translation)) { $translation = $MESSAGES["en"][$message];
/** * Manage user personal settings */ public function personalsettings() { // Save Data if (Yii::app()->request->getPost("action")) { $aData = array('lang' => Yii::app()->request->getPost('lang'), 'dateformat' => Yii::app()->request->getPost('dateformat'), 'htmleditormode' => Yii::app()->request->getPost('htmleditormode'), 'questionselectormode' => Yii::app()->request->getPost('questionselectormode'), 'templateeditormode' => Yii::app()->request->getPost('templateeditormode'), 'full_name' => Yii::app()->request->getPost('fullname'), 'email' => Yii::app()->request->getPost('email')); if (Yii::app()->request->getPost('password') != '' && !Yii::app()->getConfig('demoMode')) { if (Yii::app()->request->getPost('password') == Yii::app()->request->getPost('repeatpassword')) { $aData['password'] = hash("sha256", Yii::app()->request->getPost('password')); } else { Yii::app()->setFlashMessage(gT("Your new password was not saved because the passwords did not match."), 'error'); } } $uresult = User::model()->updateByPk(Yii::app()->session['loginID'], $aData); if (Yii::app()->request->getPost('lang') == 'auto') { $sLanguage = getBrowserLanguage(); } else { $sLanguage = Yii::app()->request->getPost('lang'); } Yii::app()->session['adminlang'] = $sLanguage; Yii::app()->setLanguage($sLanguage); Yii::app()->session['htmleditormode'] = Yii::app()->request->getPost('htmleditormode'); Yii::app()->session['questionselectormode'] = Yii::app()->request->getPost('questionselectormode'); Yii::app()->session['templateeditormode'] = Yii::app()->request->getPost('templateeditormode'); Yii::app()->session['dateformat'] = Yii::app()->request->getPost('dateformat'); Yii::app()->setFlashMessage(gT("Your personal settings were successfully saved.")); if (Yii::app()->request->getPost("saveandclose")) { $this->getController()->redirect(array("admin/survey/sa/index")); } } else { $aData = array(); } // Get user lang $user = User::model()->findByPk(Yii::app()->session['loginID']); $aLanguageData = array('auto' => gT("(Autodetect)")); foreach (getLanguageData(true, Yii::app()->session['adminlang']) as $langkey => $languagekind) { $aLanguageData[$langkey] = html_entity_decode($languagekind['nativedescription'] . ' - ' . $languagekind['description'], ENT_COMPAT, 'utf-8'); } $aData['aLanguageData'] = $aLanguageData; $aData['sSavedLanguage'] = $user->lang; $aData['sUsername'] = $user->users_name; $aData['sFullname'] = $user->full_name; $aData['sEmailAdress'] = $user->email; $aData['fullpagebar']['savebutton']['form'] = 'personalsettings'; $aData['fullpagebar']['saveandclosebutton']['form'] = 'personalsettings'; $aData['fullpagebar']['closebutton']['url_keep'] = true; $aData['fullpagebar']['closebutton']['url'] = Yii::app()->request->getUrlReferrer(Yii::app()->createUrl("admin/user/sa/index")); // Render personal settings view if (isset($_POST['saveandclose'])) { $this->getController()->redirect(array("admin/user/sa/index")); } else { $this->_renderWrappedTemplate('user', 'personalsettings', $aData); } }
return false; } elseif (strlen($letter) > 1) { return false; } elseif ($letter == $exception) { return true; } elseif (!preg_match("/[A-Z\\s_]/i", $letter) > 0) { return false; } else { return true; } } $LangUI = new LangUI(); // handles translations global $g_browser_lang; // give global access to this information $g_browser_lang = getBrowserLanguage(); // preg_match for letters, numbers, underscore, and hyphen. Reject anything else $g_browser_lang = preg_match('/^(\\w|\\-)+$/', $g_browser_lang) ? $g_browser_lang : null; // Load the language file based on config or logged in user if ($SMObj->getUserID() != NULL) { $userID = $SMObj->getUserID(); $details = $SMObj->getUserDetails($userID); include "lang/" . $details['language'] . ".php"; } else { if (isset($g_browser_lang)) { //we found a browser match load it if it exists if (file_exists('lang/' . $g_browser_lang . '.php')) { include "lang/" . $g_browser_lang . ".php"; } else { include "lang/" . $g_rb_language . ".php"; }