12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- <?php
- namespace OCA\DAV\Controller;
- use OCA\DAV\BackgroundJob\GenerateBirthdayCalendarBackgroundJob;
- use OCA\DAV\CalDAV\CalDavBackend;
- use OCA\DAV\Settings\CalDAVSettings;
- use OCP\AppFramework\Controller;
- use OCP\AppFramework\Http\Attribute\AuthorizedAdminSetting;
- use OCP\AppFramework\Http\JSONResponse;
- use OCP\AppFramework\Http\Response;
- use OCP\BackgroundJob\IJobList;
- use OCP\IConfig;
- use OCP\IDBConnection;
- use OCP\IRequest;
- use OCP\IUser;
- use OCP\IUserManager;
- class BirthdayCalendarController extends Controller {
-
- public function __construct(
- $appName,
- IRequest $request,
- protected IDBConnection $db,
- protected IConfig $config,
- protected IJobList $jobList,
- protected IUserManager $userManager,
- protected CalDavBackend $caldavBackend,
- ) {
- parent::__construct($appName, $request);
- }
-
-
- public function enable() {
- $this->config->setAppValue($this->appName, 'generateBirthdayCalendar', 'yes');
-
- $this->userManager->callForSeenUsers(function (IUser $user): void {
- $this->jobList->add(GenerateBirthdayCalendarBackgroundJob::class, [
- 'userId' => $user->getUID(),
- ]);
- });
- return new JSONResponse([]);
- }
-
-
- public function disable() {
- $this->config->setAppValue($this->appName, 'generateBirthdayCalendar', 'no');
- $this->jobList->remove(GenerateBirthdayCalendarBackgroundJob::class);
- $this->caldavBackend->deleteAllBirthdayCalendars();
- return new JSONResponse([]);
- }
- }
|