Passed
Push — master ( 9c2d70...6ef7ba )
by Roeland
10:28
created
apps/dav/lib/CalDAV/Reminder/NotificationProvider/AudioProvider.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -32,6 +32,6 @@
 block discarded – undo
32 32
  */
33 33
 class AudioProvider extends PushProvider {
34 34
 
35
-	/** @var string */
36
-	public const NOTIFICATION_TYPE = 'AUDIO';
35
+    /** @var string */
36
+    public const NOTIFICATION_TYPE = 'AUDIO';
37 37
 }
Please login to merge, or discard this patch.
apps/dav/lib/CalDAV/Reminder/Backend.php 1 patch
Indentation   +181 added lines, -181 removed lines patch added patch discarded remove patch
@@ -35,185 +35,185 @@
 block discarded – undo
35 35
  */
36 36
 class Backend {
37 37
 
38
-	/** @var IDBConnection */
39
-	protected $db;
40
-
41
-	/** @var ITimeFactory */
42
-	private $timeFactory;
43
-
44
-	/**
45
-	 * Backend constructor.
46
-	 *
47
-	 * @param IDBConnection $db
48
-	 * @param ITimeFactory $timeFactory
49
-	 */
50
-	public function __construct(IDBConnection $db,
51
-								ITimeFactory $timeFactory) {
52
-		$this->db = $db;
53
-		$this->timeFactory = $timeFactory;
54
-	}
55
-
56
-	/**
57
-	 * Get all reminders with a notification date before now
58
-	 *
59
-	 * @return array
60
-	 * @throws \Exception
61
-	 */
62
-	public function getRemindersToProcess():array {
63
-		$query = $this->db->getQueryBuilder();
64
-		$query->select(['cr.*', 'co.calendardata', 'c.displayname', 'c.principaluri'])
65
-			->from('calendar_reminders', 'cr')
66
-			->where($query->expr()->lte('cr.notification_date', $query->createNamedParameter($this->timeFactory->getTime())))
67
-			->leftJoin('cr', 'calendarobjects', 'co', $query->expr()->eq('cr.object_id', 'co.id'))
68
-			->leftJoin('cr', 'calendars', 'c', $query->expr()->eq('cr.calendar_id', 'c.id'));
69
-		$stmt = $query->execute();
70
-
71
-		return array_map(
72
-			[$this, 'fixRowTyping'],
73
-			$stmt->fetchAll()
74
-		);
75
-	}
76
-
77
-	/**
78
-	 * Get all scheduled reminders for an event
79
-	 *
80
-	 * @param int $objectId
81
-	 * @return array
82
-	 */
83
-	public function getAllScheduledRemindersForEvent(int $objectId):array {
84
-		$query = $this->db->getQueryBuilder();
85
-		$query->select('*')
86
-			->from('calendar_reminders')
87
-			->where($query->expr()->eq('object_id', $query->createNamedParameter($objectId)));
88
-		$stmt = $query->execute();
89
-
90
-		return array_map(
91
-			[$this, 'fixRowTyping'],
92
-			$stmt->fetchAll()
93
-		);
94
-	}
95
-
96
-	/**
97
-	 * Insert a new reminder into the database
98
-	 *
99
-	 * @param int $calendarId
100
-	 * @param int $objectId
101
-	 * @param string $uid
102
-	 * @param bool $isRecurring
103
-	 * @param int $recurrenceId
104
-	 * @param bool $isRecurrenceException
105
-	 * @param string $eventHash
106
-	 * @param string $alarmHash
107
-	 * @param string $type
108
-	 * @param bool $isRelative
109
-	 * @param int $notificationDate
110
-	 * @param bool $isRepeatBased
111
-	 * @return int The insert id
112
-	 */
113
-	public function insertReminder(int $calendarId,
114
-								   int $objectId,
115
-								   string $uid,
116
-								   bool $isRecurring,
117
-								   int $recurrenceId,
118
-								   bool $isRecurrenceException,
119
-								   string $eventHash,
120
-								   string $alarmHash,
121
-								   string $type,
122
-								   bool $isRelative,
123
-								   int $notificationDate,
124
-								   bool $isRepeatBased):int {
125
-		$query = $this->db->getQueryBuilder();
126
-		$query->insert('calendar_reminders')
127
-			->values([
128
-				'calendar_id' => $query->createNamedParameter($calendarId),
129
-				'object_id' => $query->createNamedParameter($objectId),
130
-				'uid' => $query->createNamedParameter($uid),
131
-				'is_recurring' => $query->createNamedParameter($isRecurring ? 1 : 0),
132
-				'recurrence_id' => $query->createNamedParameter($recurrenceId),
133
-				'is_recurrence_exception' => $query->createNamedParameter($isRecurrenceException ? 1 : 0),
134
-				'event_hash' => $query->createNamedParameter($eventHash),
135
-				'alarm_hash' => $query->createNamedParameter($alarmHash),
136
-				'type' => $query->createNamedParameter($type),
137
-				'is_relative' => $query->createNamedParameter($isRelative ? 1 : 0),
138
-				'notification_date' => $query->createNamedParameter($notificationDate),
139
-				'is_repeat_based' => $query->createNamedParameter($isRepeatBased ? 1 : 0),
140
-			])
141
-			->execute();
142
-
143
-		return $query->getLastInsertId();
144
-	}
145
-
146
-	/**
147
-	 * Sets a new notificationDate on an existing reminder
148
-	 *
149
-	 * @param int $reminderId
150
-	 * @param int $newNotificationDate
151
-	 */
152
-	public function updateReminder(int $reminderId,
153
-								   int $newNotificationDate):void {
154
-		$query = $this->db->getQueryBuilder();
155
-		$query->update('calendar_reminders')
156
-			->set('notification_date', $query->createNamedParameter($newNotificationDate))
157
-			->where($query->expr()->eq('id', $query->createNamedParameter($reminderId)))
158
-			->execute();
159
-	}
160
-
161
-	/**
162
-	 * Remove a reminder by it's id
163
-	 *
164
-	 * @param integer $reminderId
165
-	 * @return void
166
-	 */
167
-	public function removeReminder(int $reminderId):void {
168
-		$query = $this->db->getQueryBuilder();
169
-
170
-		$query->delete('calendar_reminders')
171
-			->where($query->expr()->eq('id', $query->createNamedParameter($reminderId)))
172
-			->execute();
173
-	}
174
-
175
-	/**
176
-	 * Cleans reminders in database
177
-	 *
178
-	 * @param int $objectId
179
-	 */
180
-	public function cleanRemindersForEvent(int $objectId):void {
181
-		$query = $this->db->getQueryBuilder();
182
-
183
-		$query->delete('calendar_reminders')
184
-			->where($query->expr()->eq('object_id', $query->createNamedParameter($objectId)))
185
-			->execute();
186
-	}
187
-
188
-	/**
189
-	 * Remove all reminders for a calendar
190
-	 *
191
-	 * @param int $calendarId
192
-	 * @return void
193
-	 */
194
-	public function cleanRemindersForCalendar(int $calendarId):void {
195
-		$query = $this->db->getQueryBuilder();
196
-
197
-		$query->delete('calendar_reminders')
198
-			->where($query->expr()->eq('calendar_id', $query->createNamedParameter($calendarId)))
199
-			->execute();
200
-	}
201
-
202
-	/**
203
-	 * @param array $row
204
-	 * @return array
205
-	 */
206
-	private function fixRowTyping(array $row): array {
207
-		$row['id'] = (int) $row['id'];
208
-		$row['calendar_id'] = (int) $row['calendar_id'];
209
-		$row['object_id'] = (int) $row['object_id'];
210
-		$row['is_recurring'] = (bool) $row['is_recurring'];
211
-		$row['recurrence_id'] = (int) $row['recurrence_id'];
212
-		$row['is_recurrence_exception'] = (bool) $row['is_recurrence_exception'];
213
-		$row['is_relative'] = (bool) $row['is_relative'];
214
-		$row['notification_date'] = (int) $row['notification_date'];
215
-		$row['is_repeat_based'] = (bool) $row['is_repeat_based'];
216
-
217
-		return $row;
218
-	}
38
+    /** @var IDBConnection */
39
+    protected $db;
40
+
41
+    /** @var ITimeFactory */
42
+    private $timeFactory;
43
+
44
+    /**
45
+     * Backend constructor.
46
+     *
47
+     * @param IDBConnection $db
48
+     * @param ITimeFactory $timeFactory
49
+     */
50
+    public function __construct(IDBConnection $db,
51
+                                ITimeFactory $timeFactory) {
52
+        $this->db = $db;
53
+        $this->timeFactory = $timeFactory;
54
+    }
55
+
56
+    /**
57
+     * Get all reminders with a notification date before now
58
+     *
59
+     * @return array
60
+     * @throws \Exception
61
+     */
62
+    public function getRemindersToProcess():array {
63
+        $query = $this->db->getQueryBuilder();
64
+        $query->select(['cr.*', 'co.calendardata', 'c.displayname', 'c.principaluri'])
65
+            ->from('calendar_reminders', 'cr')
66
+            ->where($query->expr()->lte('cr.notification_date', $query->createNamedParameter($this->timeFactory->getTime())))
67
+            ->leftJoin('cr', 'calendarobjects', 'co', $query->expr()->eq('cr.object_id', 'co.id'))
68
+            ->leftJoin('cr', 'calendars', 'c', $query->expr()->eq('cr.calendar_id', 'c.id'));
69
+        $stmt = $query->execute();
70
+
71
+        return array_map(
72
+            [$this, 'fixRowTyping'],
73
+            $stmt->fetchAll()
74
+        );
75
+    }
76
+
77
+    /**
78
+     * Get all scheduled reminders for an event
79
+     *
80
+     * @param int $objectId
81
+     * @return array
82
+     */
83
+    public function getAllScheduledRemindersForEvent(int $objectId):array {
84
+        $query = $this->db->getQueryBuilder();
85
+        $query->select('*')
86
+            ->from('calendar_reminders')
87
+            ->where($query->expr()->eq('object_id', $query->createNamedParameter($objectId)));
88
+        $stmt = $query->execute();
89
+
90
+        return array_map(
91
+            [$this, 'fixRowTyping'],
92
+            $stmt->fetchAll()
93
+        );
94
+    }
95
+
96
+    /**
97
+     * Insert a new reminder into the database
98
+     *
99
+     * @param int $calendarId
100
+     * @param int $objectId
101
+     * @param string $uid
102
+     * @param bool $isRecurring
103
+     * @param int $recurrenceId
104
+     * @param bool $isRecurrenceException
105
+     * @param string $eventHash
106
+     * @param string $alarmHash
107
+     * @param string $type
108
+     * @param bool $isRelative
109
+     * @param int $notificationDate
110
+     * @param bool $isRepeatBased
111
+     * @return int The insert id
112
+     */
113
+    public function insertReminder(int $calendarId,
114
+                                    int $objectId,
115
+                                    string $uid,
116
+                                    bool $isRecurring,
117
+                                    int $recurrenceId,
118
+                                    bool $isRecurrenceException,
119
+                                    string $eventHash,
120
+                                    string $alarmHash,
121
+                                    string $type,
122
+                                    bool $isRelative,
123
+                                    int $notificationDate,
124
+                                    bool $isRepeatBased):int {
125
+        $query = $this->db->getQueryBuilder();
126
+        $query->insert('calendar_reminders')
127
+            ->values([
128
+                'calendar_id' => $query->createNamedParameter($calendarId),
129
+                'object_id' => $query->createNamedParameter($objectId),
130
+                'uid' => $query->createNamedParameter($uid),
131
+                'is_recurring' => $query->createNamedParameter($isRecurring ? 1 : 0),
132
+                'recurrence_id' => $query->createNamedParameter($recurrenceId),
133
+                'is_recurrence_exception' => $query->createNamedParameter($isRecurrenceException ? 1 : 0),
134
+                'event_hash' => $query->createNamedParameter($eventHash),
135
+                'alarm_hash' => $query->createNamedParameter($alarmHash),
136
+                'type' => $query->createNamedParameter($type),
137
+                'is_relative' => $query->createNamedParameter($isRelative ? 1 : 0),
138
+                'notification_date' => $query->createNamedParameter($notificationDate),
139
+                'is_repeat_based' => $query->createNamedParameter($isRepeatBased ? 1 : 0),
140
+            ])
141
+            ->execute();
142
+
143
+        return $query->getLastInsertId();
144
+    }
145
+
146
+    /**
147
+     * Sets a new notificationDate on an existing reminder
148
+     *
149
+     * @param int $reminderId
150
+     * @param int $newNotificationDate
151
+     */
152
+    public function updateReminder(int $reminderId,
153
+                                    int $newNotificationDate):void {
154
+        $query = $this->db->getQueryBuilder();
155
+        $query->update('calendar_reminders')
156
+            ->set('notification_date', $query->createNamedParameter($newNotificationDate))
157
+            ->where($query->expr()->eq('id', $query->createNamedParameter($reminderId)))
158
+            ->execute();
159
+    }
160
+
161
+    /**
162
+     * Remove a reminder by it's id
163
+     *
164
+     * @param integer $reminderId
165
+     * @return void
166
+     */
167
+    public function removeReminder(int $reminderId):void {
168
+        $query = $this->db->getQueryBuilder();
169
+
170
+        $query->delete('calendar_reminders')
171
+            ->where($query->expr()->eq('id', $query->createNamedParameter($reminderId)))
172
+            ->execute();
173
+    }
174
+
175
+    /**
176
+     * Cleans reminders in database
177
+     *
178
+     * @param int $objectId
179
+     */
180
+    public function cleanRemindersForEvent(int $objectId):void {
181
+        $query = $this->db->getQueryBuilder();
182
+
183
+        $query->delete('calendar_reminders')
184
+            ->where($query->expr()->eq('object_id', $query->createNamedParameter($objectId)))
185
+            ->execute();
186
+    }
187
+
188
+    /**
189
+     * Remove all reminders for a calendar
190
+     *
191
+     * @param int $calendarId
192
+     * @return void
193
+     */
194
+    public function cleanRemindersForCalendar(int $calendarId):void {
195
+        $query = $this->db->getQueryBuilder();
196
+
197
+        $query->delete('calendar_reminders')
198
+            ->where($query->expr()->eq('calendar_id', $query->createNamedParameter($calendarId)))
199
+            ->execute();
200
+    }
201
+
202
+    /**
203
+     * @param array $row
204
+     * @return array
205
+     */
206
+    private function fixRowTyping(array $row): array {
207
+        $row['id'] = (int) $row['id'];
208
+        $row['calendar_id'] = (int) $row['calendar_id'];
209
+        $row['object_id'] = (int) $row['object_id'];
210
+        $row['is_recurring'] = (bool) $row['is_recurring'];
211
+        $row['recurrence_id'] = (int) $row['recurrence_id'];
212
+        $row['is_recurrence_exception'] = (bool) $row['is_recurrence_exception'];
213
+        $row['is_relative'] = (bool) $row['is_relative'];
214
+        $row['notification_date'] = (int) $row['notification_date'];
215
+        $row['is_repeat_based'] = (bool) $row['is_repeat_based'];
216
+
217
+        return $row;
218
+    }
219 219
 }
