db = $db; $this->config = $config; $this->userManager = $userManager; $this->jobList = $jobList; $this->caldavBackend = $calDavBackend; } /** * @return Response * @AuthorizedAdminSetting(settings=OCA\DAV\Settings\CalDAVSettings) */ public function enable() { $this->config->setAppValue($this->appName, 'generateBirthdayCalendar', 'yes'); // add background job for each user $this->userManager->callForSeenUsers(function (IUser $user) { $this->jobList->add(GenerateBirthdayCalendarBackgroundJob::class, [ 'userId' => $user->getUID(), ]); }); return new JSONResponse([]); } /** * @return Response * @AuthorizedAdminSetting(settings=OCA\DAV\Settings\CalDAVSettings) */ public function disable() { $this->config->setAppValue($this->appName, 'generateBirthdayCalendar', 'no'); $this->jobList->remove(GenerateBirthdayCalendarBackgroundJob::class); $this->caldavBackend->deleteAllBirthdayCalendars(); return new JSONResponse([]); } }