@@ -119,9 +119,9 @@ |
||
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]; |
@@ -33,119 +33,119 @@ |
||
33 | 33 | |
34 | 34 | class Converter { |
35 | 35 | |
36 | - /** @var AccountManager */ |
|
37 | - private $accountManager; |
|
38 | - |
|
39 | - /** |
|
40 | - * Converter constructor. |
|
41 | - * |
|
42 | - * @param AccountManager $accountManager |
|
43 | - */ |
|
44 | - public function __construct(AccountManager $accountManager) { |
|
45 | - $this->accountManager = $accountManager; |
|
46 | - } |
|
47 | - |
|
48 | - /** |
|
49 | - * @param IUser $user |
|
50 | - * @return VCard|null |
|
51 | - */ |
|
52 | - public function createCardFromUser(IUser $user) { |
|
53 | - $userData = $this->accountManager->getUser($user); |
|
54 | - |
|
55 | - $uid = $user->getUID(); |
|
56 | - $cloudId = $user->getCloudId(); |
|
57 | - $image = $this->getAvatarImage($user); |
|
58 | - |
|
59 | - $vCard = new VCard(); |
|
60 | - $vCard->VERSION = '3.0'; |
|
61 | - $vCard->UID = $uid; |
|
62 | - |
|
63 | - $publish = false; |
|
64 | - |
|
65 | - if ($image !== null && isset($userData[AccountManager::PROPERTY_AVATAR])) { |
|
66 | - $userData[AccountManager::PROPERTY_AVATAR]['value'] = true; |
|
67 | - } |
|
68 | - |
|
69 | - foreach ($userData as $property => $value) { |
|
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 | - } |
|
36 | + /** @var AccountManager */ |
|
37 | + private $accountManager; |
|
38 | + |
|
39 | + /** |
|
40 | + * Converter constructor. |
|
41 | + * |
|
42 | + * @param AccountManager $accountManager |
|
43 | + */ |
|
44 | + public function __construct(AccountManager $accountManager) { |
|
45 | + $this->accountManager = $accountManager; |
|
46 | + } |
|
47 | + |
|
48 | + /** |
|
49 | + * @param IUser $user |
|
50 | + * @return VCard|null |
|
51 | + */ |
|
52 | + public function createCardFromUser(IUser $user) { |
|
53 | + $userData = $this->accountManager->getUser($user); |
|
54 | + |
|
55 | + $uid = $user->getUID(); |
|
56 | + $cloudId = $user->getCloudId(); |
|
57 | + $image = $this->getAvatarImage($user); |
|
58 | + |
|
59 | + $vCard = new VCard(); |
|
60 | + $vCard->VERSION = '3.0'; |
|
61 | + $vCard->UID = $uid; |
|
62 | + |
|
63 | + $publish = false; |
|
64 | + |
|
65 | + if ($image !== null && isset($userData[AccountManager::PROPERTY_AVATAR])) { |
|
66 | + $userData[AccountManager::PROPERTY_AVATAR]['value'] = true; |
|
67 | + } |
|
68 | + |
|
69 | + foreach ($userData as $property => $value) { |
|
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 | } |
@@ -37,57 +37,57 @@ |
||
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 | } |
@@ -31,36 +31,36 @@ |
||
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 | } |
@@ -87,7 +87,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -37,380 +37,380 @@ |
||
37 | 37 | use OCP\IUser; |
38 | 38 | |
39 | 39 | class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess { |
40 | - /** |
|
41 | - * @var array $data |
|
42 | - */ |
|
43 | - private $data; |
|
44 | - |
|
45 | - /** |
|
46 | - * @var string $path |
|
47 | - */ |
|
48 | - private $path; |
|
49 | - |
|
50 | - /** |
|
51 | - * @var \OC\Files\Storage\Storage $storage |
|
52 | - */ |
|
53 | - private $storage; |
|
54 | - |
|
55 | - /** |
|
56 | - * @var string $internalPath |
|
57 | - */ |
|
58 | - private $internalPath; |
|
59 | - |
|
60 | - /** |
|
61 | - * @var \OCP\Files\Mount\IMountPoint |
|
62 | - */ |
|
63 | - private $mount; |
|
64 | - |
|
65 | - /** |
|
66 | - * @var IUser |
|
67 | - */ |
|
68 | - private $owner; |
|
69 | - |
|
70 | - /** |
|
71 | - * @var string[] |
|
72 | - */ |
|
73 | - private $childEtags = []; |
|
74 | - |
|
75 | - /** |
|
76 | - * @var IMountPoint[] |
|
77 | - */ |
|
78 | - private $subMounts = []; |
|
79 | - |
|
80 | - private $subMountsUsed = false; |
|
81 | - |
|
82 | - /** |
|
83 | - * The size of the file/folder without any sub mount |
|
84 | - * |
|
85 | - * @var int |
|
86 | - */ |
|
87 | - private $rawSize = 0; |
|
88 | - |
|
89 | - /** |
|
90 | - * @param string|boolean $path |
|
91 | - * @param Storage\Storage $storage |
|
92 | - * @param string $internalPath |
|
93 | - * @param array|ICacheEntry $data |
|
94 | - * @param \OCP\Files\Mount\IMountPoint $mount |
|
95 | - * @param \OCP\IUser|null $owner |
|
96 | - */ |
|
97 | - public function __construct($path, $storage, $internalPath, $data, $mount, $owner= null) { |
|
98 | - $this->path = $path; |
|
99 | - $this->storage = $storage; |
|
100 | - $this->internalPath = $internalPath; |
|
101 | - $this->data = $data; |
|
102 | - $this->mount = $mount; |
|
103 | - $this->owner = $owner; |
|
104 | - $this->rawSize = $this->data['size'] ?? 0; |
|
105 | - } |
|
106 | - |
|
107 | - public function offsetSet($offset, $value) { |
|
108 | - $this->data[$offset] = $value; |
|
109 | - } |
|
110 | - |
|
111 | - public function offsetExists($offset) { |
|
112 | - return isset($this->data[$offset]); |
|
113 | - } |
|
114 | - |
|
115 | - public function offsetUnset($offset) { |
|
116 | - unset($this->data[$offset]); |
|
117 | - } |
|
118 | - |
|
119 | - public function offsetGet($offset) { |
|
120 | - if ($offset === 'type') { |
|
121 | - return $this->getType(); |
|
122 | - } elseif ($offset === 'etag') { |
|
123 | - return $this->getEtag(); |
|
124 | - } elseif ($offset === 'size') { |
|
125 | - return $this->getSize(); |
|
126 | - } elseif ($offset === 'mtime') { |
|
127 | - return $this->getMTime(); |
|
128 | - } elseif ($offset === 'permissions') { |
|
129 | - return $this->getPermissions(); |
|
130 | - } elseif (isset($this->data[$offset])) { |
|
131 | - return $this->data[$offset]; |
|
132 | - } else { |
|
133 | - return null; |
|
134 | - } |
|
135 | - } |
|
136 | - |
|
137 | - /** |
|
138 | - * @return string |
|
139 | - */ |
|
140 | - public function getPath() { |
|
141 | - return $this->path; |
|
142 | - } |
|
143 | - |
|
144 | - /** |
|
145 | - * @return \OCP\Files\Storage |
|
146 | - */ |
|
147 | - public function getStorage() { |
|
148 | - return $this->storage; |
|
149 | - } |
|
150 | - |
|
151 | - /** |
|
152 | - * @return string |
|
153 | - */ |
|
154 | - public function getInternalPath() { |
|
155 | - return $this->internalPath; |
|
156 | - } |
|
157 | - |
|
158 | - /** |
|
159 | - * Get FileInfo ID or null in case of part file |
|
160 | - * |
|
161 | - * @return int|null |
|
162 | - */ |
|
163 | - public function getId() { |
|
164 | - return isset($this->data['fileid']) ? (int) $this->data['fileid'] : null; |
|
165 | - } |
|
166 | - |
|
167 | - /** |
|
168 | - * @return string |
|
169 | - */ |
|
170 | - public function getMimetype() { |
|
171 | - return $this->data['mimetype']; |
|
172 | - } |
|
173 | - |
|
174 | - /** |
|
175 | - * @return string |
|
176 | - */ |
|
177 | - public function getMimePart() { |
|
178 | - return $this->data['mimepart']; |
|
179 | - } |
|
180 | - |
|
181 | - /** |
|
182 | - * @return string |
|
183 | - */ |
|
184 | - public function getName() { |
|
185 | - return isset($this->data['name']) ? $this->data['name'] : basename($this->getPath()); |
|
186 | - } |
|
187 | - |
|
188 | - /** |
|
189 | - * @return string |
|
190 | - */ |
|
191 | - public function getEtag() { |
|
192 | - $this->updateEntryfromSubMounts(); |
|
193 | - if (count($this->childEtags) > 0) { |
|
194 | - $combinedEtag = $this->data['etag'] . '::' . implode('::', $this->childEtags); |
|
195 | - return md5($combinedEtag); |
|
196 | - } else { |
|
197 | - return $this->data['etag']; |
|
198 | - } |
|
199 | - } |
|
200 | - |
|
201 | - /** |
|
202 | - * @return int |
|
203 | - */ |
|
204 | - public function getSize($includeMounts = true) { |
|
205 | - if ($includeMounts) { |
|
206 | - $this->updateEntryfromSubMounts(); |
|
207 | - return isset($this->data['size']) ? 0 + $this->data['size'] : 0; |
|
208 | - } else { |
|
209 | - return $this->rawSize; |
|
210 | - } |
|
211 | - } |
|
212 | - |
|
213 | - /** |
|
214 | - * @return int |
|
215 | - */ |
|
216 | - public function getMTime() { |
|
217 | - $this->updateEntryfromSubMounts(); |
|
218 | - return (int) $this->data['mtime']; |
|
219 | - } |
|
220 | - |
|
221 | - /** |
|
222 | - * @return bool |
|
223 | - */ |
|
224 | - public function isEncrypted() { |
|
225 | - return $this->data['encrypted']; |
|
226 | - } |
|
227 | - |
|
228 | - /** |
|
229 | - * Return the currently version used for the HMAC in the encryption app |
|
230 | - * |
|
231 | - * @return int |
|
232 | - */ |
|
233 | - public function getEncryptedVersion() { |
|
234 | - return isset($this->data['encryptedVersion']) ? (int) $this->data['encryptedVersion'] : 1; |
|
235 | - } |
|
236 | - |
|
237 | - /** |
|
238 | - * @return int |
|
239 | - */ |
|
240 | - public function getPermissions() { |
|
241 | - $perms = (int) $this->data['permissions']; |
|
242 | - if (\OCP\Util::isSharingDisabledForUser() || ($this->isShared() && !\OC\Share\Share::isResharingAllowed())) { |
|
243 | - $perms = $perms & ~\OCP\Constants::PERMISSION_SHARE; |
|
244 | - } |
|
245 | - return (int) $perms; |
|
246 | - } |
|
247 | - |
|
248 | - /** |
|
249 | - * @return string \OCP\Files\FileInfo::TYPE_FILE|\OCP\Files\FileInfo::TYPE_FOLDER |
|
250 | - */ |
|
251 | - public function getType() { |
|
252 | - if (!isset($this->data['type'])) { |
|
253 | - $this->data['type'] = ($this->getMimetype() === 'httpd/unix-directory') ? self::TYPE_FOLDER : self::TYPE_FILE; |
|
254 | - } |
|
255 | - return $this->data['type']; |
|
256 | - } |
|
257 | - |
|
258 | - public function getData() { |
|
259 | - return $this->data; |
|
260 | - } |
|
261 | - |
|
262 | - /** |
|
263 | - * @param int $permissions |
|
264 | - * @return bool |
|
265 | - */ |
|
266 | - protected function checkPermissions($permissions) { |
|
267 | - return ($this->getPermissions() & $permissions) === $permissions; |
|
268 | - } |
|
269 | - |
|
270 | - /** |
|
271 | - * @return bool |
|
272 | - */ |
|
273 | - public function isReadable() { |
|
274 | - return $this->checkPermissions(\OCP\Constants::PERMISSION_READ); |
|
275 | - } |
|
276 | - |
|
277 | - /** |
|
278 | - * @return bool |
|
279 | - */ |
|
280 | - public function isUpdateable() { |
|
281 | - return $this->checkPermissions(\OCP\Constants::PERMISSION_UPDATE); |
|
282 | - } |
|
283 | - |
|
284 | - /** |
|
285 | - * Check whether new files or folders can be created inside this folder |
|
286 | - * |
|
287 | - * @return bool |
|
288 | - */ |
|
289 | - public function isCreatable() { |
|
290 | - return $this->checkPermissions(\OCP\Constants::PERMISSION_CREATE); |
|
291 | - } |
|
292 | - |
|
293 | - /** |
|
294 | - * @return bool |
|
295 | - */ |
|
296 | - public function isDeletable() { |
|
297 | - return $this->checkPermissions(\OCP\Constants::PERMISSION_DELETE); |
|
298 | - } |
|
299 | - |
|
300 | - /** |
|
301 | - * @return bool |
|
302 | - */ |
|
303 | - public function isShareable() { |
|
304 | - return $this->checkPermissions(\OCP\Constants::PERMISSION_SHARE); |
|
305 | - } |
|
306 | - |
|
307 | - /** |
|
308 | - * Check if a file or folder is shared |
|
309 | - * |
|
310 | - * @return bool |
|
311 | - */ |
|
312 | - public function isShared() { |
|
313 | - $sid = $this->getStorage()->getId(); |
|
314 | - if (!is_null($sid)) { |
|
315 | - $sid = explode(':', $sid); |
|
316 | - return ($sid[0] === 'shared'); |
|
317 | - } |
|
318 | - |
|
319 | - return false; |
|
320 | - } |
|
321 | - |
|
322 | - public function isMounted() { |
|
323 | - $storage = $this->getStorage(); |
|
324 | - if ($storage->instanceOfStorage('\OCP\Files\IHomeStorage')) { |
|
325 | - return false; |
|
326 | - } |
|
327 | - $sid = $storage->getId(); |
|
328 | - if (!is_null($sid)) { |
|
329 | - $sid = explode(':', $sid); |
|
330 | - return ($sid[0] !== 'home' and $sid[0] !== 'shared'); |
|
331 | - } |
|
332 | - |
|
333 | - return false; |
|
334 | - } |
|
335 | - |
|
336 | - /** |
|
337 | - * Get the mountpoint the file belongs to |
|
338 | - * |
|
339 | - * @return \OCP\Files\Mount\IMountPoint |
|
340 | - */ |
|
341 | - public function getMountPoint() { |
|
342 | - return $this->mount; |
|
343 | - } |
|
344 | - |
|
345 | - /** |
|
346 | - * Get the owner of the file |
|
347 | - * |
|
348 | - * @return \OCP\IUser |
|
349 | - */ |
|
350 | - public function getOwner() { |
|
351 | - return $this->owner; |
|
352 | - } |
|
353 | - |
|
354 | - /** |
|
355 | - * @param IMountPoint[] $mounts |
|
356 | - */ |
|
357 | - public function setSubMounts(array $mounts) { |
|
358 | - $this->subMounts = $mounts; |
|
359 | - } |
|
360 | - |
|
361 | - private function updateEntryfromSubMounts() { |
|
362 | - if ($this->subMountsUsed) { |
|
363 | - return; |
|
364 | - } |
|
365 | - $this->subMountsUsed = true; |
|
366 | - foreach ($this->subMounts as $mount) { |
|
367 | - $subStorage = $mount->getStorage(); |
|
368 | - if ($subStorage) { |
|
369 | - $subCache = $subStorage->getCache(''); |
|
370 | - $rootEntry = $subCache->get(''); |
|
371 | - $this->addSubEntry($rootEntry, $mount->getMountPoint()); |
|
372 | - } |
|
373 | - } |
|
374 | - } |
|
375 | - |
|
376 | - /** |
|
377 | - * Add a cache entry which is the child of this folder |
|
378 | - * |
|
379 | - * Sets the size, etag and size to for cross-storage childs |
|
380 | - * |
|
381 | - * @param array|ICacheEntry $data cache entry for the child |
|
382 | - * @param string $entryPath full path of the child entry |
|
383 | - */ |
|
384 | - public function addSubEntry($data, $entryPath) { |
|
385 | - $this->data['size'] += isset($data['size']) ? $data['size'] : 0; |
|
386 | - if (isset($data['mtime'])) { |
|
387 | - $this->data['mtime'] = max($this->data['mtime'], $data['mtime']); |
|
388 | - } |
|
389 | - if (isset($data['etag'])) { |
|
390 | - // prefix the etag with the relative path of the subentry to propagate etag on mount moves |
|
391 | - $relativeEntryPath = substr($entryPath, strlen($this->getPath())); |
|
392 | - // attach the permissions to propagate etag on permision changes of submounts |
|
393 | - $permissions = isset($data['permissions']) ? $data['permissions'] : 0; |
|
394 | - $this->childEtags[] = $relativeEntryPath . '/' . $data['etag'] . $permissions; |
|
395 | - } |
|
396 | - } |
|
397 | - |
|
398 | - /** |
|
399 | - * @inheritdoc |
|
400 | - */ |
|
401 | - public function getChecksum() { |
|
402 | - return $this->data['checksum']; |
|
403 | - } |
|
404 | - |
|
405 | - public function getExtension(): string { |
|
406 | - return pathinfo($this->getName(), PATHINFO_EXTENSION); |
|
407 | - } |
|
408 | - |
|
409 | - public function getCreationTime(): int { |
|
410 | - return (int) $this->data['creation_time']; |
|
411 | - } |
|
412 | - |
|
413 | - public function getUploadTime(): int { |
|
414 | - return (int) $this->data['upload_time']; |
|
415 | - } |
|
40 | + /** |
|
41 | + * @var array $data |
|
42 | + */ |
|
43 | + private $data; |
|
44 | + |
|
45 | + /** |
|
46 | + * @var string $path |
|
47 | + */ |
|
48 | + private $path; |
|
49 | + |
|
50 | + /** |
|
51 | + * @var \OC\Files\Storage\Storage $storage |
|
52 | + */ |
|
53 | + private $storage; |
|
54 | + |
|
55 | + /** |
|
56 | + * @var string $internalPath |
|
57 | + */ |
|
58 | + private $internalPath; |
|
59 | + |
|
60 | + /** |
|
61 | + * @var \OCP\Files\Mount\IMountPoint |
|
62 | + */ |
|
63 | + private $mount; |
|
64 | + |
|
65 | + /** |
|
66 | + * @var IUser |
|
67 | + */ |
|
68 | + private $owner; |
|
69 | + |
|
70 | + /** |
|
71 | + * @var string[] |
|
72 | + */ |
|
73 | + private $childEtags = []; |
|
74 | + |
|
75 | + /** |
|
76 | + * @var IMountPoint[] |
|
77 | + */ |
|
78 | + private $subMounts = []; |
|
79 | + |
|
80 | + private $subMountsUsed = false; |
|
81 | + |
|
82 | + /** |
|
83 | + * The size of the file/folder without any sub mount |
|
84 | + * |
|
85 | + * @var int |
|
86 | + */ |
|
87 | + private $rawSize = 0; |
|
88 | + |
|
89 | + /** |
|
90 | + * @param string|boolean $path |
|
91 | + * @param Storage\Storage $storage |
|
92 | + * @param string $internalPath |
|
93 | + * @param array|ICacheEntry $data |
|
94 | + * @param \OCP\Files\Mount\IMountPoint $mount |
|
95 | + * @param \OCP\IUser|null $owner |
|
96 | + */ |
|
97 | + public function __construct($path, $storage, $internalPath, $data, $mount, $owner= null) { |
|
98 | + $this->path = $path; |
|
99 | + $this->storage = $storage; |
|
100 | + $this->internalPath = $internalPath; |
|
101 | + $this->data = $data; |
|
102 | + $this->mount = $mount; |
|
103 | + $this->owner = $owner; |
|
104 | + $this->rawSize = $this->data['size'] ?? 0; |
|
105 | + } |
|
106 | + |
|
107 | + public function offsetSet($offset, $value) { |
|
108 | + $this->data[$offset] = $value; |
|
109 | + } |
|
110 | + |
|
111 | + public function offsetExists($offset) { |
|
112 | + return isset($this->data[$offset]); |
|
113 | + } |
|
114 | + |
|
115 | + public function offsetUnset($offset) { |
|
116 | + unset($this->data[$offset]); |
|
117 | + } |
|
118 | + |
|
119 | + public function offsetGet($offset) { |
|
120 | + if ($offset === 'type') { |
|
121 | + return $this->getType(); |
|
122 | + } elseif ($offset === 'etag') { |
|
123 | + return $this->getEtag(); |
|
124 | + } elseif ($offset === 'size') { |
|
125 | + return $this->getSize(); |
|
126 | + } elseif ($offset === 'mtime') { |
|
127 | + return $this->getMTime(); |
|
128 | + } elseif ($offset === 'permissions') { |
|
129 | + return $this->getPermissions(); |
|
130 | + } elseif (isset($this->data[$offset])) { |
|
131 | + return $this->data[$offset]; |
|
132 | + } else { |
|
133 | + return null; |
|
134 | + } |
|
135 | + } |
|
136 | + |
|
137 | + /** |
|
138 | + * @return string |
|
139 | + */ |
|
140 | + public function getPath() { |
|
141 | + return $this->path; |
|
142 | + } |
|
143 | + |
|
144 | + /** |
|
145 | + * @return \OCP\Files\Storage |
|
146 | + */ |
|
147 | + public function getStorage() { |
|
148 | + return $this->storage; |
|
149 | + } |
|
150 | + |
|
151 | + /** |
|
152 | + * @return string |
|
153 | + */ |
|
154 | + public function getInternalPath() { |
|
155 | + return $this->internalPath; |
|
156 | + } |
|
157 | + |
|
158 | + /** |
|
159 | + * Get FileInfo ID or null in case of part file |
|
160 | + * |
|
161 | + * @return int|null |
|
162 | + */ |
|
163 | + public function getId() { |
|
164 | + return isset($this->data['fileid']) ? (int) $this->data['fileid'] : null; |
|
165 | + } |
|
166 | + |
|
167 | + /** |
|
168 | + * @return string |
|
169 | + */ |
|
170 | + public function getMimetype() { |
|
171 | + return $this->data['mimetype']; |
|
172 | + } |
|
173 | + |
|
174 | + /** |
|
175 | + * @return string |
|
176 | + */ |
|
177 | + public function getMimePart() { |
|
178 | + return $this->data['mimepart']; |
|
179 | + } |
|
180 | + |
|
181 | + /** |
|
182 | + * @return string |
|
183 | + */ |
|
184 | + public function getName() { |
|
185 | + return isset($this->data['name']) ? $this->data['name'] : basename($this->getPath()); |
|
186 | + } |
|
187 | + |
|
188 | + /** |
|
189 | + * @return string |
|
190 | + */ |
|
191 | + public function getEtag() { |
|
192 | + $this->updateEntryfromSubMounts(); |
|
193 | + if (count($this->childEtags) > 0) { |
|
194 | + $combinedEtag = $this->data['etag'] . '::' . implode('::', $this->childEtags); |
|
195 | + return md5($combinedEtag); |
|
196 | + } else { |
|
197 | + return $this->data['etag']; |
|
198 | + } |
|
199 | + } |
|
200 | + |
|
201 | + /** |
|
202 | + * @return int |
|
203 | + */ |
|
204 | + public function getSize($includeMounts = true) { |
|
205 | + if ($includeMounts) { |
|
206 | + $this->updateEntryfromSubMounts(); |
|
207 | + return isset($this->data['size']) ? 0 + $this->data['size'] : 0; |
|
208 | + } else { |
|
209 | + return $this->rawSize; |
|
210 | + } |
|
211 | + } |
|
212 | + |
|
213 | + /** |
|
214 | + * @return int |
|
215 | + */ |
|
216 | + public function getMTime() { |
|
217 | + $this->updateEntryfromSubMounts(); |
|
218 | + return (int) $this->data['mtime']; |
|
219 | + } |
|
220 | + |
|
221 | + /** |
|
222 | + * @return bool |
|
223 | + */ |
|
224 | + public function isEncrypted() { |
|
225 | + return $this->data['encrypted']; |
|
226 | + } |
|
227 | + |
|
228 | + /** |
|
229 | + * Return the currently version used for the HMAC in the encryption app |
|
230 | + * |
|
231 | + * @return int |
|
232 | + */ |
|
233 | + public function getEncryptedVersion() { |
|
234 | + return isset($this->data['encryptedVersion']) ? (int) $this->data['encryptedVersion'] : 1; |
|
235 | + } |
|
236 | + |
|
237 | + /** |
|
238 | + * @return int |
|
239 | + */ |
|
240 | + public function getPermissions() { |
|
241 | + $perms = (int) $this->data['permissions']; |
|
242 | + if (\OCP\Util::isSharingDisabledForUser() || ($this->isShared() && !\OC\Share\Share::isResharingAllowed())) { |
|
243 | + $perms = $perms & ~\OCP\Constants::PERMISSION_SHARE; |
|
244 | + } |
|
245 | + return (int) $perms; |
|
246 | + } |
|
247 | + |
|
248 | + /** |
|
249 | + * @return string \OCP\Files\FileInfo::TYPE_FILE|\OCP\Files\FileInfo::TYPE_FOLDER |
|
250 | + */ |
|
251 | + public function getType() { |
|
252 | + if (!isset($this->data['type'])) { |
|
253 | + $this->data['type'] = ($this->getMimetype() === 'httpd/unix-directory') ? self::TYPE_FOLDER : self::TYPE_FILE; |
|
254 | + } |
|
255 | + return $this->data['type']; |
|
256 | + } |
|
257 | + |
|
258 | + public function getData() { |
|
259 | + return $this->data; |
|
260 | + } |
|
261 | + |
|
262 | + /** |
|
263 | + * @param int $permissions |
|
264 | + * @return bool |
|
265 | + */ |
|
266 | + protected function checkPermissions($permissions) { |
|
267 | + return ($this->getPermissions() & $permissions) === $permissions; |
|
268 | + } |
|
269 | + |
|
270 | + /** |
|
271 | + * @return bool |
|
272 | + */ |
|
273 | + public function isReadable() { |
|
274 | + return $this->checkPermissions(\OCP\Constants::PERMISSION_READ); |
|
275 | + } |
|
276 | + |
|
277 | + /** |
|
278 | + * @return bool |
|
279 | + */ |
|
280 | + public function isUpdateable() { |
|
281 | + return $this->checkPermissions(\OCP\Constants::PERMISSION_UPDATE); |
|
282 | + } |
|
283 | + |
|
284 | + /** |
|
285 | + * Check whether new files or folders can be created inside this folder |
|
286 | + * |
|
287 | + * @return bool |
|
288 | + */ |
|
289 | + public function isCreatable() { |
|
290 | + return $this->checkPermissions(\OCP\Constants::PERMISSION_CREATE); |
|
291 | + } |
|
292 | + |
|
293 | + /** |
|
294 | + * @return bool |
|
295 | + */ |
|
296 | + public function isDeletable() { |
|
297 | + return $this->checkPermissions(\OCP\Constants::PERMISSION_DELETE); |
|
298 | + } |
|
299 | + |
|
300 | + /** |
|
301 | + * @return bool |
|
302 | + */ |
|
303 | + public function isShareable() { |
|
304 | + return $this->checkPermissions(\OCP\Constants::PERMISSION_SHARE); |
|
305 | + } |
|
306 | + |
|
307 | + /** |
|
308 | + * Check if a file or folder is shared |
|
309 | + * |
|
310 | + * @return bool |
|
311 | + */ |
|
312 | + public function isShared() { |
|
313 | + $sid = $this->getStorage()->getId(); |
|
314 | + if (!is_null($sid)) { |
|
315 | + $sid = explode(':', $sid); |
|
316 | + return ($sid[0] === 'shared'); |
|
317 | + } |
|
318 | + |
|
319 | + return false; |
|
320 | + } |
|
321 | + |
|
322 | + public function isMounted() { |
|
323 | + $storage = $this->getStorage(); |
|
324 | + if ($storage->instanceOfStorage('\OCP\Files\IHomeStorage')) { |
|
325 | + return false; |
|
326 | + } |
|
327 | + $sid = $storage->getId(); |
|
328 | + if (!is_null($sid)) { |
|
329 | + $sid = explode(':', $sid); |
|
330 | + return ($sid[0] !== 'home' and $sid[0] !== 'shared'); |
|
331 | + } |
|
332 | + |
|
333 | + return false; |
|
334 | + } |
|
335 | + |
|
336 | + /** |
|
337 | + * Get the mountpoint the file belongs to |
|
338 | + * |
|
339 | + * @return \OCP\Files\Mount\IMountPoint |
|
340 | + */ |
|
341 | + public function getMountPoint() { |
|
342 | + return $this->mount; |
|
343 | + } |
|
344 | + |
|
345 | + /** |
|
346 | + * Get the owner of the file |
|
347 | + * |
|
348 | + * @return \OCP\IUser |
|
349 | + */ |
|
350 | + public function getOwner() { |
|
351 | + return $this->owner; |
|
352 | + } |
|
353 | + |
|
354 | + /** |
|
355 | + * @param IMountPoint[] $mounts |
|
356 | + */ |
|
357 | + public function setSubMounts(array $mounts) { |
|
358 | + $this->subMounts = $mounts; |
|
359 | + } |
|
360 | + |
|
361 | + private function updateEntryfromSubMounts() { |
|
362 | + if ($this->subMountsUsed) { |
|
363 | + return; |
|
364 | + } |
|
365 | + $this->subMountsUsed = true; |
|
366 | + foreach ($this->subMounts as $mount) { |
|
367 | + $subStorage = $mount->getStorage(); |
|
368 | + if ($subStorage) { |
|
369 | + $subCache = $subStorage->getCache(''); |
|
370 | + $rootEntry = $subCache->get(''); |
|
371 | + $this->addSubEntry($rootEntry, $mount->getMountPoint()); |
|
372 | + } |
|
373 | + } |
|
374 | + } |
|
375 | + |
|
376 | + /** |
|
377 | + * Add a cache entry which is the child of this folder |
|
378 | + * |
|
379 | + * Sets the size, etag and size to for cross-storage childs |
|
380 | + * |
|
381 | + * @param array|ICacheEntry $data cache entry for the child |
|
382 | + * @param string $entryPath full path of the child entry |
|
383 | + */ |
|
384 | + public function addSubEntry($data, $entryPath) { |
|
385 | + $this->data['size'] += isset($data['size']) ? $data['size'] : 0; |
|
386 | + if (isset($data['mtime'])) { |
|
387 | + $this->data['mtime'] = max($this->data['mtime'], $data['mtime']); |
|
388 | + } |
|
389 | + if (isset($data['etag'])) { |
|
390 | + // prefix the etag with the relative path of the subentry to propagate etag on mount moves |
|
391 | + $relativeEntryPath = substr($entryPath, strlen($this->getPath())); |
|
392 | + // attach the permissions to propagate etag on permision changes of submounts |
|
393 | + $permissions = isset($data['permissions']) ? $data['permissions'] : 0; |
|
394 | + $this->childEtags[] = $relativeEntryPath . '/' . $data['etag'] . $permissions; |
|
395 | + } |
|
396 | + } |
|
397 | + |
|
398 | + /** |
|
399 | + * @inheritdoc |
|
400 | + */ |
|
401 | + public function getChecksum() { |
|
402 | + return $this->data['checksum']; |
|
403 | + } |
|
404 | + |
|
405 | + public function getExtension(): string { |
|
406 | + return pathinfo($this->getName(), PATHINFO_EXTENSION); |
|
407 | + } |
|
408 | + |
|
409 | + public function getCreationTime(): int { |
|
410 | + return (int) $this->data['creation_time']; |
|
411 | + } |
|
412 | + |
|
413 | + public function getUploadTime(): int { |
|
414 | + return (int) $this->data['upload_time']; |
|
415 | + } |
|
416 | 416 | } |
@@ -7,23 +7,23 @@ |
||
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 | } |
@@ -33,87 +33,87 @@ |
||
33 | 33 | |
34 | 34 | class CalDAVRemoveEmptyValue implements IRepairStep { |
35 | 35 | |
36 | - /** @var IDBConnection */ |
|
37 | - private $db; |
|
38 | - |
|
39 | - /** @var CalDavBackend */ |
|
40 | - private $calDavBackend; |
|
41 | - |
|
42 | - /** @var ILogger */ |
|
43 | - private $logger; |
|
44 | - |
|
45 | - /** |
|
46 | - * @param IDBConnection $db |
|
47 | - * @param CalDavBackend $calDavBackend |
|
48 | - * @param ILogger $logger |
|
49 | - */ |
|
50 | - public function __construct(IDBConnection $db, CalDavBackend $calDavBackend, ILogger $logger) { |
|
51 | - $this->db = $db; |
|
52 | - $this->calDavBackend = $calDavBackend; |
|
53 | - $this->logger = $logger; |
|
54 | - } |
|
55 | - |
|
56 | - public function getName() { |
|
57 | - return 'Fix broken values of calendar objects'; |
|
58 | - } |
|
59 | - |
|
60 | - public function run(IOutput $output) { |
|
61 | - $pattern = ';VALUE=:'; |
|
62 | - $count = $warnings = 0; |
|
63 | - |
|
64 | - $objects = $this->getInvalidObjects($pattern); |
|
65 | - |
|
66 | - $output->startProgress(count($objects)); |
|
67 | - foreach ($objects as $row) { |
|
68 | - $calObject = $this->calDavBackend->getCalendarObject((int)$row['calendarid'], $row['uri']); |
|
69 | - $data = preg_replace('/' . $pattern . '/', ':', $calObject['calendardata']); |
|
70 | - |
|
71 | - if ($data !== $calObject['calendardata']) { |
|
72 | - $output->advance(); |
|
73 | - |
|
74 | - try { |
|
75 | - $this->calDavBackend->getDenormalizedData($data); |
|
76 | - } catch (InvalidDataException $e) { |
|
77 | - $this->logger->info('Calendar object for calendar {cal} with uri {uri} still invalid', [ |
|
78 | - 'app' => 'dav', |
|
79 | - 'cal' => (int)$row['calendarid'], |
|
80 | - 'uri' => $row['uri'], |
|
81 | - ]); |
|
82 | - $warnings++; |
|
83 | - continue; |
|
84 | - } |
|
85 | - |
|
86 | - $this->calDavBackend->updateCalendarObject((int)$row['calendarid'], $row['uri'], $data); |
|
87 | - $count++; |
|
88 | - } |
|
89 | - } |
|
90 | - $output->finishProgress(); |
|
91 | - |
|
92 | - if ($warnings > 0) { |
|
93 | - $output->warning(sprintf('%d events could not be updated, see log file for more information', $warnings)); |
|
94 | - } |
|
95 | - if ($count > 0) { |
|
96 | - $output->info(sprintf('Updated %d events', $count)); |
|
97 | - } |
|
98 | - } |
|
99 | - |
|
100 | - protected function getInvalidObjects($pattern) { |
|
101 | - $query = $this->db->getQueryBuilder(); |
|
102 | - $query->select(['calendarid', 'uri']) |
|
103 | - ->from('calendarobjects') |
|
104 | - ->where($query->expr()->like( |
|
105 | - 'calendardata', |
|
106 | - $query->createNamedParameter( |
|
107 | - '%' . $this->db->escapeLikeParameter($pattern) . '%', |
|
108 | - IQueryBuilder::PARAM_STR |
|
109 | - ), |
|
110 | - IQueryBuilder::PARAM_STR |
|
111 | - )); |
|
112 | - |
|
113 | - $result = $query->execute(); |
|
114 | - $rows = $result->fetchAll(); |
|
115 | - $result->closeCursor(); |
|
116 | - |
|
117 | - return $rows; |
|
118 | - } |
|
36 | + /** @var IDBConnection */ |
|
37 | + private $db; |
|
38 | + |
|
39 | + /** @var CalDavBackend */ |
|
40 | + private $calDavBackend; |
|
41 | + |
|
42 | + /** @var ILogger */ |
|
43 | + private $logger; |
|
44 | + |
|
45 | + /** |
|
46 | + * @param IDBConnection $db |
|
47 | + * @param CalDavBackend $calDavBackend |
|
48 | + * @param ILogger $logger |
|
49 | + */ |
|
50 | + public function __construct(IDBConnection $db, CalDavBackend $calDavBackend, ILogger $logger) { |
|
51 | + $this->db = $db; |
|
52 | + $this->calDavBackend = $calDavBackend; |
|
53 | + $this->logger = $logger; |
|
54 | + } |
|
55 | + |
|
56 | + public function getName() { |
|
57 | + return 'Fix broken values of calendar objects'; |
|
58 | + } |
|
59 | + |
|
60 | + public function run(IOutput $output) { |
|
61 | + $pattern = ';VALUE=:'; |
|
62 | + $count = $warnings = 0; |
|
63 | + |
|
64 | + $objects = $this->getInvalidObjects($pattern); |
|
65 | + |
|
66 | + $output->startProgress(count($objects)); |
|
67 | + foreach ($objects as $row) { |
|
68 | + $calObject = $this->calDavBackend->getCalendarObject((int)$row['calendarid'], $row['uri']); |
|
69 | + $data = preg_replace('/' . $pattern . '/', ':', $calObject['calendardata']); |
|
70 | + |
|
71 | + if ($data !== $calObject['calendardata']) { |
|
72 | + $output->advance(); |
|
73 | + |
|
74 | + try { |
|
75 | + $this->calDavBackend->getDenormalizedData($data); |
|
76 | + } catch (InvalidDataException $e) { |
|
77 | + $this->logger->info('Calendar object for calendar {cal} with uri {uri} still invalid', [ |
|
78 | + 'app' => 'dav', |
|
79 | + 'cal' => (int)$row['calendarid'], |
|
80 | + 'uri' => $row['uri'], |
|
81 | + ]); |
|
82 | + $warnings++; |
|
83 | + continue; |
|
84 | + } |
|
85 | + |
|
86 | + $this->calDavBackend->updateCalendarObject((int)$row['calendarid'], $row['uri'], $data); |
|
87 | + $count++; |
|
88 | + } |
|
89 | + } |
|
90 | + $output->finishProgress(); |
|
91 | + |
|
92 | + if ($warnings > 0) { |
|
93 | + $output->warning(sprintf('%d events could not be updated, see log file for more information', $warnings)); |
|
94 | + } |
|
95 | + if ($count > 0) { |
|
96 | + $output->info(sprintf('Updated %d events', $count)); |
|
97 | + } |
|
98 | + } |
|
99 | + |
|
100 | + protected function getInvalidObjects($pattern) { |
|
101 | + $query = $this->db->getQueryBuilder(); |
|
102 | + $query->select(['calendarid', 'uri']) |
|
103 | + ->from('calendarobjects') |
|
104 | + ->where($query->expr()->like( |
|
105 | + 'calendardata', |
|
106 | + $query->createNamedParameter( |
|
107 | + '%' . $this->db->escapeLikeParameter($pattern) . '%', |
|
108 | + IQueryBuilder::PARAM_STR |
|
109 | + ), |
|
110 | + IQueryBuilder::PARAM_STR |
|
111 | + )); |
|
112 | + |
|
113 | + $result = $query->execute(); |
|
114 | + $rows = $result->fetchAll(); |
|
115 | + $result->closeCursor(); |
|
116 | + |
|
117 | + return $rows; |
|
118 | + } |
|
119 | 119 | } |
@@ -65,8 +65,8 @@ discard block |
||
65 | 65 | |
66 | 66 | $output->startProgress(count($objects)); |
67 | 67 | foreach ($objects as $row) { |
68 | - $calObject = $this->calDavBackend->getCalendarObject((int)$row['calendarid'], $row['uri']); |
|
69 | - $data = preg_replace('/' . $pattern . '/', ':', $calObject['calendardata']); |
|
68 | + $calObject = $this->calDavBackend->getCalendarObject((int) $row['calendarid'], $row['uri']); |
|
69 | + $data = preg_replace('/'.$pattern.'/', ':', $calObject['calendardata']); |
|
70 | 70 | |
71 | 71 | if ($data !== $calObject['calendardata']) { |
72 | 72 | $output->advance(); |
@@ -76,14 +76,14 @@ discard block |
||
76 | 76 | } catch (InvalidDataException $e) { |
77 | 77 | $this->logger->info('Calendar object for calendar {cal} with uri {uri} still invalid', [ |
78 | 78 | 'app' => 'dav', |
79 | - 'cal' => (int)$row['calendarid'], |
|
79 | + 'cal' => (int) $row['calendarid'], |
|
80 | 80 | 'uri' => $row['uri'], |
81 | 81 | ]); |
82 | 82 | $warnings++; |
83 | 83 | continue; |
84 | 84 | } |
85 | 85 | |
86 | - $this->calDavBackend->updateCalendarObject((int)$row['calendarid'], $row['uri'], $data); |
|
86 | + $this->calDavBackend->updateCalendarObject((int) $row['calendarid'], $row['uri'], $data); |
|
87 | 87 | $count++; |
88 | 88 | } |
89 | 89 | } |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | ->where($query->expr()->like( |
105 | 105 | 'calendardata', |
106 | 106 | $query->createNamedParameter( |
107 | - '%' . $this->db->escapeLikeParameter($pattern) . '%', |
|
107 | + '%'.$this->db->escapeLikeParameter($pattern).'%', |
|
108 | 108 | IQueryBuilder::PARAM_STR |
109 | 109 | ), |
110 | 110 | IQueryBuilder::PARAM_STR |
@@ -39,7 +39,7 @@ |
||
39 | 39 | $reader->parseInnerTree(); |
40 | 40 | |
41 | 41 | if (!is_string($componentName)) { |
42 | - throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}comp-filter requires a valid name attribute'); |
|
42 | + throw new BadRequest('The {'.SearchPlugin::NS_Nextcloud.'}comp-filter requires a valid name attribute'); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | return $componentName; |
@@ -27,21 +27,21 @@ |
||
27 | 27 | |
28 | 28 | class CompFilter implements XmlDeserializable { |
29 | 29 | |
30 | - /** |
|
31 | - * @param Reader $reader |
|
32 | - * @throws BadRequest |
|
33 | - * @return string |
|
34 | - */ |
|
35 | - public static function xmlDeserialize(Reader $reader) { |
|
36 | - $att = $reader->parseAttributes(); |
|
37 | - $componentName = $att['name']; |
|
30 | + /** |
|
31 | + * @param Reader $reader |
|
32 | + * @throws BadRequest |
|
33 | + * @return string |
|
34 | + */ |
|
35 | + public static function xmlDeserialize(Reader $reader) { |
|
36 | + $att = $reader->parseAttributes(); |
|
37 | + $componentName = $att['name']; |
|
38 | 38 | |
39 | - $reader->parseInnerTree(); |
|
39 | + $reader->parseInnerTree(); |
|
40 | 40 | |
41 | - if (!is_string($componentName)) { |
|
42 | - throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}comp-filter requires a valid name attribute'); |
|
43 | - } |
|
41 | + if (!is_string($componentName)) { |
|
42 | + throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}comp-filter requires a valid name attribute'); |
|
43 | + } |
|
44 | 44 | |
45 | - return $componentName; |
|
46 | - } |
|
45 | + return $componentName; |
|
46 | + } |
|
47 | 47 | } |
@@ -39,7 +39,7 @@ |
||
39 | 39 | $reader->parseInnerTree(); |
40 | 40 | |
41 | 41 | if (!is_string($componentName)) { |
42 | - throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}prop-filter requires a valid name attribute'); |
|
42 | + throw new BadRequest('The {'.SearchPlugin::NS_Nextcloud.'}prop-filter requires a valid name attribute'); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | return $componentName; |
@@ -27,21 +27,21 @@ |
||
27 | 27 | |
28 | 28 | class PropFilter implements XmlDeserializable { |
29 | 29 | |
30 | - /** |
|
31 | - * @param Reader $reader |
|
32 | - * @throws BadRequest |
|
33 | - * @return string |
|
34 | - */ |
|
35 | - public static function xmlDeserialize(Reader $reader) { |
|
36 | - $att = $reader->parseAttributes(); |
|
37 | - $componentName = $att['name']; |
|
30 | + /** |
|
31 | + * @param Reader $reader |
|
32 | + * @throws BadRequest |
|
33 | + * @return string |
|
34 | + */ |
|
35 | + public static function xmlDeserialize(Reader $reader) { |
|
36 | + $att = $reader->parseAttributes(); |
|
37 | + $componentName = $att['name']; |
|
38 | 38 | |
39 | - $reader->parseInnerTree(); |
|
39 | + $reader->parseInnerTree(); |
|
40 | 40 | |
41 | - if (!is_string($componentName)) { |
|
42 | - throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}prop-filter requires a valid name attribute'); |
|
43 | - } |
|
41 | + if (!is_string($componentName)) { |
|
42 | + throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}prop-filter requires a valid name attribute'); |
|
43 | + } |
|
44 | 44 | |
45 | - return $componentName; |
|
46 | - } |
|
45 | + return $componentName; |
|
46 | + } |
|
47 | 47 | } |
@@ -40,11 +40,11 @@ |
||
40 | 40 | $reader->parseInnerTree(); |
41 | 41 | |
42 | 42 | if (!is_string($property)) { |
43 | - throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}param-filter requires a valid property attribute'); |
|
43 | + throw new BadRequest('The {'.SearchPlugin::NS_Nextcloud.'}param-filter requires a valid property attribute'); |
|
44 | 44 | |
45 | 45 | } |
46 | 46 | if (!is_string($parameter)) { |
47 | - throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}param-filter requires a valid parameter attribute'); |
|
47 | + throw new BadRequest('The {'.SearchPlugin::NS_Nextcloud.'}param-filter requires a valid parameter attribute'); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | return [ |
@@ -27,28 +27,28 @@ |
||
27 | 27 | |
28 | 28 | class ParamFilter implements XmlDeserializable { |
29 | 29 | |
30 | - /** |
|
31 | - * @param Reader $reader |
|
32 | - * @throws BadRequest |
|
33 | - * @return string |
|
34 | - */ |
|
35 | - public static function xmlDeserialize(Reader $reader) { |
|
36 | - $att = $reader->parseAttributes(); |
|
37 | - $property = $att['property']; |
|
38 | - $parameter = $att['name']; |
|
30 | + /** |
|
31 | + * @param Reader $reader |
|
32 | + * @throws BadRequest |
|
33 | + * @return string |
|
34 | + */ |
|
35 | + public static function xmlDeserialize(Reader $reader) { |
|
36 | + $att = $reader->parseAttributes(); |
|
37 | + $property = $att['property']; |
|
38 | + $parameter = $att['name']; |
|
39 | 39 | |
40 | - $reader->parseInnerTree(); |
|
40 | + $reader->parseInnerTree(); |
|
41 | 41 | |
42 | - if (!is_string($property)) { |
|
43 | - throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}param-filter requires a valid property attribute'); |
|
44 | - } |
|
45 | - if (!is_string($parameter)) { |
|
46 | - throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}param-filter requires a valid parameter attribute'); |
|
47 | - } |
|
42 | + if (!is_string($property)) { |
|
43 | + throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}param-filter requires a valid property attribute'); |
|
44 | + } |
|
45 | + if (!is_string($parameter)) { |
|
46 | + throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}param-filter requires a valid parameter attribute'); |
|
47 | + } |
|
48 | 48 | |
49 | - return [ |
|
50 | - 'property' => $property, |
|
51 | - 'parameter' => $parameter, |
|
52 | - ]; |
|
53 | - } |
|
49 | + return [ |
|
50 | + 'property' => $property, |
|
51 | + 'parameter' => $parameter, |
|
52 | + ]; |
|
53 | + } |
|
54 | 54 | } |