NC Connector: read UI status from Piwigo data directory

This commit is contained in:
Terranom674
2026-08-17 22:26:05 +02:00
parent 9e498e8fd0
commit 4ca2e0eba8

View File

@@ -113,7 +113,7 @@ function bratonien_tools_nc_connector_connection_last_status(array $connection)
$candidates = array(); $candidates = array();
if ($connection_id > 0) if ($connection_id > 0)
{ {
$candidates[] = '/var/lib/bratonien-tools/nc-connector-status/connection-'.$connection_id.'.json'; $candidates[] = rtrim(PHPWG_ROOT_PATH, '/').'/_data/bratonien-tools/nc-connector-status/connection-'.$connection_id.'.json';
} }
$config = isset($connection['config']) && is_array($connection['config']) ? $connection['config'] : array(); $config = isset($connection['config']) && is_array($connection['config']) ? $connection['config'] : array();
@@ -127,21 +127,20 @@ function bratonien_tools_nc_connector_connection_last_status(array $connection)
$candidates[] = $state_dir.'/connector-status.json'; $candidates[] = $state_dir.'/connector-status.json';
} }
$status_path = ''; $decoded = null;
foreach ($candidates as $candidate) foreach ($candidates as $candidate)
{ {
if (is_readable($candidate)) if (!is_readable($candidate))
{ {
$status_path = $candidate; continue;
}
$value = json_decode((string)@file_get_contents($candidate), true);
if (is_array($value))
{
$decoded = $value;
break; break;
} }
} }
if ($status_path === '')
{
return $empty;
}
$decoded = json_decode((string)@file_get_contents($status_path), true);
if (!is_array($decoded)) if (!is_array($decoded))
{ {
return $empty; return $empty;