@@ -43,351 +43,351 @@ |
||
43 | 43 | |
44 | 44 | class BirthdayService { |
45 | 45 | |
46 | - const BIRTHDAY_CALENDAR_URI = 'contact_birthdays'; |
|
47 | - |
|
48 | - /** @var GroupPrincipalBackend */ |
|
49 | - private $principalBackend; |
|
50 | - |
|
51 | - /** @var CalDavBackend */ |
|
52 | - private $calDavBackEnd; |
|
53 | - |
|
54 | - /** @var CardDavBackend */ |
|
55 | - private $cardDavBackEnd; |
|
56 | - |
|
57 | - /** @var IConfig */ |
|
58 | - private $config; |
|
59 | - |
|
60 | - /** @var IDBConnection */ |
|
61 | - private $dbConnection; |
|
62 | - |
|
63 | - /** |
|
64 | - * BirthdayService constructor. |
|
65 | - * |
|
66 | - * @param CalDavBackend $calDavBackEnd |
|
67 | - * @param CardDavBackend $cardDavBackEnd |
|
68 | - * @param GroupPrincipalBackend $principalBackend |
|
69 | - * @param IConfig $config; |
|
70 | - */ |
|
71 | - public function __construct(CalDavBackend $calDavBackEnd, CardDavBackend $cardDavBackEnd, GroupPrincipalBackend $principalBackend, IConfig $config, IDBConnection $dbConnection) { |
|
72 | - $this->calDavBackEnd = $calDavBackEnd; |
|
73 | - $this->cardDavBackEnd = $cardDavBackEnd; |
|
74 | - $this->principalBackend = $principalBackend; |
|
75 | - $this->config = $config; |
|
76 | - $this->dbConnection = $dbConnection; |
|
77 | - } |
|
78 | - |
|
79 | - /** |
|
80 | - * @param int $addressBookId |
|
81 | - * @param string $cardUri |
|
82 | - * @param string $cardData |
|
83 | - */ |
|
84 | - public function onCardChanged($addressBookId, $cardUri, $cardData) { |
|
85 | - if (!$this->isGloballyEnabled()) { |
|
86 | - return; |
|
87 | - } |
|
88 | - |
|
89 | - $targetPrincipals = $this->getAllAffectedPrincipals($addressBookId); |
|
90 | - $book = $this->cardDavBackEnd->getAddressBookById($addressBookId); |
|
91 | - $targetPrincipals[] = $book['principaluri']; |
|
92 | - $datesToSync = [ |
|
93 | - ['postfix' => '', 'field' => 'BDAY', 'symbol' => '*', 'utfSymbol' => ' |
@@ -28,47 +28,47 @@ |
||
28 | 28 | |
29 | 29 | class GenerateBirthdayCalendarBackgroundJob extends QueuedJob { |
30 | 30 | |
31 | - /** @var BirthdayService */ |
|
32 | - private $birthdayService; |
|
31 | + /** @var BirthdayService */ |
|
32 | + private $birthdayService; |
|
33 | 33 | |
34 | - /** @var IConfig */ |
|
35 | - private $config; |
|
34 | + /** @var IConfig */ |
|
35 | + private $config; |
|
36 | 36 | |
37 | - /** |
|
38 | - * GenerateAllBirthdayCalendarsBackgroundJob constructor. |
|
39 | - * |
|
40 | - * @param BirthdayService $birthdayService |
|
41 | - * @param IConfig $config |
|
42 | - */ |
|
43 | - public function __construct(BirthdayService $birthdayService, |
|
44 | - IConfig $config) { |
|
45 | - $this->birthdayService = $birthdayService; |
|
46 | - $this->config = $config; |
|
47 | - } |
|
37 | + /** |
|
38 | + * GenerateAllBirthdayCalendarsBackgroundJob constructor. |
|
39 | + * |
|
40 | + * @param BirthdayService $birthdayService |
|
41 | + * @param IConfig $config |
|
42 | + */ |
|
43 | + public function __construct(BirthdayService $birthdayService, |
|
44 | + IConfig $config) { |
|
45 | + $this->birthdayService = $birthdayService; |
|
46 | + $this->config = $config; |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * @param array $arguments |
|
51 | - */ |
|
52 | - public function run($arguments) { |
|
53 | - $userId = $arguments['userId']; |
|
54 | - $purgeBeforeGenerating = $arguments['purgeBeforeGenerating'] ?? false; |
|
49 | + /** |
|
50 | + * @param array $arguments |
|
51 | + */ |
|
52 | + public function run($arguments) { |
|
53 | + $userId = $arguments['userId']; |
|
54 | + $purgeBeforeGenerating = $arguments['purgeBeforeGenerating'] ?? false; |
|
55 | 55 | |
56 | - // make sure admin didn't change his mind |
|
57 | - $isGloballyEnabled = $this->config->getAppValue('dav', 'generateBirthdayCalendar', 'yes'); |
|
58 | - if ($isGloballyEnabled !== 'yes') { |
|
59 | - return; |
|
60 | - } |
|
56 | + // make sure admin didn't change his mind |
|
57 | + $isGloballyEnabled = $this->config->getAppValue('dav', 'generateBirthdayCalendar', 'yes'); |
|
58 | + if ($isGloballyEnabled !== 'yes') { |
|
59 | + return; |
|
60 | + } |
|
61 | 61 | |
62 | - // did the user opt out? |
|
63 | - $isUserEnabled = $this->config->getUserValue($userId, 'dav', 'generateBirthdayCalendar', 'yes'); |
|
64 | - if ($isUserEnabled !== 'yes') { |
|
65 | - return; |
|
66 | - } |
|
62 | + // did the user opt out? |
|
63 | + $isUserEnabled = $this->config->getUserValue($userId, 'dav', 'generateBirthdayCalendar', 'yes'); |
|
64 | + if ($isUserEnabled !== 'yes') { |
|
65 | + return; |
|
66 | + } |
|
67 | 67 | |
68 | - if ($purgeBeforeGenerating) { |
|
69 | - $this->birthdayService->resetForUser($userId); |
|
70 | - } |
|
68 | + if ($purgeBeforeGenerating) { |
|
69 | + $this->birthdayService->resetForUser($userId); |
|
70 | + } |
|
71 | 71 | |
72 | - $this->birthdayService->syncUser($userId); |
|
73 | - } |
|
72 | + $this->birthdayService->syncUser($userId); |
|
73 | + } |
|
74 | 74 | } |
@@ -32,54 +32,54 @@ |
||
32 | 32 | |
33 | 33 | class RegenerateBirthdayCalendars implements IRepairStep { |
34 | 34 | |
35 | - /** @var IUserManager */ |
|
36 | - private $userManager; |
|
35 | + /** @var IUserManager */ |
|
36 | + private $userManager; |
|
37 | 37 | |
38 | - /** @var IJobList */ |
|
39 | - private $jobList; |
|
38 | + /** @var IJobList */ |
|
39 | + private $jobList; |
|
40 | 40 | |
41 | - /** @var IConfig */ |
|
42 | - private $config; |
|
41 | + /** @var IConfig */ |
|
42 | + private $config; |
|
43 | 43 | |
44 | - /** |
|
45 | - * @param IUserManager $userManager, |
|
46 | - * @param IJobList $jobList |
|
47 | - * @param IConfig $config |
|
48 | - */ |
|
49 | - public function __construct(IUserManager $userManager, |
|
50 | - IJobList $jobList, |
|
51 | - IConfig $config) { |
|
52 | - $this->userManager = $userManager; |
|
53 | - $this->jobList = $jobList; |
|
54 | - $this->config = $config; |
|
55 | - } |
|
44 | + /** |
|
45 | + * @param IUserManager $userManager, |
|
46 | + * @param IJobList $jobList |
|
47 | + * @param IConfig $config |
|
48 | + */ |
|
49 | + public function __construct(IUserManager $userManager, |
|
50 | + IJobList $jobList, |
|
51 | + IConfig $config) { |
|
52 | + $this->userManager = $userManager; |
|
53 | + $this->jobList = $jobList; |
|
54 | + $this->config = $config; |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * @return string |
|
59 | - */ |
|
60 | - public function getName() { |
|
61 | - return 'Regenerating birthday calendars to use new icons and fix old birthday events without year'; |
|
62 | - } |
|
57 | + /** |
|
58 | + * @return string |
|
59 | + */ |
|
60 | + public function getName() { |
|
61 | + return 'Regenerating birthday calendars to use new icons and fix old birthday events without year'; |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * @param IOutput $output |
|
66 | - */ |
|
67 | - public function run(IOutput $output) { |
|
68 | - // only run once |
|
69 | - if ($this->config->getAppValue('dav', 'regeneratedBirthdayCalendarsForYearFix') === 'yes') { |
|
70 | - $output->info('Repair step already executed'); |
|
71 | - return; |
|
72 | - } |
|
64 | + /** |
|
65 | + * @param IOutput $output |
|
66 | + */ |
|
67 | + public function run(IOutput $output) { |
|
68 | + // only run once |
|
69 | + if ($this->config->getAppValue('dav', 'regeneratedBirthdayCalendarsForYearFix') === 'yes') { |
|
70 | + $output->info('Repair step already executed'); |
|
71 | + return; |
|
72 | + } |
|
73 | 73 | |
74 | - $output->info('Adding background jobs to regenerate birthday calendar'); |
|
75 | - $this->userManager->callForAllUsers(function(IUser $user) { |
|
76 | - $this->jobList->add(GenerateBirthdayCalendarBackgroundJob::class, [ |
|
77 | - 'userId' => $user->getUID(), |
|
78 | - 'purgeBeforeGenerating' => true |
|
79 | - ]); |
|
80 | - }); |
|
74 | + $output->info('Adding background jobs to regenerate birthday calendar'); |
|
75 | + $this->userManager->callForAllUsers(function(IUser $user) { |
|
76 | + $this->jobList->add(GenerateBirthdayCalendarBackgroundJob::class, [ |
|
77 | + 'userId' => $user->getUID(), |
|
78 | + 'purgeBeforeGenerating' => true |
|
79 | + ]); |
|
80 | + }); |
|
81 | 81 | |
82 | - // if all were done, no need to redo the repair during next upgrade |
|
83 | - $this->config->setAppValue('dav', 'regeneratedBirthdayCalendarsForYearFix', 'yes'); |
|
84 | - } |
|
82 | + // if all were done, no need to redo the repair during next upgrade |
|
83 | + $this->config->setAppValue('dav', 'regeneratedBirthdayCalendarsForYearFix', 'yes'); |
|
84 | + } |
|
85 | 85 | } |
86 | 86 | \ No newline at end of file |