@@ -33,85 +33,85 @@ |
||
33 | 33 | |
34 | 34 | class ImageExportPlugin extends ServerPlugin { |
35 | 35 | |
36 | - /** @var Server */ |
|
37 | - protected $server; |
|
38 | - /** @var PhotoCache */ |
|
39 | - private $cache; |
|
40 | - |
|
41 | - /** |
|
42 | - * ImageExportPlugin constructor. |
|
43 | - * |
|
44 | - * @param PhotoCache $cache |
|
45 | - */ |
|
46 | - public function __construct(PhotoCache $cache) { |
|
47 | - $this->cache = $cache; |
|
48 | - } |
|
49 | - |
|
50 | - /** |
|
51 | - * Initializes the plugin and registers event handlers |
|
52 | - * |
|
53 | - * @param Server $server |
|
54 | - * @return void |
|
55 | - */ |
|
56 | - public function initialize(Server $server) { |
|
57 | - $this->server = $server; |
|
58 | - $this->server->on('method:GET', [$this, 'httpGet'], 90); |
|
59 | - } |
|
60 | - |
|
61 | - /** |
|
62 | - * Intercepts GET requests on addressbook urls ending with ?photo. |
|
63 | - * |
|
64 | - * @param RequestInterface $request |
|
65 | - * @param ResponseInterface $response |
|
66 | - * @return bool |
|
67 | - */ |
|
68 | - public function httpGet(RequestInterface $request, ResponseInterface $response) { |
|
69 | - $queryParams = $request->getQueryParameters(); |
|
70 | - // TODO: in addition to photo we should also add logo some point in time |
|
71 | - if (!array_key_exists('photo', $queryParams)) { |
|
72 | - return true; |
|
73 | - } |
|
74 | - |
|
75 | - $size = isset($queryParams['size']) ? (int)$queryParams['size'] : -1; |
|
76 | - |
|
77 | - $path = $request->getPath(); |
|
78 | - $node = $this->server->tree->getNodeForPath($path); |
|
79 | - |
|
80 | - if (!($node instanceof Card)) { |
|
81 | - return true; |
|
82 | - } |
|
83 | - |
|
84 | - $this->server->transactionType = 'carddav-image-export'; |
|
85 | - |
|
86 | - // Checking ACL, if available. |
|
87 | - if ($aclPlugin = $this->server->getPlugin('acl')) { |
|
88 | - /** @var \Sabre\DAVACL\Plugin $aclPlugin */ |
|
89 | - $aclPlugin->checkPrivileges($path, '{DAV:}read'); |
|
90 | - } |
|
91 | - |
|
92 | - // Fetch addressbook |
|
93 | - $addressbookpath = explode('/', $path); |
|
94 | - array_pop($addressbookpath); |
|
95 | - $addressbookpath = implode('/', $addressbookpath); |
|
96 | - /** @var AddressBook $addressbook */ |
|
97 | - $addressbook = $this->server->tree->getNodeForPath($addressbookpath); |
|
98 | - |
|
99 | - $response->setHeader('Cache-Control', 'private, max-age=3600, must-revalidate'); |
|
100 | - $response->setHeader('Etag', $node->getETag()); |
|
101 | - $response->setHeader('Pragma', 'public'); |
|
102 | - |
|
103 | - try { |
|
104 | - $file = $this->cache->get($addressbook->getResourceId(), $node->getName(), $size, $node); |
|
105 | - $response->setHeader('Content-Type', $file->getMimeType()); |
|
106 | - $fileName = $node->getName() . '.' . PhotoCache::ALLOWED_CONTENT_TYPES[$file->getMimeType()]; |
|
107 | - $response->setHeader('Content-Disposition', "attachment; filename=$fileName"); |
|
108 | - $response->setStatus(200); |
|
109 | - |
|
110 | - $response->setBody($file->getContent()); |
|
111 | - } catch (NotFoundException $e) { |
|
112 | - $response->setStatus(404); |
|
113 | - } |
|
114 | - |
|
115 | - return false; |
|
116 | - } |
|
36 | + /** @var Server */ |
|
37 | + protected $server; |
|
38 | + /** @var PhotoCache */ |
|
39 | + private $cache; |
|
40 | + |
|
41 | + /** |
|
42 | + * ImageExportPlugin constructor. |
|
43 | + * |
|
44 | + * @param PhotoCache $cache |
|
45 | + */ |
|
46 | + public function __construct(PhotoCache $cache) { |
|
47 | + $this->cache = $cache; |
|
48 | + } |
|
49 | + |
|
50 | + /** |
|
51 | + * Initializes the plugin and registers event handlers |
|
52 | + * |
|
53 | + * @param Server $server |
|
54 | + * @return void |
|
55 | + */ |
|
56 | + public function initialize(Server $server) { |
|
57 | + $this->server = $server; |
|
58 | + $this->server->on('method:GET', [$this, 'httpGet'], 90); |
|
59 | + } |
|
60 | + |
|
61 | + /** |
|
62 | + * Intercepts GET requests on addressbook urls ending with ?photo. |
|
63 | + * |
|
64 | + * @param RequestInterface $request |
|
65 | + * @param ResponseInterface $response |
|
66 | + * @return bool |
|
67 | + */ |
|
68 | + public function httpGet(RequestInterface $request, ResponseInterface $response) { |
|
69 | + $queryParams = $request->getQueryParameters(); |
|
70 | + // TODO: in addition to photo we should also add logo some point in time |
|
71 | + if (!array_key_exists('photo', $queryParams)) { |
|
72 | + return true; |
|
73 | + } |
|
74 | + |
|
75 | + $size = isset($queryParams['size']) ? (int)$queryParams['size'] : -1; |
|
76 | + |
|
77 | + $path = $request->getPath(); |
|
78 | + $node = $this->server->tree->getNodeForPath($path); |
|
79 | + |
|
80 | + if (!($node instanceof Card)) { |
|
81 | + return true; |
|
82 | + } |
|
83 | + |
|
84 | + $this->server->transactionType = 'carddav-image-export'; |
|
85 | + |
|
86 | + // Checking ACL, if available. |
|
87 | + if ($aclPlugin = $this->server->getPlugin('acl')) { |
|
88 | + /** @var \Sabre\DAVACL\Plugin $aclPlugin */ |
|
89 | + $aclPlugin->checkPrivileges($path, '{DAV:}read'); |
|
90 | + } |
|
91 | + |
|
92 | + // Fetch addressbook |
|
93 | + $addressbookpath = explode('/', $path); |
|
94 | + array_pop($addressbookpath); |
|
95 | + $addressbookpath = implode('/', $addressbookpath); |
|
96 | + /** @var AddressBook $addressbook */ |
|
97 | + $addressbook = $this->server->tree->getNodeForPath($addressbookpath); |
|
98 | + |
|
99 | + $response->setHeader('Cache-Control', 'private, max-age=3600, must-revalidate'); |
|
100 | + $response->setHeader('Etag', $node->getETag()); |
|
101 | + $response->setHeader('Pragma', 'public'); |
|
102 | + |
|
103 | + try { |
|
104 | + $file = $this->cache->get($addressbook->getResourceId(), $node->getName(), $size, $node); |
|
105 | + $response->setHeader('Content-Type', $file->getMimeType()); |
|
106 | + $fileName = $node->getName() . '.' . PhotoCache::ALLOWED_CONTENT_TYPES[$file->getMimeType()]; |
|
107 | + $response->setHeader('Content-Disposition', "attachment; filename=$fileName"); |
|
108 | + $response->setStatus(200); |
|
109 | + |
|
110 | + $response->setBody($file->getContent()); |
|
111 | + } catch (NotFoundException $e) { |
|
112 | + $response->setStatus(404); |
|
113 | + } |
|
114 | + |
|
115 | + return false; |
|
116 | + } |
|
117 | 117 | } |
@@ -30,17 +30,17 @@ |
||
30 | 30 | |
31 | 31 | class ReasonsController extends Controller { |
32 | 32 | |
33 | - /** |
|
34 | - * @NoCSRFRequired |
|
35 | - * @NoAdminRequired |
|
36 | - * @NoSubAdminRequired |
|
37 | - */ |
|
38 | - public function getPdf() { |
|
39 | - $data = file_get_contents(__DIR__ . '/../../data/Reasons to use Nextcloud.pdf'); |
|
33 | + /** |
|
34 | + * @NoCSRFRequired |
|
35 | + * @NoAdminRequired |
|
36 | + * @NoSubAdminRequired |
|
37 | + */ |
|
38 | + public function getPdf() { |
|
39 | + $data = file_get_contents(__DIR__ . '/../../data/Reasons to use Nextcloud.pdf'); |
|
40 | 40 | |
41 | - $resp = new DataDisplayResponse($data); |
|
42 | - $resp->addHeader('Content-Type', 'application/pdf'); |
|
41 | + $resp = new DataDisplayResponse($data); |
|
42 | + $resp->addHeader('Content-Type', 'application/pdf'); |
|
43 | 43 | |
44 | - return $resp; |
|
45 | - } |
|
44 | + return $resp; |
|
45 | + } |
|
46 | 46 | } |
@@ -4,66 +4,66 @@ |
||
4 | 4 | </p> |
5 | 5 | <p> |
6 | 6 | <?php print_unescaped(str_replace( |
7 | - [ |
|
8 | - '{communityopen}', |
|
9 | - '{githubopen}', |
|
10 | - '{licenseopen}', |
|
11 | - '{linkclose}', |
|
12 | - ], |
|
13 | - [ |
|
14 | - '<a href="https://nextcloud.com/contribute" target="_blank" rel="noreferrer noopener">', |
|
15 | - '<a href="https://github.com/nextcloud" target="_blank" rel="noreferrer noopener">', |
|
16 | - '<a href="https://www.gnu.org/licenses/agpl-3.0.html" target="_blank" rel="noreferrer noopener">', |
|
17 | - '</a>', |
|
18 | - ], |
|
19 | - $l->t('Developed by the {communityopen}Nextcloud community{linkclose}, the {githubopen}source code{linkclose} is licensed under the {licenseopen}AGPL{linkclose}.') |
|
20 | - )); ?> |
|
7 | + [ |
|
8 | + '{communityopen}', |
|
9 | + '{githubopen}', |
|
10 | + '{licenseopen}', |
|
11 | + '{linkclose}', |
|
12 | + ], |
|
13 | + [ |
|
14 | + '<a href="https://nextcloud.com/contribute" target="_blank" rel="noreferrer noopener">', |
|
15 | + '<a href="https://github.com/nextcloud" target="_blank" rel="noreferrer noopener">', |
|
16 | + '<a href="https://www.gnu.org/licenses/agpl-3.0.html" target="_blank" rel="noreferrer noopener">', |
|
17 | + '</a>', |
|
18 | + ], |
|
19 | + $l->t('Developed by the {communityopen}Nextcloud community{linkclose}, the {githubopen}source code{linkclose} is licensed under the {licenseopen}AGPL{linkclose}.') |
|
20 | + )); ?> |
|
21 | 21 | </p> |
22 | 22 | |
23 | 23 | <p class="social-button"> |
24 | 24 | <?php print_unescaped(str_replace( |
25 | - [ |
|
26 | - '{facebookimage}', |
|
27 | - '{twitterimage}', |
|
28 | - '{mastodonimage}', |
|
29 | - '{rssimage}', |
|
30 | - '{mailimage}', |
|
31 | - '{facebookopen}', |
|
32 | - '{twitteropen}', |
|
33 | - '{mastodonopen}', |
|
34 | - '{rssopen}', |
|
35 | - '{newsletteropen}', |
|
36 | - '{linkclose}', |
|
37 | - '{facebooktext}', |
|
38 | - '{twittertext}', |
|
39 | - '{mastodontext}', |
|
40 | - '{rsstext}', |
|
41 | - '{mailtext}', |
|
42 | - ], |
|
43 | - [ |
|
44 | - image_path('core', 'facebook.svg'), |
|
45 | - image_path('core', 'twitter.svg'), |
|
46 | - image_path('core', 'mastodon.svg'), |
|
47 | - image_path('core', 'rss.svg'), |
|
48 | - image_path('core', 'mail.svg'), |
|
49 | - '<a target="_blank" rel="noreferrer noopener" href="https://www.facebook.com/Nextclouders/">', |
|
50 | - '<a target="_blank" rel="noreferrer noopener" href="https://twitter.com/nextclouders">', |
|
51 | - '<a target="_blank" rel="noreferrer noopener" href="https://mastodon.xyz/@nextcloud">', |
|
52 | - '<a target="_blank" rel="noreferrer noopener" href="https://nextcloud.com/news/">', |
|
53 | - '<a target="_blank" rel="noreferrer noopener" href="https://newsletter.nextcloud.com/?p=subscribe&id=1">', |
|
54 | - '</a>', |
|
55 | - $l->t('Like our Facebook page'), |
|
56 | - $l->t('Follow us on Twitter'), |
|
57 | - $l->t('Follow us on Mastodon'), |
|
58 | - $l->t('Check out our blog'), |
|
59 | - $l->t('Subscribe to our newsletter'), |
|
25 | + [ |
|
26 | + '{facebookimage}', |
|
27 | + '{twitterimage}', |
|
28 | + '{mastodonimage}', |
|
29 | + '{rssimage}', |
|
30 | + '{mailimage}', |
|
31 | + '{facebookopen}', |
|
32 | + '{twitteropen}', |
|
33 | + '{mastodonopen}', |
|
34 | + '{rssopen}', |
|
35 | + '{newsletteropen}', |
|
36 | + '{linkclose}', |
|
37 | + '{facebooktext}', |
|
38 | + '{twittertext}', |
|
39 | + '{mastodontext}', |
|
40 | + '{rsstext}', |
|
41 | + '{mailtext}', |
|
42 | + ], |
|
43 | + [ |
|
44 | + image_path('core', 'facebook.svg'), |
|
45 | + image_path('core', 'twitter.svg'), |
|
46 | + image_path('core', 'mastodon.svg'), |
|
47 | + image_path('core', 'rss.svg'), |
|
48 | + image_path('core', 'mail.svg'), |
|
49 | + '<a target="_blank" rel="noreferrer noopener" href="https://www.facebook.com/Nextclouders/">', |
|
50 | + '<a target="_blank" rel="noreferrer noopener" href="https://twitter.com/nextclouders">', |
|
51 | + '<a target="_blank" rel="noreferrer noopener" href="https://mastodon.xyz/@nextcloud">', |
|
52 | + '<a target="_blank" rel="noreferrer noopener" href="https://nextcloud.com/news/">', |
|
53 | + '<a target="_blank" rel="noreferrer noopener" href="https://newsletter.nextcloud.com/?p=subscribe&id=1">', |
|
54 | + '</a>', |
|
55 | + $l->t('Like our Facebook page'), |
|
56 | + $l->t('Follow us on Twitter'), |
|
57 | + $l->t('Follow us on Mastodon'), |
|
58 | + $l->t('Check out our blog'), |
|
59 | + $l->t('Subscribe to our newsletter'), |
|
60 | 60 | |
61 | - ], |
|
61 | + ], |
|
62 | 62 | '{facebookopen}<img width="50" src="{facebookimage}" title="{facebooktext}" alt="{facebooktext}">{linkclose} |
63 | 63 | {twitteropen}<img width="50" src="{twitterimage}" title="{twittertext}" alt="{twittertext}">{linkclose} |
64 | 64 | {mastodonopen}<img width="50" src="{mastodonimage}" title="{mastodontext}" alt="{mastodontext}">{linkclose} |
65 | 65 | {rssopen}<img class="img-circle" width="50" src="{rssimage}" title="{rsstext}" alt="{rsstext}">{linkclose} |
66 | 66 | {newsletteropen}<img width="50" src="{mailimage}" title="{mailtext}" alt="{mailtext}">{linkclose}' |
67 | - )); ?> |
|
67 | + )); ?> |
|
68 | 68 | </p> |
69 | 69 | </div> |
@@ -36,22 +36,22 @@ |
||
36 | 36 | */ |
37 | 37 | class Version0002Date20200902144824 extends SimpleMigrationStep { |
38 | 38 | |
39 | - /** |
|
40 | - * @param IOutput $output |
|
41 | - * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
42 | - * @param array $options |
|
43 | - * @return null|ISchemaWrapper |
|
44 | - * @since 20.0.0 |
|
45 | - */ |
|
46 | - public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) { |
|
47 | - /** @var ISchemaWrapper $schema */ |
|
48 | - $schema = $schemaClosure(); |
|
49 | - |
|
50 | - $statusTable = $schema->getTable('user_status'); |
|
51 | - |
|
52 | - $statusTable->addIndex(['status_timestamp'], 'user_status_tstmp_ix'); |
|
53 | - $statusTable->addIndex(['is_user_defined', 'status'], 'user_status_iud_ix'); |
|
54 | - |
|
55 | - return $schema; |
|
56 | - } |
|
39 | + /** |
|
40 | + * @param IOutput $output |
|
41 | + * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
42 | + * @param array $options |
|
43 | + * @return null|ISchemaWrapper |
|
44 | + * @since 20.0.0 |
|
45 | + */ |
|
46 | + public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) { |
|
47 | + /** @var ISchemaWrapper $schema */ |
|
48 | + $schema = $schemaClosure(); |
|
49 | + |
|
50 | + $statusTable = $schema->getTable('user_status'); |
|
51 | + |
|
52 | + $statusTable->addIndex(['status_timestamp'], 'user_status_tstmp_ix'); |
|
53 | + $statusTable->addIndex(['is_user_defined', 'status'], 'user_status_iud_ix'); |
|
54 | + |
|
55 | + return $schema; |
|
56 | + } |
|
57 | 57 | } |
@@ -25,45 +25,45 @@ |
||
25 | 25 | namespace OCA\Files\Activity\Settings; |
26 | 26 | |
27 | 27 | class FileChanged extends FileActivitySettings { |
28 | - /** |
|
29 | - * @return string Lowercase a-z and underscore only identifier |
|
30 | - * @since 11.0.0 |
|
31 | - */ |
|
32 | - public function getIdentifier() { |
|
33 | - return 'file_changed'; |
|
34 | - } |
|
28 | + /** |
|
29 | + * @return string Lowercase a-z and underscore only identifier |
|
30 | + * @since 11.0.0 |
|
31 | + */ |
|
32 | + public function getIdentifier() { |
|
33 | + return 'file_changed'; |
|
34 | + } |
|
35 | 35 | |
36 | - /** |
|
37 | - * @return string A translated string |
|
38 | - * @since 11.0.0 |
|
39 | - */ |
|
40 | - public function getName() { |
|
41 | - return $this->l->t('A file or folder has been <strong>changed</strong>'); |
|
42 | - } |
|
36 | + /** |
|
37 | + * @return string A translated string |
|
38 | + * @since 11.0.0 |
|
39 | + */ |
|
40 | + public function getName() { |
|
41 | + return $this->l->t('A file or folder has been <strong>changed</strong>'); |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * @return int whether the filter should be rather on the top or bottom of |
|
46 | - * the admin section. The filters are arranged in ascending order of the |
|
47 | - * priority values. It is required to return a value between 0 and 100. |
|
48 | - * @since 11.0.0 |
|
49 | - */ |
|
50 | - public function getPriority() { |
|
51 | - return 2; |
|
52 | - } |
|
44 | + /** |
|
45 | + * @return int whether the filter should be rather on the top or bottom of |
|
46 | + * the admin section. The filters are arranged in ascending order of the |
|
47 | + * priority values. It is required to return a value between 0 and 100. |
|
48 | + * @since 11.0.0 |
|
49 | + */ |
|
50 | + public function getPriority() { |
|
51 | + return 2; |
|
52 | + } |
|
53 | 53 | |
54 | - public function canChangeMail() { |
|
55 | - return true; |
|
56 | - } |
|
54 | + public function canChangeMail() { |
|
55 | + return true; |
|
56 | + } |
|
57 | 57 | |
58 | - public function isDefaultEnabledMail() { |
|
59 | - return false; |
|
60 | - } |
|
58 | + public function isDefaultEnabledMail() { |
|
59 | + return false; |
|
60 | + } |
|
61 | 61 | |
62 | - public function canChangeNotification() { |
|
63 | - return true; |
|
64 | - } |
|
62 | + public function canChangeNotification() { |
|
63 | + return true; |
|
64 | + } |
|
65 | 65 | |
66 | - public function isDefaultEnabledNotification() { |
|
67 | - return false; |
|
68 | - } |
|
66 | + public function isDefaultEnabledNotification() { |
|
67 | + return false; |
|
68 | + } |
|
69 | 69 | } |
@@ -34,15 +34,15 @@ |
||
34 | 34 | * @since 15.0.0 |
35 | 35 | */ |
36 | 36 | interface IWriteStreamStorage extends IStorage { |
37 | - /** |
|
38 | - * Write the data from a stream to a file |
|
39 | - * |
|
40 | - * @param string $path |
|
41 | - * @param resource $stream |
|
42 | - * @param int|null $size the size of the stream if known in advance |
|
43 | - * @return int the number of bytes written |
|
44 | - * @throws GenericFileException |
|
45 | - * @since 15.0.0 |
|
46 | - */ |
|
47 | - public function writeStream(string $path, $stream, int $size = null): int; |
|
37 | + /** |
|
38 | + * Write the data from a stream to a file |
|
39 | + * |
|
40 | + * @param string $path |
|
41 | + * @param resource $stream |
|
42 | + * @param int|null $size the size of the stream if known in advance |
|
43 | + * @return int the number of bytes written |
|
44 | + * @throws GenericFileException |
|
45 | + * @since 15.0.0 |
|
46 | + */ |
|
47 | + public function writeStream(string $path, $stream, int $size = null): int; |
|
48 | 48 | } |
@@ -35,143 +35,143 @@ |
||
35 | 35 | * @since 6.0.0 |
36 | 36 | */ |
37 | 37 | interface IManager { |
38 | - /** |
|
39 | - * Generates a new IEvent object |
|
40 | - * |
|
41 | - * Make sure to call at least the following methods before sending it to the |
|
42 | - * app with via the publish() method: |
|
43 | - * - setApp() |
|
44 | - * - setType() |
|
45 | - * - setAffectedUser() |
|
46 | - * - setSubject() |
|
47 | - * - setObject() |
|
48 | - * |
|
49 | - * @return IEvent |
|
50 | - * @since 8.2.0 |
|
51 | - */ |
|
52 | - public function generateEvent(): IEvent; |
|
53 | - |
|
54 | - /** |
|
55 | - * Publish an event to the activity consumers |
|
56 | - * |
|
57 | - * Make sure to call at least the following methods before sending an Event: |
|
58 | - * - setApp() |
|
59 | - * - setType() |
|
60 | - * - setAffectedUser() |
|
61 | - * - setSubject() |
|
62 | - * - setObject() |
|
63 | - * |
|
64 | - * @param IEvent $event |
|
65 | - * @throws \BadMethodCallException if required values have not been set |
|
66 | - * @since 8.2.0 |
|
67 | - */ |
|
68 | - public function publish(IEvent $event): void; |
|
69 | - |
|
70 | - /** |
|
71 | - * In order to improve lazy loading a closure can be registered which will be called in case |
|
72 | - * activity consumers are actually requested |
|
73 | - * |
|
74 | - * $callable has to return an instance of \OCP\Activity\IConsumer |
|
75 | - * |
|
76 | - * @param \Closure $callable |
|
77 | - * @since 6.0.0 |
|
78 | - */ |
|
79 | - public function registerConsumer(\Closure $callable): void; |
|
80 | - |
|
81 | - /** |
|
82 | - * @param string $filter Class must implement OCA\Activity\IFilter |
|
83 | - * @since 11.0.0 |
|
84 | - */ |
|
85 | - public function registerFilter(string $filter): void; |
|
86 | - |
|
87 | - /** |
|
88 | - * @return IFilter[] |
|
89 | - * @since 11.0.0 |
|
90 | - */ |
|
91 | - public function getFilters(): array; |
|
92 | - |
|
93 | - /** |
|
94 | - * @param string $id |
|
95 | - * @return IFilter |
|
96 | - * @throws \InvalidArgumentException when the filter was not found |
|
97 | - * @since 11.0.0 |
|
98 | - */ |
|
99 | - public function getFilterById(string $id): IFilter; |
|
100 | - |
|
101 | - /** |
|
102 | - * @param string $setting Class must implement OCA\Activity\ISetting |
|
103 | - * @since 11.0.0 |
|
104 | - */ |
|
105 | - public function registerSetting(string $setting): void; |
|
106 | - |
|
107 | - /** |
|
108 | - * @return ActivitySettings[] |
|
109 | - * @since 11.0.0 |
|
110 | - */ |
|
111 | - public function getSettings(): array; |
|
112 | - |
|
113 | - /** |
|
114 | - * @param string $provider Class must implement OCA\Activity\IProvider |
|
115 | - * @since 11.0.0 |
|
116 | - */ |
|
117 | - public function registerProvider(string $provider): void; |
|
118 | - |
|
119 | - /** |
|
120 | - * @return IProvider[] |
|
121 | - * @since 11.0.0 |
|
122 | - */ |
|
123 | - public function getProviders(): array; |
|
124 | - |
|
125 | - /** |
|
126 | - * @param string $id |
|
127 | - * @return ActivitySettings |
|
128 | - * @throws \InvalidArgumentException when the setting was not found |
|
129 | - * @since 11.0.0 |
|
130 | - */ |
|
131 | - public function getSettingById(string $id): ActivitySettings; |
|
132 | - |
|
133 | - /** |
|
134 | - * @param string $type |
|
135 | - * @param int $id |
|
136 | - * @since 8.2.0 |
|
137 | - */ |
|
138 | - public function setFormattingObject(string $type, int $id): void; |
|
139 | - |
|
140 | - /** |
|
141 | - * @return bool |
|
142 | - * @since 8.2.0 |
|
143 | - */ |
|
144 | - public function isFormattingFilteredObject(): bool; |
|
145 | - |
|
146 | - /** |
|
147 | - * @param bool $status Set to true, when parsing events should not use SVG icons |
|
148 | - * @since 12.0.1 |
|
149 | - */ |
|
150 | - public function setRequirePNG(bool $status): void; |
|
151 | - |
|
152 | - /** |
|
153 | - * @return bool |
|
154 | - * @since 12.0.1 |
|
155 | - */ |
|
156 | - public function getRequirePNG(): bool; |
|
157 | - |
|
158 | - /** |
|
159 | - * Set the user we need to use |
|
160 | - * |
|
161 | - * @param string|null $currentUserId |
|
162 | - * @throws \UnexpectedValueException If the user is invalid |
|
163 | - * @since 9.0.1 |
|
164 | - */ |
|
165 | - public function setCurrentUserId(string $currentUserId = null): void; |
|
166 | - |
|
167 | - /** |
|
168 | - * Get the user we need to use |
|
169 | - * |
|
170 | - * Either the user is logged in, or we try to get it from the token |
|
171 | - * |
|
172 | - * @return string |
|
173 | - * @throws \UnexpectedValueException If the token is invalid, does not exist or is not unique |
|
174 | - * @since 8.1.0 |
|
175 | - */ |
|
176 | - public function getCurrentUserId(): string; |
|
38 | + /** |
|
39 | + * Generates a new IEvent object |
|
40 | + * |
|
41 | + * Make sure to call at least the following methods before sending it to the |
|
42 | + * app with via the publish() method: |
|
43 | + * - setApp() |
|
44 | + * - setType() |
|
45 | + * - setAffectedUser() |
|
46 | + * - setSubject() |
|
47 | + * - setObject() |
|
48 | + * |
|
49 | + * @return IEvent |
|
50 | + * @since 8.2.0 |
|
51 | + */ |
|
52 | + public function generateEvent(): IEvent; |
|
53 | + |
|
54 | + /** |
|
55 | + * Publish an event to the activity consumers |
|
56 | + * |
|
57 | + * Make sure to call at least the following methods before sending an Event: |
|
58 | + * - setApp() |
|
59 | + * - setType() |
|
60 | + * - setAffectedUser() |
|
61 | + * - setSubject() |
|
62 | + * - setObject() |
|
63 | + * |
|
64 | + * @param IEvent $event |
|
65 | + * @throws \BadMethodCallException if required values have not been set |
|
66 | + * @since 8.2.0 |
|
67 | + */ |
|
68 | + public function publish(IEvent $event): void; |
|
69 | + |
|
70 | + /** |
|
71 | + * In order to improve lazy loading a closure can be registered which will be called in case |
|
72 | + * activity consumers are actually requested |
|
73 | + * |
|
74 | + * $callable has to return an instance of \OCP\Activity\IConsumer |
|
75 | + * |
|
76 | + * @param \Closure $callable |
|
77 | + * @since 6.0.0 |
|
78 | + */ |
|
79 | + public function registerConsumer(\Closure $callable): void; |
|
80 | + |
|
81 | + /** |
|
82 | + * @param string $filter Class must implement OCA\Activity\IFilter |
|
83 | + * @since 11.0.0 |
|
84 | + */ |
|
85 | + public function registerFilter(string $filter): void; |
|
86 | + |
|
87 | + /** |
|
88 | + * @return IFilter[] |
|
89 | + * @since 11.0.0 |
|
90 | + */ |
|
91 | + public function getFilters(): array; |
|
92 | + |
|
93 | + /** |
|
94 | + * @param string $id |
|
95 | + * @return IFilter |
|
96 | + * @throws \InvalidArgumentException when the filter was not found |
|
97 | + * @since 11.0.0 |
|
98 | + */ |
|
99 | + public function getFilterById(string $id): IFilter; |
|
100 | + |
|
101 | + /** |
|
102 | + * @param string $setting Class must implement OCA\Activity\ISetting |
|
103 | + * @since 11.0.0 |
|
104 | + */ |
|
105 | + public function registerSetting(string $setting): void; |
|
106 | + |
|
107 | + /** |
|
108 | + * @return ActivitySettings[] |
|
109 | + * @since 11.0.0 |
|
110 | + */ |
|
111 | + public function getSettings(): array; |
|
112 | + |
|
113 | + /** |
|
114 | + * @param string $provider Class must implement OCA\Activity\IProvider |
|
115 | + * @since 11.0.0 |
|
116 | + */ |
|
117 | + public function registerProvider(string $provider): void; |
|
118 | + |
|
119 | + /** |
|
120 | + * @return IProvider[] |
|
121 | + * @since 11.0.0 |
|
122 | + */ |
|
123 | + public function getProviders(): array; |
|
124 | + |
|
125 | + /** |
|
126 | + * @param string $id |
|
127 | + * @return ActivitySettings |
|
128 | + * @throws \InvalidArgumentException when the setting was not found |
|
129 | + * @since 11.0.0 |
|
130 | + */ |
|
131 | + public function getSettingById(string $id): ActivitySettings; |
|
132 | + |
|
133 | + /** |
|
134 | + * @param string $type |
|
135 | + * @param int $id |
|
136 | + * @since 8.2.0 |
|
137 | + */ |
|
138 | + public function setFormattingObject(string $type, int $id): void; |
|
139 | + |
|
140 | + /** |
|
141 | + * @return bool |
|
142 | + * @since 8.2.0 |
|
143 | + */ |
|
144 | + public function isFormattingFilteredObject(): bool; |
|
145 | + |
|
146 | + /** |
|
147 | + * @param bool $status Set to true, when parsing events should not use SVG icons |
|
148 | + * @since 12.0.1 |
|
149 | + */ |
|
150 | + public function setRequirePNG(bool $status): void; |
|
151 | + |
|
152 | + /** |
|
153 | + * @return bool |
|
154 | + * @since 12.0.1 |
|
155 | + */ |
|
156 | + public function getRequirePNG(): bool; |
|
157 | + |
|
158 | + /** |
|
159 | + * Set the user we need to use |
|
160 | + * |
|
161 | + * @param string|null $currentUserId |
|
162 | + * @throws \UnexpectedValueException If the user is invalid |
|
163 | + * @since 9.0.1 |
|
164 | + */ |
|
165 | + public function setCurrentUserId(string $currentUserId = null): void; |
|
166 | + |
|
167 | + /** |
|
168 | + * Get the user we need to use |
|
169 | + * |
|
170 | + * Either the user is logged in, or we try to get it from the token |
|
171 | + * |
|
172 | + * @return string |
|
173 | + * @throws \UnexpectedValueException If the token is invalid, does not exist or is not unique |
|
174 | + * @since 8.1.0 |
|
175 | + */ |
|
176 | + public function getCurrentUserId(): string; |
|
177 | 177 | } |
@@ -33,89 +33,89 @@ |
||
33 | 33 | * Repairs shares with invalid data |
34 | 34 | */ |
35 | 35 | class RepairInvalidShares implements IRepairStep { |
36 | - public const CHUNK_SIZE = 200; |
|
37 | - |
|
38 | - /** @var \OCP\IConfig */ |
|
39 | - protected $config; |
|
40 | - |
|
41 | - /** @var \OCP\IDBConnection */ |
|
42 | - protected $connection; |
|
43 | - |
|
44 | - /** |
|
45 | - * @param \OCP\IConfig $config |
|
46 | - * @param \OCP\IDBConnection $connection |
|
47 | - */ |
|
48 | - public function __construct($config, $connection) { |
|
49 | - $this->connection = $connection; |
|
50 | - $this->config = $config; |
|
51 | - } |
|
52 | - |
|
53 | - public function getName() { |
|
54 | - return 'Repair invalid shares'; |
|
55 | - } |
|
56 | - |
|
57 | - /** |
|
58 | - * Adjust file share permissions |
|
59 | - */ |
|
60 | - private function adjustFileSharePermissions(IOutput $out) { |
|
61 | - $mask = \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE; |
|
62 | - $builder = $this->connection->getQueryBuilder(); |
|
63 | - |
|
64 | - $permsFunc = $builder->expr()->bitwiseAnd('permissions', $mask); |
|
65 | - $builder |
|
66 | - ->update('share') |
|
67 | - ->set('permissions', $permsFunc) |
|
68 | - ->where($builder->expr()->eq('item_type', $builder->expr()->literal('file'))) |
|
69 | - ->andWhere($builder->expr()->neq('permissions', $permsFunc)); |
|
70 | - |
|
71 | - $updatedEntries = $builder->execute(); |
|
72 | - if ($updatedEntries > 0) { |
|
73 | - $out->info('Fixed file share permissions for ' . $updatedEntries . ' shares'); |
|
74 | - } |
|
75 | - } |
|
76 | - |
|
77 | - /** |
|
78 | - * Remove shares where the parent share does not exist anymore |
|
79 | - */ |
|
80 | - private function removeSharesNonExistingParent(IOutput $out) { |
|
81 | - $deletedEntries = 0; |
|
82 | - |
|
83 | - $query = $this->connection->getQueryBuilder(); |
|
84 | - $query->select('s1.parent') |
|
85 | - ->from('share', 's1') |
|
86 | - ->where($query->expr()->isNotNull('s1.parent')) |
|
87 | - ->andWhere($query->expr()->isNull('s2.id')) |
|
88 | - ->leftJoin('s1', 'share', 's2', $query->expr()->eq('s1.parent', 's2.id')) |
|
89 | - ->groupBy('s1.parent') |
|
90 | - ->setMaxResults(self::CHUNK_SIZE); |
|
91 | - |
|
92 | - $deleteQuery = $this->connection->getQueryBuilder(); |
|
93 | - $deleteQuery->delete('share') |
|
94 | - ->where($deleteQuery->expr()->eq('parent', $deleteQuery->createParameter('parent'))); |
|
95 | - |
|
96 | - $deletedInLastChunk = self::CHUNK_SIZE; |
|
97 | - while ($deletedInLastChunk === self::CHUNK_SIZE) { |
|
98 | - $deletedInLastChunk = 0; |
|
99 | - $result = $query->execute(); |
|
100 | - while ($row = $result->fetch()) { |
|
101 | - $deletedInLastChunk++; |
|
102 | - $deletedEntries += $deleteQuery->setParameter('parent', (int) $row['parent']) |
|
103 | - ->execute(); |
|
104 | - } |
|
105 | - $result->closeCursor(); |
|
106 | - } |
|
107 | - |
|
108 | - if ($deletedEntries) { |
|
109 | - $out->info('Removed ' . $deletedEntries . ' shares where the parent did not exist'); |
|
110 | - } |
|
111 | - } |
|
112 | - |
|
113 | - public function run(IOutput $out) { |
|
114 | - $ocVersionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0'); |
|
115 | - if (version_compare($ocVersionFromBeforeUpdate, '12.0.0.11', '<')) { |
|
116 | - $this->adjustFileSharePermissions($out); |
|
117 | - } |
|
118 | - |
|
119 | - $this->removeSharesNonExistingParent($out); |
|
120 | - } |
|
36 | + public const CHUNK_SIZE = 200; |
|
37 | + |
|
38 | + /** @var \OCP\IConfig */ |
|
39 | + protected $config; |
|
40 | + |
|
41 | + /** @var \OCP\IDBConnection */ |
|
42 | + protected $connection; |
|
43 | + |
|
44 | + /** |
|
45 | + * @param \OCP\IConfig $config |
|
46 | + * @param \OCP\IDBConnection $connection |
|
47 | + */ |
|
48 | + public function __construct($config, $connection) { |
|
49 | + $this->connection = $connection; |
|
50 | + $this->config = $config; |
|
51 | + } |
|
52 | + |
|
53 | + public function getName() { |
|
54 | + return 'Repair invalid shares'; |
|
55 | + } |
|
56 | + |
|
57 | + /** |
|
58 | + * Adjust file share permissions |
|
59 | + */ |
|
60 | + private function adjustFileSharePermissions(IOutput $out) { |
|
61 | + $mask = \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE; |
|
62 | + $builder = $this->connection->getQueryBuilder(); |
|
63 | + |
|
64 | + $permsFunc = $builder->expr()->bitwiseAnd('permissions', $mask); |
|
65 | + $builder |
|
66 | + ->update('share') |
|
67 | + ->set('permissions', $permsFunc) |
|
68 | + ->where($builder->expr()->eq('item_type', $builder->expr()->literal('file'))) |
|
69 | + ->andWhere($builder->expr()->neq('permissions', $permsFunc)); |
|
70 | + |
|
71 | + $updatedEntries = $builder->execute(); |
|
72 | + if ($updatedEntries > 0) { |
|
73 | + $out->info('Fixed file share permissions for ' . $updatedEntries . ' shares'); |
|
74 | + } |
|
75 | + } |
|
76 | + |
|
77 | + /** |
|
78 | + * Remove shares where the parent share does not exist anymore |
|
79 | + */ |
|
80 | + private function removeSharesNonExistingParent(IOutput $out) { |
|
81 | + $deletedEntries = 0; |
|
82 | + |
|
83 | + $query = $this->connection->getQueryBuilder(); |
|
84 | + $query->select('s1.parent') |
|
85 | + ->from('share', 's1') |
|
86 | + ->where($query->expr()->isNotNull('s1.parent')) |
|
87 | + ->andWhere($query->expr()->isNull('s2.id')) |
|
88 | + ->leftJoin('s1', 'share', 's2', $query->expr()->eq('s1.parent', 's2.id')) |
|
89 | + ->groupBy('s1.parent') |
|
90 | + ->setMaxResults(self::CHUNK_SIZE); |
|
91 | + |
|
92 | + $deleteQuery = $this->connection->getQueryBuilder(); |
|
93 | + $deleteQuery->delete('share') |
|
94 | + ->where($deleteQuery->expr()->eq('parent', $deleteQuery->createParameter('parent'))); |
|
95 | + |
|
96 | + $deletedInLastChunk = self::CHUNK_SIZE; |
|
97 | + while ($deletedInLastChunk === self::CHUNK_SIZE) { |
|
98 | + $deletedInLastChunk = 0; |
|
99 | + $result = $query->execute(); |
|
100 | + while ($row = $result->fetch()) { |
|
101 | + $deletedInLastChunk++; |
|
102 | + $deletedEntries += $deleteQuery->setParameter('parent', (int) $row['parent']) |
|
103 | + ->execute(); |
|
104 | + } |
|
105 | + $result->closeCursor(); |
|
106 | + } |
|
107 | + |
|
108 | + if ($deletedEntries) { |
|
109 | + $out->info('Removed ' . $deletedEntries . ' shares where the parent did not exist'); |
|
110 | + } |
|
111 | + } |
|
112 | + |
|
113 | + public function run(IOutput $out) { |
|
114 | + $ocVersionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0'); |
|
115 | + if (version_compare($ocVersionFromBeforeUpdate, '12.0.0.11', '<')) { |
|
116 | + $this->adjustFileSharePermissions($out); |
|
117 | + } |
|
118 | + |
|
119 | + $this->removeSharesNonExistingParent($out); |
|
120 | + } |
|
121 | 121 | } |
@@ -24,30 +24,30 @@ |
||
24 | 24 | namespace OC\Files\Cache; |
25 | 25 | |
26 | 26 | class NullWatcher extends Watcher { |
27 | - private $policy; |
|
27 | + private $policy; |
|
28 | 28 | |
29 | - public function __construct() { |
|
30 | - } |
|
29 | + public function __construct() { |
|
30 | + } |
|
31 | 31 | |
32 | - public function setPolicy($policy) { |
|
33 | - $this->policy = $policy; |
|
34 | - } |
|
32 | + public function setPolicy($policy) { |
|
33 | + $this->policy = $policy; |
|
34 | + } |
|
35 | 35 | |
36 | - public function getPolicy() { |
|
37 | - return $this->policy; |
|
38 | - } |
|
36 | + public function getPolicy() { |
|
37 | + return $this->policy; |
|
38 | + } |
|
39 | 39 | |
40 | - public function checkUpdate($path, $cachedEntry = null) { |
|
41 | - return false; |
|
42 | - } |
|
40 | + public function checkUpdate($path, $cachedEntry = null) { |
|
41 | + return false; |
|
42 | + } |
|
43 | 43 | |
44 | - public function update($path, $cachedData) { |
|
45 | - } |
|
44 | + public function update($path, $cachedData) { |
|
45 | + } |
|
46 | 46 | |
47 | - public function needsUpdate($path, $cachedData) { |
|
48 | - return false; |
|
49 | - } |
|
47 | + public function needsUpdate($path, $cachedData) { |
|
48 | + return false; |
|
49 | + } |
|
50 | 50 | |
51 | - public function cleanFolder($path) { |
|
52 | - } |
|
51 | + public function cleanFolder($path) { |
|
52 | + } |
|
53 | 53 | } |