Please login to merge, or discard this patch.
apps/dav/appinfo/app.php 1 patch
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -33,59 +33,59 @@  discard block
 block discarded – undo
33 33
 $app->registerHooks();
34 34
 
35 35
 \OC::$server->registerService('CardDAVSyncService', function() use ($app) {
36
-	return $app->getSyncService();
36
+    return $app->getSyncService();
37 37
 });
38 38
 
39 39
 $eventDispatcher = \OC::$server->getEventDispatcher();
40 40
 
41 41
 $eventDispatcher->addListener('OCP\Federation\TrustedServerEvent::remove',
42
-	function(GenericEvent $event) use ($app) {
43
-		/** @var CardDavBackend $cardDavBackend */
44
-		$cardDavBackend = $app->getContainer()->query(CardDavBackend::class);
45
-		$addressBookUri = $event->getSubject();
46
-		$addressBook = $cardDavBackend->getAddressBooksByUri('principals/system/system', $addressBookUri);
47
-		if (!is_null($addressBook)) {
48
-			$cardDavBackend->deleteAddressBook($addressBook['id']);
49
-		}
50
-	}
42
+    function(GenericEvent $event) use ($app) {
43
+        /** @var CardDavBackend $cardDavBackend */
44
+        $cardDavBackend = $app->getContainer()->query(CardDavBackend::class);
45
+        $addressBookUri = $event->getSubject();
46
+        $addressBook = $cardDavBackend->getAddressBooksByUri('principals/system/system', $addressBookUri);
47
+        if (!is_null($addressBook)) {
48
+            $cardDavBackend->deleteAddressBook($addressBook['id']);
49
+        }
50
+    }
51 51
 );
