Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 10 additions & 38 deletions administrator/components/com_contact/models/contacts.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,46 +214,18 @@ protected function getListQuery()

if ($assoc)
{
$query->select('COUNT(' . $db->quoteName('asso2.id') . ') > 1 as ' . $db->quoteName('association'))
->join(
'LEFT',
$db->quoteName('#__associations', 'asso') . ' ON ' . $db->quoteName('asso.id') . ' = ' . $db->quoteName('a.id')
. ' AND ' . $db->quoteName('asso.context') . ' = ' . $db->quote('com_contact.item')
)
->join(
'LEFT',
$db->quoteName('#__associations', 'asso2') . ' ON ' . $db->quoteName('asso2.key') . ' = ' . $db->quoteName('asso.key')
)
->group(
$db->quoteName(
array(
'a.id',
'a.name',
'a.alias',
'a.checked_out',
'a.checked_out_time',
'a.catid',
'a.user_id',
'a.published',
'a.access',
'a.created',
'a.created_by',
'a.ordering',
'a.featured',
'a.language',
'a.publish_up',
'a.publish_down',
'ul.name' ,
'ul.email',
'l.title' ,
'l.image' ,
'uc.name' ,
'ag.title' ,
'c.title',
'c.level'
)
$subQuery = $db->getQuery(true)
->select('COUNT(' . $db->quoteName('asso1.id') . ') > 1')
->from($db->quoteName('#__associations', 'asso1'))
->join('INNER', $db->quoteName('#__associations', 'asso2') . ' ON ' . $db->quoteName('asso1.key') . ' = ' . $db->quoteName('asso2.key'))
->where(
array(
$db->quoteName('asso1.id') . ' = ' . $db->quoteName('a.id'),
$db->quoteName('asso1.context') . ' = ' . $db->quote('com_contact.item'),
)
);

$query->select('(' . $subQuery . ') AS ' . $db->quoteName('association'));
}

// Filter by access level.
Expand Down
19 changes: 12 additions & 7 deletions administrator/components/com_content/models/articles.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,8 @@ protected function getListQuery()
->join('LEFT', '#__users AS ua ON ua.id = a.created_by');

// Join on voting table
$assogroup = 'a.id, l.title, l.image, uc.name, ag.title, c.title, ua.name, c.created_user_id, c.level, parent.id';

if (JPluginHelper::isEnabled('content', 'vote'))
{
$assogroup .= ', v.rating_sum, v.rating_count';
$query->select('COALESCE(NULLIF(ROUND(v.rating_sum / v.rating_count, 0), 0), 0) AS rating,
COALESCE(NULLIF(v.rating_count, 0), 0) as rating_count')
->join('LEFT', '#__content_rating AS v ON a.id = v.content_id');
Expand All @@ -232,10 +229,18 @@ protected function getListQuery()
// Join over the associations.
if (JLanguageAssociations::isEnabled())
{
$query->select('CASE WHEN COUNT(asso2.id)>1 THEN 1 ELSE 0 END as association')
->join('LEFT', '#__associations AS asso ON asso.id = a.id AND asso.context=' . $db->quote('com_content.item'))
->join('LEFT', '#__associations AS asso2 ON ' . $db->quoteName('asso2.key') . ' = ' . $db->quoteName('asso.key'))
->group($assogroup);
$subQuery = $db->getQuery(true)
->select('COUNT(' . $db->quoteName('asso1.id') . ') > 1')
->from($db->quoteName('#__associations', 'asso1'))
->join('INNER', $db->quoteName('#__associations', 'asso2') . ' ON ' . $db->quoteName('asso1.key') . ' = ' . $db->quoteName('asso2.key'))
->where(
array(
$db->quoteName('asso1.id') . ' = ' . $db->quoteName('a.id'),
$db->quoteName('asso1.context') . ' = ' . $db->quote('com_content.item'),
)
);

$query->select('(' . $subQuery . ') AS ' . $db->quoteName('association'));
}

// Filter by access level.
Expand Down
16 changes: 12 additions & 4 deletions administrator/components/com_menus/models/items.php
Original file line number Diff line number Diff line change
Expand Up @@ -304,10 +304,18 @@ protected function getListQuery()

if ($assoc)
{
$query->select('COUNT(asso2.id)>1 as association')
->join('LEFT', '#__associations AS asso ON asso.id = a.id AND asso.context=' . $db->quote('com_menus.item'))
->join('LEFT', '#__associations AS asso2 ON asso2.key = asso.key')
->group('a.id, e.enabled, l.title, l.image, u.name, c.element, ag.title, e.name, mt.id, mt.title, l.sef');
$subQuery = $db->getQuery(true)
->select('COUNT(' . $db->quoteName('asso1.id') . ') > 1')
->from($db->quoteName('#__associations', 'asso1'))
->join('INNER', $db->quoteName('#__associations', 'asso2') . ' ON ' . $db->quoteName('asso1.key') . ' = ' . $db->quoteName('asso2.key'))
->where(
array(
$db->quoteName('asso1.id') . ' = ' . $db->quoteName('a.id'),
$db->quoteName('asso1.context') . ' = ' . $db->quote('com_menus.item'),
)
);

$query->select('(' . $subQuery . ') AS ' . $db->quoteName('association'));
}

// Join over the extensions
Expand Down
16 changes: 12 additions & 4 deletions administrator/components/com_newsfeeds/models/newsfeeds.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,18 @@ protected function getListQuery()

if ($assoc)
{
$query->select('COUNT(asso2.id)>1 AS association')
->join('LEFT', $db->quoteName('#__associations', 'asso') . ' ON asso.id = a.id AND asso.context = ' . $db->quote('com_newsfeeds.item'))
->join('LEFT', $db->quoteName('#__associations', 'asso2') . ' ON asso2.key = asso.key')
->group('a.id, l.title, l.image, uc.name, ag.title, c.title');
$subQuery = $db->getQuery(true)
->select('COUNT(' . $db->quoteName('asso1.id') . ') > 1')
->from($db->quoteName('#__associations', 'asso1'))
->join('INNER', $db->quoteName('#__associations', 'asso2') . ' ON ' . $db->quoteName('asso1.key') . ' = ' . $db->quoteName('asso2.key'))
->where(
array(
$db->quoteName('asso1.id') . ' = ' . $db->quoteName('a.id'),
$db->quoteName('asso1.context') . ' = ' . $db->quote('com_newsfeeds.item'),
)
);

$query->select('(' . $subQuery . ') AS ' . $db->quoteName('association'));
}

// Filter by access level.
Expand Down