Files
MokoSuiteBackup/source/packages/com_mokojoombackup/src/Table/BackupTable.php
T

50 lines
1.1 KiB
PHP
Raw Normal View History

<?php
/**
* @package MokoJoomBackup
* @subpackage com_mokojoombackup
* @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\MokoJoomBackup\Administrator\Table;
defined('_JEXEC') or die;
use Joomla\CMS\Table\Table;
use Joomla\Database\DatabaseDriver;
class BackupTable extends Table
{
public function __construct(DatabaseDriver $db)
{
parent::__construct('#__mokojoombackup_records', 'id', $db);
}
public function check(): bool
{
if (empty($this->profile_id)) {
$this->setError('Profile ID is required.');
return false;
}
if (empty($this->backupstart) || $this->backupstart === '0000-00-00 00:00:00') {
$this->backupstart = date('Y-m-d H:i:s');
}
return true;
}
public function delete($pk = null): bool
{
// Delete the archive file if it exists
if (!empty($this->absolute_path) && is_file($this->absolute_path)) {
@unlink($this->absolute_path);
}
return parent::delete($pk);
}
}