mirror of
https://github.com/Terranom674/Piwigo_Bratonien_Tools.git
synced 2026-09-19 22:14:33 +00:00
Compare commits
14 Commits
fix/dialog
...
fix/webdav
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
370ead2b90 | ||
|
|
5d9e017131 | ||
|
|
76de2b037c | ||
|
|
e2e82162c6 | ||
|
|
7a9eb1baa6 | ||
|
|
e800f11f64 | ||
|
|
4808f08590 | ||
|
|
6fd89df5d0 | ||
|
|
99126088e7 | ||
|
|
e53a3848bb | ||
|
|
0f0c71acaf | ||
|
|
9847690f50 | ||
|
|
a2f5dc3919 | ||
|
|
cd3bf7c8ee |
@@ -6,11 +6,18 @@ if (!defined('PHPWG_ROOT_PATH'))
|
|||||||
|
|
||||||
if (isset($GLOBALS['template']) && is_object($GLOBALS['template']) && method_exists($GLOBALS['template'], 'func_combine_script'))
|
if (isset($GLOBALS['template']) && is_object($GLOBALS['template']) && method_exists($GLOBALS['template'], 'func_combine_script'))
|
||||||
{
|
{
|
||||||
|
$script_version = function_exists('bratonien_tools_current_version') ? bratonien_tools_current_version() : '0.9.6.15';
|
||||||
$GLOBALS['template']->func_combine_script(array(
|
$GLOBALS['template']->func_combine_script(array(
|
||||||
'id'=>'bratonien_nc_connector_edit_v2',
|
'id'=>'bratonien_nc_connector_edit_v2',
|
||||||
'path'=>BRATONIEN_TOOLS_PATH.'js/nc_connector_edit_v2.js',
|
'path'=>BRATONIEN_TOOLS_PATH.'js/nc_connector_edit_v2.js',
|
||||||
'load'=>'footer',
|
'load'=>'footer',
|
||||||
'version'=>function_exists('bratonien_tools_current_version') ? bratonien_tools_current_version() : '0.9.6.10',
|
'version'=>$script_version,
|
||||||
|
));
|
||||||
|
$GLOBALS['template']->func_combine_script(array(
|
||||||
|
'id'=>'bratonien_nc_connector_source_ui',
|
||||||
|
'path'=>BRATONIEN_TOOLS_PATH.'js/nc_connector_source_ui.js',
|
||||||
|
'load'=>'footer',
|
||||||
|
'version'=>$script_version,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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 {'&':'&','<':'<','>':'>','"':'"',"'":'''}[c];
|
return {'&':'&','<':'<','>':'>','"':'"',"'":'''}[c];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -239,13 +239,14 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function rebuildLocalActions(deleteForm, id) {
|
function rebuildLocalActions(deleteForm, id, connectionData) {
|
||||||
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"]');
|
||||||
if (migrate) form.remove();
|
var editStart = form.querySelector('button[value="nc_connector_edit_start"]');
|
||||||
|
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();
|
||||||
@@ -265,7 +266,8 @@
|
|||||||
info.textContent = 'WebDAV-Migration wird geprüft …';
|
info.textContent = 'WebDAV-Migration wird geprüft …';
|
||||||
actions.insertBefore(info, deleteForm);
|
actions.insertBefore(info, deleteForm);
|
||||||
|
|
||||||
loadConnection(id).then(function (data) {
|
var dataPromise = connectionData ? Promise.resolve(connectionData) : loadConnection(id);
|
||||||
|
dataPromise.then(function (data) {
|
||||||
var webdav = data.webdav || {};
|
var webdav = data.webdav || {};
|
||||||
if (webdav.migration_ready) {
|
if (webdav.migration_ready) {
|
||||||
info.remove();
|
info.remove();
|
||||||
@@ -279,15 +281,44 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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');
|
||||||
var card = deleteButton.closest('details');
|
if (!deleteForm) return;
|
||||||
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 text = card.textContent || '';
|
var id = idInput.value;
|
||||||
var isLocal = text.indexOf('bestehende Legacy-Konfiguration') !== -1;
|
|
||||||
if (isLocal) rebuildLocalActions(deleteForm, idInput.value);
|
loadConnection(id).then(function (data) {
|
||||||
|
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);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
|||||||
90
js/nc_connector_source_ui.js
Normal file
90
js/nc_connector_source_ui.js
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
(function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
function enhanceMigrationButtons(root) {
|
||||||
|
[].slice.call(root.querySelectorAll('button[value="nc_connector_migrate_start"]')).forEach(function (button) {
|
||||||
|
button.textContent = 'Nextcloud-Ordner auswählen & migrieren';
|
||||||
|
button.title = 'Die WebDAV-Quelle wird im Nextcloud-Ordnerbrowser ausgewählt. Der bestehende SMB-/Legacy-Speicher wird nicht als WebDAV-Quelle übernommen.';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function enhanceEditor(root) {
|
||||||
|
var form = root.querySelector('[data-edit-v2-form]');
|
||||||
|
if (!form || form.dataset.sourceUiEnhanced === '1') return;
|
||||||
|
form.dataset.sourceUiEnhanced = '1';
|
||||||
|
|
||||||
|
var headings = [].slice.call(form.querySelectorAll('h5'));
|
||||||
|
var legacyHeading = headings.find(function (node) {
|
||||||
|
return (node.textContent || '').trim() === 'Bestehender Legacy-Weg';
|
||||||
|
});
|
||||||
|
var storageHeading = headings.find(function (node) {
|
||||||
|
return (node.textContent || '').trim() === 'Speicherorte';
|
||||||
|
});
|
||||||
|
var storageList = form.querySelector('[data-storage-list]');
|
||||||
|
var addStorage = form.querySelector('[data-add-storage]');
|
||||||
|
|
||||||
|
if (legacyHeading && !form.querySelector('[data-webdav-source-note]')) {
|
||||||
|
var note = document.createElement('p');
|
||||||
|
note.dataset.webdavSourceNote = '1';
|
||||||
|
note.className = 'bratonien-main-cache__warning';
|
||||||
|
note.innerHTML = '<strong>Wichtig:</strong> Der folgende SMB-/lokale Speicher gehört ausschließlich zum bisherigen Legacy-Fallback. Er wird <strong>nicht</strong> als WebDAV-Quelle übernommen. Die WebDAV-Quellordner werden beim Start der Migration direkt aus Nextcloud angezeigt und ausgewählt.';
|
||||||
|
legacyHeading.insertAdjacentElement('beforebegin', note);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (storageHeading && storageList && addStorage) {
|
||||||
|
storageHeading.textContent = 'Legacy-Speicher (nur Fallback)';
|
||||||
|
|
||||||
|
var details = document.createElement('details');
|
||||||
|
details.dataset.legacyStorageTechnical = '1';
|
||||||
|
details.style.marginTop = '.75rem';
|
||||||
|
var summary = document.createElement('summary');
|
||||||
|
summary.textContent = 'Technische Legacy-Speicherzuordnung bearbeiten';
|
||||||
|
details.appendChild(summary);
|
||||||
|
|
||||||
|
var info = document.createElement('p');
|
||||||
|
info.className = 'bratonien-base-note';
|
||||||
|
info.textContent = 'Diese Felder betreffen nur den alten Fallback-Weg. Für WebDAV werden keine SMB-Adressen oder lokalen Mount-Pfade eingegeben.';
|
||||||
|
details.appendChild(info);
|
||||||
|
|
||||||
|
storageHeading.insertAdjacentElement('beforebegin', details);
|
||||||
|
details.appendChild(storageHeading);
|
||||||
|
details.appendChild(storageList);
|
||||||
|
details.appendChild(addStorage);
|
||||||
|
|
||||||
|
addStorage.textContent = 'Legacy-Speicher manuell hinzufügen';
|
||||||
|
addStorage.title = 'Nur für den alten Legacy-Fallback. WebDAV-Ordner werden im Nextcloud-Ordnerbrowser ausgewählt.';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function enhance(root) {
|
||||||
|
if (!root || root.nodeType !== 1) return;
|
||||||
|
enhanceMigrationButtons(root);
|
||||||
|
if (root.matches && root.matches('#bratonien-nc-connection-edit-v2')) enhanceEditor(root);
|
||||||
|
var dialog = root.querySelector ? root.querySelector('#bratonien-nc-connection-edit-v2') : null;
|
||||||
|
if (dialog) enhanceEditor(dialog);
|
||||||
|
}
|
||||||
|
|
||||||
|
function start() {
|
||||||
|
var section = document.getElementById('nc-connector');
|
||||||
|
if (!section) return;
|
||||||
|
|
||||||
|
enhance(section);
|
||||||
|
enhanceMigrationButtons(document);
|
||||||
|
|
||||||
|
var observer = new MutationObserver(function (mutations) {
|
||||||
|
mutations.forEach(function (mutation) {
|
||||||
|
[].slice.call(mutation.addedNodes || []).forEach(function (node) {
|
||||||
|
if (node && node.nodeType === 1) enhance(node);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
var dialog = document.getElementById('bratonien-nc-connection-edit-v2');
|
||||||
|
if (dialog) enhanceEditor(dialog);
|
||||||
|
enhanceMigrationButtons(document);
|
||||||
|
});
|
||||||
|
|
||||||
|
observer.observe(document.body, {childList:true, subtree:true});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', start);
|
||||||
|
else start();
|
||||||
|
})();
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
Plugin Name: Bratonien Tools
|
Plugin Name: Bratonien Tools
|
||||||
Version: 0.9.6.12
|
Version: 0.9.6.15
|
||||||
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
|
||||||
|
|||||||
@@ -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_url = trim((string)($_POST['nc_nextcloud_url'] ?? ($config['nextcloud_url'] ?? '')));
|
$nextcloud_input = 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_url !== '' || $nextcloud_user !== '' || $nextcloud_password !== '';
|
$has_any_nextcloud = $nextcloud_input !== '' || $nextcloud_user !== '' || $nextcloud_password !== '';
|
||||||
if ($has_any_nextcloud)
|
if ($has_any_nextcloud)
|
||||||
{
|
{
|
||||||
$missing = array();
|
$missing = array();
|
||||||
if ($nextcloud_url === '') $missing[] = 'nc_nextcloud_url';
|
if ($nextcloud_input === '') $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,47 +122,68 @@ try
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$nextcloud_url = bratonien_tools_nc_wizard_normalize_url($nextcloud_url);
|
$candidate_urls = bratonien_tools_nc_wizard_candidate_urls($nextcloud_input);
|
||||||
}
|
}
|
||||||
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');
|
||||||
}
|
}
|
||||||
|
|
||||||
$status_url = $nextcloud_url.'/status.php';
|
$nextcloud_url = '';
|
||||||
$probe = bratonien_tools_nc_edit_probe($status_url);
|
$last_probe = null;
|
||||||
if (!$probe['ok'])
|
$last_status_url = '';
|
||||||
|
foreach ($candidate_urls as $candidate_url)
|
||||||
{
|
{
|
||||||
$technical = $probe['errno'] >= 0
|
$status_url = $candidate_url.'/status.php';
|
||||||
? 'cURL '.$probe['errno'].($probe['error'] !== '' ? ': '.$probe['error'] : '')
|
$probe = bratonien_tools_nc_edit_probe($status_url);
|
||||||
: $probe['error'];
|
$last_probe = $probe;
|
||||||
bratonien_tools_nc_edit_fail(
|
$last_status_url = $status_url;
|
||||||
'Die Nextcloud-Adresse ist vom Piwigo-Server aus nicht erreichbar.',
|
|
||||||
array('nc_nextcloud_url'),
|
if (!$probe['ok'] || $probe['http'] < 200 || $probe['http'] >= 300)
|
||||||
'Nextcloud / WebDAV – Erreichbarkeit',
|
{
|
||||||
$technical.' · Ziel: '.$status_url
|
continue;
|
||||||
);
|
}
|
||||||
|
|
||||||
|
$status = json_decode($probe['body'], true);
|
||||||
|
if (!is_array($status) || empty($status['installed']))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$nextcloud_url = $candidate_url;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if ($probe['http'] < 200 || $probe['http'] >= 300)
|
|
||||||
|
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 Nextcloud-Adresse antwortet status.php nicht erfolgreich.',
|
'Unter der angegebenen Adresse wurde keine erreichbare installierte Nextcloud gefunden. Ohne angegebenes Protokoll wurden HTTPS und HTTP geprüft.',
|
||||||
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'),
|
array('nc_nextcloud_url'),
|
||||||
'Nextcloud / WebDAV – Erkennung',
|
'Nextcloud / WebDAV – Erkennung',
|
||||||
'status.php lieferte keine installierte Nextcloud.'
|
'Geprüft: '.implode(' ; ', $attempts).($last_probe ? ' · Letzter HTTP-Status: '.$last_probe['http'] : '')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$_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'));
|
||||||
if (!$user_probe['ok'])
|
if (!$user_probe['ok'])
|
||||||
|
|||||||
1
noop2-remove-marker.txt
Normal file
1
noop2-remove-marker.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
stale branch only
|
||||||
Reference in New Issue
Block a user