Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for #6904 --> Fixed the check on published content languages. #7130

Closed
wants to merge 7 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 5 additions & 20 deletions plugins/system/languagefilter/languagefilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,6 @@ class PlgSystemLanguageFilter extends JPlugin

private $user_lang_code;

/**
* JDatabaseDriver instance
*
* @var JDatabaseDriver
* @since 3.4.2
*/
protected $db = null;

/**
* Application object.
*
Expand Down Expand Up @@ -525,24 +517,17 @@ public function onUserLogin($user, $options = array())
$assoc = JLanguageAssociations::isEnabled();
$lang_code = $user['language'];

// If no language is specified for this user, we set it to the site default language
if (empty($lang_code))
{
$lang_code = $this->default_lang;
}

// Get a 1-dimensional array of published language codes
$query = $this->db->getQuery(true)
->select($this->db->quoteName('a.lang_code'))
->from($this->db->quoteName('#__languages', 'a'))
->where($this->db->quoteName('published') . ' = 1');
$this->db->setQuery($query);
$lang_codes = $this->db->loadColumn();

// The user language has been deleted/disabled or the related content language does not exist/has been unpublished
// The language has been deleted/disabled or the related content language does not exist/has been unpublished
// or the related home page does not exist/has been unpublished
if (!array_key_exists($lang_code, MultilangstatusHelper::getSitelangs())
|| !in_array($lang_code, $lang_codes)
|| !array_key_exists($lang_code, MultilangstatusHelper::getHomepages()))
if (!array_key_exists($lang_code, $this->lang_codes)
|| !array_key_exists($lang_code, MultilangstatusHelper::getHomepages())
|| !JFolder::exists(JPATH_SITE . '/language/' . $lang_code))
{
$lang_code = $this->current_lang;
}
Expand Down