| Server IP : 81.19.159.101 / Your IP : 216.73.217.111 Web Server : Apache System : Linux www58.world4you.com 4.18.0-553.126.2.lve.el8.x86_64 #1 SMP Thu May 28 14:12:30 UTC 2026 x86_64 User : ftp8817043 ( 2681) PHP Version : 8.4.21 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /home/.sites/103/site8817043/web/wp-content/plugins/akeebabackupwp/app/Solo/Model/ |
Upload File : |
<?php
/**
* @package solo
* @copyright Copyright (c)2014-2025 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Solo\Model;
use Akeeba\Engine\Platform;
use Awf\Container\Container;
use Awf\Mvc\DataModel;
use Awf\Text\Language;
use Awf\Text\Text;
use RuntimeException;
class Profiles extends DataModel
{
/**
* Public constructor
*
* @param Container $container Configuration parameters
*/
public function __construct(?Container $container = null, ?Language $language = null)
{
$this->tableName = '#__ak_profiles';
$this->idFieldName = 'id';
parent::__construct($container, $language);
$this->addBehaviour('filters');
}
/**
* Prevent the deletion of the default backup profile
*
* @param integer $id The profile ID which is about to be deleted
*
* @throws \RuntimeException When some wise guy tries to delete the default backup profile
*/
public function onBeforeDelete($id)
{
if ($id == 1)
{
throw new RuntimeException(Text::_('COM_AKEEBA_PROFILE_ERR_CANNOTDELETEDEFAULT'), 403);
}
// If you're deleting the current backup profile we have to switch to the default profile (#1)
$activeProfile = Platform::getInstance()->get_active_profile();
if ($id == $activeProfile)
{
throw new RuntimeException(Text::sprintf('COM_AKEEBA_PROFILE_ERR_CANNOTDELETEACTIVE', $id), 500);
}
}
/**
* Check the data for validity.
*
* @return DataModel Self, for chaining
*
* @throws \RuntimeException When the data bound to this record is invalid
*/
public function check()
{
if (!$this->description)
{
throw new RuntimeException(Text::_('COM_AKEEBA_PROFILE_ERR_NODESCRIPTION'));
}
if (!$this->quickicon)
{
$this->quickicon = 0;
}
return parent::check();
}
/**
* Save a profile from imported configuration data. The $data array must contain the keys description (profile
* description), configuration (engine configuration INI data) and filters (inclusion and inclusion filters JSON
* configuration data).
*
* @param array $data See above
*
* @returns void
*
* @throws RuntimeException When an iport error occurs
*/
public function import($data)
{
// Check for data validity
$isValid =
is_array($data) &&
!empty($data) &&
array_key_exists('description', $data) &&
array_key_exists('configuration', $data) &&
array_key_exists('filters', $data);
if (!$isValid)
{
throw new RuntimeException(Text::_('COM_AKEEBA_PROFILES_ERR_IMPORT_INVALID'));
}
// Unset the id, if it exists
if (array_key_exists('id', $data))
{
unset($data['id']);
}
$data['akeeba.flag.confwiz'] = 1;
// Try saving the profile
$result = $this->save($data);
if (!$result)
{
throw new RuntimeException(Text::_('COM_AKEEBA_PROFILES_ERR_IMPORT_FAILED'));
}
}
/**
* Resets the configuration and filters of a backup profile without touching its ID, name, or description.
*
* @return bool True on success
* @since 9.0.3
*/
public function resetConfiguration(int $pk): bool
{
$this->findOrFail($pk);
$this->save(
[
'configuration' => '',
'filters' => '',
]
);
return true;
}
}