I THINK it would just be a matter of reading the add-on's hashes.json file and deleting the files/folders listed in it.
Perhaps the solution would be for add-ons that do this to use a separate core add-on, like TH does for themes (the UIX add-on).What happens with files that are shipped with multiple add-ons, such as shared libraries in that case? It's a bit more complex than it seems on a first glance.
We don't do this to share functionality, but to do stuff that is unfortunately not possible with themes alone. From a user perspective, it's unfortunately super unnecessary clutter.Perhaps the solution would be for add-ons that do this to use a separate core add-on, like TH does for themes (the UIX add-on).
I know that, it was just a very general example.We don't do this to share functionality, but to do stuff that is unfortunately not possible with themes alone. From a user perspective, it's unfortunately super unnecessary clutter.
How about flagging them programatically and not allowing them to be removed, if such a system is implemented which removes addon files? Those files would be skipped. And maybe a log somewhere in the ACP mentioning which files are skipped, so one can clear them later.What happens with files that are shipped with multiple add-ons, such as shared libraries in that case? It's a bit more complex than it seems on a first glance.
As long as an add-on's hashes in their hashes.json aren't shared with any other add-on it should be safe to delete a file references in hashes.json. Probably want other sanity check as well.What happens with files that are shipped with multiple add-ons, such as shared libraries in that case? It's a bit more complex than it seems on a first glance.
As long as an add-on's hashes in their hashes.json aren't shared with any other add-on it should be safe to delete a file references in hashes.json.
Maybe @XDinc wants to share his addon with us here on XF, until the option is officially created?
namespace Your\Namespace\XF\Admin\Controller;
use XF\Mvc\ParameterBag;
class YourClass extends XFCP_AddOn
{
public function actionDeleteFiles(ParameterBag $params)
{
$addOn = $this->assertAddOnAvailable($params['addon_id_url']);
if (!$addOn->canInstall())
{
return $this->error(\XF::phrase('x_files_of_this_add_on_can_not_be_removed_reason'));
}
$warnings = [];
if (!$addOn->hasHashes())
{
$warnings[] = \XF::phrase('x_hashes_file_for_this_add_on_missing');
}
if ($this->isPost())
{
if ($addOn->hasHashes())
{
foreach ($addOn->getHashes() as $path => $hash)
{
unlink($path);
}
}
$addOnDirectoryIterator = new \RecursiveDirectoryIterator($addOn->getAddOnDirectory(), \FilesystemIterator::SKIP_DOTS);
$addOnRecursiveIterator = new \RecursiveIteratorIterator($addOnDirectoryIterator, \RecursiveIteratorIterator::CHILD_FIRST);
foreach ($addOnRecursiveIterator as $file)
{
$file->isDir() ? rmdir($file) : unlink($file);
}
if (file_exists($addOn->getAddOnDirectory()))
{
rmdir($addOn->getAddOnDirectory());
}
return $this->redirect($this->buildLink('add-ons'));
}
else
{
$viewParams = [
'addOn' => $addOn,
'warnings' => $warnings
];
return $this->view('your_remove_templates', $viewParams);
}
}
}
I agree, uninstalling and removing files should be done with care and not by some automated process. Maybe once an addon is uninstalled, and admins have verified everything is functioning correctly, then have a button to click to remove the files.
this woulld be hard unless if they have one specific addon folder but some addon use styles, src, data, and so on and let say themehouse and XFA that have addons depending on each other it would be a disaster if you removed those filesI agree, uninstalling and removing files should be done with care and not by some automated process. Maybe once an addon is uninstalled, and admins have verified everything is functioning correctly, then have a button to click to remove the files.
We use essential cookies to make this site work, and optional cookies to enhance your experience.