/** * This method should handle any login logic and report back to the subject * * @param array $user Holds the user data * @param array $options Array holding options (remember, autoregister, group) * * @return boolean True on success * @since 1.5 */ public function onUserLogin($user, $options = array()) { $app = JFactory::getApplication(); $menu = $app->getMenu(); if ($app->isSite() && $this->params->get('automatic_change', 1)) { // Load associations if ($app->get('menu_associations', 0)) { $active = $menu->getActive(); if ($active) { $associations = MenusHelper::getAssociations($active->id); } } $lang_code = $user['language']; if (empty($lang_code)) { $lang_code = self::$default_lang; } if ($lang_code != self::$tag) { // Change language self::$tag = $lang_code; // Create a cookie $conf = JFactory::getConfig(); $cookie_domain = $conf->get('config.cookie_domain', ''); $cookie_path = $conf->get('config.cookie_path', '/'); setcookie(JApplication::getHash('language'), $lang_code, time() + 365 * 86400, $cookie_path, $cookie_domain); // Change the language code JFactory::getLanguage()->setLanguage($lang_code); // Change the redirect (language have changed) if (isset($associations[$lang_code]) && $menu->getItem($associations[$lang_code])) { $itemid = $associations[$lang_code]; $app->setUserState('users.login.form.return', 'index.php?&Itemid=' . $itemid); } else { $itemid = isset($homes[$lang_code]) ? $homes[$lang_code]->id : $homes['*']->id; $app->setUserState('users.login.form.return', 'index.php?&Itemid=' . $itemid); } } } }
/** * This method should handle any login logic and report back to the subject * * @param array $user Holds the user data * @param array $options Array holding options (remember, autoregister, group) * * @return boolean True on success * @since 1.5 */ public function onUserLogin($user, $options = array()) { $app = JFactory::getApplication(); $menu = App::get('menu'); if (App::isSite() && $this->params->get('automatic_change', 1)) { // Load associations $assoc = isset($app->menu_associations) ? $app->menu_associations : 0; if ($assoc) { $active = $menu->getActive(); if ($active) { $associations = MenusHelper::getAssociations($active->id); } } $lang_code = $user['language']; if (empty($lang_code)) { $lang_code = self::$default_lang; } if ($lang_code != self::$tag) { // Change language self::$tag = $lang_code; // Create a cookie $cookie_domain = Config::get('cookie_domain', ''); $cookie_path = Config::get('cookie_path', '/'); setcookie(App::hash('language'), $lang_code, $this->getLangCookieTime(), $cookie_path, $cookie_domain); // Change the language code Lang::setLanguage($lang_code); // Change the redirect (language have changed) if (isset($associations[$lang_code]) && $menu->getItem($associations[$lang_code])) { $itemid = $associations[$lang_code]; User::setState('users.login.form.return', 'index.php?&Itemid=' . $itemid); } else { $itemid = isset(self::$homes[$lang_code]) ? self::$homes[$lang_code]->id : self::$homes['*']->id; User::setState('users.login.form.return', 'index.php?&Itemid=' . $itemid); } } } }
/** * This method should handle any login logic and report back to the subject * * @param array $user Holds the user data * @param array $options Array holding options (remember, autoregister, group) * * @return boolean True on success * @since 1.5 */ public function onUserLogin($user, $options = array()) { $app = JFactory::getApplication(); if ($app->isSite()) { $lang_code = $user['language']; if (empty($lang_code)) { $lang_code = self::$default_lang; } self::$tag = $lang_code; // Create a cookie $conf = JFactory::getConfig(); $cookie_domain = $conf->get('config.cookie_domain', ''); $cookie_path = $conf->get('config.cookie_path', '/'); setcookie(JUtility::getHash('language'), $lang_code, time() + 365 * 86400, $cookie_path, $cookie_domain); } }
/** * This method should handle any login logic and report back to the subject * * @param array $user Holds the user data * @param array $options Array holding options (remember, autoregister, group) * * @return boolean True on success * @since 1.5 */ public function onUserLogin($user, $options = array()) { $app = JFactory::getApplication(); if ($app->isSite() && $this->params->get('automatic_change', 1)) { $lang_code = $user['language']; if (empty($lang_code)) { $lang_code = self::$default_lang; } if ($lang_code != self::$tag) { // Change language self::$tag = $lang_code; // Create a cookie $conf = JFactory::getConfig(); $cookie_domain = $conf->get('config.cookie_domain', ''); $cookie_path = $conf->get('config.cookie_path', '/'); setcookie(JApplication::getHash('language'), $lang_code, time() + 365 * 86400, $cookie_path, $cookie_domain); // Change the redirect (language have changed) $app->setUserState('users.login.form.return', 'index.php?option=com_users&view=profile'); } } }