Commit b87b7551 authored by xorti's avatar xorti

[bp/r65975][NEW] Enable cleanup of the vendor and composer.lock from the web...

[bp/r65975][NEW] Enable cleanup of the vendor and composer.lock from the web interface to manage packages
parent 006d126b
......@@ -41,6 +41,46 @@ if ($access->ticketMatch()) {
$smarty->assign('diagnostic_composer_output', $composerManager->getComposer()->execDiagnose());
}
}
if ($_POST['remove-composer-locker']) {
$path = $tikipath . DIRECTORY_SEPARATOR . 'composer.lock';
if (file_exists($path)) {
if (is_writable($path)) {
unlink($path);
$smarty->assign('composer_management_success', tr('composer.lock file was removed'));
} else {
$smarty->assign('composer_management_error', tr('composer.lock file is not writable, so it can not be removed')
);
}
} else {
$smarty->assign('composer_management_success', tr('composer.lock file do not exists'));
}
}
if ($_POST['clean-vendor-folder']) {
$dir = $tikipath . DIRECTORY_SEPARATOR . 'vendor/';
if (file_exists($dir)) {
if (is_writable($dir)) {
$files = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($dir, FilesystemIterator::SKIP_DOTS),
RecursiveIteratorIterator::CHILD_FIRST
);
foreach ($files as $file) {
if ($file->getFilename() === '.htaccess') {
continue;
}
if ($file->isDir()) {
rmdir($file->getRealPath());
} else {
unlink($file->getRealPath());
}
}
$smarty->assign('composer_management_success', tr('Vendor folder contents was removed'));
} else {
$smarty->assign('composer_management_error', tr('Vendor folder is not writable'));
}
} else {
$smarty->assign('composer_management_success', tr('Vendor folder do not exists'));
}
}
}
}
......
......@@ -59,17 +59,17 @@
{/if}
</td>
<td>{$entry.installed|default:'&nbsp;'}</td>
<td>{if $entry.installed && $entry.key}
<td>
{if $entry.key}
<form action="tiki-admin.php?page=packages&cookietab=1" method="post">
<input type="hidden" name="redirect" value="0">
<input type="hidden" name="installed" value="{$entry.installed}">
{ticket}
{if $entry.upgradeVersion}
<button name="auto-update-package" value="{$entry.key}">{tr}Update{/tr}</button>
{if $entry.installed && $entry.upgradeVersion}
<button name="auto-update-package" value="{$entry.key}">{tr}Update{/tr}</button>
{/if}
<button name="auto-remove-package" value="{$entry.key}">{tr}Remove{/tr}</button>
</form>
{else}
&nbsp;
{/if}
</td>
</tr>
......@@ -246,7 +246,17 @@
{ticket}
<button name="auto-run-diagnostics" value="run">{tr}Diagnose Composer{/tr}</button>
</form>
{if isset($diagnostic_composer_location) || $diagnostic_composer_output}
<br />
<h4>{tr}Composer management{/tr}</h4>
<form action="tiki-admin.php?page=packages&cookietab=4" method="post">
<input type="hidden" name="redirect" value="0">
{ticket}
<button name="remove-composer-locker" value="run">{tr}Remove composer.lock{/tr}</button>
<button name="clean-vendor-folder" value="run">{tr}Clean vendor folder{/tr}</button>
</form>
<br />
{if isset($diagnostic_composer_location) || $diagnostic_composer_output || $composer_management_success || $composer_management_error}
<br />
<h4>Results</h4>
{if isset($diagnostic_composer_location) }
......@@ -256,6 +266,18 @@
<p><strong>Composer diagnose output</strong></p>
<pre>{$diagnostic_composer_output}</pre>
{/if}
{if $composer_management_success}
{remarksbox type="success" title="{tr}Success{/tr}" close="n"}
{$composer_management_success}
{/remarksbox}
{/if}
{if $composer_management_error}
{remarksbox type="error" title="{tr}Error{/tr}" close="n"}
{$composer_management_error}
{/remarksbox}
{/if}
<br>
{/if}
{/tab}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment