1b481f2e2c
Universal: Pre-Release / Build Pre-Release (${{ inputs.stability || github.ref_name }}) (push) Successful in 18s
The ordering column was unused in the profiles UI — profiles sort by ID. Drops the column via migration, removes all references from model, config query, importer, and install SQL. Claude-Session: https://claude.ai/code/session_01MbEjBtsSjPuTWhqqrMS2wG
74 lines
2.0 KiB
PHP
74 lines
2.0 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @package MokoSuiteBackup
|
|
* @subpackage com_mokosuitebackup
|
|
* @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
|
|
*/
|
|
|
|
namespace Joomla\Component\MokoSuiteBackup\Administrator\Model;
|
|
|
|
defined('_JEXEC') or die;
|
|
|
|
use Joomla\CMS\MVC\Model\ListModel;
|
|
use Joomla\Database\QueryInterface;
|
|
|
|
class ProfilesModel extends ListModel
|
|
{
|
|
public function __construct($config = [])
|
|
{
|
|
if (empty($config['filter_fields'])) {
|
|
$config['filter_fields'] = [
|
|
'id', 'a.id',
|
|
'title', 'a.title',
|
|
'backup_type', 'a.backup_type',
|
|
'published', 'a.published',
|
|
];
|
|
}
|
|
|
|
parent::__construct($config);
|
|
}
|
|
|
|
protected function getListQuery(): QueryInterface
|
|
{
|
|
$db = $this->getDatabase();
|
|
$query = $db->getQuery(true);
|
|
|
|
$query->select('a.*')
|
|
->from($db->quoteName('#__mokosuitebackup_profiles', 'a'));
|
|
|
|
// Subquery: count of backup records per profile
|
|
$subQuery = $db->getQuery(true)
|
|
->select('COUNT(*)')
|
|
->from($db->quoteName('#__mokosuitebackup_records', 'r'))
|
|
->where($db->quoteName('r.profile_id') . ' = ' . $db->quoteName('a.id'));
|
|
$query->select('(' . $subQuery . ') AS ' . $db->quoteName('backup_count'));
|
|
|
|
$published = $this->getState('filter.published');
|
|
|
|
if (is_numeric($published)) {
|
|
$query->where($db->quoteName('a.published') . ' = ' . (int) $published);
|
|
}
|
|
|
|
$search = $this->getState('filter.search');
|
|
|
|
if (!empty($search)) {
|
|
$search = $db->quote('%' . $db->escape(trim($search), true) . '%');
|
|
$query->where('(' . $db->quoteName('a.title') . ' LIKE ' . $search . ')');
|
|
}
|
|
|
|
$orderCol = $this->state->get('list.ordering', 'a.id');
|
|
$orderDir = $this->state->get('list.direction', 'ASC');
|
|
$query->order($db->escape($orderCol) . ' ' . $db->escape($orderDir));
|
|
|
|
return $query;
|
|
}
|
|
|
|
protected function populateState($ordering = 'a.id', $direction = 'ASC'): void
|
|
{
|
|
parent::populateState($ordering, $direction);
|
|
}
|
|
}
|