52 52
 
53 53
 $eventDispatcher->addListener('\OCA\DAV\CalDAV\CalDavBackend::createSubscription',
54
-	function(GenericEvent $event) use ($app) {
55
-		$jobList = $app->getContainer()->getServer()->getJobList();
56
-		$subscriptionData = $event->getArgument('subscriptionData');
57
-
58
-		$jobList->add(\OCA\DAV\BackgroundJob\RefreshWebcalJob::class, [
59
-			'principaluri' => $subscriptionData['principaluri'],
60
-			'uri' => $subscriptionData['uri']
61
-		]);
62
-	}
54
+    function(GenericEvent $event) use ($app) {
55
+        $jobList = $app->getContainer()->getServer()->getJobList();
56
+        $subscriptionData = $event->getArgument('subscriptionData');
57
+
58
+        $jobList->add(\OCA\DAV\BackgroundJob\RefreshWebcalJob::class, [
59
+            'principaluri' => $subscriptionData['principaluri'],
60
+            'uri' => $subscriptionData['uri']
61
+        ]);
62
+    }
63 63
 );
64 64
 
65 65
 $eventDispatcher->addListener('\OCA\DAV\CalDAV\CalDavBackend::deleteSubscription',
66
-	function(GenericEvent $event) use ($app) {
67
-		$jobList = $app->getContainer()->getServer()->getJobList();
68
-		$subscriptionData = $event->getArgument('subscriptionData');
69
-
70
-		$jobList->remove(\OCA\DAV\BackgroundJob\RefreshWebcalJob::class, [
71
-			'principaluri' => $subscriptionData['principaluri'],
72
-			'uri' => $subscriptionData['uri']
73
-		]);
74
-
75
-		/** @var \OCA\DAV\CalDAV\CalDavBackend $calDavBackend */
76
-		$calDavBackend = $app->getContainer()->query(\OCA\DAV\CalDAV\CalDavBackend::class);
77
-		$calDavBackend->purgeAllCachedEventsForSubscription($subscriptionData['id']);
78
-	}
66
+    function(GenericEvent $event) use ($app) {
67
+        $jobList = $app->getContainer()->getServer()->getJobList();
68
+        $subscriptionData = $event->getArgument('subscriptionData');
69
+
70
+        $jobList->remove(\OCA\DAV\BackgroundJob\RefreshWebcalJob::class, [
71
+            'principaluri' => $subscriptionData['principaluri'],
72
+            'uri' => $subscriptionData['uri']
73
+        ]);
74
+
75
+        /** @var \OCA\DAV\CalDAV\CalDavBackend $calDavBackend */
76
+        $calDavBackend = $app->getContainer()->query(\OCA\DAV\CalDAV\CalDavBackend::class);
77
+        $calDavBackend->purgeAllCachedEventsForSubscription($subscriptionData['id']);
78
+    }
79 79
 );
