mirror of
https://github.com/Terranom674/Piwigo_Bratonien_Tools.git
synced 2026-09-19 14:04:34 +00:00
Persist wizard auth for WebDAV connections
This commit is contained in:
@@ -14,7 +14,10 @@ function bratonien_tools_nc_connector_create_webdav_placeholder_from_wizard()
|
|||||||
{
|
{
|
||||||
$state = bratonien_tools_nc_wizard_state();
|
$state = bratonien_tools_nc_wizard_state();
|
||||||
|
|
||||||
if (empty($state['scan_ok'])) throw new RuntimeException('Die Nextcloud-Verbindung wurde noch nicht erfolgreich geprüft.');
|
if (empty($state['scan_ok']) || empty($state['technical_complete']))
|
||||||
|
{
|
||||||
|
throw new RuntimeException('Die WebDAV-Verbindung wurde im Assistenten noch nicht vollständig vorbereitet.');
|
||||||
|
}
|
||||||
|
|
||||||
$base_url = rtrim(trim((string)($state['base_url'] ?? '')), '/');
|
$base_url = rtrim(trim((string)($state['base_url'] ?? '')), '/');
|
||||||
$username = trim((string)($state['username'] ?? ''));
|
$username = trim((string)($state['username'] ?? ''));
|
||||||
@@ -36,8 +39,10 @@ function bratonien_tools_nc_connector_create_webdav_placeholder_from_wizard()
|
|||||||
$roots = array();
|
$roots = array();
|
||||||
foreach ($selected as $path)
|
foreach ($selected as $path)
|
||||||
{
|
{
|
||||||
|
$fileid = isset($selected_ids[$path]) ? (int)$selected_ids[$path] : 0;
|
||||||
|
if ($fileid < 1) throw new RuntimeException('Für ein ausgewähltes Nextcloud-Verzeichnis fehlt die eindeutige Datei-ID.');
|
||||||
$roots[] = array(
|
$roots[] = array(
|
||||||
'fileid'=>isset($selected_ids[$path]) ? (int)$selected_ids[$path] : 0,
|
'fileid'=>$fileid,
|
||||||
'display_name'=>basename($path),
|
'display_name'=>basename($path),
|
||||||
'webdav_path'=>$path,
|
'webdav_path'=>$path,
|
||||||
);
|
);
|
||||||
@@ -48,6 +53,12 @@ function bratonien_tools_nc_connector_create_webdav_placeholder_from_wizard()
|
|||||||
$gallery_root = rtrim(trim((string)($state['gallery_root'] ?? '')), '/');
|
$gallery_root = rtrim(trim((string)($state['gallery_root'] ?? '')), '/');
|
||||||
if ($gallery_root === '') $gallery_root = rtrim(PHPWG_ROOT_PATH, '/').'/galleries';
|
if ($gallery_root === '') $gallery_root = rtrim(PHPWG_ROOT_PATH, '/').'/galleries';
|
||||||
|
|
||||||
|
$api_key_id = ($state['api_status'] ?? '') === 'ok' ? trim((string)($state['_api_key_id'] ?? '')) : '';
|
||||||
|
$api_key_secret = ($state['api_status'] ?? '') === 'ok' ? trim((string)($state['_api_key_secret'] ?? '')) : '';
|
||||||
|
$fallback_user = trim((string)($state['_fallback_user'] ?? ''));
|
||||||
|
$fallback_password = (string)($state['_fallback_password'] ?? '');
|
||||||
|
$api_enabled = $api_key_id !== '' && $api_key_secret !== '';
|
||||||
|
|
||||||
$config = array(
|
$config = array(
|
||||||
'origin'=>'native',
|
'origin'=>'native',
|
||||||
'source_mode'=>'webdav-placeholder',
|
'source_mode'=>'webdav-placeholder',
|
||||||
@@ -64,7 +75,7 @@ function bratonien_tools_nc_connector_create_webdav_placeholder_from_wizard()
|
|||||||
'full_sync_seconds'=>86400,
|
'full_sync_seconds'=>86400,
|
||||||
'parallel_test'=>true,
|
'parallel_test'=>true,
|
||||||
'piwigo_auth'=>'connection-scoped',
|
'piwigo_auth'=>'connection-scoped',
|
||||||
'api_enabled'=>false,
|
'api_enabled'=>$api_enabled,
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach (array('product'=>'nextcloud_product', 'version'=>'nextcloud_version') as $state_key=>$config_key)
|
foreach (array('product'=>'nextcloud_product', 'version'=>'nextcloud_version') as $state_key=>$config_key)
|
||||||
@@ -76,10 +87,10 @@ function bratonien_tools_nc_connector_create_webdav_placeholder_from_wizard()
|
|||||||
$secret_payload = json_encode(array(
|
$secret_payload = json_encode(array(
|
||||||
'v'=>3,
|
'v'=>3,
|
||||||
'db_password'=>'',
|
'db_password'=>'',
|
||||||
'piwigo_user'=>'',
|
'piwigo_user'=>$fallback_user,
|
||||||
'piwigo_password'=>'',
|
'piwigo_password'=>$fallback_password,
|
||||||
'api_key_id'=>'',
|
'api_key_id'=>$api_key_id,
|
||||||
'api_key_secret'=>'',
|
'api_key_secret'=>$api_key_secret,
|
||||||
'nextcloud_user'=>$username,
|
'nextcloud_user'=>$username,
|
||||||
'nextcloud_password'=>$password,
|
'nextcloud_password'=>$password,
|
||||||
), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||||
|
|||||||
Reference in New Issue
Block a user