Completed
Push — master ( c65848...a5c801 )
by Blizzz
112:32 queued 99:32
created
apps/dav/lib/Connector/Sabre/SharesPlugin.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 
149 149
 		$shareTypesByFileId = [];
150 150
 
151
-		foreach($shares as $fileId => $sharesForFile) {
151
+		foreach ($shares as $fileId => $sharesForFile) {
152 152
 			$types = array_map(function(IShare $share) {
153 153
 				return $share->getShareType();
154 154
 			}, $sharesForFile);
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 			}
190 190
 		}
191 191
 
192
-		$propFind->handle(self::SHARETYPES_PROPERTYNAME, function () use ($sabreNode) {
192
+		$propFind->handle(self::SHARETYPES_PROPERTYNAME, function() use ($sabreNode) {
193 193
 			if (isset($this->cachedShareTypes[$sabreNode->getId()])) {
194 194
 				$shareTypes = $this->cachedShareTypes[$sabreNode->getId()];
195 195
 			} else {
Please login to merge, or discard this patch.
Indentation   +177 added lines, -177 removed lines patch added patch discarded remove patch
@@ -32,181 +32,181 @@
 block discarded – undo
32 32
  */
33 33
 class SharesPlugin extends \Sabre\DAV\ServerPlugin {
34 34
 
35
-	const NS_OWNCLOUD = 'http://owncloud.org/ns';
36
-	const SHARETYPES_PROPERTYNAME = '{http://owncloud.org/ns}share-types';
37
-
38
-	/**
39
-	 * Reference to main server object
40
-	 *
41
-	 * @var \Sabre\DAV\Server
42
-	 */
43
-	private $server;
44
-
45
-	/**
46
-	 * @var \OCP\Share\IManager
47
-	 */
48
-	private $shareManager;
49
-
50
-	/**
51
-	 * @var \Sabre\DAV\Tree
52
-	 */
53
-	private $tree;
54
-
55
-	/**
56
-	 * @var string
57
-	 */
58
-	private $userId;
59
-
60
-	/**
61
-	 * @var \OCP\Files\Folder
62
-	 */
63
-	private $userFolder;
64
-
65
-	/**
66
-	 * @var IShare[]
67
-	 */
68
-	private $cachedShareTypes;
69
-
70
-	private $cachedFolders = [];
71
-
72
-	/**
73
-	 * @param \Sabre\DAV\Tree $tree tree
74
-	 * @param IUserSession $userSession user session
75
-	 * @param \OCP\Files\Folder $userFolder user home folder
76
-	 * @param \OCP\Share\IManager $shareManager share manager
77
-	 */
78
-	public function __construct(
79
-		\Sabre\DAV\Tree $tree,
80
-		IUserSession $userSession,
81
-		\OCP\Files\Folder $userFolder,
82
-		\OCP\Share\IManager $shareManager
83
-	) {
84
-		$this->tree = $tree;
85
-		$this->shareManager = $shareManager;
86
-		$this->userFolder = $userFolder;
87
-		$this->userId = $userSession->getUser()->getUID();
88
-		$this->cachedShareTypes = [];
89
-	}
90
-
91
-	/**
92
-	 * This initializes the plugin.
93
-	 *
94
-	 * This function is called by \Sabre\DAV\Server, after
95
-	 * addPlugin is called.
96
-	 *
97
-	 * This method should set up the required event subscriptions.
98
-	 *
99
-	 * @param \Sabre\DAV\Server $server
100
-	 */
101
-	public function initialize(\Sabre\DAV\Server $server) {
102
-		$server->xml->namespacesMap[self::NS_OWNCLOUD] = 'oc';
103
-		$server->xml->elementMap[self::SHARETYPES_PROPERTYNAME] = 'OCA\\DAV\\Connector\\Sabre\\ShareTypeList';
104
-		$server->protectedProperties[] = self::SHARETYPES_PROPERTYNAME;
105
-
106
-		$this->server = $server;
107
-		$this->server->on('propFind', array($this, 'handleGetProperties'));
108
-	}
109
-
110
-	/**
111
-	 * Return a list of share types for outgoing shares
112
-	 *
113
-	 * @param \OCP\Files\Node $node file node
114
-	 *
115
-	 * @return int[] array of share types
116
-	 */
117
-	private function getShareTypes(\OCP\Files\Node $node) {
118
-		$shareTypes = [];
119
-		$requestedShareTypes = [
120
-			\OCP\Share::SHARE_TYPE_USER,
121
-			\OCP\Share::SHARE_TYPE_GROUP,
122
-			\OCP\Share::SHARE_TYPE_LINK,
123
-			\OCP\Share::SHARE_TYPE_REMOTE,
124
-			\OCP\Share::SHARE_TYPE_EMAIL,
125
-		];
126
-		foreach ($requestedShareTypes as $requestedShareType) {
127
-			// one of each type is enough to find out about the types
128
-			$shares = $this->shareManager->getSharesBy(
129
-				$this->userId,
130
-				$requestedShareType,
131
-				$node,
132
-				false,
133
-				1
134
-			);
135
-			if (!empty($shares)) {
136
-				$shareTypes[] = $requestedShareType;
137
-			}
138
-		}
139
-		return $shareTypes;
140
-	}
141
-
142
-	private function getSharesTypesInFolder(\OCP\Files\Folder $node) {
143
-		$shares = $this->shareManager->getSharesInFolder(
144
-			$this->userId,
145
-			$node,
146
-			true
147
-		);
148
-
149
-		$shareTypesByFileId = [];
150
-
151
-		foreach($shares as $fileId => $sharesForFile) {
152
-			$types = array_map(function(IShare $share) {
153
-				return $share->getShareType();
154
-			}, $sharesForFile);
155
-			$types = array_unique($types);
156
-			sort($types);
157
-			$shareTypesByFileId[$fileId] = $types;
158
-		}
159
-
160
-		return $shareTypesByFileId;
161
-	}
162
-
163
-	/**
164
-	 * Adds shares to propfind response
165
-	 *
166
-	 * @param PropFind $propFind propfind object
167
-	 * @param \Sabre\DAV\INode $sabreNode sabre node
168
-	 */
169
-	public function handleGetProperties(
170
-		PropFind $propFind,
171
-		\Sabre\DAV\INode $sabreNode
172
-	) {
173
-		if (!($sabreNode instanceof \OCA\DAV\Connector\Sabre\Node)) {
174
-			return;
175
-		}
176
-
177
-		// need prefetch ?
178
-		if ($sabreNode instanceof \OCA\DAV\Connector\Sabre\Directory
179
-			&& $propFind->getDepth() !== 0
180
-			&& !is_null($propFind->getStatus(self::SHARETYPES_PROPERTYNAME))
181
-		) {
182
-			$folderNode = $this->userFolder->get($sabreNode->getPath());
183
-
184
-			$childShares = $this->getSharesTypesInFolder($folderNode);
185
-			$this->cachedFolders[] = $sabreNode->getPath();
186
-			$this->cachedShareTypes[$folderNode->getId()] = $this->getShareTypes($folderNode);
187
-			foreach ($childShares as $id => $shares) {
188
-				$this->cachedShareTypes[$id] = $shares;
189
-			}
190
-		}
191
-
192
-		$propFind->handle(self::SHARETYPES_PROPERTYNAME, function () use ($sabreNode) {
193
-			if (isset($this->cachedShareTypes[$sabreNode->getId()])) {
194
-				$shareTypes = $this->cachedShareTypes[$sabreNode->getId()];
195
-			} else {
196
-				list($parentPath,) = \Sabre\Uri\split($sabreNode->getPath());
197
-				if ($parentPath === '') {
198
-					$parentPath = '/';
199
-				}
200
-				// if we already cached the folder this file is in we know there are no shares for this file
201
-				if (array_search($parentPath, $this->cachedFolders) === false) {
202
-					$node = $this->userFolder->get($sabreNode->getPath());
203
-					$shareTypes = $this->getShareTypes($node);
204
-				} else {
205
-					return [];
206
-				}
207
-			}
208
-
209
-			return new ShareTypeList($shareTypes);
210
-		});
211
-	}
35
+    const NS_OWNCLOUD = 'http://owncloud.org/ns';
36
+    const SHARETYPES_PROPERTYNAME = '{http://owncloud.org/ns}share-types';
37
+
38
+    /**
39
+     * Reference to main server object
40
+     *
41
+     * @var \Sabre\DAV\Server
42
+     */
43
+    private $server;
44
+
45
+    /**
46
+     * @var \OCP\Share\IManager
47
+     */
48
+    private $shareManager;
49
+
50
+    /**
51
+     * @var \Sabre\DAV\Tree
52
+     */
53
+    private $tree;
54
+
55
+    /**
56
+     * @var string
57
+     */
58
+    private $userId;
59
+
60
+    /**
61
+     * @var \OCP\Files\Folder
62
+     */
63
+    private $userFolder;
64
+
65
+    /**
66
+     * @var IShare[]
67
+     */
68
+    private $cachedShareTypes;
69
+
70
+    private $cachedFolders = [];
71
+
72
+    /**
73
+     * @param \Sabre\DAV\Tree $tree tree
74
+     * @param IUserSession $userSession user session
75
+     * @param \OCP\Files\Folder $userFolder user home folder
76
+     * @param \OCP\Share\IManager $shareManager share manager
77
+     */
78
+    public function __construct(
79
+        \Sabre\DAV\Tree $tree,
80
+        IUserSession $userSession,
81
+        \OCP\Files\Folder $userFolder,
82
+        \OCP\Share\IManager $shareManager
83
+    ) {
84
+        $this->tree = $tree;
85
+        $this->shareManager = $shareManager;
86
+        $this->userFolder = $userFolder;
87
+        $this->userId = $userSession->getUser()->getUID();
88
+        $this->cachedShareTypes = [];
89
+    }
90
+
91
+    /**
92
+     * This initializes the plugin.
93
+     *
94
+     * This function is called by \Sabre\DAV\Server, after
95
+     * addPlugin is called.
96
+     *
97
+     * This method should set up the required event subscriptions.
98
+     *
99
+     * @param \Sabre\DAV\Server $server
100
+     */
101
+    public function initialize(\Sabre\DAV\Server $server) {
102
+        $server->xml->namespacesMap[self::NS_OWNCLOUD] = 'oc';
103
+        $server->xml->elementMap[self::SHARETYPES_PROPERTYNAME] = 'OCA\\DAV\\Connector\\Sabre\\ShareTypeList';
104
+        $server->protectedProperties[] = self::SHARETYPES_PROPERTYNAME;
105
+
106
+        $this->server = $server;
107
+        $this->server->on('propFind', array($this, 'handleGetProperties'));
108
+    }
109
+
110
+    /**
111
+     * Return a list of share types for outgoing shares
112
+     *
113
+     * @param \OCP\Files\Node $node file node
114
+     *
115
+     * @return int[] array of share types
116
+     */
117
+    private function getShareTypes(\OCP\Files\Node $node) {
118
+        $shareTypes = [];
119
+        $requestedShareTypes = [
120
+            \OCP\Share::SHARE_TYPE_USER,
121
+            \OCP\Share::SHARE_TYPE_GROUP,
122
+            \OCP\Share::SHARE_TYPE_LINK,
123
+            \OCP\Share::SHARE_TYPE_REMOTE,
124
+            \OCP\Share::SHARE_TYPE_EMAIL,
125
+        ];
126
+        foreach ($requestedShareTypes as $requestedShareType) {
127
+            // one of each type is enough to find out about the types
128
+            $shares = $this->shareManager->getSharesBy(
129
+                $this->userId,
130
+                $requestedShareType,
131
+                $node,
132
+                false,
133
+                1
134
+            );
135
+            if (!empty($shares)) {
136
+                $shareTypes[] = $requestedShareType;
137
+            }
138
+        }
139
+        return $shareTypes;
140
+    }
141
+
142
+    private function getSharesTypesInFolder(\OCP\Files\Folder $node) {
143
+        $shares = $this->shareManager->getSharesInFolder(
144
+            $this->userId,
145
+            $node,
146
+            true
147
+        );
148
+
149
+        $shareTypesByFileId = [];
150
+
151
+        foreach($shares as $fileId => $sharesForFile) {
152
+            $types = array_map(function(IShare $share) {
153
+                return $share->getShareType();
154
+            }, $sharesForFile);
155
+            $types = array_unique($types);
156
+            sort($types);
157
+            $shareTypesByFileId[$fileId] = $types;
158
+        }
159
+
160
+        return $shareTypesByFileId;
161
+    }
162
+
163
+    /**
164
+     * Adds shares to propfind response
165
+     *
166
+     * @param PropFind $propFind propfind object
167
+     * @param \Sabre\DAV\INode $sabreNode sabre node
168
+     */
169
+    public function handleGetProperties(
170
+        PropFind $propFind,
171
+        \Sabre\DAV\INode $sabreNode
172
+    ) {
173
+        if (!($sabreNode instanceof \OCA\DAV\Connector\Sabre\Node)) {
174
+            return;
175
+        }
176
+
177
+        // need prefetch ?
178
+        if ($sabreNode instanceof \OCA\DAV\Connector\Sabre\Directory
179
+            && $propFind->getDepth() !== 0
180
+            && !is_null($propFind->getStatus(self::SHARETYPES_PROPERTYNAME))
181
+        ) {
182
+            $folderNode = $this->userFolder->get($sabreNode->getPath());
183
+
184
+            $childShares = $this->getSharesTypesInFolder($folderNode);
185
+            $this->cachedFolders[] = $sabreNode->getPath();
186
+            $this->cachedShareTypes[$folderNode->getId()] = $this->getShareTypes($folderNode);
187
+            foreach ($childShares as $id => $shares) {
188
+                $this->cachedShareTypes[$id] = $shares;
189
+            }
190
+        }
191
+
192
+        $propFind->handle(self::SHARETYPES_PROPERTYNAME, function () use ($sabreNode) {
193
+            if (isset($this->cachedShareTypes[$sabreNode->getId()])) {
194
+                $shareTypes = $this->cachedShareTypes[$sabreNode->getId()];
195
+            } else {
196
+                list($parentPath,) = \Sabre\Uri\split($sabreNode->getPath());
197
+                if ($parentPath === '') {
198
+                    $parentPath = '/';
199
+                }
200
+                // if we already cached the folder this file is in we know there are no shares for this file
201
+                if (array_search($parentPath, $this->cachedFolders) === false) {
202
+                    $node = $this->userFolder->get($sabreNode->getPath());
203
+                    $shareTypes = $this->getShareTypes($node);
204
+                } else {
205
+                    return [];
206
+                }
207
+            }
208
+
209
+            return new ShareTypeList($shareTypes);
210
+        });
211
+    }
212 212
 }
Please login to merge, or discard this patch.
apps/dav/lib/Connector/LegacyDAVACL.php 3 patches
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -32,42 +32,42 @@
 block discarded – undo
32 32
 
33 33
 class LegacyDAVACL extends DavAclPlugin {
34 34
 
35
-	/**
36
-	 * @inheritdoc
37
-	 */
38
-	public function getCurrentUserPrincipals() {
39
-		$principalV2 = $this->getCurrentUserPrincipal();
35
+    /**
36
+     * @inheritdoc
37
+     */
38
+    public function getCurrentUserPrincipals() {
39
+        $principalV2 = $this->getCurrentUserPrincipal();
40 40
 
41
-		if (is_null($principalV2)) return [];
41
+        if (is_null($principalV2)) return [];
42 42
 
43
-		$principalV1 = $this->convertPrincipal($principalV2, false);
44
-		return array_merge(
45
-			[
46
-				$principalV2,
47
-				$principalV1
48
-			],
49
-			$this->getPrincipalMembership($principalV1)
50
-		);
51
-	}
43
+        $principalV1 = $this->convertPrincipal($principalV2, false);
44
+        return array_merge(
45
+            [
46
+                $principalV2,
47
+                $principalV1
48
+            ],
49
+            $this->getPrincipalMembership($principalV1)
50
+        );
51
+    }
52 52
 
53
-	private function convertPrincipal($principal, $toV2) {
54
-		list(, $name) = URLUtil::splitPath($principal);
55
-		if ($toV2) {
56
-			return "principals/users/$name";
57
-		}
58
-		return "principals/$name";
59
-	}
53
+    private function convertPrincipal($principal, $toV2) {
54
+        list(, $name) = URLUtil::splitPath($principal);
55
+        if ($toV2) {
56
+            return "principals/users/$name";
57
+        }
58
+        return "principals/$name";
59
+    }
60 60
 
61
-	public function propFind(PropFind $propFind, INode $node) {
62
-		/* Overload current-user-principal */
63
-		$propFind->handle('{DAV:}current-user-principal', function () {
64
-			if ($url = parent::getCurrentUserPrincipal()) {
65
-				return new Principal(Principal::HREF, $url . '/');
66
-			} else {
67
-				return new Principal(Principal::UNAUTHENTICATED);
68
-			}
69
-		});
61
+    public function propFind(PropFind $propFind, INode $node) {
62
+        /* Overload current-user-principal */
63
+        $propFind->handle('{DAV:}current-user-principal', function () {
64
+            if ($url = parent::getCurrentUserPrincipal()) {
65
+                return new Principal(Principal::HREF, $url . '/');
66
+            } else {
67
+                return new Principal(Principal::UNAUTHENTICATED);
68
+            }
69
+        });
70 70
 
71
-		return parent::propFind($propFind, $node);
72
-	}
71
+        return parent::propFind($propFind, $node);
72
+    }
73 73
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -60,9 +60,9 @@
 block discarded – undo
60 60
 
61 61
 	public function propFind(PropFind $propFind, INode $node) {
62 62
 		/* Overload current-user-principal */
63
-		$propFind->handle('{DAV:}current-user-principal', function () {
63
+		$propFind->handle('{DAV:}current-user-principal', function() {
64 64
 			if ($url = parent::getCurrentUserPrincipal()) {
65
-				return new Principal(Principal::HREF, $url . '/');
65
+				return new Principal(Principal::HREF, $url.'/');
66 66
 			} else {
67 67
 				return new Principal(Principal::UNAUTHENTICATED);
68 68
 			}
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -38,7 +38,9 @@
 block discarded – undo
38 38
 	public function getCurrentUserPrincipals() {
39 39
 		$principalV2 = $this->getCurrentUserPrincipal();
40 40
 
41
-		if (is_null($principalV2)) return [];
41
+		if (is_null($principalV2)) {
42
+		    return [];
43
+		}
42 44
 
43 45
 		$principalV1 = $this->convertPrincipal($principalV2, false);
44 46
 		return array_merge(
Please login to merge, or discard this patch.
apps/dav/lib/Migration/ValueFix.php 2 patches
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -29,43 +29,43 @@
 block discarded – undo
29 29
 
30 30
 class ValueFix extends QueuedJob {
31 31
 
32
-	/** @var CalDavBackend */
33
-	private $calDavBackend;
32
+    /** @var CalDavBackend */
33
+    private $calDavBackend;
34 34
 
35
-	/** @var ILogger */
36
-	private $logger;
35
+    /** @var ILogger */
36
+    private $logger;
37 37
 
38
-	public function __construct(CalDavBackend $calDavBackend, ILogger $logger) {
39
-		$this->calDavBackend = $calDavBackend;
40
-		$this->logger = $logger;
41
-	}
38
+    public function __construct(CalDavBackend $calDavBackend, ILogger $logger) {
39
+        $this->calDavBackend = $calDavBackend;
40
+        $this->logger = $logger;
41
+    }
42 42
 
43
-	public function run($argument) {
44
-		$user = $argument['user'];
43
+    public function run($argument) {
44
+        $user = $argument['user'];
45 45
 
46
-		$pattern = '/;VALUE=:/';
47
- 		$principal = 'principals/users/' . $user;
48
-		$calendars = $this->calDavBackend->getCalendarsForUser($principal);
49
-		foreach ($calendars as $calendar) {
50
-			$objects = $this->calDavBackend->getCalendarObjects($calendar['id']);
51
-			foreach ($objects as $object) {
52
-				$calObject = $this->calDavBackend->getCalendarObject($calendar['id'], $object['uri']);
53
-				$data = preg_replace($pattern, ':', $calObject['calendardata']);
54
-				if ($data !== $calObject['calendardata']) {
55
-					try {
56
-						$this->calDavBackend->getDenormalizedData($data);
57
-					} catch (InvalidDataException $e) {
58
-						$this->logger->info('Calendar object for calendar {cal} with uri {uri} still invalid', [
59
-							'app'=> 'dav',
60
-							'cal' => $calendar['id'],
61
-							'uri' => $object['uri'],
62
-						]);
63
-						continue;
64
-					}
65
-					$this->calDavBackend->updateCalendarObject($calendar['id'], $object['uri'], $data);
66
-				}
67
-			}
68
-		}
69
-	}
46
+        $pattern = '/;VALUE=:/';
47
+            $principal = 'principals/users/' . $user;
48
+        $calendars = $this->calDavBackend->getCalendarsForUser($principal);
49
+        foreach ($calendars as $calendar) {
50
+            $objects = $this->calDavBackend->getCalendarObjects($calendar['id']);
51
+            foreach ($objects as $object) {
52
+                $calObject = $this->calDavBackend->getCalendarObject($calendar['id'], $object['uri']);
53
+                $data = preg_replace($pattern, ':', $calObject['calendardata']);
54
+                if ($data !== $calObject['calendardata']) {
55
+                    try {
56
+                        $this->calDavBackend->getDenormalizedData($data);
57
+                    } catch (InvalidDataException $e) {
58
+                        $this->logger->info('Calendar object for calendar {cal} with uri {uri} still invalid', [
59
+                            'app'=> 'dav',
60
+                            'cal' => $calendar['id'],
61
+                            'uri' => $object['uri'],
62
+                        ]);
63
+                        continue;
64
+                    }
65
+                    $this->calDavBackend->updateCalendarObject($calendar['id'], $object['uri'], $data);
66
+                }
67
+            }
68
+        }
69
+    }
70 70
 
71 71
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@
 block discarded – undo
44 44
 		$user = $argument['user'];
45 45
 
46 46
 		$pattern = '/;VALUE=:/';
47
- 		$principal = 'principals/users/' . $user;
47
+ 		$principal = 'principals/users/'.$user;
48 48
 		$calendars = $this->calDavBackend->getCalendarsForUser($principal);
49 49
 		foreach ($calendars as $calendar) {
50 50
 			$objects = $this->calDavBackend->getCalendarObjects($calendar['id']);
Please login to merge, or discard this patch.
apps/dav/lib/Migration/ValueFixInsert.php 2 patches
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -31,33 +31,33 @@
 block discarded – undo
31 31
 
32 32
 class ValueFixInsert implements IRepairStep {
33 33
 
34
-	/** @var IUserManager */
35
-	private $userManager;
36
-
37
-	/** @var IJobList */
38
-	private $jobList;
39
-
40
-	/** @var IConfig */
41
-	private $config;
42
-
43
-	public function __construct(IUserManager $userManager,
44
-								IJobList $jobList,
45
-								IConfig $config) {
46
-		$this->userManager = $userManager;
47
-		$this->jobList = $jobList;
48
-		$this->config = $config;
49
-	}
50
-
51
-	public function getName() {
52
-		return 'Insert ValueFix background job for each user';
53
-	}
54
-
55
-	public function run(IOutput $output) {
56
-		if ($this->config->getAppValue('dav', self::class . '_ran', 'false') !== 'true') {
57
-			$this->userManager->callForSeenUsers(function (IUser $user) {
58
-				$this->jobList->add(ValueFix::class, ['user' => $user->getUID()]);
59
-			});
60
-			$this->config->setAppValue('dav', self::class . '_ran', 'true');
61
-		}
62
-	}
34
+    /** @var IUserManager */
35
+    private $userManager;
36
+
37
+    /** @var IJobList */
38
+    private $jobList;
39
+
40
+    /** @var IConfig */
41
+    private $config;
42
+
43
+    public function __construct(IUserManager $userManager,
44
+                                IJobList $jobList,
45
+                                IConfig $config) {
46
+        $this->userManager = $userManager;
47
+        $this->jobList = $jobList;
48
+        $this->config = $config;
49
+    }
50
+
51
+    public function getName() {
52
+        return 'Insert ValueFix background job for each user';
53
+    }
54
+
55
+    public function run(IOutput $output) {
56
+        if ($this->config->getAppValue('dav', self::class . '_ran', 'false') !== 'true') {
57
+            $this->userManager->callForSeenUsers(function (IUser $user) {
58
+                $this->jobList->add(ValueFix::class, ['user' => $user->getUID()]);
59
+            });
60
+            $this->config->setAppValue('dav', self::class . '_ran', 'true');
61
+        }
62
+    }
63 63
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -53,11 +53,11 @@
 block discarded – undo
53 53
 	}
54 54
 
55 55
 	public function run(IOutput $output) {
56
-		if ($this->config->getAppValue('dav', self::class . '_ran', 'false') !== 'true') {
57
-			$this->userManager->callForSeenUsers(function (IUser $user) {
56
+		if ($this->config->getAppValue('dav', self::class.'_ran', 'false') !== 'true') {
57
+			$this->userManager->callForSeenUsers(function(IUser $user) {
58 58
 				$this->jobList->add(ValueFix::class, ['user' => $user->getUID()]);
59 59
 			});
60
-			$this->config->setAppValue('dav', self::class . '_ran', 'true');
60
+			$this->config->setAppValue('dav', self::class.'_ran', 'true');
61 61
 		}
62 62
 	}
63 63
 }
Please login to merge, or discard this patch.
apps/dav/lib/Migration/FixBirthdayCalendarComponent.php 1 patch
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -28,35 +28,35 @@
 block discarded – undo
28 28
 
29 29
 class FixBirthdayCalendarComponent implements IRepairStep {
30 30
 
31
-	/** @var IDBConnection */
32
-	private $connection;
33
-
34
-	/**
35
-	 * FixBirthdayCalendarComponent constructor.
36
-	 *
37
-	 * @param IDBConnection $connection
38
-	 */
39
-	public function __construct(IDBConnection $connection) {
40
-		$this->connection = $connection;
41
-	}
42
-
43
-	/**
44
-	 * @inheritdoc
45
-	 */
46
-	public function getName() {
47
-		return 'Fix component of birthday calendars';
48
-	}
49
-
50
-	/**
51
-	 * @inheritdoc
52
-	 */
53
-	public function run(IOutput $output) {
54
-		$query = $this->connection->getQueryBuilder();
55
-		$updated = $query->update('calendars')
56
-			->set('components', $query->createNamedParameter('VEVENT'))
57
-			->where($query->expr()->eq('uri', $query->createNamedParameter(BirthdayService::BIRTHDAY_CALENDAR_URI)))
58
-			->execute();
59
-
60
-		$output->info("$updated birthday calendars updated.");
61
-	}
31
+    /** @var IDBConnection */
32
+    private $connection;
33
+
34
+    /**
35
+     * FixBirthdayCalendarComponent constructor.
36
+     *
37
+     * @param IDBConnection $connection
38
+     */
39
+    public function __construct(IDBConnection $connection) {
40
+        $this->connection = $connection;
41
+    }
42
+
43
+    /**
44
+     * @inheritdoc
45
+     */
46
+    public function getName() {
47
+        return 'Fix component of birthday calendars';
48
+    }
49
+
50
+    /**
51
+     * @inheritdoc
52
+     */
53
+    public function run(IOutput $output) {
54
+        $query = $this->connection->getQueryBuilder();
55
+        $updated = $query->update('calendars')
56
+            ->set('components', $query->createNamedParameter('VEVENT'))
57
+            ->where($query->expr()->eq('uri', $query->createNamedParameter(BirthdayService::BIRTHDAY_CALENDAR_URI)))
58
+            ->execute();
59
+
60
+        $output->info("$updated birthday calendars updated.");
61
+    }
62 62
 }
Please login to merge, or discard this patch.
apps/dav/lib/Command/SyncBirthdayCalendar.php 1 patch
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -33,55 +33,55 @@
 block discarded – undo
33 33
 
34 34
 class SyncBirthdayCalendar extends Command {
35 35
 
36
-	/** @var BirthdayService */
37
-	private $birthdayService;
36
+    /** @var BirthdayService */
37
+    private $birthdayService;
38 38
 
39
-	/** @var IUserManager */
40
-	private $userManager;
39
+    /** @var IUserManager */
40
+    private $userManager;
41 41
 
42
-	/**
43
-	 * @param IUserManager $userManager
44
-	 * @param BirthdayService $birthdayService
45
-	 */
46
-	function __construct(IUserManager $userManager, BirthdayService $birthdayService) {
47
-		parent::__construct();
48
-		$this->birthdayService = $birthdayService;
49
-		$this->userManager = $userManager;
50
-	}
42
+    /**
43
+     * @param IUserManager $userManager
44
+     * @param BirthdayService $birthdayService
45
+     */
46
+    function __construct(IUserManager $userManager, BirthdayService $birthdayService) {
47
+        parent::__construct();
48
+        $this->birthdayService = $birthdayService;
49
+        $this->userManager = $userManager;
50
+    }
51 51
 
52
-	protected function configure() {
53
-		$this
54
-			->setName('dav:sync-birthday-calendar')
55
-			->setDescription('Synchronizes the birthday calendar')
56
-			->addArgument('user',
57
-				InputArgument::OPTIONAL,
58
-				'User for whom the birthday calendar will be synchronized');
59
-	}
52
+    protected function configure() {
53
+        $this
54
+            ->setName('dav:sync-birthday-calendar')
55
+            ->setDescription('Synchronizes the birthday calendar')
56
+            ->addArgument('user',
57
+                InputArgument::OPTIONAL,
58
+                'User for whom the birthday calendar will be synchronized');
59
+    }
60 60
 
61
-	/**
62
-	 * @param InputInterface $input
63
-	 * @param OutputInterface $output
64
-	 */
65
-	protected function execute(InputInterface $input, OutputInterface $output) {
66
-		$user = $input->getArgument('user');
67
-		if (!is_null($user)) {
68
-			if (!$this->userManager->userExists($user)) {
69
-				throw new \InvalidArgumentException("User <$user> in unknown.");
70
-			}
71
-			$output->writeln("Start birthday calendar sync for $user");
72
-			$this->birthdayService->syncUser($user);
73
-			return;
74
-		}
75
-		$output->writeln("Start birthday calendar sync for all users ...");
76
-		$p = new ProgressBar($output);
77
-		$p->start();
78
-		$this->userManager->callForAllUsers(function($user) use ($p)  {
79
-			$p->advance();
80
-			/** @var IUser $user */
81
-			$this->birthdayService->syncUser($user->getUID());
82
-		});
61
+    /**
62
+     * @param InputInterface $input
63
+     * @param OutputInterface $output
64
+     */
65
+    protected function execute(InputInterface $input, OutputInterface $output) {
66
+        $user = $input->getArgument('user');
67
+        if (!is_null($user)) {
68
+            if (!$this->userManager->userExists($user)) {
69
+                throw new \InvalidArgumentException("User <$user> in unknown.");
70
+            }
71
+            $output->writeln("Start birthday calendar sync for $user");
72
+            $this->birthdayService->syncUser($user);
73
+            return;
74
+        }
75
+        $output->writeln("Start birthday calendar sync for all users ...");
76
+        $p = new ProgressBar($output);
77
+        $p->start();
78
+        $this->userManager->callForAllUsers(function($user) use ($p)  {
79
+            $p->advance();
80
+            /** @var IUser $user */
81
+            $this->birthdayService->syncUser($user->getUID());
82
+        });
83 83
 
84
-		$p->finish();
85
-		$output->writeln('');
86
-	}
84
+        $p->finish();
85
+        $output->writeln('');
86
+    }
87 87
 }
Please login to merge, or discard this patch.
apps/dav/lib/Command/CreateCalendar.php 1 patch
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -33,53 +33,53 @@
 block discarded – undo
33 33
 
34 34
 class CreateCalendar extends Command {
35 35
 
36
-	/** @var IUserManager */
37
-	protected $userManager;
36
+    /** @var IUserManager */
37
+    protected $userManager;
38 38
 
39
-	/** @var IGroupManager $groupManager */
40
-	private $groupManager;
39
+    /** @var IGroupManager $groupManager */
40
+    private $groupManager;
41 41
 
42
-	/** @var \OCP\IDBConnection */
43
-	protected $dbConnection;
42
+    /** @var \OCP\IDBConnection */
43
+    protected $dbConnection;
44 44
 
45
-	/**
46
-	 * @param IUserManager $userManager
47
-	 * @param IGroupManager $groupManager
48
-	 * @param IDBConnection $dbConnection
49
-	 */
50
-	function __construct(IUserManager $userManager, IGroupManager $groupManager, IDBConnection $dbConnection) {
51
-		parent::__construct();
52
-		$this->userManager = $userManager;
53
-		$this->groupManager = $groupManager;
54
-		$this->dbConnection = $dbConnection;
55
-	}
45
+    /**
46
+     * @param IUserManager $userManager
47
+     * @param IGroupManager $groupManager
48
+     * @param IDBConnection $dbConnection
49
+     */
50
+    function __construct(IUserManager $userManager, IGroupManager $groupManager, IDBConnection $dbConnection) {
51
+        parent::__construct();
52
+        $this->userManager = $userManager;
53
+        $this->groupManager = $groupManager;
54
+        $this->dbConnection = $dbConnection;
55
+    }
56 56
 
57
-	protected function configure() {
58
-		$this
59
-			->setName('dav:create-calendar')
60
-			->setDescription('Create a dav calendar')
61
-			->addArgument('user',
62
-				InputArgument::REQUIRED,
63
-				'User for whom the calendar will be created')
64
-			->addArgument('name',
65
-				InputArgument::REQUIRED,
66
-				'Name of the calendar');
67
-	}
57
+    protected function configure() {
58
+        $this
59
+            ->setName('dav:create-calendar')
60
+            ->setDescription('Create a dav calendar')
61
+            ->addArgument('user',
62
+                InputArgument::REQUIRED,
63
+                'User for whom the calendar will be created')
64
+            ->addArgument('name',
65
+                InputArgument::REQUIRED,
66
+                'Name of the calendar');
67
+    }
68 68
 
69
-	protected function execute(InputInterface $input, OutputInterface $output) {
70
-		$user = $input->getArgument('user');
71
-		if (!$this->userManager->userExists($user)) {
72
-			throw new \InvalidArgumentException("User <$user> in unknown.");
73
-		}
74
-		$principalBackend = new Principal(
75
-			$this->userManager,
76
-			$this->groupManager
77
-		);
78
-		$random = \OC::$server->getSecureRandom();
79
-		$dispatcher = \OC::$server->getEventDispatcher();
69
+    protected function execute(InputInterface $input, OutputInterface $output) {
70
+        $user = $input->getArgument('user');
71
+        if (!$this->userManager->userExists($user)) {
72
+            throw new \InvalidArgumentException("User <$user> in unknown.");
73
+        }
74
+        $principalBackend = new Principal(
75
+            $this->userManager,
76
+            $this->groupManager
77
+        );
78
+        $random = \OC::$server->getSecureRandom();
79
+        $dispatcher = \OC::$server->getEventDispatcher();
80 80
 
81
-		$name = $input->getArgument('name');
82
-		$caldav = new CalDavBackend($this->dbConnection, $principalBackend, $this->userManager, $random, $dispatcher);
83
-		$caldav->createCalendar("principals/users/$user", $name, []);
84
-	}
81
+        $name = $input->getArgument('name');
82
+        $caldav = new CalDavBackend($this->dbConnection, $principalBackend, $this->userManager, $random, $dispatcher);
83
+        $caldav->createCalendar("principals/users/$user", $name, []);
84
+    }
85 85
 }
Please login to merge, or discard this patch.
apps/dav/lib/Capabilities.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -26,11 +26,11 @@
 block discarded – undo
26 26
 
27 27
 class Capabilities implements ICapability {
28 28
 
29
-	public function getCapabilities() {
30
-		return [
31
-			'dav' => [
32
-				'chunking' => '1.0',
33
-			]
34
-		];
35
-	}
29
+    public function getCapabilities() {
30
+        return [
31
+            'dav' => [
32
+                'chunking' => '1.0',
33
+            ]
34
+        ];
35
+    }
36 36
 }
Please login to merge, or discard this patch.
apps/dav/lib/RootCollection.php 1 patch
Indentation   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -37,86 +37,86 @@
 block discarded – undo
37 37
 
38 38
 class RootCollection extends SimpleCollection {
39 39
 
40
-	public function __construct() {
41
-		$config = \OC::$server->getConfig();
42
-		$random = \OC::$server->getSecureRandom();
43
-		$userManager = \OC::$server->getUserManager();
44
-		$db = \OC::$server->getDatabaseConnection();
45
-		$dispatcher = \OC::$server->getEventDispatcher();
46
-		$userPrincipalBackend = new Principal(
47
-			$userManager,
48
-			\OC::$server->getGroupManager()
49
-		);
50
-		$groupPrincipalBackend = new GroupPrincipalBackend(
51
-			\OC::$server->getGroupManager()
52
-		);
53
-		// as soon as debug mode is enabled we allow listing of principals
54
-		$disableListing = !$config->getSystemValue('debug', false);
40
+    public function __construct() {
41
+        $config = \OC::$server->getConfig();
42
+        $random = \OC::$server->getSecureRandom();
43
+        $userManager = \OC::$server->getUserManager();
44
+        $db = \OC::$server->getDatabaseConnection();
45
+        $dispatcher = \OC::$server->getEventDispatcher();
46
+        $userPrincipalBackend = new Principal(
47
+            $userManager,
48
+            \OC::$server->getGroupManager()
49
+        );
50
+        $groupPrincipalBackend = new GroupPrincipalBackend(
51
+            \OC::$server->getGroupManager()
52
+        );
53
+        // as soon as debug mode is enabled we allow listing of principals
54
+        $disableListing = !$config->getSystemValue('debug', false);
55 55
 
56
-		// setup the first level of the dav tree
57
-		$userPrincipals = new Collection($userPrincipalBackend, 'principals/users');
58
-		$userPrincipals->disableListing = $disableListing;
59
-		$groupPrincipals = new Collection($groupPrincipalBackend, 'principals/groups');
60
-		$groupPrincipals->disableListing = $disableListing;
61
-		$systemPrincipals = new Collection(new SystemPrincipalBackend(), 'principals/system');
62
-		$systemPrincipals->disableListing = $disableListing;
63
-		$filesCollection = new Files\RootCollection($userPrincipalBackend, 'principals/users');
64
-		$filesCollection->disableListing = $disableListing;
65
-		$caldavBackend = new CalDavBackend($db, $userPrincipalBackend, $userManager, $random, $dispatcher);
66
-		$calendarRoot = new CalendarRoot($userPrincipalBackend, $caldavBackend, 'principals/users');
67
-		$calendarRoot->disableListing = $disableListing;
68
-		$publicCalendarRoot = new PublicCalendarRoot($caldavBackend);
69
-		$publicCalendarRoot->disableListing = $disableListing;
56
+        // setup the first level of the dav tree
57
+        $userPrincipals = new Collection($userPrincipalBackend, 'principals/users');
58
+        $userPrincipals->disableListing = $disableListing;
59
+        $groupPrincipals = new Collection($groupPrincipalBackend, 'principals/groups');
60
+        $groupPrincipals->disableListing = $disableListing;
61
+        $systemPrincipals = new Collection(new SystemPrincipalBackend(), 'principals/system');
62
+        $systemPrincipals->disableListing = $disableListing;
63
+        $filesCollection = new Files\RootCollection($userPrincipalBackend, 'principals/users');
64
+        $filesCollection->disableListing = $disableListing;
65
+        $caldavBackend = new CalDavBackend($db, $userPrincipalBackend, $userManager, $random, $dispatcher);
66
+        $calendarRoot = new CalendarRoot($userPrincipalBackend, $caldavBackend, 'principals/users');
67
+        $calendarRoot->disableListing = $disableListing;
68
+        $publicCalendarRoot = new PublicCalendarRoot($caldavBackend);
69
+        $publicCalendarRoot->disableListing = $disableListing;
70 70
 
71
-		$systemTagCollection = new SystemTag\SystemTagsByIdCollection(
72
-			\OC::$server->getSystemTagManager(),
73
-			\OC::$server->getUserSession(),
74
-			\OC::$server->getGroupManager()
75
-		);
76
-		$systemTagRelationsCollection = new SystemTag\SystemTagsRelationsCollection(
77
-			\OC::$server->getSystemTagManager(),
78
-			\OC::$server->getSystemTagObjectMapper(),
79
-			\OC::$server->getUserSession(),
80
-			\OC::$server->getGroupManager(),
81
-			\OC::$server->getEventDispatcher()
82
-		);
83
-		$commentsCollection = new Comments\RootCollection(
84
-			\OC::$server->getCommentsManager(),
85
-			\OC::$server->getUserManager(),
86
-			\OC::$server->getUserSession(),
87
-			\OC::$server->getEventDispatcher(),
88
-			\OC::$server->getLogger()
89
-		);
71
+        $systemTagCollection = new SystemTag\SystemTagsByIdCollection(
72
+            \OC::$server->getSystemTagManager(),
73
+            \OC::$server->getUserSession(),
74
+            \OC::$server->getGroupManager()
75
+        );
76
+        $systemTagRelationsCollection = new SystemTag\SystemTagsRelationsCollection(
77
+            \OC::$server->getSystemTagManager(),
78
+            \OC::$server->getSystemTagObjectMapper(),
79
+            \OC::$server->getUserSession(),
80
+            \OC::$server->getGroupManager(),
81
+            \OC::$server->getEventDispatcher()
82
+        );
83
+        $commentsCollection = new Comments\RootCollection(
84
+            \OC::$server->getCommentsManager(),
85
+            \OC::$server->getUserManager(),
86
+            \OC::$server->getUserSession(),
87
+            \OC::$server->getEventDispatcher(),
88
+            \OC::$server->getLogger()
89
+        );
90 90
 
91
-		$usersCardDavBackend = new CardDavBackend($db, $userPrincipalBackend, \OC::$server->getUserManager(), $dispatcher);
92
-		$usersAddressBookRoot = new AddressBookRoot($userPrincipalBackend, $usersCardDavBackend, 'principals/users');
93
-		$usersAddressBookRoot->disableListing = $disableListing;
91
+        $usersCardDavBackend = new CardDavBackend($db, $userPrincipalBackend, \OC::$server->getUserManager(), $dispatcher);
92
+        $usersAddressBookRoot = new AddressBookRoot($userPrincipalBackend, $usersCardDavBackend, 'principals/users');
93
+        $usersAddressBookRoot->disableListing = $disableListing;
94 94
 
95
-		$systemCardDavBackend = new CardDavBackend($db, $userPrincipalBackend, \OC::$server->getUserManager(), $dispatcher);
96
-		$systemAddressBookRoot = new AddressBookRoot(new SystemPrincipalBackend(), $systemCardDavBackend, 'principals/system');
97
-		$systemAddressBookRoot->disableListing = $disableListing;
95
+        $systemCardDavBackend = new CardDavBackend($db, $userPrincipalBackend, \OC::$server->getUserManager(), $dispatcher);
96
+        $systemAddressBookRoot = new AddressBookRoot(new SystemPrincipalBackend(), $systemCardDavBackend, 'principals/system');
97
+        $systemAddressBookRoot->disableListing = $disableListing;
98 98
 
99
-		$uploadCollection = new Upload\RootCollection($userPrincipalBackend, 'principals/users');
100
-		$uploadCollection->disableListing = $disableListing;
99
+        $uploadCollection = new Upload\RootCollection($userPrincipalBackend, 'principals/users');
100
+        $uploadCollection->disableListing = $disableListing;
101 101
 
102
-		$children = [
103
-				new SimpleCollection('principals', [
104
-						$userPrincipals,
105
-						$groupPrincipals,
106
-						$systemPrincipals]),
107
-				$filesCollection,
108
-				$calendarRoot,
109
-				$publicCalendarRoot,
110
-				new SimpleCollection('addressbooks', [
111
-						$usersAddressBookRoot,
112
-						$systemAddressBookRoot]),
113
-				$systemTagCollection,
114
-				$systemTagRelationsCollection,
115
-				$commentsCollection,
116
-				$uploadCollection,
117
-		];
102
+        $children = [
103
+                new SimpleCollection('principals', [
104
+                        $userPrincipals,
105
+                        $groupPrincipals,
106
+                        $systemPrincipals]),
107
+                $filesCollection,
108
+                $calendarRoot,
109
+                $publicCalendarRoot,
110
+                new SimpleCollection('addressbooks', [
111
+                        $usersAddressBookRoot,
112
+                        $systemAddressBookRoot]),
113
+                $systemTagCollection,
114
+                $systemTagRelationsCollection,
115
+                $commentsCollection,
116
+                $uploadCollection,
117
+        ];
118 118
 
119
-		parent::__construct('root', $children);
120
-	}
119
+        parent::__construct('root', $children);
120
+    }
121 121
 
122 122
 }
Please login to merge, or discard this patch.