80 80
 
81 81
 $eventHandler = function() use ($app) {
82
-	try {
83
-		$job = $app->getContainer()->query(\OCA\DAV\BackgroundJob\UpdateCalendarResourcesRoomsBackgroundJob::class);
84
-		$job->run([]);
85
-		$app->getContainer()->getServer()->getJobList()->setLastRun($job);
86
-	} catch(\Exception $ex) {
87
-		$app->getContainer()->getServer()->getLogger()->logException($ex);
88
-	}
82
+    try {
83
+        $job = $app->getContainer()->query(\OCA\DAV\BackgroundJob\UpdateCalendarResourcesRoomsBackgroundJob::class);
84
+        $job->run([]);
85
+        $app->getContainer()->getServer()->getJobList()->setLastRun($job);
86
+    } catch(\Exception $ex) {
87
+        $app->getContainer()->getServer()->getLogger()->logException($ex);
88
+    }
89 89
 };
90 90
 
91 91
 $eventDispatcher->addListener('\OCP\Calendar\Resource\ForceRefreshEvent', $eventHandler);
@@ -93,20 +93,20 @@  discard block
 block discarded – undo
93 93
 
94 94
 $cm = \OC::$server->getContactsManager();
95 95
 $cm->register(function() use ($cm, $app) {
96
-	$user = \OC::$server->getUserSession()->getUser();
97
-	if (!is_null($user)) {
98
-		$app->setupContactsProvider($cm, $user->getUID());
99
-	} else {
100
-		$app->setupSystemContactsProvider($cm);
101
-	}
96
+    $user = \OC::$server->getUserSession()->getUser();
97
+    if (!is_null($user)) {
98
+        $app->setupContactsProvider($cm, $user->getUID());
99
+    } else {
100
+        $app->setupSystemContactsProvider($cm);
101
+    }
102 102
 });
103 103
 
104 104
 $calendarManager = \OC::$server->getCalendarManager();
105 105
 $calendarManager->register(function() use ($calendarManager, $app) {
106
-	$user = \OC::$server->getUserSession()->getUser();
107
-	if ($user !== null) {
108
-		$app->setupCalendarProvider($calendarManager, $user->getUID());
109
-	}
106
+    $user = \OC::$server->getUserSession()->getUser();
107
+    if ($user !== null) {
108
+        $app->setupCalendarProvider($calendarManager, $user->getUID());
109
+    }
110 110
 });
111 111
 
112 112
 $app->registerNotifier();
Please login to merge, or discard this patch.