Passed
Push — master ( 645109...008e6d )
by Christoph
12:14 queued 12s
created
apps/files_trashbin/appinfo/app.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@
 block discarded – undo
28 28
 // register hooks
29 29
 \OCA\Files_Trashbin\Trashbin::registerHooks();
30 30
 
31
-\OCA\Files\App::getNavigationManager()->add(function () {
31
+\OCA\Files\App::getNavigationManager()->add(function() {
32 32
 	$l = \OC::$server->getL10N('files_trashbin');
33 33
 	return [
34 34
 		'id' => 'trashbin',
Please login to merge, or discard this patch.
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -29,13 +29,13 @@
 block discarded – undo
29 29
 \OCA\Files_Trashbin\Trashbin::registerHooks();
30 30
 
31 31
 \OCA\Files\App::getNavigationManager()->add(function () {
32
-	$l = \OC::$server->getL10N('files_trashbin');
33
-	return [
34
-		'id' => 'trashbin',
35
-		'appname' => 'files_trashbin',
36
-		'script' => 'list.php',
37
-		'order' => 50,
38
-		'name' => $l->t('Deleted files'),
39
-		'classes' => 'pinned',
40
-	];
32
+    $l = \OC::$server->getL10N('files_trashbin');
33
+    return [
34
+        'id' => 'trashbin',
35
+        'appname' => 'files_trashbin',
36
+        'script' => 'list.php',
37
+        'order' => 50,
38
+        'name' => $l->t('Deleted files'),
39
+        'classes' => 'pinned',
40
+    ];
41 41
 });
Please login to merge, or discard this patch.
apps/dav/lib/CardDAV/Converter.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -119,9 +119,9 @@
 block discarded – undo
119 119
 		$elements = explode(' ', $fullName);
120 120
 		$result = ['', '', '', '', ''];
121 121
 		if (count($elements) > 2) {
122
-			$result[0] = implode(' ', array_slice($elements, count($elements)-1));
122
+			$result[0] = implode(' ', array_slice($elements, count($elements) - 1));
123 123
 			$result[1] = $elements[0];
124
-			$result[2] = implode(' ', array_slice($elements, 1, count($elements)-2));
124
+			$result[2] = implode(' ', array_slice($elements, 1, count($elements) - 2));
125 125
 		} elseif (count($elements) === 2) {
126 126
 			$result[0] = $elements[1];
127 127
 			$result[1] = $elements[0];
Please login to merge, or discard this patch.
Indentation   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -31,122 +31,122 @@
 block discarded – undo
31 31
 
32 32
 class Converter {
33 33
 
34
-	/** @var AccountManager */
35
-	private $accountManager;
36
-
37
-	/**
38
-	 * Converter constructor.
39
-	 *
40
-	 * @param AccountManager $accountManager
41
-	 */
42
-	public function __construct(AccountManager $accountManager) {
43
-		$this->accountManager = $accountManager;
44
-	}
45
-
46
-	/**
47
-	 * @param IUser $user
48
-	 * @return VCard|null
49
-	 */
50
-	public function createCardFromUser(IUser $user) {
51
-
52
-		$userData = $this->accountManager->getUser($user);
53
-
54
-		$uid = $user->getUID();
55
-		$cloudId = $user->getCloudId();
56
-		$image = $this->getAvatarImage($user);
57
-
58
-		$vCard = new VCard();
59
-		$vCard->VERSION = '3.0';
60
-		$vCard->UID = $uid;
61
-
62
-		$publish = false;
63
-
64
-		if ($image !== null && isset($userData[AccountManager::PROPERTY_AVATAR])) {
65
-			$userData[AccountManager::PROPERTY_AVATAR]['value'] = true;
66
-		}
67
-
68
-		foreach ($userData as $property => $value) {
69
-
70
-			$shareWithTrustedServers =
71
-				$value['scope'] === AccountManager::VISIBILITY_CONTACTS_ONLY ||
72
-				$value['scope'] === AccountManager::VISIBILITY_PUBLIC;
73
-
74
-			$emptyValue = !isset($value['value']) || $value['value'] === '';
75
-
76
-			if ($shareWithTrustedServers && !$emptyValue) {
77
-				$publish = true;
78
-				switch ($property) {
79
-					case AccountManager::PROPERTY_DISPLAYNAME:
80
-						$vCard->add(new Text($vCard, 'FN', $value['value']));
81
-						$vCard->add(new Text($vCard, 'N', $this->splitFullName($value['value'])));
82
-						break;
83
-					case AccountManager::PROPERTY_AVATAR:
84
-						if ($image !== null) {
85
-							$vCard->add('PHOTO', $image->data(), ['ENCODING' => 'b', 'TYPE' => $image->mimeType()]);
86
-						}
87
-						break;
88
-					case AccountManager::PROPERTY_EMAIL:
89
-						$vCard->add(new Text($vCard, 'EMAIL', $value['value'], ['TYPE' => 'OTHER']));
90
-						break;
91
-					case AccountManager::PROPERTY_WEBSITE:
92
-						$vCard->add(new Text($vCard, 'URL', $value['value']));
93
-						break;
94
-					case AccountManager::PROPERTY_PHONE:
95
-						$vCard->add(new Text($vCard, 'TEL', $value['value'], ['TYPE' => 'OTHER']));
96
-						break;
97
-					case AccountManager::PROPERTY_ADDRESS:
98
-						$vCard->add(new Text($vCard, 'ADR', $value['value'], ['TYPE' => 'OTHER']));
99
-						break;
100
-					case AccountManager::PROPERTY_TWITTER:
101
-						$vCard->add(new Text($vCard, 'X-SOCIALPROFILE', $value['value'], ['TYPE' => 'TWITTER']));
102
-						break;
103
-				}
104
-			}
105
-		}
106
-
107
-		if ($publish && !empty($cloudId)) {
108
-			$vCard->add(new Text($vCard, 'CLOUD', $cloudId));
109
-			$vCard->validate();
110
-			return $vCard;
111
-		}
112
-
113
-		return null;
114
-	}
115
-
116
-	/**
117
-	 * @param string $fullName
118
-	 * @return string[]
119
-	 */
120
-	public function splitFullName($fullName) {
121
-		// Very basic western style parsing. I'm not gonna implement
122
-		// https://github.com/android/platform_packages_providers_contactsprovider/blob/master/src/com/android/providers/contacts/NameSplitter.java ;)
123
-
124
-		$elements = explode(' ', $fullName);
125
-		$result = ['', '', '', '', ''];
126
-		if (count($elements) > 2) {
127
-			$result[0] = implode(' ', array_slice($elements, count($elements)-1));
128
-			$result[1] = $elements[0];
129
-			$result[2] = implode(' ', array_slice($elements, 1, count($elements)-2));
130
-		} elseif (count($elements) === 2) {
131
-			$result[0] = $elements[1];
132
-			$result[1] = $elements[0];
133
-		} else {
134
-			$result[0] = $elements[0];
135
-		}
136
-
137
-		return $result;
138
-	}
139
-
140
-	/**
141
-	 * @param IUser $user
142
-	 * @return null|IImage
143
-	 */
144
-	private function getAvatarImage(IUser $user) {
145
-		try {
146
-			return $user->getAvatarImage(-1);
147
-		} catch (\Exception $ex) {
148
-			return null;
149
-		}
150
-	}
34
+    /** @var AccountManager */
35
+    private $accountManager;
36
+
37
+    /**
38
+     * Converter constructor.
39
+     *
40
+     * @param AccountManager $accountManager
41
+     */
42
+    public function __construct(AccountManager $accountManager) {
43
+        $this->accountManager = $accountManager;
44
+    }
45
+
46
+    /**
47
+     * @param IUser $user
48
+     * @return VCard|null
49
+     */
50
+    public function createCardFromUser(IUser $user) {
51
+
52
+        $userData = $this->accountManager->getUser($user);
53
+
54
+        $uid = $user->getUID();
55
+        $cloudId = $user->getCloudId();
56
+        $image = $this->getAvatarImage($user);
57
+
58
+        $vCard = new VCard();
59
+        $vCard->VERSION = '3.0';
60
+        $vCard->UID = $uid;
61
+
62
+        $publish = false;
63
+
64
+        if ($image !== null && isset($userData[AccountManager::PROPERTY_AVATAR])) {
65
+            $userData[AccountManager::PROPERTY_AVATAR]['value'] = true;
66
+        }
67
+
68
+        foreach ($userData as $property => $value) {
69
+
70
+            $shareWithTrustedServers =
71
+                $value['scope'] === AccountManager::VISIBILITY_CONTACTS_ONLY ||
72
+                $value['scope'] === AccountManager::VISIBILITY_PUBLIC;
73
+
74
+            $emptyValue = !isset($value['value']) || $value['value'] === '';
75
+
76
+            if ($shareWithTrustedServers && !$emptyValue) {
77
+                $publish = true;
78
+                switch ($property) {
79
+                    case AccountManager::PROPERTY_DISPLAYNAME:
80
+                        $vCard->add(new Text($vCard, 'FN', $value['value']));
81
+                        $vCard->add(new Text($vCard, 'N', $this->splitFullName($value['value'])));
82
+                        break;
83
+                    case AccountManager::PROPERTY_AVATAR:
84
+                        if ($image !== null) {
85
+                            $vCard->add('PHOTO', $image->data(), ['ENCODING' => 'b', 'TYPE' => $image->mimeType()]);
86
+                        }
87
+                        break;
88
+                    case AccountManager::PROPERTY_EMAIL:
89
+                        $vCard->add(new Text($vCard, 'EMAIL', $value['value'], ['TYPE' => 'OTHER']));
90
+                        break;
91
+                    case AccountManager::PROPERTY_WEBSITE:
92
+                        $vCard->add(new Text($vCard, 'URL', $value['value']));
93
+                        break;
94
+                    case AccountManager::PROPERTY_PHONE:
95
+                        $vCard->add(new Text($vCard, 'TEL', $value['value'], ['TYPE' => 'OTHER']));
96
+                        break;
97
+                    case AccountManager::PROPERTY_ADDRESS:
98
+                        $vCard->add(new Text($vCard, 'ADR', $value['value'], ['TYPE' => 'OTHER']));
99
+                        break;
100
+                    case AccountManager::PROPERTY_TWITTER:
101
+                        $vCard->add(new Text($vCard, 'X-SOCIALPROFILE', $value['value'], ['TYPE' => 'TWITTER']));
102
+                        break;
103
+                }
104
+            }
105
+        }
106
+
107
+        if ($publish && !empty($cloudId)) {
108
+            $vCard->add(new Text($vCard, 'CLOUD', $cloudId));
109
+            $vCard->validate();
110
+            return $vCard;
111
+        }
112
+
113
+        return null;
114
+    }
115
+
116
+    /**
117
+     * @param string $fullName
118
+     * @return string[]
119
+     */
120
+    public function splitFullName($fullName) {
121
+        // Very basic western style parsing. I'm not gonna implement
122
+        // https://github.com/android/platform_packages_providers_contactsprovider/blob/master/src/com/android/providers/contacts/NameSplitter.java ;)
123
+
124
+        $elements = explode(' ', $fullName);
125
+        $result = ['', '', '', '', ''];
126
+        if (count($elements) > 2) {
127
+            $result[0] = implode(' ', array_slice($elements, count($elements)-1));
128
+            $result[1] = $elements[0];
129
+            $result[2] = implode(' ', array_slice($elements, 1, count($elements)-2));
130
+        } elseif (count($elements) === 2) {
131
+            $result[0] = $elements[1];
132
+            $result[1] = $elements[0];
133
+        } else {
134
+            $result[0] = $elements[0];
135
+        }
136
+
137
+        return $result;
138
+    }
139
+
140
+    /**
141
+     * @param IUser $user
142
+     * @return null|IImage
143
+     */
144
+    private function getAvatarImage(IUser $user) {
145
+        try {
146
+            return $user->getAvatarImage(-1);
147
+        } catch (\Exception $ex) {
148
+            return null;
149
+        }
150
+    }
151 151
 
152 152
 }
Please login to merge, or discard this patch.
apps/dav/lib/Connector/Sabre/DummyGetResponsePlugin.php 2 patches
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -39,33 +39,33 @@
 block discarded – undo
39 39
  * @package OCA\DAV\Connector\Sabre
40 40
  */
41 41
 class DummyGetResponsePlugin extends \Sabre\DAV\ServerPlugin {
42
-	/** @var \Sabre\DAV\Server */
43
-	protected $server;
42
+    /** @var \Sabre\DAV\Server */
43
+    protected $server;
44 44
 
45
-	/**
46
-	 * @param \Sabre\DAV\Server $server
47
-	 * @return void
48
-	 */
49
-	function initialize(\Sabre\DAV\Server $server) {
50
-		$this->server = $server;
51
-		$this->server->on('method:GET', [$this, 'httpGet'], 200);
52
-	}
45
+    /**
46
+     * @param \Sabre\DAV\Server $server
47
+     * @return void
48
+     */
49
+    function initialize(\Sabre\DAV\Server $server) {
50
+        $this->server = $server;
51
+        $this->server->on('method:GET', [$this, 'httpGet'], 200);
52
+    }
53 53
 
54
-	/**
55
-	 * @param RequestInterface $request
56
-	 * @param ResponseInterface $response
57
-	 * @return false
58
-	 */
59
-	function httpGet(RequestInterface $request, ResponseInterface $response) {
60
-		$string = 'This is the WebDAV interface. It can only be accessed by ' .
61
-			'WebDAV clients such as the Nextcloud desktop sync client.';
62
-		$stream = fopen('php://memory','r+');
63
-		fwrite($stream, $string);
64
-		rewind($stream);
54
+    /**
55
+     * @param RequestInterface $request
56
+     * @param ResponseInterface $response
57
+     * @return false
58
+     */
59
+    function httpGet(RequestInterface $request, ResponseInterface $response) {
60
+        $string = 'This is the WebDAV interface. It can only be accessed by ' .
61
+            'WebDAV clients such as the Nextcloud desktop sync client.';
62
+        $stream = fopen('php://memory','r+');
63
+        fwrite($stream, $string);
64
+        rewind($stream);
65 65
 
66
-		$response->setStatus(200);
67
-		$response->setBody($stream);
66
+        $response->setStatus(200);
67
+        $response->setBody($stream);
68 68
 
69
-		return false;
70
-	}
69
+        return false;
70
+    }
71 71
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -57,9 +57,9 @@
 block discarded – undo
57 57
 	 * @return false
58 58
 	 */
59 59
 	function httpGet(RequestInterface $request, ResponseInterface $response) {
60
-		$string = 'This is the WebDAV interface. It can only be accessed by ' .
60
+		$string = 'This is the WebDAV interface. It can only be accessed by '.
61 61
 			'WebDAV clients such as the Nextcloud desktop sync client.';
62
-		$stream = fopen('php://memory','r+');
62
+		$stream = fopen('php://memory', 'r+');
63 63
 		fwrite($stream, $string);
64 64
 		rewind($stream);
65 65
 
Please login to merge, or discard this patch.
lib/private/Migration/ConsoleOutput.php 1 patch
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -37,57 +37,57 @@
 block discarded – undo
37 37
  */
38 38
 class ConsoleOutput implements IOutput {
39 39
 
40
-	/** @var OutputInterface */
41
-	private $output;
40
+    /** @var OutputInterface */
41
+    private $output;
42 42
 
43
-	/** @var ProgressBar */
44
-	private $progressBar;
43
+    /** @var ProgressBar */
44
+    private $progressBar;
45 45
 
46
-	public function __construct(OutputInterface $output) {
47
-		$this->output = $output;
48
-	}
46
+    public function __construct(OutputInterface $output) {
47
+        $this->output = $output;
48
+    }
49 49
 
50
-	/**
51
-	 * @param string $message
52
-	 */
53
-	public function info($message) {
54
-		$this->output->writeln("<info>$message</info>");
55
-	}
50
+    /**
51
+     * @param string $message
52
+     */
53
+    public function info($message) {
54
+        $this->output->writeln("<info>$message</info>");
55
+    }
56 56
 
57
-	/**
58
-	 * @param string $message
59
-	 */
60
-	public function warning($message) {
61
-		$this->output->writeln("<comment>$message</comment>");
62
-	}
57
+    /**
58
+     * @param string $message
59
+     */
60
+    public function warning($message) {
61
+        $this->output->writeln("<comment>$message</comment>");
62
+    }
63 63
 
64
-	/**
65
-	 * @param int $max
66
-	 */
67
-	public function startProgress($max = 0) {
68
-		if (!is_null($this->progressBar)) {
69
-			$this->progressBar->finish();
70
-		}
71
-		$this->progressBar = new ProgressBar($this->output);
72
-		$this->progressBar->start($max);
73
-	}
64
+    /**
65
+     * @param int $max
66
+     */
67
+    public function startProgress($max = 0) {
68
+        if (!is_null($this->progressBar)) {
69
+            $this->progressBar->finish();
70
+        }
71
+        $this->progressBar = new ProgressBar($this->output);
72
+        $this->progressBar->start($max);
73
+    }
74 74
 
75
-	/**
76
-	 * @param int $step
77
-	 * @param string $description
78
-	 */
79
-	public function advance($step = 1, $description = '') {
80
-		if (!is_null($this->progressBar)) {
81
-			$this->progressBar = new ProgressBar($this->output);
82
-			$this->progressBar->start();
83
-		}
84
-		$this->progressBar->advance($step);
85
-	}
75
+    /**
76
+     * @param int $step
77
+     * @param string $description
78
+     */
79
+    public function advance($step = 1, $description = '') {
80
+        if (!is_null($this->progressBar)) {
81
+            $this->progressBar = new ProgressBar($this->output);
82
+            $this->progressBar->start();
83
+        }
84
+        $this->progressBar->advance($step);
85
+    }
86 86
 
87
-	public function finishProgress() {
88
-		if (is_null($this->progressBar)) {
89
-			return;
90
-		}
91
-		$this->progressBar->finish();
92
-	}
87
+    public function finishProgress() {
88
+        if (is_null($this->progressBar)) {
89
+            return;
90
+        }
91
+        $this->progressBar->finish();
92
+    }
93 93
 }
Please login to merge, or discard this patch.
lib/public/Contacts/ContactsMenu/IEntry.php 1 patch
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -31,36 +31,36 @@
 block discarded – undo
31 31
  */
32 32
 interface IEntry extends JsonSerializable {
33 33
 
34
-	/**
35
-	 * @since 12.0
36
-	 * @return string
37
-	 */
38
-	public function getFullName();
34
+    /**
35
+     * @since 12.0
36
+     * @return string
37
+     */
38
+    public function getFullName();
39 39
 
40
-	/**
41
-	 * @since 12.0
42
-	 * @return string[]
43
-	 */
44
-	public function getEMailAddresses();
40
+    /**
41
+     * @since 12.0
42
+     * @return string[]
43
+     */
44
+    public function getEMailAddresses();
45 45
 
46
-	/**
47
-	 * @since 12.0
48
-	 * @return string|null image URI
49
-	 */
50
-	public function getAvatar();
46
+    /**
47
+     * @since 12.0
48
+     * @return string|null image URI
49
+     */
50
+    public function getAvatar();
51 51
 
52
-	/**
53
-	 * @since 12.0
54
-	 * @param IAction $action an action to show in the contacts menu
55
-	 */
56
-	public function addAction(IAction $action);
52
+    /**
53
+     * @since 12.0
54
+     * @param IAction $action an action to show in the contacts menu
55
+     */
56
+    public function addAction(IAction $action);
57 57
 
58
-	/**
59
-	 * Get an arbitrary property from the contact
60
-	 *
61
-	 * @since 12.0
62
-	 * @param string $key
63
-	 * @return mixed the value of the property or null
64
-	 */
65
-	public function getProperty($key);
58
+    /**
59
+     * Get an arbitrary property from the contact
60
+     *
61
+     * @since 12.0
62
+     * @param string $key
63
+     * @return mixed the value of the property or null
64
+     */
65
+    public function getProperty($key);
66 66
 }
Please login to merge, or discard this patch.
lib/private/Files/FileInfo.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 	 * @param \OCP\Files\Mount\IMountPoint $mount
88 88
 	 * @param \OCP\IUser|null $owner
89 89
 	 */
90
-	public function __construct($path, $storage, $internalPath, $data, $mount, $owner= null) {
90
+	public function __construct($path, $storage, $internalPath, $data, $mount, $owner = null) {
91 91
 		$this->path = $path;
92 92
 		$this->storage = $storage;
93 93
 		$this->internalPath = $internalPath;
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 	 * @return int|null
154 154
 	 */
155 155
 	public function getId() {
156
-		return isset($this->data['fileid']) ? (int)  $this->data['fileid'] : null;
156
+		return isset($this->data['fileid']) ? (int) $this->data['fileid'] : null;
157 157
 	}
158 158
 
159 159
 	/**
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 	public function getEtag() {
184 184
 		$this->updateEntryfromSubMounts();
185 185
 		if (count($this->childEtags) > 0) {
186
-			$combinedEtag = $this->data['etag'] . '::' . implode('::', $this->childEtags);
186
+			$combinedEtag = $this->data['etag'].'::'.implode('::', $this->childEtags);
187 187
 			return md5($combinedEtag);
188 188
 		} else {
189 189
 			return $this->data['etag'];
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
 			$relativeEntryPath = substr($entryPath, strlen($this->getPath()));
380 380
 			// attach the permissions to propagate etag on permision changes of submounts
381 381
 			$permissions = isset($data['permissions']) ? $data['permissions'] : 0;
382
-			$this->childEtags[] = $relativeEntryPath . '/' . $data['etag'] . $permissions;
382
+			$this->childEtags[] = $relativeEntryPath.'/'.$data['etag'].$permissions;
383 383
 		}
384 384
 	}
385 385
 
Please login to merge, or discard this patch.
Indentation   +376 added lines, -376 removed lines patch added patch discarded remove patch
@@ -38,380 +38,380 @@
 block discarded – undo
38 38
 use OCP\IUser;
39 39
 
40 40
 class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess {
41
-	/**
42
-	 * @var array $data
43
-	 */
44
-	private $data;
45
-
46
-	/**
47
-	 * @var string $path
48
-	 */
49
-	private $path;
50
-
51
-	/**
52
-	 * @var \OC\Files\Storage\Storage $storage
53
-	 */
54
-	private $storage;
55
-
56
-	/**
57
-	 * @var string $internalPath
58
-	 */
59
-	private $internalPath;
60
-
61
-	/**
62
-	 * @var \OCP\Files\Mount\IMountPoint
63
-	 */
64
-	private $mount;
65
-
66
-	/**
67
-	 * @var IUser
68
-	 */
69
-	private $owner;
70
-
71
-	/**
72
-	 * @var string[]
73
-	 */
74
-	private $childEtags = [];
75
-
76
-	/**
77
-	 * @var IMountPoint[]
78
-	 */
79
-	private $subMounts = [];
80
-
81
-	private $subMountsUsed = false;
82
-
83
-	/**
84
-	 * The size of the file/folder without any sub mount
85
-	 *
86
-	 * @var int
87
-	 */
88
-	private $rawSize = 0;
89
-
90
-	/**
91
-	 * @param string|boolean $path
92
-	 * @param Storage\Storage $storage
93
-	 * @param string $internalPath
94
-	 * @param array|ICacheEntry $data
95
-	 * @param \OCP\Files\Mount\IMountPoint $mount
96
-	 * @param \OCP\IUser|null $owner
97
-	 */
98
-	public function __construct($path, $storage, $internalPath, $data, $mount, $owner= null) {
99
-		$this->path = $path;
100
-		$this->storage = $storage;
101
-		$this->internalPath = $internalPath;
102
-		$this->data = $data;
103
-		$this->mount = $mount;
104
-		$this->owner = $owner;
105
-		$this->rawSize = $this->data['size'] ?? 0;
106
-	}
107
-
108
-	public function offsetSet($offset, $value) {
109
-		$this->data[$offset] = $value;
110
-	}
111
-
112
-	public function offsetExists($offset) {
113
-		return isset($this->data[$offset]);
114
-	}
115
-
116
-	public function offsetUnset($offset) {
117
-		unset($this->data[$offset]);
118
-	}
119
-
120
-	public function offsetGet($offset) {
121
-		if ($offset === 'type') {
122
-			return $this->getType();
123
-		} else if ($offset === 'etag') {
124
-			return $this->getEtag();
125
-		} else if ($offset === 'size') {
126
-			return $this->getSize();
127
-		} else if ($offset === 'mtime') {
128
-			return $this->getMTime();
129
-		} elseif ($offset === 'permissions') {
130
-			return $this->getPermissions();
131
-		} elseif (isset($this->data[$offset])) {
132
-			return $this->data[$offset];
133
-		} else {
134
-			return null;
135
-		}
136
-	}
137
-
138
-	/**
139
-	 * @return string
140
-	 */
141
-	public function getPath() {
142
-		return $this->path;
143
-	}
144
-
145
-	/**
146
-	 * @return \OCP\Files\Storage
147
-	 */
148
-	public function getStorage() {
149
-		return $this->storage;
150
-	}
151
-
152
-	/**
153
-	 * @return string
154
-	 */
155
-	public function getInternalPath() {
156
-		return $this->internalPath;
157
-	}
158
-
159
-	/**
160
-	 * Get FileInfo ID or null in case of part file
161
-	 *
162
-	 * @return int|null
163
-	 */
164
-	public function getId() {
165
-		return isset($this->data['fileid']) ? (int)  $this->data['fileid'] : null;
166
-	}
167
-
168
-	/**
169
-	 * @return string
170
-	 */
171
-	public function getMimetype() {
172
-		return $this->data['mimetype'];
173
-	}
174
-
175
-	/**
176
-	 * @return string
177
-	 */
178
-	public function getMimePart() {
179
-		return $this->data['mimepart'];
180
-	}
181
-
182
-	/**
183
-	 * @return string
184
-	 */
185
-	public function getName() {
186
-		return isset($this->data['name']) ? $this->data['name'] : basename($this->getPath());
187
-	}
188
-
189
-	/**
190
-	 * @return string
191
-	 */
192
-	public function getEtag() {
193
-		$this->updateEntryfromSubMounts();
194
-		if (count($this->childEtags) > 0) {
195
-			$combinedEtag = $this->data['etag'] . '::' . implode('::', $this->childEtags);
196
-			return md5($combinedEtag);
197
-		} else {
198
-			return $this->data['etag'];
199
-		}
200
-	}
201
-
202
-	/**
203
-	 * @return int
204
-	 */
205
-	public function getSize($includeMounts = true) {
206
-		if ($includeMounts) {
207
-			$this->updateEntryfromSubMounts();
208
-			return isset($this->data['size']) ? 0 + $this->data['size'] : 0;
209
-		} else {
210
-			return $this->rawSize;
211
-		}
212
-	}
213
-
214
-	/**
215
-	 * @return int
216
-	 */
217
-	public function getMTime() {
218
-		$this->updateEntryfromSubMounts();
219
-		return (int) $this->data['mtime'];
220
-	}
221
-
222
-	/**
223
-	 * @return bool
224
-	 */
225
-	public function isEncrypted() {
226
-		return $this->data['encrypted'];
227
-	}
228
-
229
-	/**
230
-	 * Return the currently version used for the HMAC in the encryption app
231
-	 *
232
-	 * @return int
233
-	 */
234
-	public function getEncryptedVersion() {
235
-		return isset($this->data['encryptedVersion']) ? (int) $this->data['encryptedVersion'] : 1;
236
-	}
237
-
238
-	/**
239
-	 * @return int
240
-	 */
241
-	public function getPermissions() {
242
-		$perms = (int) $this->data['permissions'];
243
-		if (\OCP\Util::isSharingDisabledForUser() || ($this->isShared() && !\OC\Share\Share::isResharingAllowed())) {
244
-			$perms = $perms & ~\OCP\Constants::PERMISSION_SHARE;
245
-		}
246
-		return (int) $perms;
247
-	}
248
-
249
-	/**
250
-	 * @return string \OCP\Files\FileInfo::TYPE_FILE|\OCP\Files\FileInfo::TYPE_FOLDER
251
-	 */
252
-	public function getType() {
253
-		if (!isset($this->data['type'])) {
254
-			$this->data['type'] = ($this->getMimetype() === 'httpd/unix-directory') ? self::TYPE_FOLDER : self::TYPE_FILE;
255
-		}
256
-		return $this->data['type'];
257
-	}
258
-
259
-	public function getData() {
260
-		return $this->data;
261
-	}
262
-
263
-	/**
264
-	 * @param int $permissions
265
-	 * @return bool
266
-	 */
267
-	protected function checkPermissions($permissions) {
268
-		return ($this->getPermissions() & $permissions) === $permissions;
269
-	}
270
-
271
-	/**
272
-	 * @return bool
273
-	 */
274
-	public function isReadable() {
275
-		return $this->checkPermissions(\OCP\Constants::PERMISSION_READ);
276
-	}
277
-
278
-	/**
279
-	 * @return bool
280
-	 */
281
-	public function isUpdateable() {
282
-		return $this->checkPermissions(\OCP\Constants::PERMISSION_UPDATE);
283
-	}
284
-
285
-	/**
286
-	 * Check whether new files or folders can be created inside this folder
287
-	 *
288
-	 * @return bool
289
-	 */
290
-	public function isCreatable() {
291
-		return $this->checkPermissions(\OCP\Constants::PERMISSION_CREATE);
292
-	}
293
-
294
-	/**
295
-	 * @return bool
296
-	 */
297
-	public function isDeletable() {
298
-		return $this->checkPermissions(\OCP\Constants::PERMISSION_DELETE);
299
-	}
300
-
301
-	/**
302
-	 * @return bool
303
-	 */
304
-	public function isShareable() {
305
-		return $this->checkPermissions(\OCP\Constants::PERMISSION_SHARE);
306
-	}
307
-
308
-	/**
309
-	 * Check if a file or folder is shared
310
-	 *
311
-	 * @return bool
312
-	 */
313
-	public function isShared() {
314
-		$sid = $this->getStorage()->getId();
315
-		if (!is_null($sid)) {
316
-			$sid = explode(':', $sid);
317
-			return ($sid[0] === 'shared');
318
-		}
319
-
320
-		return false;
321
-	}
322
-
323
-	public function isMounted() {
324
-		$storage = $this->getStorage();
325
-		if ($storage->instanceOfStorage('\OCP\Files\IHomeStorage')) {
326
-			return false;
327
-		}
328
-		$sid = $storage->getId();
329
-		if (!is_null($sid)) {
330
-			$sid = explode(':', $sid);
331
-			return ($sid[0] !== 'home' and $sid[0] !== 'shared');
332
-		}
333
-
334
-		return false;
335
-	}
336
-
337
-	/**
338
-	 * Get the mountpoint the file belongs to
339
-	 *
340
-	 * @return \OCP\Files\Mount\IMountPoint
341
-	 */
342
-	public function getMountPoint() {
343
-		return $this->mount;
344
-	}
345
-
346
-	/**
347
-	 * Get the owner of the file
348
-	 *
349
-	 * @return \OCP\IUser
350
-	 */
351
-	public function getOwner() {
352
-		return $this->owner;
353
-	}
354
-
355
-	/**
356
-	 * @param IMountPoint[] $mounts
357
-	 */
358
-	public function setSubMounts(array $mounts) {
359
-		$this->subMounts = $mounts;
360
-	}
361
-
362
-	private function updateEntryfromSubMounts() {
363
-		if ($this->subMountsUsed) {
364
-			return;
365
-		}
366
-		$this->subMountsUsed = true;
367
-		foreach ($this->subMounts as $mount) {
368
-			$subStorage = $mount->getStorage();
369
-			if ($subStorage) {
370
-				$subCache = $subStorage->getCache('');
371
-				$rootEntry = $subCache->get('');
372
-				$this->addSubEntry($rootEntry, $mount->getMountPoint());
373
-			}
374
-		}
375
-	}
376
-
377
-	/**
378
-	 * Add a cache entry which is the child of this folder
379
-	 *
380
-	 * Sets the size, etag and size to for cross-storage childs
381
-	 *
382
-	 * @param array|ICacheEntry $data cache entry for the child
383
-	 * @param string $entryPath full path of the child entry
384
-	 */
385
-	public function addSubEntry($data, $entryPath) {
386
-		$this->data['size'] += isset($data['size']) ? $data['size'] : 0;
387
-		if (isset($data['mtime'])) {
388
-			$this->data['mtime'] = max($this->data['mtime'], $data['mtime']);
389
-		}
390
-		if (isset($data['etag'])) {
391
-			// prefix the etag with the relative path of the subentry to propagate etag on mount moves
392
-			$relativeEntryPath = substr($entryPath, strlen($this->getPath()));
393
-			// attach the permissions to propagate etag on permision changes of submounts
394
-			$permissions = isset($data['permissions']) ? $data['permissions'] : 0;
395
-			$this->childEtags[] = $relativeEntryPath . '/' . $data['etag'] . $permissions;
396
-		}
397
-	}
398
-
399
-	/**
400
-	 * @inheritdoc
401
-	 */
402
-	public function getChecksum() {
403
-		return $this->data['checksum'];
404
-	}
405
-
406
-	public function getExtension(): string {
407
-		return pathinfo($this->getName(), PATHINFO_EXTENSION);
408
-	}
409
-
410
-	public function getCreationTime(): int {
411
-		return (int) $this->data['creation_time'];
412
-	}
413
-
414
-	public function getUploadTime(): int {
415
-		return (int) $this->data['upload_time'];
416
-	}
41
+    /**
42
+     * @var array $data
43
+     */
44
+    private $data;
45
+
46
+    /**
47
+     * @var string $path
48
+     */
49
+    private $path;
50
+
51
+    /**
52
+     * @var \OC\Files\Storage\Storage $storage
53
+     */
54
+    private $storage;
55
+
56
+    /**
57
+     * @var string $internalPath
58
+     */
59
+    private $internalPath;
60
+
61
+    /**
62
+     * @var \OCP\Files\Mount\IMountPoint
63
+     */
64
+    private $mount;
65
+
66
+    /**
67
+     * @var IUser
68
+     */
69
+    private $owner;
70
+
71
+    /**
72
+     * @var string[]
73
+     */
74
+    private $childEtags = [];
75
+
76
+    /**
77
+     * @var IMountPoint[]
78
+     */
79
+    private $subMounts = [];
80
+
81
+    private $subMountsUsed = false;
82
+
83
+    /**
84
+     * The size of the file/folder without any sub mount
85
+     *
86
+     * @var int
87
+     */
88
+    private $rawSize = 0;
89
+
90
+    /**
91
+     * @param string|boolean $path
92
+     * @param Storage\Storage $storage
93
+     * @param string $internalPath
94
+     * @param array|ICacheEntry $data
95
+     * @param \OCP\Files\Mount\IMountPoint $mount
96
+     * @param \OCP\IUser|null $owner
97
+     */
98
+    public function __construct($path, $storage, $internalPath, $data, $mount, $owner= null) {
99
+        $this->path = $path;
100
+        $this->storage = $storage;
101
+        $this->internalPath = $internalPath;
102
+        $this->data = $data;
103
+        $this->mount = $mount;
104
+        $this->owner = $owner;
105
+        $this->rawSize = $this->data['size'] ?? 0;
106
+    }
107
+
108
+    public function offsetSet($offset, $value) {
109
+        $this->data[$offset] = $value;
110
+    }
111
+
112
+    public function offsetExists($offset) {
113
+        return isset($this->data[$offset]);
114
+    }
115
+
116
+    public function offsetUnset($offset) {
117
+        unset($this->data[$offset]);
118
+    }
119
+
120
+    public function offsetGet($offset) {
121
+        if ($offset === 'type') {
122
+            return $this->getType();
123
+        } else if ($offset === 'etag') {
124
+            return $this->getEtag();
125
+        } else if ($offset === 'size') {
126
+            return $this->getSize();
127
+        } else if ($offset === 'mtime') {
128
+            return $this->getMTime();
129
+        } elseif ($offset === 'permissions') {
130
+            return $this->getPermissions();
131
+        } elseif (isset($this->data[$offset])) {
132
+            return $this->data[$offset];
133
+        } else {
134
+            return null;
135
+        }
136
+    }
137
+
138
+    /**
139
+     * @return string
140
+     */
141
+    public function getPath() {
142
+        return $this->path;
143
+    }
144
+
145
+    /**
146
+     * @return \OCP\Files\Storage
147
+     */
148
+    public function getStorage() {
149
+        return $this->storage;
150
+    }
151
+
152
+    /**
153
+     * @return string
154
+     */
155
+    public function getInternalPath() {
156
+        return $this->internalPath;
157
+    }
158
+
159
+    /**
160
+     * Get FileInfo ID or null in case of part file
161
+     *
162
+     * @return int|null
163
+     */
164
+    public function getId() {
165
+        return isset($this->data['fileid']) ? (int)  $this->data['fileid'] : null;
166
+    }
167
+
168
+    /**
169
+     * @return string
170
+     */
171
+    public function getMimetype() {
172
+        return $this->data['mimetype'];
173
+    }
174
+
175
+    /**
176
+     * @return string
177
+     */
178
+    public function getMimePart() {
179
+        return $this->data['mimepart'];
180
+    }
181
+
182
+    /**
183
+     * @return string
184
+     */
185
+    public function getName() {
186
+        return isset($this->data['name']) ? $this->data['name'] : basename($this->getPath());
187
+    }
188
+
189
+    /**
190
+     * @return string
191
+     */
192
+    public function getEtag() {
193
+        $this->updateEntryfromSubMounts();
194
+        if (count($this->childEtags) > 0) {
195
+            $combinedEtag = $this->data['etag'] . '::' . implode('::', $this->childEtags);
196
+            return md5($combinedEtag);
197
+        } else {
198
+            return $this->data['etag'];
199
+        }
200
+    }
201
+
202
+    /**
203
+     * @return int
204
+     */
205
+    public function getSize($includeMounts = true) {
206
+        if ($includeMounts) {
207
+            $this->updateEntryfromSubMounts();
208
+            return isset($this->data['size']) ? 0 + $this->data['size'] : 0;
209
+        } else {
210
+            return $this->rawSize;
211
+        }
212
+    }
213
+
214
+    /**
215
+     * @return int
216
+     */
217
+    public function getMTime() {
218
+        $this->updateEntryfromSubMounts();
219
+        return (int) $this->data['mtime'];
220
+    }
221
+
222
+    /**
223
+     * @return bool
224
+     */
225
+    public function isEncrypted() {
226
+        return $this->data['encrypted'];
227
+    }
228
+
229
+    /**
230
+     * Return the currently version used for the HMAC in the encryption app
231
+     *
232
+     * @return int
233
+     */
234
+    public function getEncryptedVersion() {
235
+        return isset($this->data['encryptedVersion']) ? (int) $this->data['encryptedVersion'] : 1;
236
+    }
237
+
238
+    /**
239
+     * @return int
240
+     */
241
+    public function getPermissions() {
242
+        $perms = (int) $this->data['permissions'];
243
+        if (\OCP\Util::isSharingDisabledForUser() || ($this->isShared() && !\OC\Share\Share::isResharingAllowed())) {
244
+            $perms = $perms & ~\OCP\Constants::PERMISSION_SHARE;
245
+        }
246
+        return (int) $perms;
247
+    }
248
+
249
+    /**
250
+     * @return string \OCP\Files\FileInfo::TYPE_FILE|\OCP\Files\FileInfo::TYPE_FOLDER
251
+     */
252
+    public function getType() {
253
+        if (!isset($this->data['type'])) {
254
+            $this->data['type'] = ($this->getMimetype() === 'httpd/unix-directory') ? self::TYPE_FOLDER : self::TYPE_FILE;
255
+        }
256
+        return $this->data['type'];
257
+    }
258
+
259
+    public function getData() {
260
+        return $this->data;
261
+    }
262
+
263
+    /**
264
+     * @param int $permissions
265
+     * @return bool
266
+     */
267
+    protected function checkPermissions($permissions) {
268
+        return ($this->getPermissions() & $permissions) === $permissions;
269
+    }
270
+
271
+    /**
272
+     * @return bool
273
+     */
274
+    public function isReadable() {
275
+        return $this->checkPermissions(\OCP\Constants::PERMISSION_READ);
276
+    }
277
+
278
+    /**
279
+     * @return bool
280
+     */
281
+    public function isUpdateable() {
282
+        return $this->checkPermissions(\OCP\Constants::PERMISSION_UPDATE);
283
+    }
284
+
285
+    /**
286
+     * Check whether new files or folders can be created inside this folder
287
+     *
288
+     * @return bool
289
+     */
290
+    public function isCreatable() {
291
+        return $this->checkPermissions(\OCP\Constants::PERMISSION_CREATE);
292
+    }
293
+
294
+    /**
295
+     * @return bool
296
+     */
297
+    public function isDeletable() {
298
+        return $this->checkPermissions(\OCP\Constants::PERMISSION_DELETE);
299
+    }
300
+
301
+    /**
302
+     * @return bool
303
+     */
304
+    public function isShareable() {
305
+        return $this->checkPermissions(\OCP\Constants::PERMISSION_SHARE);
306
+    }
307
+
308
+    /**
309
+     * Check if a file or folder is shared
310
+     *
311
+     * @return bool
312
+     */
313
+    public function isShared() {
314
+        $sid = $this->getStorage()->getId();
315
+        if (!is_null($sid)) {
316
+            $sid = explode(':', $sid);
317
+            return ($sid[0] === 'shared');
318
+        }
319
+
320
+        return false;
321
+    }
322
+
323
+    public function isMounted() {
324
+        $storage = $this->getStorage();
325
+        if ($storage->instanceOfStorage('\OCP\Files\IHomeStorage')) {
326
+            return false;
327
+        }
328
+        $sid = $storage->getId();
329
+        if (!is_null($sid)) {
330
+            $sid = explode(':', $sid);
331
+            return ($sid[0] !== 'home' and $sid[0] !== 'shared');
332
+        }
333
+
334
+        return false;
335
+    }
336
+
337
+    /**
338
+     * Get the mountpoint the file belongs to
339
+     *
340
+     * @return \OCP\Files\Mount\IMountPoint
341
+     */
342
+    public function getMountPoint() {
343
+        return $this->mount;
344
+    }
345
+
346
+    /**
347
+     * Get the owner of the file
348
+     *
349
+     * @return \OCP\IUser
350
+     */
351
+    public function getOwner() {
352
+        return $this->owner;
353
+    }
354
+
355
+    /**
356
+     * @param IMountPoint[] $mounts
357
+     */
358
+    public function setSubMounts(array $mounts) {
359
+        $this->subMounts = $mounts;
360
+    }
361
+
362
+    private function updateEntryfromSubMounts() {
363
+        if ($this->subMountsUsed) {
364
+            return;
365
+        }
366
+        $this->subMountsUsed = true;
367
+        foreach ($this->subMounts as $mount) {
368
+            $subStorage = $mount->getStorage();
369
+            if ($subStorage) {
370
+                $subCache = $subStorage->getCache('');
371
+                $rootEntry = $subCache->get('');
372
+                $this->addSubEntry($rootEntry, $mount->getMountPoint());
373
+            }
374
+        }
375
+    }
376
+
377
+    /**
378
+     * Add a cache entry which is the child of this folder
379
+     *
380
+     * Sets the size, etag and size to for cross-storage childs
381
+     *
382
+     * @param array|ICacheEntry $data cache entry for the child
383
+     * @param string $entryPath full path of the child entry
384
+     */
385
+    public function addSubEntry($data, $entryPath) {
386
+        $this->data['size'] += isset($data['size']) ? $data['size'] : 0;
387
+        if (isset($data['mtime'])) {
388
+            $this->data['mtime'] = max($this->data['mtime'], $data['mtime']);
389
+        }
390
+        if (isset($data['etag'])) {
391
+            // prefix the etag with the relative path of the subentry to propagate etag on mount moves
392
+            $relativeEntryPath = substr($entryPath, strlen($this->getPath()));
393
+            // attach the permissions to propagate etag on permision changes of submounts
394
+            $permissions = isset($data['permissions']) ? $data['permissions'] : 0;
395
+            $this->childEtags[] = $relativeEntryPath . '/' . $data['etag'] . $permissions;
396
+        }
397
+    }
398
+
399
+    /**
400
+     * @inheritdoc
401
+     */
402
+    public function getChecksum() {
403
+        return $this->data['checksum'];
404
+    }
405
+
406
+    public function getExtension(): string {
407
+        return pathinfo($this->getName(), PATHINFO_EXTENSION);
408
+    }
409
+
410
+    public function getCreationTime(): int {
411
+        return (int) $this->data['creation_time'];
412
+    }
413
+
414
+    public function getUploadTime(): int {
415
+        return (int) $this->data['upload_time'];
416
+    }
417 417
 }
Please login to merge, or discard this patch.
apps/dav/lib/Avatars/AvatarHome.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 	public function getChild($name) {
60 60
 		$elements = pathinfo($name);
61 61
 		$ext = isset($elements['extension']) ? $elements['extension'] : '';
62
-		$size = (int)(isset($elements['filename']) ? $elements['filename'] : '64');
62
+		$size = (int) (isset($elements['filename']) ? $elements['filename'] : '64');
63 63
 		if (!in_array($ext, ['jpeg', 'png'], true)) {
64 64
 			throw new MethodNotAllowed('File format not allowed');
65 65
 		}
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 			return [
79 79
 				$this->getChild('96.jpeg')
80 80
 			];
81
-		} catch(NotFound $exception) {
81
+		} catch (NotFound $exception) {
82 82
 			return [];
83 83
 		}
84 84
 	}
Please login to merge, or discard this patch.
Indentation   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -35,89 +35,89 @@
 block discarded – undo
35 35
 
36 36
 class AvatarHome implements ICollection {
37 37
 
38
-	/** @var array */
39
-	private $principalInfo;
40
-	/** @var IAvatarManager */
41
-	private $avatarManager;
42
-
43
-	/**
44
-	 * AvatarHome constructor.
45
-	 *
46
-	 * @param array $principalInfo
47
-	 * @param IAvatarManager $avatarManager
48
-	 */
49
-	public function __construct($principalInfo, IAvatarManager $avatarManager) {
50
-		$this->principalInfo = $principalInfo;
51
-		$this->avatarManager = $avatarManager;
52
-	}
53
-
54
-	public function createFile($name, $data = null) {
55
-		throw new Forbidden('Permission denied to create a file');
56
-	}
57
-
58
-	public function createDirectory($name) {
59
-		throw new Forbidden('Permission denied to create a folder');
60
-	}
61
-
62
-	public function getChild($name) {
63
-		$elements = pathinfo($name);
64
-		$ext = isset($elements['extension']) ? $elements['extension'] : '';
65
-		$size = (int)(isset($elements['filename']) ? $elements['filename'] : '64');
66
-		if (!in_array($ext, ['jpeg', 'png'], true)) {
67
-			throw new MethodNotAllowed('File format not allowed');
68
-		}
69
-		if ($size <= 0 || $size > 1024) {
70
-			throw new MethodNotAllowed('Invalid image size');
71
-		}
72
-		$avatar = $this->avatarManager->getAvatar($this->getName());
73
-		if (!$avatar->exists()) {
74
-			throw new NotFound();
75
-		}
76
-		return new AvatarNode($size, $ext, $avatar);
77
-	}
78
-
79
-	public function getChildren() {
80
-		try {
81
-			return [
82
-				$this->getChild('96.jpeg')
83
-			];
84
-		} catch(NotFound $exception) {
85
-			return [];
86
-		}
87
-	}
88
-
89
-	public function childExists($name) {
90
-		try {
91
-			$ret = $this->getChild($name);
92
-			return $ret !== null;
93
-		} catch (NotFound $ex) {
94
-			return false;
95
-		} catch (MethodNotAllowed $ex) {
96
-			return false;
97
-		}
98
-	}
99
-
100
-	public function delete() {
101
-		throw new Forbidden('Permission denied to delete this folder');
102
-	}
103
-
104
-	public function getName() {
105
-		list(,$name) = Uri\split($this->principalInfo['uri']);
106
-		return $name;
107
-	}
108
-
109
-	public function setName($name) {
110
-		throw new Forbidden('Permission denied to rename this folder');
111
-	}
112
-
113
-	/**
114
-	 * Returns the last modification time, as a unix timestamp
115
-	 *
116
-	 * @return int|null
117
-	 */
118
-	public function getLastModified() {
119
-		return null;
120
-	}
38
+    /** @var array */
39
+    private $principalInfo;
40
+    /** @var IAvatarManager */
41
+    private $avatarManager;
42
+
43
+    /**
44
+     * AvatarHome constructor.
45
+     *
46
+     * @param array $principalInfo
47
+     * @param IAvatarManager $avatarManager
48
+     */
49
+    public function __construct($principalInfo, IAvatarManager $avatarManager) {
50
+        $this->principalInfo = $principalInfo;
51
+        $this->avatarManager = $avatarManager;
52
+    }
53
+
54
+    public function createFile($name, $data = null) {
55
+        throw new Forbidden('Permission denied to create a file');
56
+    }
57
+
58
+    public function createDirectory($name) {
59
+        throw new Forbidden('Permission denied to create a folder');
60
+    }
61
+
62
+    public function getChild($name) {
63
+        $elements = pathinfo($name);
64
+        $ext = isset($elements['extension']) ? $elements['extension'] : '';
65
+        $size = (int)(isset($elements['filename']) ? $elements['filename'] : '64');
66
+        if (!in_array($ext, ['jpeg', 'png'], true)) {
67
+            throw new MethodNotAllowed('File format not allowed');
68
+        }
69
+        if ($size <= 0 || $size > 1024) {
70
+            throw new MethodNotAllowed('Invalid image size');
71
+        }
72
+        $avatar = $this->avatarManager->getAvatar($this->getName());
73
+        if (!$avatar->exists()) {
74
+            throw new NotFound();
75
+        }
76
+        return new AvatarNode($size, $ext, $avatar);
77
+    }
78
+
79
+    public function getChildren() {
80
+        try {
81
+            return [
82
+                $this->getChild('96.jpeg')
83
+            ];
84
+        } catch(NotFound $exception) {
85
+            return [];
86
+        }
87
+    }
88
+
89
+    public function childExists($name) {
90
+        try {
91
+            $ret = $this->getChild($name);
92
+            return $ret !== null;
93
+        } catch (NotFound $ex) {
94
+            return false;
95
+        } catch (MethodNotAllowed $ex) {
96
+            return false;
97
+        }
98
+    }
99
+
100
+    public function delete() {
101
+        throw new Forbidden('Permission denied to delete this folder');
102
+    }
103
+
104
+    public function getName() {
105
+        list(,$name) = Uri\split($this->principalInfo['uri']);
106
+        return $name;
107
+    }
108
+
109
+    public function setName($name) {
110
+        throw new Forbidden('Permission denied to rename this folder');
111
+    }
112
+
113
+    /**
114
+     * Returns the last modification time, as a unix timestamp
115
+     *
116
+     * @return int|null
117
+     */
118
+    public function getLastModified() {
119
+        return null;
120
+    }
121 121
 
122 122
 
123 123
 }
Please login to merge, or discard this patch.
apps/dav/lib/Avatars/AvatarNode.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -89,7 +89,7 @@
 block discarded – undo
89 89
 	public function getLastModified() {
90 90
 		$timestamp = $this->avatar->getFile($this->size)->getMTime();
91 91
 		if (!empty($timestamp)) {
92
-			return (int)$timestamp;
92
+			return (int) $timestamp;
93 93
 		}
94 94
 		return $timestamp;
95 95
 
Please login to merge, or discard this patch.
Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -27,72 +27,72 @@
 block discarded – undo
27 27
 use Sabre\DAV\File;
28 28
 
29 29
 class AvatarNode extends File {
30
-	private $ext;
31
-	private $size;
32
-	private $avatar;
30
+    private $ext;
31
+    private $size;
32
+    private $avatar;
33 33
 
34
-	/**
35
-	 * AvatarNode constructor.
36
-	 *
37
-	 * @param integer $size
38
-	 * @param string $ext
39
-	 * @param IAvatar $avatar
40
-	 */
41
-	public function __construct($size, $ext, $avatar) {
42
-		$this->size = $size;
43
-		$this->ext = $ext;
44
-		$this->avatar = $avatar;
45
-	}
34
+    /**
35
+     * AvatarNode constructor.
36
+     *
37
+     * @param integer $size
38
+     * @param string $ext
39
+     * @param IAvatar $avatar
40
+     */
41
+    public function __construct($size, $ext, $avatar) {
42
+        $this->size = $size;
43
+        $this->ext = $ext;
44
+        $this->avatar = $avatar;
45
+    }
46 46
 
47
-	/**
48
-	 * Returns the name of the node.
49
-	 *
50
-	 * This is used to generate the url.
51
-	 *
52
-	 * @return string
53
-	 */
54
-	public function getName() {
55
-		return "$this->size.$this->ext";
56
-	}
47
+    /**
48
+     * Returns the name of the node.
49
+     *
50
+     * This is used to generate the url.
51
+     *
52
+     * @return string
53
+     */
54
+    public function getName() {
55
+        return "$this->size.$this->ext";
56
+    }
57 57
 
58
-	public function get() {
59
-		$image = $this->avatar->get($this->size);
60
-		$res = $image->resource();
58
+    public function get() {
59
+        $image = $this->avatar->get($this->size);
60
+        $res = $image->resource();
61 61
 
62
-		ob_start();
63
-		if ($this->ext === 'png') {
64
-			imagepng($res);
65
-		} else {
66
-			imagejpeg($res);
67
-		}
62
+        ob_start();
63
+        if ($this->ext === 'png') {
64
+            imagepng($res);
65
+        } else {
66
+            imagejpeg($res);
67
+        }
68 68
 
69
-		return ob_get_clean();
70
-	}
69
+        return ob_get_clean();
70
+    }
71 71
 
72
-	/**
73
-	 * Returns the mime-type for a file
74
-	 *
75
-	 * If null is returned, we'll assume application/octet-stream
76
-	 *
77
-	 * @return string|null
78
-	 */
79
-	public function getContentType() {
80
-		if ($this->ext === 'png') {
81
-			return 'image/png';
82
-		}
83
-		return 'image/jpeg';
84
-	}
72
+    /**
73
+     * Returns the mime-type for a file
74
+     *
75
+     * If null is returned, we'll assume application/octet-stream
76
+     *
77
+     * @return string|null
78
+     */
79
+    public function getContentType() {
80
+        if ($this->ext === 'png') {
81
+            return 'image/png';
82
+        }
83
+        return 'image/jpeg';
84
+    }
85 85
 
86
-	public function getETag() {
87
-		return $this->avatar->getFile($this->size)->getEtag();
88
-	}
86
+    public function getETag() {
87
+        return $this->avatar->getFile($this->size)->getEtag();
88
+    }
89 89
 
90
-	public function getLastModified() {
91
-		$timestamp = $this->avatar->getFile($this->size)->getMTime();
92
-		if (!empty($timestamp)) {
93
-			return (int)$timestamp;
94
-		}
95
-		return $timestamp;
90
+    public function getLastModified() {
91
+        $timestamp = $this->avatar->getFile($this->size)->getMTime();
92
+        if (!empty($timestamp)) {
93
+            return (int)$timestamp;
94
+        }
95
+        return $timestamp;
96 96
 
97
-	}
97
+    }
98 98
 }
Please login to merge, or discard this patch.
apps/dav/lib/Avatars/RootCollection.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -7,23 +7,23 @@
 block discarded – undo
7 7
 
8 8
 class RootCollection extends AbstractPrincipalCollection {
9 9
 
10
-	/**
11
-	 * This method returns a node for a principal.
12
-	 *
13
-	 * The passed array contains principal information, and is guaranteed to
14
-	 * at least contain a uri item. Other properties may or may not be
15
-	 * supplied by the authentication backend.
16
-	 *
17
-	 * @param array $principalInfo
18
-	 * @return AvatarHome
19
-	 */
20
-	public function getChildForPrincipal(array $principalInfo) {
21
-		$avatarManager = \OC::$server->getAvatarManager();
22
-		return new AvatarHome($principalInfo, $avatarManager);
23
-	}
10
+    /**
11
+     * This method returns a node for a principal.
12
+     *
13
+     * The passed array contains principal information, and is guaranteed to
14
+     * at least contain a uri item. Other properties may or may not be
15
+     * supplied by the authentication backend.
16
+     *
17
+     * @param array $principalInfo
18
+     * @return AvatarHome
19
+     */
20
+    public function getChildForPrincipal(array $principalInfo) {
21
+        $avatarManager = \OC::$server->getAvatarManager();
22
+        return new AvatarHome($principalInfo, $avatarManager);
23
+    }
24 24
 
25
-	public function getName() {
26
-		return 'avatars';
27
-	}
25
+    public function getName() {
26
+        return 'avatars';
27
+    }
28 28
 
29 29
 }
Please login to merge, or discard this patch.