@@ -26,27 +26,27 @@ |
||
26 | 26 | |
27 | 27 | class RequestTime extends Controller { |
28 | 28 | |
29 | - /** |
|
30 | - * @NoAdminRequired |
|
31 | - * |
|
32 | - * @param string $search |
|
33 | - * @return JSONResponse |
|
34 | - */ |
|
35 | - public function getTimezones($search = '') { |
|
36 | - $timezones = \DateTimeZone::listIdentifiers(); |
|
29 | + /** |
|
30 | + * @NoAdminRequired |
|
31 | + * |
|
32 | + * @param string $search |
|
33 | + * @return JSONResponse |
|
34 | + */ |
|
35 | + public function getTimezones($search = '') { |
|
36 | + $timezones = \DateTimeZone::listIdentifiers(); |
|
37 | 37 | |
38 | - if ($search !== '') { |
|
39 | - $timezones = array_filter($timezones, function ($timezone) use ($search) { |
|
40 | - return stripos($timezone, $search) !== false; |
|
41 | - }); |
|
42 | - } |
|
38 | + if ($search !== '') { |
|
39 | + $timezones = array_filter($timezones, function ($timezone) use ($search) { |
|
40 | + return stripos($timezone, $search) !== false; |
|
41 | + }); |
|
42 | + } |
|
43 | 43 | |
44 | - $timezones = array_slice($timezones, 0, 10); |
|
44 | + $timezones = array_slice($timezones, 0, 10); |
|
45 | 45 | |
46 | - $response = []; |
|
47 | - foreach ($timezones as $timezone) { |
|
48 | - $response[$timezone] = $timezone; |
|
49 | - } |
|
50 | - return new JSONResponse($response); |
|
51 | - } |
|
46 | + $response = []; |
|
47 | + foreach ($timezones as $timezone) { |
|
48 | + $response[$timezone] = $timezone; |
|
49 | + } |
|
50 | + return new JSONResponse($response); |
|
51 | + } |
|
52 | 52 | } |
@@ -36,7 +36,7 @@ |
||
36 | 36 | $timezones = \DateTimeZone::listIdentifiers(); |
37 | 37 | |
38 | 38 | if ($search !== '') { |
39 | - $timezones = array_filter($timezones, function ($timezone) use ($search) { |
|
39 | + $timezones = array_filter($timezones, function($timezone) use ($search) { |
|
40 | 40 | return stripos($timezone, $search) !== false; |
41 | 41 | }); |
42 | 42 | } |
@@ -164,7 +164,7 @@ |
||
164 | 164 | * @since 14.0.0 |
165 | 165 | */ |
166 | 166 | public function render(): string { |
167 | - $detailContent = ($this->detail !== '') ? ' <span class="download-size">(' . Util::sanitizeHTML($this->detail) . ')</span>' : ''; |
|
167 | + $detailContent = ($this->detail !== '') ? ' <span class="download-size">('.Util::sanitizeHTML($this->detail).')</span>' : ''; |
|
168 | 168 | return sprintf( |
169 | 169 | '<li id="%s"><a href="%s"><span class="icon %s"></span>%s %s</a></li>', |
170 | 170 | Util::sanitizeHTML($this->id), Util::sanitizeHTML($this->link), Util::sanitizeHTML($this->icon), Util::sanitizeHTML($this->label), $detailContent |
@@ -31,93 +31,93 @@ |
||
31 | 31 | * @since 14.0.0 |
32 | 32 | */ |
33 | 33 | class SimpleMenuAction implements IMenuAction { |
34 | - /** @var string */ |
|
35 | - private $id; |
|
34 | + /** @var string */ |
|
35 | + private $id; |
|
36 | 36 | |
37 | - /** @var string */ |
|
38 | - private $label; |
|
37 | + /** @var string */ |
|
38 | + private $label; |
|
39 | 39 | |
40 | - /** @var string */ |
|
41 | - private $icon; |
|
40 | + /** @var string */ |
|
41 | + private $icon; |
|
42 | 42 | |
43 | - /** @var string */ |
|
44 | - private $link; |
|
43 | + /** @var string */ |
|
44 | + private $link; |
|
45 | 45 | |
46 | - /** @var int */ |
|
47 | - private $priority; |
|
46 | + /** @var int */ |
|
47 | + private $priority; |
|
48 | 48 | |
49 | - /** @var string */ |
|
50 | - private $detail; |
|
49 | + /** @var string */ |
|
50 | + private $detail; |
|
51 | 51 | |
52 | - /** |
|
53 | - * SimpleMenuAction constructor. |
|
54 | - * |
|
55 | - * @param string $id |
|
56 | - * @param string $label |
|
57 | - * @param string $icon |
|
58 | - * @param string $link |
|
59 | - * @param int $priority |
|
60 | - * @param string $detail |
|
61 | - * @since 14.0.0 |
|
62 | - */ |
|
63 | - public function __construct(string $id, string $label, string $icon, string $link = '', int $priority = 100, string $detail = '') { |
|
64 | - $this->id = $id; |
|
65 | - $this->label = $label; |
|
66 | - $this->icon = $icon; |
|
67 | - $this->link = $link; |
|
68 | - $this->priority = $priority; |
|
69 | - $this->detail = $detail; |
|
70 | - } |
|
52 | + /** |
|
53 | + * SimpleMenuAction constructor. |
|
54 | + * |
|
55 | + * @param string $id |
|
56 | + * @param string $label |
|
57 | + * @param string $icon |
|
58 | + * @param string $link |
|
59 | + * @param int $priority |
|
60 | + * @param string $detail |
|
61 | + * @since 14.0.0 |
|
62 | + */ |
|
63 | + public function __construct(string $id, string $label, string $icon, string $link = '', int $priority = 100, string $detail = '') { |
|
64 | + $this->id = $id; |
|
65 | + $this->label = $label; |
|
66 | + $this->icon = $icon; |
|
67 | + $this->link = $link; |
|
68 | + $this->priority = $priority; |
|
69 | + $this->detail = $detail; |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * @return string |
|
74 | - * @since 14.0.0 |
|
75 | - */ |
|
76 | - public function getId(): string { |
|
77 | - return $this->id; |
|
78 | - } |
|
72 | + /** |
|
73 | + * @return string |
|
74 | + * @since 14.0.0 |
|
75 | + */ |
|
76 | + public function getId(): string { |
|
77 | + return $this->id; |
|
78 | + } |
|
79 | 79 | |
80 | - /** |
|
81 | - * @return string |
|
82 | - * @since 14.0.0 |
|
83 | - */ |
|
84 | - public function getLabel(): string { |
|
85 | - return $this->label; |
|
86 | - } |
|
80 | + /** |
|
81 | + * @return string |
|
82 | + * @since 14.0.0 |
|
83 | + */ |
|
84 | + public function getLabel(): string { |
|
85 | + return $this->label; |
|
86 | + } |
|
87 | 87 | |
88 | - /** |
|
89 | - * @return string |
|
90 | - * @since 14.0.0 |
|
91 | - */ |
|
92 | - public function getIcon(): string { |
|
93 | - return $this->icon; |
|
94 | - } |
|
88 | + /** |
|
89 | + * @return string |
|
90 | + * @since 14.0.0 |
|
91 | + */ |
|
92 | + public function getIcon(): string { |
|
93 | + return $this->icon; |
|
94 | + } |
|
95 | 95 | |
96 | - /** |
|
97 | - * @return string |
|
98 | - * @since 14.0.0 |
|
99 | - */ |
|
100 | - public function getLink(): string { |
|
101 | - return $this->link; |
|
102 | - } |
|
96 | + /** |
|
97 | + * @return string |
|
98 | + * @since 14.0.0 |
|
99 | + */ |
|
100 | + public function getLink(): string { |
|
101 | + return $this->link; |
|
102 | + } |
|
103 | 103 | |
104 | - /** |
|
105 | - * @return int |
|
106 | - * @since 14.0.0 |
|
107 | - */ |
|
108 | - public function getPriority(): int { |
|
109 | - return $this->priority; |
|
110 | - } |
|
104 | + /** |
|
105 | + * @return int |
|
106 | + * @since 14.0.0 |
|
107 | + */ |
|
108 | + public function getPriority(): int { |
|
109 | + return $this->priority; |
|
110 | + } |
|
111 | 111 | |
112 | - /** |
|
113 | - * @return string |
|
114 | - * @since 14.0.0 |
|
115 | - */ |
|
116 | - public function render(): string { |
|
117 | - $detailContent = ($this->detail !== '') ? ' <span class="download-size">(' . Util::sanitizeHTML($this->detail) . ')</span>' : ''; |
|
118 | - return sprintf( |
|
119 | - '<li id="%s"><a href="%s"><span class="icon %s"></span>%s %s</a></li>', |
|
120 | - Util::sanitizeHTML($this->id), Util::sanitizeHTML($this->link), Util::sanitizeHTML($this->icon), Util::sanitizeHTML($this->label), $detailContent |
|
121 | - ); |
|
122 | - } |
|
112 | + /** |
|
113 | + * @return string |
|
114 | + * @since 14.0.0 |
|
115 | + */ |
|
116 | + public function render(): string { |
|
117 | + $detailContent = ($this->detail !== '') ? ' <span class="download-size">(' . Util::sanitizeHTML($this->detail) . ')</span>' : ''; |
|
118 | + return sprintf( |
|
119 | + '<li id="%s"><a href="%s"><span class="icon %s"></span>%s %s</a></li>', |
|
120 | + Util::sanitizeHTML($this->id), Util::sanitizeHTML($this->link), Util::sanitizeHTML($this->icon), Util::sanitizeHTML($this->label), $detailContent |
|
121 | + ); |
|
122 | + } |
|
123 | 123 | } |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | |
85 | 85 | // Get all mount point owners |
86 | 86 | $cache = $this->mountCollection->getMountCache(); |
87 | - $mounts = $cache->getMountsForFileId((int)$event->getComment()->getObjectId()); |
|
87 | + $mounts = $cache->getMountsForFileId((int) $event->getComment()->getObjectId()); |
|
88 | 88 | if (empty($mounts)) { |
89 | 89 | return; |
90 | 90 | } |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | foreach ($mounts as $mount) { |
94 | 94 | $owner = $mount->getUser()->getUID(); |
95 | 95 | $ownerFolder = $this->rootFolder->getUserFolder($owner); |
96 | - $nodes = $ownerFolder->getById((int)$event->getComment()->getObjectId()); |
|
96 | + $nodes = $ownerFolder->getById((int) $event->getComment()->getObjectId()); |
|
97 | 97 | if (!empty($nodes)) { |
98 | 98 | /** @var Node $node */ |
99 | 99 | $node = array_shift($nodes); |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | foreach ($users as $user => $path) { |
122 | 122 | // numerical user ids end up as integers from array keys, but string |
123 | 123 | // is required |
124 | - $activity->setAffectedUser((string)$user); |
|
124 | + $activity->setAffectedUser((string) $user); |
|
125 | 125 | |
126 | 126 | $activity->setSubject('add_comment_subject', [ |
127 | 127 | 'actor' => $actor, |
@@ -35,88 +35,88 @@ |
||
35 | 35 | use OCP\Share\IShareHelper; |
36 | 36 | |
37 | 37 | class Listener { |
38 | - protected IManager $activityManager; |
|
39 | - protected IUserSession $session; |
|
40 | - protected IAppManager $appManager; |
|
41 | - protected IMountProviderCollection $mountCollection; |
|
42 | - protected IRootFolder $rootFolder; |
|
43 | - protected IShareHelper $shareHelper; |
|
38 | + protected IManager $activityManager; |
|
39 | + protected IUserSession $session; |
|
40 | + protected IAppManager $appManager; |
|
41 | + protected IMountProviderCollection $mountCollection; |
|
42 | + protected IRootFolder $rootFolder; |
|
43 | + protected IShareHelper $shareHelper; |
|
44 | 44 | |
45 | - /** |
|
46 | - * Listener constructor. |
|
47 | - */ |
|
48 | - public function __construct(IManager $activityManager, |
|
49 | - IUserSession $session, |
|
50 | - IAppManager $appManager, |
|
51 | - IMountProviderCollection $mountCollection, |
|
52 | - IRootFolder $rootFolder, |
|
53 | - IShareHelper $shareHelper) { |
|
54 | - $this->activityManager = $activityManager; |
|
55 | - $this->session = $session; |
|
56 | - $this->appManager = $appManager; |
|
57 | - $this->mountCollection = $mountCollection; |
|
58 | - $this->rootFolder = $rootFolder; |
|
59 | - $this->shareHelper = $shareHelper; |
|
60 | - } |
|
45 | + /** |
|
46 | + * Listener constructor. |
|
47 | + */ |
|
48 | + public function __construct(IManager $activityManager, |
|
49 | + IUserSession $session, |
|
50 | + IAppManager $appManager, |
|
51 | + IMountProviderCollection $mountCollection, |
|
52 | + IRootFolder $rootFolder, |
|
53 | + IShareHelper $shareHelper) { |
|
54 | + $this->activityManager = $activityManager; |
|
55 | + $this->session = $session; |
|
56 | + $this->appManager = $appManager; |
|
57 | + $this->mountCollection = $mountCollection; |
|
58 | + $this->rootFolder = $rootFolder; |
|
59 | + $this->shareHelper = $shareHelper; |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * @param CommentsEvent $event |
|
64 | - */ |
|
65 | - public function commentEvent(CommentsEvent $event) { |
|
66 | - if ($event->getComment()->getObjectType() !== 'files' |
|
67 | - || $event->getEvent() !== CommentsEvent::EVENT_ADD |
|
68 | - || !$this->appManager->isInstalled('activity')) { |
|
69 | - // Comment not for file, not adding a comment or no activity-app enabled (save the energy) |
|
70 | - return; |
|
71 | - } |
|
62 | + /** |
|
63 | + * @param CommentsEvent $event |
|
64 | + */ |
|
65 | + public function commentEvent(CommentsEvent $event) { |
|
66 | + if ($event->getComment()->getObjectType() !== 'files' |
|
67 | + || $event->getEvent() !== CommentsEvent::EVENT_ADD |
|
68 | + || !$this->appManager->isInstalled('activity')) { |
|
69 | + // Comment not for file, not adding a comment or no activity-app enabled (save the energy) |
|
70 | + return; |
|
71 | + } |
|
72 | 72 | |
73 | - // Get all mount point owners |
|
74 | - $cache = $this->mountCollection->getMountCache(); |
|
75 | - $mounts = $cache->getMountsForFileId((int)$event->getComment()->getObjectId()); |
|
76 | - if (empty($mounts)) { |
|
77 | - return; |
|
78 | - } |
|
73 | + // Get all mount point owners |
|
74 | + $cache = $this->mountCollection->getMountCache(); |
|
75 | + $mounts = $cache->getMountsForFileId((int)$event->getComment()->getObjectId()); |
|
76 | + if (empty($mounts)) { |
|
77 | + return; |
|
78 | + } |
|
79 | 79 | |
80 | - $users = []; |
|
81 | - foreach ($mounts as $mount) { |
|
82 | - $owner = $mount->getUser()->getUID(); |
|
83 | - $ownerFolder = $this->rootFolder->getUserFolder($owner); |
|
84 | - $nodes = $ownerFolder->getById((int)$event->getComment()->getObjectId()); |
|
85 | - if (!empty($nodes)) { |
|
86 | - /** @var Node $node */ |
|
87 | - $node = array_shift($nodes); |
|
88 | - $al = $this->shareHelper->getPathsForAccessList($node); |
|
89 | - $users += $al['users']; |
|
90 | - } |
|
91 | - } |
|
80 | + $users = []; |
|
81 | + foreach ($mounts as $mount) { |
|
82 | + $owner = $mount->getUser()->getUID(); |
|
83 | + $ownerFolder = $this->rootFolder->getUserFolder($owner); |
|
84 | + $nodes = $ownerFolder->getById((int)$event->getComment()->getObjectId()); |
|
85 | + if (!empty($nodes)) { |
|
86 | + /** @var Node $node */ |
|
87 | + $node = array_shift($nodes); |
|
88 | + $al = $this->shareHelper->getPathsForAccessList($node); |
|
89 | + $users += $al['users']; |
|
90 | + } |
|
91 | + } |
|
92 | 92 | |
93 | - $actor = $this->session->getUser(); |
|
94 | - if ($actor instanceof IUser) { |
|
95 | - $actor = $actor->getUID(); |
|
96 | - } else { |
|
97 | - $actor = ''; |
|
98 | - } |
|
93 | + $actor = $this->session->getUser(); |
|
94 | + if ($actor instanceof IUser) { |
|
95 | + $actor = $actor->getUID(); |
|
96 | + } else { |
|
97 | + $actor = ''; |
|
98 | + } |
|
99 | 99 | |
100 | - $activity = $this->activityManager->generateEvent(); |
|
101 | - $activity->setApp('comments') |
|
102 | - ->setType('comments') |
|
103 | - ->setAuthor($actor) |
|
104 | - ->setObject($event->getComment()->getObjectType(), (int) $event->getComment()->getObjectId()) |
|
105 | - ->setMessage('add_comment_message', [ |
|
106 | - 'commentId' => $event->getComment()->getId(), |
|
107 | - ]); |
|
100 | + $activity = $this->activityManager->generateEvent(); |
|
101 | + $activity->setApp('comments') |
|
102 | + ->setType('comments') |
|
103 | + ->setAuthor($actor) |
|
104 | + ->setObject($event->getComment()->getObjectType(), (int) $event->getComment()->getObjectId()) |
|
105 | + ->setMessage('add_comment_message', [ |
|
106 | + 'commentId' => $event->getComment()->getId(), |
|
107 | + ]); |
|
108 | 108 | |
109 | - foreach ($users as $user => $path) { |
|
110 | - // numerical user ids end up as integers from array keys, but string |
|
111 | - // is required |
|
112 | - $activity->setAffectedUser((string)$user); |
|
109 | + foreach ($users as $user => $path) { |
|
110 | + // numerical user ids end up as integers from array keys, but string |
|
111 | + // is required |
|
112 | + $activity->setAffectedUser((string)$user); |
|
113 | 113 | |
114 | - $activity->setSubject('add_comment_subject', [ |
|
115 | - 'actor' => $actor, |
|
116 | - 'fileId' => (int) $event->getComment()->getObjectId(), |
|
117 | - 'filePath' => trim($path, '/'), |
|
118 | - ]); |
|
119 | - $this->activityManager->publish($activity); |
|
120 | - } |
|
121 | - } |
|
114 | + $activity->setSubject('add_comment_subject', [ |
|
115 | + 'actor' => $actor, |
|
116 | + 'fileId' => (int) $event->getComment()->getObjectId(), |
|
117 | + 'filePath' => trim($path, '/'), |
|
118 | + ]); |
|
119 | + $this->activityManager->publish($activity); |
|
120 | + } |
|
121 | + } |
|
122 | 122 | } |
@@ -30,21 +30,21 @@ |
||
30 | 30 | * @package OC\IntegrityCheck\Helpers |
31 | 31 | */ |
32 | 32 | class EnvironmentHelper { |
33 | - /** |
|
34 | - * Provides \OC::$SERVERROOT |
|
35 | - * |
|
36 | - * @return string |
|
37 | - */ |
|
38 | - public function getServerRoot(): string { |
|
39 | - return rtrim(\OC::$SERVERROOT, '/'); |
|
40 | - } |
|
33 | + /** |
|
34 | + * Provides \OC::$SERVERROOT |
|
35 | + * |
|
36 | + * @return string |
|
37 | + */ |
|
38 | + public function getServerRoot(): string { |
|
39 | + return rtrim(\OC::$SERVERROOT, '/'); |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * Provides \OC_Util::getChannel() |
|
44 | - * |
|
45 | - * @return string |
|
46 | - */ |
|
47 | - public function getChannel(): string { |
|
48 | - return \OC_Util::getChannel(); |
|
49 | - } |
|
42 | + /** |
|
43 | + * Provides \OC_Util::getChannel() |
|
44 | + * |
|
45 | + * @return string |
|
46 | + */ |
|
47 | + public function getChannel(): string { |
|
48 | + return \OC_Util::getChannel(); |
|
49 | + } |
|
50 | 50 | } |
@@ -36,7 +36,7 @@ |
||
36 | 36 | * @package OC\AppFramework\Middleware\Security\Exceptions |
37 | 37 | */ |
38 | 38 | class NotAdminException extends SecurityException { |
39 | - public function __construct(string $message) { |
|
40 | - parent::__construct($message, Http::STATUS_FORBIDDEN); |
|
41 | - } |
|
39 | + public function __construct(string $message) { |
|
40 | + parent::__construct($message, Http::STATUS_FORBIDDEN); |
|
41 | + } |
|
42 | 42 | } |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | $dir = $pathinfo['dirname']; |
59 | 59 | $i = 2; |
60 | 60 | while ($view->file_exists($path) || in_array($path, $excludeList)) { |
61 | - $path = Filesystem::normalizePath($dir . '/' . $name . ' ('.$i.')' . $ext); |
|
61 | + $path = Filesystem::normalizePath($dir.'/'.$name.' ('.$i.')'.$ext); |
|
62 | 62 | $i++; |
63 | 63 | } |
64 | 64 | |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | $dir = ''; |
83 | 83 | $subdirs = explode('/', $shareFolder); |
84 | 84 | foreach ($subdirs as $subdir) { |
85 | - $dir = $dir . '/' . $subdir; |
|
85 | + $dir = $dir.'/'.$subdir; |
|
86 | 86 | if (!$view->is_dir($dir)) { |
87 | 87 | $view->mkdir($dir); |
88 | 88 | } |
@@ -32,81 +32,81 @@ |
||
32 | 32 | use OCA\Files_Sharing\AppInfo\Application; |
33 | 33 | |
34 | 34 | class Helper { |
35 | - public static function registerHooks() { |
|
36 | - \OCP\Util::connectHook('OC_Filesystem', 'post_rename', '\OCA\Files_Sharing\Updater', 'renameHook'); |
|
37 | - \OCP\Util::connectHook('OC_Filesystem', 'post_delete', '\OCA\Files_Sharing\Hooks', 'unshareChildren'); |
|
35 | + public static function registerHooks() { |
|
36 | + \OCP\Util::connectHook('OC_Filesystem', 'post_rename', '\OCA\Files_Sharing\Updater', 'renameHook'); |
|
37 | + \OCP\Util::connectHook('OC_Filesystem', 'post_delete', '\OCA\Files_Sharing\Hooks', 'unshareChildren'); |
|
38 | 38 | |
39 | - \OCP\Util::connectHook('OC_User', 'post_deleteUser', '\OCA\Files_Sharing\Hooks', 'deleteUser'); |
|
40 | - } |
|
39 | + \OCP\Util::connectHook('OC_User', 'post_deleteUser', '\OCA\Files_Sharing\Hooks', 'deleteUser'); |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * check if file name already exists and generate unique target |
|
44 | - * |
|
45 | - * @param string $path |
|
46 | - * @param array $excludeList |
|
47 | - * @param View $view |
|
48 | - * @return string $path |
|
49 | - */ |
|
50 | - public static function generateUniqueTarget($path, $excludeList, $view) { |
|
51 | - $pathinfo = pathinfo($path); |
|
52 | - $ext = isset($pathinfo['extension']) ? '.'.$pathinfo['extension'] : ''; |
|
53 | - $name = $pathinfo['filename']; |
|
54 | - $dir = $pathinfo['dirname']; |
|
55 | - $i = 2; |
|
56 | - while ($view->file_exists($path) || in_array($path, $excludeList)) { |
|
57 | - $path = Filesystem::normalizePath($dir . '/' . $name . ' ('.$i.')' . $ext); |
|
58 | - $i++; |
|
59 | - } |
|
42 | + /** |
|
43 | + * check if file name already exists and generate unique target |
|
44 | + * |
|
45 | + * @param string $path |
|
46 | + * @param array $excludeList |
|
47 | + * @param View $view |
|
48 | + * @return string $path |
|
49 | + */ |
|
50 | + public static function generateUniqueTarget($path, $excludeList, $view) { |
|
51 | + $pathinfo = pathinfo($path); |
|
52 | + $ext = isset($pathinfo['extension']) ? '.'.$pathinfo['extension'] : ''; |
|
53 | + $name = $pathinfo['filename']; |
|
54 | + $dir = $pathinfo['dirname']; |
|
55 | + $i = 2; |
|
56 | + while ($view->file_exists($path) || in_array($path, $excludeList)) { |
|
57 | + $path = Filesystem::normalizePath($dir . '/' . $name . ' ('.$i.')' . $ext); |
|
58 | + $i++; |
|
59 | + } |
|
60 | 60 | |
61 | - return $path; |
|
62 | - } |
|
61 | + return $path; |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * get default share folder |
|
66 | - * |
|
67 | - * @param \OC\Files\View|null $view |
|
68 | - * @param string|null $userId |
|
69 | - * @return string |
|
70 | - */ |
|
71 | - public static function getShareFolder(View $view = null, string $userId = null): string { |
|
72 | - if ($view === null) { |
|
73 | - $view = Filesystem::getView(); |
|
74 | - } |
|
64 | + /** |
|
65 | + * get default share folder |
|
66 | + * |
|
67 | + * @param \OC\Files\View|null $view |
|
68 | + * @param string|null $userId |
|
69 | + * @return string |
|
70 | + */ |
|
71 | + public static function getShareFolder(View $view = null, string $userId = null): string { |
|
72 | + if ($view === null) { |
|
73 | + $view = Filesystem::getView(); |
|
74 | + } |
|
75 | 75 | |
76 | - $config = \OC::$server->getConfig(); |
|
77 | - $systemDefault = $config->getSystemValue('share_folder', '/'); |
|
78 | - $allowCustomShareFolder = $config->getSystemValueBool('sharing.allow_custom_share_folder', true); |
|
76 | + $config = \OC::$server->getConfig(); |
|
77 | + $systemDefault = $config->getSystemValue('share_folder', '/'); |
|
78 | + $allowCustomShareFolder = $config->getSystemValueBool('sharing.allow_custom_share_folder', true); |
|
79 | 79 | |
80 | - // Init custom shareFolder |
|
81 | - $shareFolder = $systemDefault; |
|
82 | - if ($userId !== null && $allowCustomShareFolder) { |
|
83 | - $shareFolder = $config->getUserValue($userId, Application::APP_ID, 'share_folder', $systemDefault); |
|
84 | - } |
|
80 | + // Init custom shareFolder |
|
81 | + $shareFolder = $systemDefault; |
|
82 | + if ($userId !== null && $allowCustomShareFolder) { |
|
83 | + $shareFolder = $config->getUserValue($userId, Application::APP_ID, 'share_folder', $systemDefault); |
|
84 | + } |
|
85 | 85 | |
86 | - // Verify and sanitize path |
|
87 | - $shareFolder = Filesystem::normalizePath($shareFolder); |
|
86 | + // Verify and sanitize path |
|
87 | + $shareFolder = Filesystem::normalizePath($shareFolder); |
|
88 | 88 | |
89 | - // Init path if folder doesn't exists |
|
90 | - if (!$view->file_exists($shareFolder)) { |
|
91 | - $dir = ''; |
|
92 | - $subdirs = explode('/', $shareFolder); |
|
93 | - foreach ($subdirs as $subdir) { |
|
94 | - $dir = $dir . '/' . $subdir; |
|
95 | - if (!$view->is_dir($dir)) { |
|
96 | - $view->mkdir($dir); |
|
97 | - } |
|
98 | - } |
|
99 | - } |
|
89 | + // Init path if folder doesn't exists |
|
90 | + if (!$view->file_exists($shareFolder)) { |
|
91 | + $dir = ''; |
|
92 | + $subdirs = explode('/', $shareFolder); |
|
93 | + foreach ($subdirs as $subdir) { |
|
94 | + $dir = $dir . '/' . $subdir; |
|
95 | + if (!$view->is_dir($dir)) { |
|
96 | + $view->mkdir($dir); |
|
97 | + } |
|
98 | + } |
|
99 | + } |
|
100 | 100 | |
101 | - return $shareFolder; |
|
102 | - } |
|
101 | + return $shareFolder; |
|
102 | + } |
|
103 | 103 | |
104 | - /** |
|
105 | - * set default share folder |
|
106 | - * |
|
107 | - * @param string $shareFolder |
|
108 | - */ |
|
109 | - public static function setShareFolder($shareFolder) { |
|
110 | - \OC::$server->getConfig()->setSystemValue('share_folder', $shareFolder); |
|
111 | - } |
|
104 | + /** |
|
105 | + * set default share folder |
|
106 | + * |
|
107 | + * @param string $shareFolder |
|
108 | + */ |
|
109 | + public static function setShareFolder($shareFolder) { |
|
110 | + \OC::$server->getConfig()->setSystemValue('share_folder', $shareFolder); |
|
111 | + } |
|
112 | 112 | } |
@@ -32,23 +32,23 @@ |
||
32 | 32 | * @package OC\Security\CSRF |
33 | 33 | */ |
34 | 34 | class CsrfTokenGenerator { |
35 | - /** @var ISecureRandom */ |
|
36 | - private $random; |
|
35 | + /** @var ISecureRandom */ |
|
36 | + private $random; |
|
37 | 37 | |
38 | - /** |
|
39 | - * @param ISecureRandom $random |
|
40 | - */ |
|
41 | - public function __construct(ISecureRandom $random) { |
|
42 | - $this->random = $random; |
|
43 | - } |
|
38 | + /** |
|
39 | + * @param ISecureRandom $random |
|
40 | + */ |
|
41 | + public function __construct(ISecureRandom $random) { |
|
42 | + $this->random = $random; |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * Generate a new CSRF token. |
|
47 | - * |
|
48 | - * @param int $length Length of the token in characters. |
|
49 | - * @return string |
|
50 | - */ |
|
51 | - public function generateToken(int $length = 32): string { |
|
52 | - return $this->random->generate($length); |
|
53 | - } |
|
45 | + /** |
|
46 | + * Generate a new CSRF token. |
|
47 | + * |
|
48 | + * @param int $length Length of the token in characters. |
|
49 | + * @return string |
|
50 | + */ |
|
51 | + public function generateToken(int $length = 32): string { |
|
52 | + return $this->random->generate($length); |
|
53 | + } |
|
54 | 54 | } |
@@ -25,25 +25,25 @@ |
||
25 | 25 | namespace OC\Security\IdentityProof; |
26 | 26 | |
27 | 27 | class Key { |
28 | - /** @var string */ |
|
29 | - private $publicKey; |
|
30 | - /** @var string */ |
|
31 | - private $privateKey; |
|
28 | + /** @var string */ |
|
29 | + private $publicKey; |
|
30 | + /** @var string */ |
|
31 | + private $privateKey; |
|
32 | 32 | |
33 | - /** |
|
34 | - * @param string $publicKey |
|
35 | - * @param string $privateKey |
|
36 | - */ |
|
37 | - public function __construct(string $publicKey, string $privateKey) { |
|
38 | - $this->publicKey = $publicKey; |
|
39 | - $this->privateKey = $privateKey; |
|
40 | - } |
|
33 | + /** |
|
34 | + * @param string $publicKey |
|
35 | + * @param string $privateKey |
|
36 | + */ |
|
37 | + public function __construct(string $publicKey, string $privateKey) { |
|
38 | + $this->publicKey = $publicKey; |
|
39 | + $this->privateKey = $privateKey; |
|
40 | + } |
|
41 | 41 | |
42 | - public function getPrivate(): string { |
|
43 | - return $this->privateKey; |
|
44 | - } |
|
42 | + public function getPrivate(): string { |
|
43 | + return $this->privateKey; |
|
44 | + } |
|
45 | 45 | |
46 | - public function getPublic(): string { |
|
47 | - return $this->publicKey; |
|
48 | - } |
|
46 | + public function getPublic(): string { |
|
47 | + return $this->publicKey; |
|
48 | + } |
|
49 | 49 | } |
@@ -100,7 +100,7 @@ |
||
100 | 100 | |
101 | 101 | // casted to string because cast to float cause equality for non equal numbers |
102 | 102 | // and integer has the problem of limited size on 32 bit systems |
103 | - if ((string)$expectedSize !== (string)$actualSize) { |
|
103 | + if ((string) $expectedSize !== (string) $actualSize) { |
|
104 | 104 | throw new BadRequest("Chunks on server do not sum up to $expectedSize but to $actualSize bytes"); |
105 | 105 | } |
106 | 106 | } |
@@ -35,97 +35,97 @@ |
||
35 | 35 | |
36 | 36 | class ChunkingPlugin extends ServerPlugin { |
37 | 37 | |
38 | - /** @var Server */ |
|
39 | - private $server; |
|
40 | - /** @var FutureFile */ |
|
41 | - private $sourceNode; |
|
38 | + /** @var Server */ |
|
39 | + private $server; |
|
40 | + /** @var FutureFile */ |
|
41 | + private $sourceNode; |
|
42 | 42 | |
43 | - /** |
|
44 | - * @inheritdoc |
|
45 | - */ |
|
46 | - public function initialize(Server $server) { |
|
47 | - $server->on('beforeMove', [$this, 'beforeMove']); |
|
48 | - $this->server = $server; |
|
49 | - } |
|
43 | + /** |
|
44 | + * @inheritdoc |
|
45 | + */ |
|
46 | + public function initialize(Server $server) { |
|
47 | + $server->on('beforeMove', [$this, 'beforeMove']); |
|
48 | + $this->server = $server; |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * @param string $sourcePath source path |
|
53 | - * @param string $destination destination path |
|
54 | - * @return bool|void |
|
55 | - * @throws BadRequest |
|
56 | - * @throws NotFound |
|
57 | - */ |
|
58 | - public function beforeMove($sourcePath, $destination) { |
|
59 | - $this->sourceNode = $this->server->tree->getNodeForPath($sourcePath); |
|
60 | - if (!$this->sourceNode instanceof FutureFile) { |
|
61 | - // skip handling as the source is not a chunked FutureFile |
|
62 | - return; |
|
63 | - } |
|
51 | + /** |
|
52 | + * @param string $sourcePath source path |
|
53 | + * @param string $destination destination path |
|
54 | + * @return bool|void |
|
55 | + * @throws BadRequest |
|
56 | + * @throws NotFound |
|
57 | + */ |
|
58 | + public function beforeMove($sourcePath, $destination) { |
|
59 | + $this->sourceNode = $this->server->tree->getNodeForPath($sourcePath); |
|
60 | + if (!$this->sourceNode instanceof FutureFile) { |
|
61 | + // skip handling as the source is not a chunked FutureFile |
|
62 | + return; |
|
63 | + } |
|
64 | 64 | |
65 | - try { |
|
66 | - /** @var INode $destinationNode */ |
|
67 | - $destinationNode = $this->server->tree->getNodeForPath($destination); |
|
68 | - if ($destinationNode instanceof Directory) { |
|
69 | - throw new BadRequest("The given destination $destination is a directory."); |
|
70 | - } |
|
71 | - } catch (NotFound $e) { |
|
72 | - // If the destination does not exist yet it's not a directory either ;) |
|
73 | - } |
|
65 | + try { |
|
66 | + /** @var INode $destinationNode */ |
|
67 | + $destinationNode = $this->server->tree->getNodeForPath($destination); |
|
68 | + if ($destinationNode instanceof Directory) { |
|
69 | + throw new BadRequest("The given destination $destination is a directory."); |
|
70 | + } |
|
71 | + } catch (NotFound $e) { |
|
72 | + // If the destination does not exist yet it's not a directory either ;) |
|
73 | + } |
|
74 | 74 | |
75 | - $this->verifySize(); |
|
76 | - return $this->performMove($sourcePath, $destination); |
|
77 | - } |
|
75 | + $this->verifySize(); |
|
76 | + return $this->performMove($sourcePath, $destination); |
|
77 | + } |
|
78 | 78 | |
79 | - /** |
|
80 | - * Move handler for future file. |
|
81 | - * |
|
82 | - * This overrides the default move behavior to prevent Sabre |
|
83 | - * to delete the target file before moving. Because deleting would |
|
84 | - * lose the file id and metadata. |
|
85 | - * |
|
86 | - * @param string $path source path |
|
87 | - * @param string $destination destination path |
|
88 | - * @return bool|void false to stop handling, void to skip this handler |
|
89 | - */ |
|
90 | - public function performMove($path, $destination) { |
|
91 | - $fileExists = $this->server->tree->nodeExists($destination); |
|
92 | - // do a move manually, skipping Sabre's default "delete" for existing nodes |
|
93 | - try { |
|
94 | - $this->server->tree->move($path, $destination); |
|
95 | - } catch (Forbidden $e) { |
|
96 | - $sourceNode = $this->server->tree->getNodeForPath($path); |
|
97 | - if ($sourceNode instanceof FutureFile) { |
|
98 | - $sourceNode->delete(); |
|
99 | - } |
|
100 | - throw $e; |
|
101 | - } |
|
79 | + /** |
|
80 | + * Move handler for future file. |
|
81 | + * |
|
82 | + * This overrides the default move behavior to prevent Sabre |
|
83 | + * to delete the target file before moving. Because deleting would |
|
84 | + * lose the file id and metadata. |
|
85 | + * |
|
86 | + * @param string $path source path |
|
87 | + * @param string $destination destination path |
|
88 | + * @return bool|void false to stop handling, void to skip this handler |
|
89 | + */ |
|
90 | + public function performMove($path, $destination) { |
|
91 | + $fileExists = $this->server->tree->nodeExists($destination); |
|
92 | + // do a move manually, skipping Sabre's default "delete" for existing nodes |
|
93 | + try { |
|
94 | + $this->server->tree->move($path, $destination); |
|
95 | + } catch (Forbidden $e) { |
|
96 | + $sourceNode = $this->server->tree->getNodeForPath($path); |
|
97 | + if ($sourceNode instanceof FutureFile) { |
|
98 | + $sourceNode->delete(); |
|
99 | + } |
|
100 | + throw $e; |
|
101 | + } |
|
102 | 102 | |
103 | - // trigger all default events (copied from CorePlugin::move) |
|
104 | - $this->server->emit('afterMove', [$path, $destination]); |
|
105 | - $this->server->emit('afterUnbind', [$path]); |
|
106 | - $this->server->emit('afterBind', [$destination]); |
|
103 | + // trigger all default events (copied from CorePlugin::move) |
|
104 | + $this->server->emit('afterMove', [$path, $destination]); |
|
105 | + $this->server->emit('afterUnbind', [$path]); |
|
106 | + $this->server->emit('afterBind', [$destination]); |
|
107 | 107 | |
108 | - $response = $this->server->httpResponse; |
|
109 | - $response->setHeader('Content-Length', '0'); |
|
110 | - $response->setStatus($fileExists ? 204 : 201); |
|
108 | + $response = $this->server->httpResponse; |
|
109 | + $response->setHeader('Content-Length', '0'); |
|
110 | + $response->setStatus($fileExists ? 204 : 201); |
|
111 | 111 | |
112 | - return false; |
|
113 | - } |
|
112 | + return false; |
|
113 | + } |
|
114 | 114 | |
115 | - /** |
|
116 | - * @throws BadRequest |
|
117 | - */ |
|
118 | - private function verifySize() { |
|
119 | - $expectedSize = $this->server->httpRequest->getHeader('OC-Total-Length'); |
|
120 | - if ($expectedSize === null) { |
|
121 | - return; |
|
122 | - } |
|
123 | - $actualSize = $this->sourceNode->getSize(); |
|
115 | + /** |
|
116 | + * @throws BadRequest |
|
117 | + */ |
|
118 | + private function verifySize() { |
|
119 | + $expectedSize = $this->server->httpRequest->getHeader('OC-Total-Length'); |
|
120 | + if ($expectedSize === null) { |
|
121 | + return; |
|
122 | + } |
|
123 | + $actualSize = $this->sourceNode->getSize(); |
|
124 | 124 | |
125 | - // casted to string because cast to float cause equality for non equal numbers |
|
126 | - // and integer has the problem of limited size on 32 bit systems |
|
127 | - if ((string)$expectedSize !== (string)$actualSize) { |
|
128 | - throw new BadRequest("Chunks on server do not sum up to $expectedSize but to $actualSize bytes"); |
|
129 | - } |
|
130 | - } |
|
125 | + // casted to string because cast to float cause equality for non equal numbers |
|
126 | + // and integer has the problem of limited size on 32 bit systems |
|
127 | + if ((string)$expectedSize !== (string)$actualSize) { |
|
128 | + throw new BadRequest("Chunks on server do not sum up to $expectedSize but to $actualSize bytes"); |
|
129 | + } |
|
130 | + } |
|
131 | 131 | } |