Compare commits

..
Author SHA1 Message Date
Terranom674 13b1656c18 Disable automatic workflow triggers; manual runs only 2026-10-19 20:27:26 +02:00
3 changed files with 41 additions and 93 deletions

No files matched your search

+9 -40
View File
@@ -19,7 +19,7 @@
function escapeHtml(value) { function escapeHtml(value) {
return String(value == null ? '' : value).replace(/[&<>"']/g, function (c) { return String(value == null ? '' : value).replace(/[&<>"']/g, function (c) {
return {'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot',"'":'&#039;'}[c]; return {'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#039;'}[c];
}); });
} }
@@ -239,14 +239,13 @@
}); });
} }
function rebuildLocalActions(deleteForm, id, connectionData) { function rebuildLocalActions(deleteForm, id) {
var actions = deleteForm.parentElement; var actions = deleteForm.parentElement;
if (!actions) return; if (!actions) return;
[].slice.call(actions.querySelectorAll('form')).forEach(function (form) { [].slice.call(actions.querySelectorAll('form')).forEach(function (form) {
var migrate = form.querySelector('button[value="nc_connector_migrate_start"]'); var migrate = form.querySelector('button[value="nc_connector_migrate_start"]');
var editStart = form.querySelector('button[value="nc_connector_edit_start"]'); if (migrate) form.remove();
if (migrate || editStart) form.remove();
}); });
[].slice.call(actions.children).forEach(function (child) { [].slice.call(actions.children).forEach(function (child) {
if (child.tagName === 'BUTTON' && (child.textContent || '').trim() === 'Bearbeiten') child.remove(); if (child.tagName === 'BUTTON' && (child.textContent || '').trim() === 'Bearbeiten') child.remove();
@@ -266,8 +265,7 @@
info.textContent = 'WebDAV-Migration wird geprüft …'; info.textContent = 'WebDAV-Migration wird geprüft …';
actions.insertBefore(info, deleteForm); actions.insertBefore(info, deleteForm);
var dataPromise = connectionData ? Promise.resolve(connectionData) : loadConnection(id); loadConnection(id).then(function (data) {
dataPromise.then(function (data) {
var webdav = data.webdav || {}; var webdav = data.webdav || {};
if (webdav.migration_ready) { if (webdav.migration_ready) {
info.remove(); info.remove();
@@ -281,44 +279,15 @@
}); });
} }
function rebuildRemoteActions(deleteForm, id) {
var actions = deleteForm.parentElement;
if (!actions) return;
[].slice.call(actions.querySelectorAll('form')).forEach(function (form) {
var oldEdit = form.querySelector('button[value="nc_connector_edit_start"]');
var oldMigrate = form.querySelector('button[value="nc_connector_migrate_start"]');
if (oldEdit || oldMigrate) form.remove();
});
[].slice.call(actions.children).forEach(function (child) {
if (child.tagName === 'BUTTON' && (child.textContent || '').trim() === 'Bearbeiten') child.remove();
if (child.dataset && child.dataset.ncMigrationInfo) child.remove();
});
actions.insertBefore(postForm('Bearbeiten', 'nc_connector_edit_start', id, 'edit'), deleteForm);
}
[].slice.call(section.querySelectorAll('button[value="nc_connector_edit_start"]')).forEach(function (button) {
var form = button.closest('form');
if (form) form.remove();
});
[].slice.call(section.querySelectorAll('button[value="nc_connector_delete"]')).forEach(function (deleteButton) { [].slice.call(section.querySelectorAll('button[value="nc_connector_delete"]')).forEach(function (deleteButton) {
var deleteForm = deleteButton.closest('form'); var deleteForm = deleteButton.closest('form');
if (!deleteForm) return; var card = deleteButton.closest('details');
if (!deleteForm || !card) return;
var idInput = deleteForm.querySelector('input[name="connection_id"]'); var idInput = deleteForm.querySelector('input[name="connection_id"]');
if (!idInput) return; if (!idInput) return;
var id = idInput.value; var text = card.textContent || '';
var isLocal = text.indexOf('bestehende Legacy-Konfiguration') !== -1;
loadConnection(id).then(function (data) { if (isLocal) rebuildLocalActions(deleteForm, idInput.value);
if (data.adapter === 'local') rebuildLocalActions(deleteForm, id, data);
else rebuildRemoteActions(deleteForm, id);
}).catch(function (error) {
var actions = deleteForm.parentElement;
if (!actions) return;
var info = document.createElement('span');
info.className = 'bratonien-main-cache__warning';
info.textContent = 'Verbindungstyp konnte nicht geladen werden: '+(error.message || String(error));
actions.insertBefore(info, deleteForm);
});
}); });
}); });
})(); })();
+1 -1
View File
@@ -1,7 +1,7 @@
<?php <?php
/* /*
Plugin Name: Bratonien Tools Plugin Name: Bratonien Tools
Version: 0.9.6.14 Version: 0.9.6.12
Description: Erweiterbare Administrationswerkzeuge fuer die Bratonien-Piwigo-Installation. Description: Erweiterbare Administrationswerkzeuge fuer die Bratonien-Piwigo-Installation.
Plugin URI: https://github.com/Terranom674/Piwigo_Bratonien_Tools Plugin URI: https://github.com/Terranom674/Piwigo_Bratonien_Tools
Author: Bratonien Author: Bratonien
+31 -52
View File
@@ -99,16 +99,16 @@ try
$config = isset($connection['config']) && is_array($connection['config']) ? $connection['config'] : array(); $config = isset($connection['config']) && is_array($connection['config']) ? $connection['config'] : array();
$credentials = bratonien_tools_nc_connector_scoped_secret($connection); $credentials = bratonien_tools_nc_connector_scoped_secret($connection);
$nextcloud_input = trim((string)($_POST['nc_nextcloud_url'] ?? ($config['nextcloud_url'] ?? ''))); $nextcloud_url = trim((string)($_POST['nc_nextcloud_url'] ?? ($config['nextcloud_url'] ?? '')));
$nextcloud_user = trim((string)($_POST['nc_nextcloud_user'] ?? ($credentials['nextcloud_user'] ?? ''))); $nextcloud_user = trim((string)($_POST['nc_nextcloud_user'] ?? ($credentials['nextcloud_user'] ?? '')));
$submitted_nc_password = (string)($_POST['nc_nextcloud_password'] ?? ''); $submitted_nc_password = (string)($_POST['nc_nextcloud_password'] ?? '');
$nextcloud_password = $submitted_nc_password !== '' ? $submitted_nc_password : (string)($credentials['nextcloud_password'] ?? ''); $nextcloud_password = $submitted_nc_password !== '' ? $submitted_nc_password : (string)($credentials['nextcloud_password'] ?? '');
$has_any_nextcloud = $nextcloud_input !== '' || $nextcloud_user !== '' || $nextcloud_password !== ''; $has_any_nextcloud = $nextcloud_url !== '' || $nextcloud_user !== '' || $nextcloud_password !== '';
if ($has_any_nextcloud) if ($has_any_nextcloud)
{ {
$missing = array(); $missing = array();
if ($nextcloud_input === '') $missing[] = 'nc_nextcloud_url'; if ($nextcloud_url === '') $missing[] = 'nc_nextcloud_url';
if ($nextcloud_user === '') $missing[] = 'nc_nextcloud_user'; if ($nextcloud_user === '') $missing[] = 'nc_nextcloud_user';
if ($nextcloud_password === '') $missing[] = 'nc_nextcloud_password'; if ($nextcloud_password === '') $missing[] = 'nc_nextcloud_password';
if ($missing) if ($missing)
@@ -122,67 +122,46 @@ try
try try
{ {
$candidate_urls = bratonien_tools_nc_wizard_candidate_urls($nextcloud_input); $nextcloud_url = bratonien_tools_nc_wizard_normalize_url($nextcloud_url);
} }
catch (Throwable $e) catch (Throwable $e)
{ {
bratonien_tools_nc_edit_fail($e->getMessage(), array('nc_nextcloud_url'), 'Nextcloud / WebDAV'); bratonien_tools_nc_edit_fail($e->getMessage(), array('nc_nextcloud_url'), 'Nextcloud / WebDAV');
} }
$nextcloud_url = ''; $status_url = $nextcloud_url.'/status.php';
$last_probe = null; $probe = bratonien_tools_nc_edit_probe($status_url);
$last_status_url = ''; if (!$probe['ok'])
foreach ($candidate_urls as $candidate_url)
{ {
$status_url = $candidate_url.'/status.php'; $technical = $probe['errno'] >= 0
$probe = bratonien_tools_nc_edit_probe($status_url); ? 'cURL '.$probe['errno'].($probe['error'] !== '' ? ': '.$probe['error'] : '')
$last_probe = $probe; : $probe['error'];
$last_status_url = $status_url;
if (!$probe['ok'] || $probe['http'] < 200 || $probe['http'] >= 300)
{
continue;
}
$status = json_decode($probe['body'], true);
if (!is_array($status) || empty($status['installed']))
{
continue;
}
$nextcloud_url = $candidate_url;
break;
}
if ($nextcloud_url === '')
{
$attempts = array();
foreach ($candidate_urls as $candidate_url)
{
$attempts[] = $candidate_url.'/status.php';
}
if (is_array($last_probe) && !$last_probe['ok'])
{
$technical = $last_probe['errno'] >= 0
? 'cURL '.$last_probe['errno'].($last_probe['error'] !== '' ? ': '.$last_probe['error'] : '')
: $last_probe['error'];
bratonien_tools_nc_edit_fail(
'Die Nextcloud-Adresse ist vom Piwigo-Server aus nicht erreichbar. Ohne angegebenes Protokoll wurden HTTPS und HTTP geprüft.',
array('nc_nextcloud_url'),
'Nextcloud / WebDAV – Erreichbarkeit',
$technical.' · Geprüft: '.implode(' ; ', $attempts)
);
}
bratonien_tools_nc_edit_fail( bratonien_tools_nc_edit_fail(
'Unter der angegebenen Adresse wurde keine erreichbare installierte Nextcloud gefunden. Ohne angegebenes Protokoll wurden HTTPS und HTTP geprüft.', 'Die Nextcloud-Adresse ist vom Piwigo-Server aus nicht erreichbar.',
array('nc_nextcloud_url'), array('nc_nextcloud_url'),
'Nextcloud / WebDAV – Erreichbarkeit',
$technical.' · Ziel: '.$status_url
);
}
if ($probe['http'] < 200 || $probe['http'] >= 300)
{
bratonien_tools_nc_edit_fail(
'Unter der angegebenen Nextcloud-Adresse antwortet status.php nicht erfolgreich.',
array('nc_nextcloud_url'),
'Nextcloud / WebDAV – Erreichbarkeit',
'HTTP '.$probe['http'].' · Ziel: '.$status_url
);
}
$status = json_decode($probe['body'], true);
if (!is_array($status) || empty($status['installed']))
{
bratonien_tools_nc_edit_fail(
'Die Adresse ist erreichbar, dort wurde aber keine installierte Nextcloud erkannt.',
array('nc_nextcloud_url'),
'Nextcloud / WebDAV – Erkennung', 'Nextcloud / WebDAV – Erkennung',
'Geprüft: '.implode(' ; ', $attempts).($last_probe ? ' · Letzter HTTP-Status: '.$last_probe['http'] : '') 'status.php lieferte keine installierte Nextcloud.'
); );
} }
$_POST['nc_nextcloud_url'] = $nextcloud_url;
$user_url = $nextcloud_url.'/ocs/v2.php/cloud/user?format=json'; $user_url = $nextcloud_url.'/ocs/v2.php/cloud/user?format=json';
$user_probe = bratonien_tools_nc_edit_probe($user_url, $nextcloud_user, $nextcloud_password, array('OCS-APIRequest: true')); $user_probe = bratonien_tools_nc_edit_probe($user_url, $nextcloud_user, $nextcloud_password, array('OCS-APIRequest: true'));