* Account Import: if deleting or deactivating of deleted accounts is configured, run first import as a non-incremental one to do so

This commit is contained in:
ralf 2024-01-29 14:09:05 +02:00
parent b924e3a03d
commit a2f9700b96

View File

@ -937,7 +937,9 @@ class Import
const LOG_FILE = 'setup/account-import.log';
/**
* Run incremental import via async job
* Run import via async job
*
* First daily run is a full import, if deleting or deactivating accounts is configured, all others are incremental imports
*
* @return void
*/
@ -946,7 +948,8 @@ class Import
try {
$import = new self();
$import->logger(date('Y-m-d H:i:s O').' LDAP account import started', 'info');
$import->run(false);
$import->run(in_array($GLOBALS['egw_info']['server']['account_import_delete'] ?? 'no', ['yes', 'deactivate']) &&
self::firstRunToday());
$import->logger(date('Y-m-d H:i:s O').' LDAP account import finished', 'info');
}
catch (\InvalidArgumentException $e) {
@ -961,6 +964,21 @@ class Import
}
}
/**
* Check if current time / run is the first one for today
*
* @return bool
*/
public static function firstRunToday()
{
if (empty($frequency=$GLOBALS['egw_info']['server']['account_import_frequency']))
{
return false;
}
// check current time <= time of first run today (frequency is in hours)
return time() <= mktime(ceil($frequency), round((60*$frequency)%60), 60); // 60 seconds grace time
}
/**
* Tail the async import log
*