You've already forked onlyoffice-owncloud
mirror of
https://github.com/ONLYOFFICE/onlyoffice-owncloud.git
synced 2025-07-30 10:43:07 +03:00
134 lines
3.0 KiB
PHP
134 lines
3.0 KiB
PHP
<?php
|
|
/**
|
|
* @author Ascensio System SIA <integration@onlyoffice.com>
|
|
*
|
|
* (c) Copyright Ascensio System SIA 2025
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*
|
|
*/
|
|
|
|
namespace OCA\Onlyoffice\Controller;
|
|
|
|
use OC\AppFramework\Http;
|
|
use OC\BackgroundJob\TimedJob;
|
|
use OCP\AppFramework\Controller;
|
|
use OCP\AppFramework\Http\DataDisplayResponse;
|
|
use OCP\AppFramework\Http\DataResponse;
|
|
use OCP\AppFramework\Http\Response;
|
|
use OCP\BackgroundJob\IJob;
|
|
use OCP\BackgroundJob\IJobList;
|
|
use OCP\ILogger;
|
|
use OCP\IRequest;
|
|
|
|
use OCA\Onlyoffice\Cron\EditorsCheck;
|
|
use OCA\Onlyoffice\AppConfig;
|
|
|
|
/**
|
|
* Class JobListController
|
|
*
|
|
* @package OCA\Onlyoffice\Controller
|
|
*/
|
|
class JobListController extends Controller {
|
|
/**
|
|
* Logger
|
|
*
|
|
* @var ILogger
|
|
*/
|
|
private $logger;
|
|
|
|
/**
|
|
* Job list
|
|
*
|
|
* @var IJobList
|
|
*/
|
|
private $jobList;
|
|
|
|
/**
|
|
* Application configuration
|
|
*
|
|
* @var AppConfig
|
|
*/
|
|
private $config;
|
|
|
|
/**
|
|
* JobListController constructor.
|
|
*
|
|
* @param string $AppName - application name
|
|
* @param IRequest $request - request object
|
|
* @param ILogger $logger
|
|
* @param AppConfig $config - application configuration
|
|
* @param IJobList $jobList - job list
|
|
*/
|
|
public function __construct($AppName, IRequest $request, ILogger $logger, AppConfig $config, IJobList $jobList) {
|
|
parent::__construct($AppName, $request);
|
|
$this->logger = $logger;
|
|
$this->config = $config;
|
|
$this->jobList = $jobList;
|
|
}
|
|
|
|
/**
|
|
* Add a job to list
|
|
*
|
|
* @param IJob|string $job
|
|
*
|
|
* @return void
|
|
*/
|
|
private function addJob($job) {
|
|
if (!$this->jobList->has($job, null)) {
|
|
$this->jobList->add($job);
|
|
$this->logger->debug("Job '" . $job . "' added to JobList.", ["app" => $this->appName]);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Remove a job from list
|
|
*
|
|
* @param IJob|string $job
|
|
*
|
|
* @return void
|
|
*/
|
|
private function removeJob($job) {
|
|
if ($this->jobList->has($job, null)) {
|
|
$this->jobList->remove($job);
|
|
$this->logger->debug("Job '" . $job . "' removed from JobList.", ["app" => $this->appName]);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Add or remove EditorsCheck job depending on the value of _editors_check_interval
|
|
*
|
|
* @return void
|
|
*/
|
|
private function checkEditorsCheckJob() {
|
|
if (!$this->config->getCronChecker()) {
|
|
$this->removeJob(EditorsCheck::class);
|
|
return;
|
|
}
|
|
if ($this->config->getEditorsCheckInterval() > 0) {
|
|
$this->addJob(EditorsCheck::class);
|
|
} else {
|
|
$this->removeJob(EditorsCheck::class);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Method for sequentially calling checks of all jobs
|
|
*
|
|
* @return void
|
|
*/
|
|
public function checkAllJobs() {
|
|
$this->checkEditorsCheckJob();
|
|
}
|
|
}
|