a537132836
Universal: PR Check / Branch Policy (pull_request) Successful in 1s
Universal: PR Check / Validate PR (pull_request) Failing after 4s
Universal: PR Check / Secret Scan (pull_request) Successful in 5s
RC Revert / Rename rc/ back to dev/ (pull_request) Has been skipped
Branch Cleanup / Delete merged branch (pull_request) Successful in 1s
Universal: Auto Version Bump / Version Bump (push) Successful in 9s
Joomla: Metadata Validation / Validate Joomla Metadata (pull_request) Successful in 30s
Universal: PR Check / Build RC Package (pull_request) Has been cancelled
Universal: PR Check / Report Issues (pull_request) Has been cancelled
Authored-by: Moko Consulting
52 lines
1.5 KiB
PHP
52 lines
1.5 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @package MokoSuiteCross
|
|
* @subpackage com_mokosuitecross
|
|
* @author Moko Consulting <hello@mokoconsulting.tech>
|
|
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
|
* @license GNU General Public License version 3 or later; see LICENSE
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
*/
|
|
|
|
namespace Joomla\Component\MokoSuiteCross\Site\Model;
|
|
|
|
defined('_JEXEC') or die;
|
|
|
|
use Joomla\CMS\Factory;
|
|
use Joomla\CMS\MVC\Model\ListModel;
|
|
|
|
class PostsModel extends ListModel
|
|
{
|
|
protected function getListQuery()
|
|
{
|
|
$db = $this->getDatabase();
|
|
$user = Factory::getApplication()->getIdentity();
|
|
$query = $db->getQuery(true);
|
|
|
|
$query->select([
|
|
'a.id AS article_id',
|
|
'a.title AS article_title',
|
|
'a.alias AS article_alias',
|
|
'a.catid',
|
|
'MAX(p.posted_at) AS last_posted',
|
|
'COUNT(p.id) AS post_count',
|
|
'GROUP_CONCAT(DISTINCT s.service_type ORDER BY s.service_type SEPARATOR \',\') AS service_types',
|
|
])
|
|
->from($db->quoteName('#__mokosuitecross_posts', 'p'))
|
|
->join('INNER', $db->quoteName('#__content', 'a') . ' ON a.id = p.article_id')
|
|
->join('INNER', $db->quoteName('#__mokosuitecross_services', 's') . ' ON s.id = p.service_id')
|
|
->where('p.status = ' . $db->quote('posted'))
|
|
->where('a.state = 1');
|
|
|
|
// Access filtering
|
|
$groups = $user->getAuthorisedViewLevels();
|
|
$query->where('a.access IN (' . implode(',', array_map('intval', $groups)) . ')');
|
|
|
|
$query->group('a.id, a.title, a.alias, a.catid')
|
|
->order('last_posted DESC');
|
|
|
|
return $query;
|
|
}
|
|
}
|