@ -28,6 +28,7 @@
namespace OCA\Settings\Settings\Admin;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\Settings\ISettings;
@ -36,12 +37,16 @@ class Server implements ISettings {
/** @var IDBConnection */
private $connection;
/** @var ITimeFactory */
private $timeFactory;
/** @var IConfig */
private $config;
public function __construct(IDBConnection $connection,
ITimeFactory $timeFactory,
IConfig $config) {
$this->connection = $connection;
$this->timeFactory = $timeFactory;
$this->config = $config;
}
@ -49,6 +54,20 @@ class Server implements ISettings {
* @return TemplateResponse
*/
public function getForm() {
$parameters = [
// Background jobs
'backgroundjobs_mode' => $this->config->getAppValue('core', 'backgroundjobs_mode', 'ajax'),
'lastcron' => $this->config->getAppValue('core', 'lastcron', false),
'cronMaxAge' => $this->cronMaxAge(),
'cronErrors' => $this->config->getAppValue('core', 'cronErrors'),
'cli_based_cron_possible' => function_exists('posix_getpwuid'),
'cli_based_cron_user' => function_exists('posix_getpwuid') ? posix_getpwuid(fileowner(\OC::$configDir . 'config.php'))['name'] : '',
];
return new TemplateResponse('settings', 'settings/admin/server', $parameters, '');
}
protected function cronMaxAge(): int {
$query = $this->connection->getQueryBuilder();
$query->select('last_checked')
->from('jobs')
@ -59,21 +78,11 @@ class Server implements ISettings {
if ($row = $result->fetch()) {
$maxAge = (int) $row['last_checked'];
} else {
$maxAge = time();
$maxAge = $ this->timeFactory->getT ime();
}
$result->closeCursor();
$parameters = [
// Background jobs
'backgroundjobs_mode' => $this->config->getAppValue('core', 'backgroundjobs_mode', 'ajax'),
'lastcron' => $this->config->getAppValue('core', 'lastcron', false),
'cronMaxAge' => $maxAge,
'cronErrors' => $this->config->getAppValue('core', 'cronErrors'),
'cli_based_cron_possible' => function_exists('posix_getpwuid'),
'cli_based_cron_user' => function_exists('posix_getpwuid') ? posix_getpwuid(fileowner(\OC::$configDir . 'config.php'))['name'] : '',
];
return new TemplateResponse('settings', 'settings/admin/server', $parameters, '');
return $maxAge;
}
/**