Skip to content

Commit

Permalink
Remove addition query and check after #19314
Browse files Browse the repository at this point in the history
  • Loading branch information
Septdir committed Apr 24, 2018
1 parent 4e3ae20 commit 01e6786
Showing 1 changed file with 4 additions and 25 deletions.
29 changes: 4 additions & 25 deletions components/com_content/helpers/association.php
Expand Up @@ -23,8 +23,8 @@ abstract class ContentHelperAssociation extends CategoryHelperAssociation
/**
* Method to get the associations for a given item
*
* @param integer $id Id of the item
* @param string $view Name of the view
* @param integer $id Id of the item
* @param string $view Name of the view
*
* @return array Array of associations for the item
*
Expand All @@ -35,8 +35,6 @@ public static function getAssociations($id = 0, $view = null)
$jinput = JFactory::getApplication()->input;
$view = $view === null ? $jinput->get('view') : $view;
$id = empty($id) ? $jinput->getInt('id') : $id;
$user = JFactory::getUser();
$groups = implode(',', $user->getAuthorisedViewLevels());

if ($view === 'article')
{
Expand All @@ -48,26 +46,7 @@ public static function getAssociations($id = 0, $view = null)

foreach ($associations as $tag => $item)
{
if ($item->language != JFactory::getLanguage()->getTag())
{
$arrId = explode(':', $item->id);
$assocId = $arrId[0];

$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select($db->qn('state'))
->from($db->qn('#__content'))
->where($db->qn('id') . ' = ' . (int) ($assocId))
->where('access IN (' . $groups . ')');
$db->setQuery($query);

$result = (int) $db->loadResult();

if ($result > 0)
{
$return[$tag] = ContentHelperRoute::getArticleRoute($item->id, (int) $item->catid, $item->language);
}
}
$return[$tag] = ContentHelperRoute::getArticleRoute($item->id, (int) $item->catid, $item->language);
}

return $return;
Expand All @@ -85,7 +64,7 @@ public static function getAssociations($id = 0, $view = null)
/**
* Method to display in frontend the associations for a given article
*
* @param integer $id Id of the article
* @param integer $id Id of the article
*
* @return array An array containing the association URL and the related language object
*
Expand Down

0 comments on commit 01e6786

Please sign in to comment.