2026-06-02 13:47:36 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @package MokoJoomBackup
|
2026-06-06 14:52:27 -05:00
|
|
|
* @subpackage com_mokojoombackup
|
2026-06-02 13:47:36 -05:00
|
|
|
* @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
|
|
|
|
|
*/
|
|
|
|
|
|
2026-06-06 14:52:27 -05:00
|
|
|
namespace Joomla\Component\MokoJoomBackup\Administrator\Model;
|
2026-06-02 13:47:36 -05:00
|
|
|
|
|
|
|
|
defined('_JEXEC') or die;
|
|
|
|
|
|
|
|
|
|
use Joomla\CMS\MVC\Model\ListModel;
|
|
|
|
|
use Joomla\Database\QueryInterface;
|
|
|
|
|
|
|
|
|
|
class BackupsModel extends ListModel
|
|
|
|
|
{
|
|
|
|
|
public function __construct($config = [])
|
|
|
|
|
{
|
|
|
|
|
if (empty($config['filter_fields'])) {
|
|
|
|
|
$config['filter_fields'] = [
|
|
|
|
|
'id', 'a.id',
|
|
|
|
|
'profile_id', 'a.profile_id',
|
|
|
|
|
'status', 'a.status',
|
|
|
|
|
'origin', 'a.origin',
|
|
|
|
|
'backup_type', 'a.backup_type',
|
|
|
|
|
'total_size', 'a.total_size',
|
|
|
|
|
'backupstart', 'a.backupstart',
|
|
|
|
|
'backupend', 'a.backupend',
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
parent::__construct($config);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function getListQuery(): QueryInterface
|
|
|
|
|
{
|
|
|
|
|
$db = $this->getDatabase();
|
|
|
|
|
$query = $db->getQuery(true);
|
|
|
|
|
|
|
|
|
|
$query->select('a.*')
|
2026-06-06 14:52:27 -05:00
|
|
|
->from($db->quoteName('#__mokojoombackup_records', 'a'));
|
2026-06-02 13:47:36 -05:00
|
|
|
|
|
|
|
|
// Join profile title
|
|
|
|
|
$query->select($db->quoteName('p.title', 'profile_title'))
|
2026-06-06 14:52:27 -05:00
|
|
|
->join('LEFT', $db->quoteName('#__mokojoombackup_profiles', 'p') . ' ON p.id = a.profile_id');
|
2026-06-02 13:47:36 -05:00
|
|
|
|
|
|
|
|
// Filter by status
|
|
|
|
|
$status = $this->getState('filter.status');
|
|
|
|
|
|
|
|
|
|
if (!empty($status)) {
|
|
|
|
|
$query->where($db->quoteName('a.status') . ' = ' . $db->quote($status));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Filter by profile
|
|
|
|
|
$profileId = $this->getState('filter.profile_id');
|
|
|
|
|
|
|
|
|
|
if (is_numeric($profileId)) {
|
|
|
|
|
$query->where($db->quoteName('a.profile_id') . ' = ' . (int) $profileId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Filter by search
|
|
|
|
|
$search = $this->getState('filter.search');
|
|
|
|
|
|
|
|
|
|
if (!empty($search)) {
|
|
|
|
|
$search = $db->quote('%' . $db->escape(trim($search), true) . '%');
|
|
|
|
|
$query->where('(' . $db->quoteName('a.description') . ' LIKE ' . $search . ')');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$orderCol = $this->state->get('list.ordering', 'a.backupstart');
|
|
|
|
|
$orderDir = $this->state->get('list.direction', 'DESC');
|
|
|
|
|
$query->order($db->escape($orderCol) . ' ' . $db->escape($orderDir));
|
|
|
|
|
|
|
|
|
|
return $query;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function populateState($ordering = 'a.backupstart', $direction = 'DESC'): void
|
|
|
|
|
{
|
|
|
|
|
parent::populateState($ordering, $direction);
|
|
|
|
|
}
|
|
|
|
|
}
|