@@ -24,61 +24,61 @@ |
||
24 | 24 | namespace OCA\Files\Activity\Settings; |
25 | 25 | |
26 | 26 | class FavoriteAction extends FileActivitySettings { |
27 | - /** |
|
28 | - * @return string Lowercase a-z and underscore only identifier |
|
29 | - * @since 11.0.0 |
|
30 | - */ |
|
31 | - public function getIdentifier() { |
|
32 | - return 'favorite'; |
|
33 | - } |
|
27 | + /** |
|
28 | + * @return string Lowercase a-z and underscore only identifier |
|
29 | + * @since 11.0.0 |
|
30 | + */ |
|
31 | + public function getIdentifier() { |
|
32 | + return 'favorite'; |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * @return string A translated string |
|
37 | - * @since 11.0.0 |
|
38 | - */ |
|
39 | - public function getName() { |
|
40 | - return $this->l->t('A file has been added to or removed from your <strong>favorites</strong>'); |
|
41 | - } |
|
35 | + /** |
|
36 | + * @return string A translated string |
|
37 | + * @since 11.0.0 |
|
38 | + */ |
|
39 | + public function getName() { |
|
40 | + return $this->l->t('A file has been added to or removed from your <strong>favorites</strong>'); |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * @return int whether the filter should be rather on the top or bottom of |
|
45 | - * the admin section. The filters are arranged in ascending order of the |
|
46 | - * priority values. It is required to return a value between 0 and 100. |
|
47 | - * @since 11.0.0 |
|
48 | - */ |
|
49 | - public function getPriority() { |
|
50 | - return 5; |
|
51 | - } |
|
43 | + /** |
|
44 | + * @return int whether the filter should be rather on the top or bottom of |
|
45 | + * the admin section. The filters are arranged in ascending order of the |
|
46 | + * priority values. It is required to return a value between 0 and 100. |
|
47 | + * @since 11.0.0 |
|
48 | + */ |
|
49 | + public function getPriority() { |
|
50 | + return 5; |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * @return bool True when the option can be changed for the stream |
|
55 | - * @since 11.0.0 |
|
56 | - */ |
|
57 | - public function canChangeStream() { |
|
58 | - return true; |
|
59 | - } |
|
53 | + /** |
|
54 | + * @return bool True when the option can be changed for the stream |
|
55 | + * @since 11.0.0 |
|
56 | + */ |
|
57 | + public function canChangeStream() { |
|
58 | + return true; |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * @return bool True when the option can be changed for the stream |
|
63 | - * @since 11.0.0 |
|
64 | - */ |
|
65 | - public function isDefaultEnabledStream() { |
|
66 | - return true; |
|
67 | - } |
|
61 | + /** |
|
62 | + * @return bool True when the option can be changed for the stream |
|
63 | + * @since 11.0.0 |
|
64 | + */ |
|
65 | + public function isDefaultEnabledStream() { |
|
66 | + return true; |
|
67 | + } |
|
68 | 68 | |
69 | - /** |
|
70 | - * @return bool True when the option can be changed for the mail |
|
71 | - * @since 11.0.0 |
|
72 | - */ |
|
73 | - public function canChangeMail() { |
|
74 | - return true; |
|
75 | - } |
|
69 | + /** |
|
70 | + * @return bool True when the option can be changed for the mail |
|
71 | + * @since 11.0.0 |
|
72 | + */ |
|
73 | + public function canChangeMail() { |
|
74 | + return true; |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * @return bool True when the option can be changed for the stream |
|
79 | - * @since 11.0.0 |
|
80 | - */ |
|
81 | - public function isDefaultEnabledMail() { |
|
82 | - return false; |
|
83 | - } |
|
77 | + /** |
|
78 | + * @return bool True when the option can be changed for the stream |
|
79 | + * @since 11.0.0 |
|
80 | + */ |
|
81 | + public function isDefaultEnabledMail() { |
|
82 | + return false; |
|
83 | + } |
|
84 | 84 | } |
@@ -24,61 +24,61 @@ |
||
24 | 24 | namespace OCA\Files\Activity\Settings; |
25 | 25 | |
26 | 26 | class FileFavorite extends FileActivitySettings { |
27 | - /** |
|
28 | - * @return string Lowercase a-z and underscore only identifier |
|
29 | - * @since 11.0.0 |
|
30 | - */ |
|
31 | - public function getIdentifier() { |
|
32 | - return 'file_favorite'; |
|
33 | - } |
|
27 | + /** |
|
28 | + * @return string Lowercase a-z and underscore only identifier |
|
29 | + * @since 11.0.0 |
|
30 | + */ |
|
31 | + public function getIdentifier() { |
|
32 | + return 'file_favorite'; |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * @return string A translated string |
|
37 | - * @since 11.0.0 |
|
38 | - */ |
|
39 | - public function getName() { |
|
40 | - return $this->l->t('Limit notifications about creation and changes to your <strong>favorite files</strong> <em>(Stream only)</em>'); |
|
41 | - } |
|
35 | + /** |
|
36 | + * @return string A translated string |
|
37 | + * @since 11.0.0 |
|
38 | + */ |
|
39 | + public function getName() { |
|
40 | + return $this->l->t('Limit notifications about creation and changes to your <strong>favorite files</strong> <em>(Stream only)</em>'); |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * @return int whether the filter should be rather on the top or bottom of |
|
45 | - * the admin section. The filters are arranged in ascending order of the |
|
46 | - * priority values. It is required to return a value between 0 and 100. |
|
47 | - * @since 11.0.0 |
|
48 | - */ |
|
49 | - public function getPriority() { |
|
50 | - return 2; |
|
51 | - } |
|
43 | + /** |
|
44 | + * @return int whether the filter should be rather on the top or bottom of |
|
45 | + * the admin section. The filters are arranged in ascending order of the |
|
46 | + * priority values. It is required to return a value between 0 and 100. |
|
47 | + * @since 11.0.0 |
|
48 | + */ |
|
49 | + public function getPriority() { |
|
50 | + return 2; |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * @return bool True when the option can be changed for the stream |
|
55 | - * @since 11.0.0 |
|
56 | - */ |
|
57 | - public function canChangeStream() { |
|
58 | - return true; |
|
59 | - } |
|
53 | + /** |
|
54 | + * @return bool True when the option can be changed for the stream |
|
55 | + * @since 11.0.0 |
|
56 | + */ |
|
57 | + public function canChangeStream() { |
|
58 | + return true; |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * @return bool True when the option can be changed for the stream |
|
63 | - * @since 11.0.0 |
|
64 | - */ |
|
65 | - public function isDefaultEnabledStream() { |
|
66 | - return false; |
|
67 | - } |
|
61 | + /** |
|
62 | + * @return bool True when the option can be changed for the stream |
|
63 | + * @since 11.0.0 |
|
64 | + */ |
|
65 | + public function isDefaultEnabledStream() { |
|
66 | + return false; |
|
67 | + } |
|
68 | 68 | |
69 | - /** |
|
70 | - * @return bool True when the option can be changed for the mail |
|
71 | - * @since 11.0.0 |
|
72 | - */ |
|
73 | - public function canChangeMail() { |
|
74 | - return false; |
|
75 | - } |
|
69 | + /** |
|
70 | + * @return bool True when the option can be changed for the mail |
|
71 | + * @since 11.0.0 |
|
72 | + */ |
|
73 | + public function canChangeMail() { |
|
74 | + return false; |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * @return bool True when the option can be changed for the stream |
|
79 | - * @since 11.0.0 |
|
80 | - */ |
|
81 | - public function isDefaultEnabledMail() { |
|
82 | - return false; |
|
83 | - } |
|
77 | + /** |
|
78 | + * @return bool True when the option can be changed for the stream |
|
79 | + * @since 11.0.0 |
|
80 | + */ |
|
81 | + public function isDefaultEnabledMail() { |
|
82 | + return false; |
|
83 | + } |
|
84 | 84 | } |
@@ -24,61 +24,61 @@ |
||
24 | 24 | namespace OCA\Files\Activity\Settings; |
25 | 25 | |
26 | 26 | class FileRestored extends FileActivitySettings { |
27 | - /** |
|
28 | - * @return string Lowercase a-z and underscore only identifier |
|
29 | - * @since 11.0.0 |
|
30 | - */ |
|
31 | - public function getIdentifier() { |
|
32 | - return 'file_restored'; |
|
33 | - } |
|
27 | + /** |
|
28 | + * @return string Lowercase a-z and underscore only identifier |
|
29 | + * @since 11.0.0 |
|
30 | + */ |
|
31 | + public function getIdentifier() { |
|
32 | + return 'file_restored'; |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * @return string A translated string |
|
37 | - * @since 11.0.0 |
|
38 | - */ |
|
39 | - public function getName() { |
|
40 | - return $this->l->t('A file or folder has been <strong>restored</strong>'); |
|
41 | - } |
|
35 | + /** |
|
36 | + * @return string A translated string |
|
37 | + * @since 11.0.0 |
|
38 | + */ |
|
39 | + public function getName() { |
|
40 | + return $this->l->t('A file or folder has been <strong>restored</strong>'); |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * @return int whether the filter should be rather on the top or bottom of |
|
45 | - * the admin section. The filters are arranged in ascending order of the |
|
46 | - * priority values. It is required to return a value between 0 and 100. |
|
47 | - * @since 11.0.0 |
|
48 | - */ |
|
49 | - public function getPriority() { |
|
50 | - return 4; |
|
51 | - } |
|
43 | + /** |
|
44 | + * @return int whether the filter should be rather on the top or bottom of |
|
45 | + * the admin section. The filters are arranged in ascending order of the |
|
46 | + * priority values. It is required to return a value between 0 and 100. |
|
47 | + * @since 11.0.0 |
|
48 | + */ |
|
49 | + public function getPriority() { |
|
50 | + return 4; |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * @return bool True when the option can be changed for the stream |
|
55 | - * @since 11.0.0 |
|
56 | - */ |
|
57 | - public function canChangeStream() { |
|
58 | - return true; |
|
59 | - } |
|
53 | + /** |
|
54 | + * @return bool True when the option can be changed for the stream |
|
55 | + * @since 11.0.0 |
|
56 | + */ |
|
57 | + public function canChangeStream() { |
|
58 | + return true; |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * @return bool True when the option can be changed for the stream |
|
63 | - * @since 11.0.0 |
|
64 | - */ |
|
65 | - public function isDefaultEnabledStream() { |
|
66 | - return true; |
|
67 | - } |
|
61 | + /** |
|
62 | + * @return bool True when the option can be changed for the stream |
|
63 | + * @since 11.0.0 |
|
64 | + */ |
|
65 | + public function isDefaultEnabledStream() { |
|
66 | + return true; |
|
67 | + } |
|
68 | 68 | |
69 | - /** |
|
70 | - * @return bool True when the option can be changed for the mail |
|
71 | - * @since 11.0.0 |
|
72 | - */ |
|
73 | - public function canChangeMail() { |
|
74 | - return true; |
|
75 | - } |
|
69 | + /** |
|
70 | + * @return bool True when the option can be changed for the mail |
|
71 | + * @since 11.0.0 |
|
72 | + */ |
|
73 | + public function canChangeMail() { |
|
74 | + return true; |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * @return bool True when the option can be changed for the stream |
|
79 | - * @since 11.0.0 |
|
80 | - */ |
|
81 | - public function isDefaultEnabledMail() { |
|
82 | - return false; |
|
83 | - } |
|
77 | + /** |
|
78 | + * @return bool True when the option can be changed for the stream |
|
79 | + * @since 11.0.0 |
|
80 | + */ |
|
81 | + public function isDefaultEnabledMail() { |
|
82 | + return false; |
|
83 | + } |
|
84 | 84 | } |
@@ -24,61 +24,61 @@ |
||
24 | 24 | namespace OCA\Files\Activity\Settings; |
25 | 25 | |
26 | 26 | class FileDeleted extends FileActivitySettings { |
27 | - /** |
|
28 | - * @return string Lowercase a-z and underscore only identifier |
|
29 | - * @since 11.0.0 |
|
30 | - */ |
|
31 | - public function getIdentifier() { |
|
32 | - return 'file_deleted'; |
|
33 | - } |
|
27 | + /** |
|
28 | + * @return string Lowercase a-z and underscore only identifier |
|
29 | + * @since 11.0.0 |
|
30 | + */ |
|
31 | + public function getIdentifier() { |
|
32 | + return 'file_deleted'; |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * @return string A translated string |
|
37 | - * @since 11.0.0 |
|
38 | - */ |
|
39 | - public function getName() { |
|
40 | - return $this->l->t('A file or folder has been <strong>deleted</strong>'); |
|
41 | - } |
|
35 | + /** |
|
36 | + * @return string A translated string |
|
37 | + * @since 11.0.0 |
|
38 | + */ |
|
39 | + public function getName() { |
|
40 | + return $this->l->t('A file or folder has been <strong>deleted</strong>'); |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * @return int whether the filter should be rather on the top or bottom of |
|
45 | - * the admin section. The filters are arranged in ascending order of the |
|
46 | - * priority values. It is required to return a value between 0 and 100. |
|
47 | - * @since 11.0.0 |
|
48 | - */ |
|
49 | - public function getPriority() { |
|
50 | - return 3; |
|
51 | - } |
|
43 | + /** |
|
44 | + * @return int whether the filter should be rather on the top or bottom of |
|
45 | + * the admin section. The filters are arranged in ascending order of the |
|
46 | + * priority values. It is required to return a value between 0 and 100. |
|
47 | + * @since 11.0.0 |
|
48 | + */ |
|
49 | + public function getPriority() { |
|
50 | + return 3; |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * @return bool True when the option can be changed for the stream |
|
55 | - * @since 11.0.0 |
|
56 | - */ |
|
57 | - public function canChangeStream() { |
|
58 | - return true; |
|
59 | - } |
|
53 | + /** |
|
54 | + * @return bool True when the option can be changed for the stream |
|
55 | + * @since 11.0.0 |
|
56 | + */ |
|
57 | + public function canChangeStream() { |
|
58 | + return true; |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * @return bool True when the option can be changed for the stream |
|
63 | - * @since 11.0.0 |
|
64 | - */ |
|
65 | - public function isDefaultEnabledStream() { |
|
66 | - return true; |
|
67 | - } |
|
61 | + /** |
|
62 | + * @return bool True when the option can be changed for the stream |
|
63 | + * @since 11.0.0 |
|
64 | + */ |
|
65 | + public function isDefaultEnabledStream() { |
|
66 | + return true; |
|
67 | + } |
|
68 | 68 | |
69 | - /** |
|
70 | - * @return bool True when the option can be changed for the mail |
|
71 | - * @since 11.0.0 |
|
72 | - */ |
|
73 | - public function canChangeMail() { |
|
74 | - return true; |
|
75 | - } |
|
69 | + /** |
|
70 | + * @return bool True when the option can be changed for the mail |
|
71 | + * @since 11.0.0 |
|
72 | + */ |
|
73 | + public function canChangeMail() { |
|
74 | + return true; |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * @return bool True when the option can be changed for the stream |
|
79 | - * @since 11.0.0 |
|
80 | - */ |
|
81 | - public function isDefaultEnabledMail() { |
|
82 | - return false; |
|
83 | - } |
|
77 | + /** |
|
78 | + * @return bool True when the option can be changed for the stream |
|
79 | + * @since 11.0.0 |
|
80 | + */ |
|
81 | + public function isDefaultEnabledMail() { |
|
82 | + return false; |
|
83 | + } |
|
84 | 84 | } |
@@ -24,61 +24,61 @@ |
||
24 | 24 | namespace OCA\Files\Activity\Settings; |
25 | 25 | |
26 | 26 | class FileChanged extends FileActivitySettings { |
27 | - /** |
|
28 | - * @return string Lowercase a-z and underscore only identifier |
|
29 | - * @since 11.0.0 |
|
30 | - */ |
|
31 | - public function getIdentifier() { |
|
32 | - return 'file_changed'; |
|
33 | - } |
|
27 | + /** |
|
28 | + * @return string Lowercase a-z and underscore only identifier |
|
29 | + * @since 11.0.0 |
|
30 | + */ |
|
31 | + public function getIdentifier() { |
|
32 | + return 'file_changed'; |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * @return string A translated string |
|
37 | - * @since 11.0.0 |
|
38 | - */ |
|
39 | - public function getName() { |
|
40 | - return $this->l->t('A file or folder has been <strong>changed</strong> or <strong>renamed</strong>'); |
|
41 | - } |
|
35 | + /** |
|
36 | + * @return string A translated string |
|
37 | + * @since 11.0.0 |
|
38 | + */ |
|
39 | + public function getName() { |
|
40 | + return $this->l->t('A file or folder has been <strong>changed</strong> or <strong>renamed</strong>'); |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * @return int whether the filter should be rather on the top or bottom of |
|
45 | - * the admin section. The filters are arranged in ascending order of the |
|
46 | - * priority values. It is required to return a value between 0 and 100. |
|
47 | - * @since 11.0.0 |
|
48 | - */ |
|
49 | - public function getPriority() { |
|
50 | - return 1; |
|
51 | - } |
|
43 | + /** |
|
44 | + * @return int whether the filter should be rather on the top or bottom of |
|
45 | + * the admin section. The filters are arranged in ascending order of the |
|
46 | + * priority values. It is required to return a value between 0 and 100. |
|
47 | + * @since 11.0.0 |
|
48 | + */ |
|
49 | + public function getPriority() { |
|
50 | + return 1; |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * @return bool True when the option can be changed for the stream |
|
55 | - * @since 11.0.0 |
|
56 | - */ |
|
57 | - public function canChangeStream() { |
|
58 | - return true; |
|
59 | - } |
|
53 | + /** |
|
54 | + * @return bool True when the option can be changed for the stream |
|
55 | + * @since 11.0.0 |
|
56 | + */ |
|
57 | + public function canChangeStream() { |
|
58 | + return true; |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * @return bool True when the option can be changed for the stream |
|
63 | - * @since 11.0.0 |
|
64 | - */ |
|
65 | - public function isDefaultEnabledStream() { |
|
66 | - return true; |
|
67 | - } |
|
61 | + /** |
|
62 | + * @return bool True when the option can be changed for the stream |
|
63 | + * @since 11.0.0 |
|
64 | + */ |
|
65 | + public function isDefaultEnabledStream() { |
|
66 | + return true; |
|
67 | + } |
|
68 | 68 | |
69 | - /** |
|
70 | - * @return bool True when the option can be changed for the mail |
|
71 | - * @since 11.0.0 |
|
72 | - */ |
|
73 | - public function canChangeMail() { |
|
74 | - return true; |
|
75 | - } |
|
69 | + /** |
|
70 | + * @return bool True when the option can be changed for the mail |
|
71 | + * @since 11.0.0 |
|
72 | + */ |
|
73 | + public function canChangeMail() { |
|
74 | + return true; |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * @return bool True when the option can be changed for the stream |
|
79 | - * @since 11.0.0 |
|
80 | - */ |
|
81 | - public function isDefaultEnabledMail() { |
|
82 | - return false; |
|
83 | - } |
|
77 | + /** |
|
78 | + * @return bool True when the option can be changed for the stream |
|
79 | + * @since 11.0.0 |
|
80 | + */ |
|
81 | + public function isDefaultEnabledMail() { |
|
82 | + return false; |
|
83 | + } |
|
84 | 84 | } |
@@ -28,21 +28,21 @@ |
||
28 | 28 | use OCP\IL10N; |
29 | 29 | |
30 | 30 | abstract class FileActivitySettings extends ActivitySettings { |
31 | - /** @var IL10N */ |
|
32 | - protected $l; |
|
33 | - |
|
34 | - /** |
|
35 | - * @param IL10N $l |
|
36 | - */ |
|
37 | - public function __construct(IL10N $l) { |
|
38 | - $this->l = $l; |
|
39 | - } |
|
40 | - |
|
41 | - public function getGroupIdentifier() { |
|
42 | - return 'files'; |
|
43 | - } |
|
44 | - |
|
45 | - public function getGroupName() { |
|
46 | - return $this->l->t('Files'); |
|
47 | - } |
|
31 | + /** @var IL10N */ |
|
32 | + protected $l; |
|
33 | + |
|
34 | + /** |
|
35 | + * @param IL10N $l |
|
36 | + */ |
|
37 | + public function __construct(IL10N $l) { |
|
38 | + $this->l = $l; |
|
39 | + } |
|
40 | + |
|
41 | + public function getGroupIdentifier() { |
|
42 | + return 'files'; |
|
43 | + } |
|
44 | + |
|
45 | + public function getGroupName() { |
|
46 | + return $this->l->t('Files'); |
|
47 | + } |
|
48 | 48 | } |
@@ -24,61 +24,61 @@ |
||
24 | 24 | namespace OCA\Files\Activity\Settings; |
25 | 25 | |
26 | 26 | class FileCreated extends FileActivitySettings { |
27 | - /** |
|
28 | - * @return string Lowercase a-z and underscore only identifier |
|
29 | - * @since 11.0.0 |
|
30 | - */ |
|
31 | - public function getIdentifier() { |
|
32 | - return 'file_created'; |
|
33 | - } |
|
27 | + /** |
|
28 | + * @return string Lowercase a-z and underscore only identifier |
|
29 | + * @since 11.0.0 |
|
30 | + */ |
|
31 | + public function getIdentifier() { |
|
32 | + return 'file_created'; |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * @return string A translated string |
|
37 | - * @since 11.0.0 |
|
38 | - */ |
|
39 | - public function getName() { |
|
40 | - return $this->l->t('A new file or folder has been <strong>created</strong>'); |
|
41 | - } |
|
35 | + /** |
|
36 | + * @return string A translated string |
|
37 | + * @since 11.0.0 |
|
38 | + */ |
|
39 | + public function getName() { |
|
40 | + return $this->l->t('A new file or folder has been <strong>created</strong>'); |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * @return int whether the filter should be rather on the top or bottom of |
|
45 | - * the admin section. The filters are arranged in ascending order of the |
|
46 | - * priority values. It is required to return a value between 0 and 100. |
|
47 | - * @since 11.0.0 |
|
48 | - */ |
|
49 | - public function getPriority() { |
|
50 | - return 0; |
|
51 | - } |
|
43 | + /** |
|
44 | + * @return int whether the filter should be rather on the top or bottom of |
|
45 | + * the admin section. The filters are arranged in ascending order of the |
|
46 | + * priority values. It is required to return a value between 0 and 100. |
|
47 | + * @since 11.0.0 |
|
48 | + */ |
|
49 | + public function getPriority() { |
|
50 | + return 0; |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * @return bool True when the option can be changed for the stream |
|
55 | - * @since 11.0.0 |
|
56 | - */ |
|
57 | - public function canChangeStream() { |
|
58 | - return true; |
|
59 | - } |
|
53 | + /** |
|
54 | + * @return bool True when the option can be changed for the stream |
|
55 | + * @since 11.0.0 |
|
56 | + */ |
|
57 | + public function canChangeStream() { |
|
58 | + return true; |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * @return bool True when the option can be changed for the stream |
|
63 | - * @since 11.0.0 |
|
64 | - */ |
|
65 | - public function isDefaultEnabledStream() { |
|
66 | - return true; |
|
67 | - } |
|
61 | + /** |
|
62 | + * @return bool True when the option can be changed for the stream |
|
63 | + * @since 11.0.0 |
|
64 | + */ |
|
65 | + public function isDefaultEnabledStream() { |
|
66 | + return true; |
|
67 | + } |
|
68 | 68 | |
69 | - /** |
|
70 | - * @return bool True when the option can be changed for the mail |
|
71 | - * @since 11.0.0 |
|
72 | - */ |
|
73 | - public function canChangeMail() { |
|
74 | - return true; |
|
75 | - } |
|
69 | + /** |
|
70 | + * @return bool True when the option can be changed for the mail |
|
71 | + * @since 11.0.0 |
|
72 | + */ |
|
73 | + public function canChangeMail() { |
|
74 | + return true; |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * @return bool True when the option can be changed for the stream |
|
79 | - * @since 11.0.0 |
|
80 | - */ |
|
81 | - public function isDefaultEnabledMail() { |
|
82 | - return false; |
|
83 | - } |
|
77 | + /** |
|
78 | + * @return bool True when the option can be changed for the stream |
|
79 | + * @since 11.0.0 |
|
80 | + */ |
|
81 | + public function isDefaultEnabledMail() { |
|
82 | + return false; |
|
83 | + } |
|
84 | 84 | } |
@@ -32,39 +32,39 @@ |
||
32 | 32 | * class based one |
33 | 33 | */ |
34 | 34 | class ActivitySettingsAdapter extends ActivitySettings { |
35 | - private $oldSettings; |
|
36 | - private $l10n; |
|
35 | + private $oldSettings; |
|
36 | + private $l10n; |
|
37 | 37 | |
38 | - public function __construct(ISetting $oldSettings, IL10N $l10n) { |
|
39 | - $this->oldSettings = $oldSettings; |
|
40 | - $this->l10n = $l10n; |
|
41 | - } |
|
38 | + public function __construct(ISetting $oldSettings, IL10N $l10n) { |
|
39 | + $this->oldSettings = $oldSettings; |
|
40 | + $this->l10n = $l10n; |
|
41 | + } |
|
42 | 42 | |
43 | - public function getIdentifier() { |
|
44 | - return $this->oldSettings->getIdentifier(); |
|
45 | - } |
|
43 | + public function getIdentifier() { |
|
44 | + return $this->oldSettings->getIdentifier(); |
|
45 | + } |
|
46 | 46 | |
47 | - public function getName() { |
|
48 | - return $this->oldSettings->getName(); |
|
49 | - } |
|
47 | + public function getName() { |
|
48 | + return $this->oldSettings->getName(); |
|
49 | + } |
|
50 | 50 | |
51 | - public function getGroupIdentifier() { |
|
52 | - return 'other'; |
|
53 | - } |
|
51 | + public function getGroupIdentifier() { |
|
52 | + return 'other'; |
|
53 | + } |
|
54 | 54 | |
55 | - public function getGroupName() { |
|
56 | - return $this->l10n->t('Other activities'); |
|
57 | - } |
|
55 | + public function getGroupName() { |
|
56 | + return $this->l10n->t('Other activities'); |
|
57 | + } |
|
58 | 58 | |
59 | - public function getPriority() { |
|
60 | - return $this->oldSettings->getPriority(); |
|
61 | - } |
|
59 | + public function getPriority() { |
|
60 | + return $this->oldSettings->getPriority(); |
|
61 | + } |
|
62 | 62 | |
63 | - public function canChangeMail() { |
|
64 | - return $this->oldSettings->canChangeMail(); |
|
65 | - } |
|
63 | + public function canChangeMail() { |
|
64 | + return $this->oldSettings->canChangeMail(); |
|
65 | + } |
|
66 | 66 | |
67 | - public function isDefaultEnabledMail() { |
|
68 | - return $this->oldSettings->isDefaultEnabledMail(); |
|
69 | - } |
|
67 | + public function isDefaultEnabledMail() { |
|
68 | + return $this->oldSettings->isDefaultEnabledMail(); |
|
69 | + } |
|
70 | 70 | } |
@@ -43,358 +43,358 @@ |
||
43 | 43 | use OCP\RichObjectStrings\IValidator; |
44 | 44 | |
45 | 45 | class Manager implements IManager { |
46 | - /** @var IRequest */ |
|
47 | - protected $request; |
|
48 | - |
|
49 | - /** @var IUserSession */ |
|
50 | - protected $session; |
|
51 | - |
|
52 | - /** @var IConfig */ |
|
53 | - protected $config; |
|
54 | - |
|
55 | - /** @var IValidator */ |
|
56 | - protected $validator; |
|
57 | - |
|
58 | - /** @var string */ |
|
59 | - protected $formattingObjectType; |
|
60 | - |
|
61 | - /** @var int */ |
|
62 | - protected $formattingObjectId; |
|
63 | - |
|
64 | - /** @var bool */ |
|
65 | - protected $requirePNG = false; |
|
66 | - |
|
67 | - /** @var string */ |
|
68 | - protected $currentUserId; |
|
69 | - |
|
70 | - protected $l10n; |
|
71 | - |
|
72 | - public function __construct( |
|
73 | - IRequest $request, |
|
74 | - IUserSession $session, |
|
75 | - IConfig $config, |
|
76 | - IValidator $validator, |
|
77 | - IL10N $l10n |
|
78 | - ) { |
|
79 | - $this->request = $request; |
|
80 | - $this->session = $session; |
|
81 | - $this->config = $config; |
|
82 | - $this->validator = $validator; |
|
83 | - $this->l10n = $l10n; |
|
84 | - } |
|
85 | - |
|
86 | - /** @var \Closure[] */ |
|
87 | - private $consumersClosures = []; |
|
88 | - |
|
89 | - /** @var IConsumer[] */ |
|
90 | - private $consumers = []; |
|
91 | - |
|
92 | - /** |
|
93 | - * @return \OCP\Activity\IConsumer[] |
|
94 | - */ |
|
95 | - protected function getConsumers(): array { |
|
96 | - if (!empty($this->consumers)) { |
|
97 | - return $this->consumers; |
|
98 | - } |
|
99 | - |
|
100 | - $this->consumers = []; |
|
101 | - foreach ($this->consumersClosures as $consumer) { |
|
102 | - $c = $consumer(); |
|
103 | - if ($c instanceof IConsumer) { |
|
104 | - $this->consumers[] = $c; |
|
105 | - } else { |
|
106 | - throw new \InvalidArgumentException('The given consumer does not implement the \OCP\Activity\IConsumer interface'); |
|
107 | - } |
|
108 | - } |
|
109 | - |
|
110 | - return $this->consumers; |
|
111 | - } |
|
112 | - |
|
113 | - /** |
|
114 | - * Generates a new IEvent object |
|
115 | - * |
|
116 | - * Make sure to call at least the following methods before sending it to the |
|
117 | - * app with via the publish() method: |
|
118 | - * - setApp() |
|
119 | - * - setType() |
|
120 | - * - setAffectedUser() |
|
121 | - * - setSubject() |
|
122 | - * |
|
123 | - * @return IEvent |
|
124 | - */ |
|
125 | - public function generateEvent(): IEvent { |
|
126 | - return new Event($this->validator); |
|
127 | - } |
|
128 | - |
|
129 | - /** |
|
130 | - * Publish an event to the activity consumers |
|
131 | - * |
|
132 | - * Make sure to call at least the following methods before sending an Event: |
|
133 | - * - setApp() |
|
134 | - * - setType() |
|
135 | - * - setAffectedUser() |
|
136 | - * - setSubject() |
|
137 | - * |
|
138 | - * @param IEvent $event |
|
139 | - * @throws \BadMethodCallException if required values have not been set |
|
140 | - */ |
|
141 | - public function publish(IEvent $event): void { |
|
142 | - if ($event->getAuthor() === '') { |
|
143 | - if ($this->session->getUser() instanceof IUser) { |
|
144 | - $event->setAuthor($this->session->getUser()->getUID()); |
|
145 | - } |
|
146 | - } |
|
147 | - |
|
148 | - if (!$event->getTimestamp()) { |
|
149 | - $event->setTimestamp(time()); |
|
150 | - } |
|
151 | - |
|
152 | - if (!$event->isValid()) { |
|
153 | - throw new \BadMethodCallException('The given event is invalid'); |
|
154 | - } |
|
155 | - |
|
156 | - foreach ($this->getConsumers() as $c) { |
|
157 | - $c->receive($event); |
|
158 | - } |
|
159 | - } |
|
160 | - |
|
161 | - /** |
|
162 | - * In order to improve lazy loading a closure can be registered which will be called in case |
|
163 | - * activity consumers are actually requested |
|
164 | - * |
|
165 | - * $callable has to return an instance of OCA\Activity\IConsumer |
|
166 | - * |
|
167 | - * @param \Closure $callable |
|
168 | - */ |
|
169 | - public function registerConsumer(\Closure $callable): void { |
|
170 | - $this->consumersClosures[] = $callable; |
|
171 | - $this->consumers = []; |
|
172 | - } |
|
173 | - |
|
174 | - /** @var string[] */ |
|
175 | - protected $filterClasses = []; |
|
176 | - |
|
177 | - /** @var IFilter[] */ |
|
178 | - protected $filters = []; |
|
179 | - |
|
180 | - /** |
|
181 | - * @param string $filter Class must implement OCA\Activity\IFilter |
|
182 | - * @return void |
|
183 | - */ |
|
184 | - public function registerFilter(string $filter): void { |
|
185 | - $this->filterClasses[$filter] = false; |
|
186 | - } |
|
187 | - |
|
188 | - /** |
|
189 | - * @return IFilter[] |
|
190 | - * @throws \InvalidArgumentException |
|
191 | - */ |
|
192 | - public function getFilters(): array { |
|
193 | - foreach ($this->filterClasses as $class => $false) { |
|
194 | - /** @var IFilter $filter */ |
|
195 | - $filter = \OC::$server->query($class); |
|
196 | - |
|
197 | - if (!$filter instanceof IFilter) { |
|
198 | - throw new \InvalidArgumentException('Invalid activity filter registered'); |
|
199 | - } |
|
200 | - |
|
201 | - $this->filters[$filter->getIdentifier()] = $filter; |
|
202 | - |
|
203 | - unset($this->filterClasses[$class]); |
|
204 | - } |
|
205 | - return $this->filters; |
|
206 | - } |
|
207 | - |
|
208 | - /** |
|
209 | - * @param string $id |
|
210 | - * @return IFilter |
|
211 | - * @throws \InvalidArgumentException when the filter was not found |
|
212 | - * @since 11.0.0 |
|
213 | - */ |
|
214 | - public function getFilterById(string $id): IFilter { |
|
215 | - $filters = $this->getFilters(); |
|
216 | - |
|
217 | - if (isset($filters[$id])) { |
|
218 | - return $filters[$id]; |
|
219 | - } |
|
220 | - |
|
221 | - throw new \InvalidArgumentException('Requested filter does not exist'); |
|
222 | - } |
|
223 | - |
|
224 | - /** @var string[] */ |
|
225 | - protected $providerClasses = []; |
|
226 | - |
|
227 | - /** @var IProvider[] */ |
|
228 | - protected $providers = []; |
|
229 | - |
|
230 | - /** |
|
231 | - * @param string $provider Class must implement OCA\Activity\IProvider |
|
232 | - * @return void |
|
233 | - */ |
|
234 | - public function registerProvider(string $provider): void { |
|
235 | - $this->providerClasses[$provider] = false; |
|
236 | - } |
|
237 | - |
|
238 | - /** |
|
239 | - * @return IProvider[] |
|
240 | - * @throws \InvalidArgumentException |
|
241 | - */ |
|
242 | - public function getProviders(): array { |
|
243 | - foreach ($this->providerClasses as $class => $false) { |
|
244 | - /** @var IProvider $provider */ |
|
245 | - $provider = \OC::$server->query($class); |
|
246 | - |
|
247 | - if (!$provider instanceof IProvider) { |
|
248 | - throw new \InvalidArgumentException('Invalid activity provider registered'); |
|
249 | - } |
|
250 | - |
|
251 | - $this->providers[] = $provider; |
|
252 | - |
|
253 | - unset($this->providerClasses[$class]); |
|
254 | - } |
|
255 | - return $this->providers; |
|
256 | - } |
|
257 | - |
|
258 | - /** @var string[] */ |
|
259 | - protected $settingsClasses = []; |
|
260 | - |
|
261 | - /** @var ISetting[] */ |
|
262 | - protected $settings = []; |
|
263 | - |
|
264 | - /** |
|
265 | - * @param string $setting Class must implement OCA\Activity\ISetting |
|
266 | - * @return void |
|
267 | - */ |
|
268 | - public function registerSetting(string $setting): void { |
|
269 | - $this->settingsClasses[$setting] = false; |
|
270 | - } |
|
271 | - |
|
272 | - /** |
|
273 | - * @return ActivitySettings[] |
|
274 | - * @throws \InvalidArgumentException |
|
275 | - */ |
|
276 | - public function getSettings(): array { |
|
277 | - foreach ($this->settingsClasses as $class => $false) { |
|
278 | - /** @var ISetting $setting */ |
|
279 | - $setting = \OC::$server->query($class); |
|
280 | - |
|
281 | - if ($setting instanceof ISetting) { |
|
282 | - if (!$setting instanceof ActivitySettings) { |
|
283 | - $setting = new ActivitySettingsAdapter($setting, $this->l10n); |
|
284 | - } |
|
285 | - } else { |
|
286 | - throw new \InvalidArgumentException('Invalid activity filter registered'); |
|
287 | - } |
|
288 | - |
|
289 | - $this->settings[$setting->getIdentifier()] = $setting; |
|
290 | - |
|
291 | - unset($this->settingsClasses[$class]); |
|
292 | - } |
|
293 | - return $this->settings; |
|
294 | - } |
|
295 | - |
|
296 | - /** |
|
297 | - * @param string $id |
|
298 | - * @return ActivitySettings |
|
299 | - * @throws \InvalidArgumentException when the setting was not found |
|
300 | - * @since 11.0.0 |
|
301 | - */ |
|
302 | - public function getSettingById(string $id): ActivitySettings { |
|
303 | - $settings = $this->getSettings(); |
|
304 | - |
|
305 | - if (isset($settings[$id])) { |
|
306 | - return $settings[$id]; |
|
307 | - } |
|
308 | - |
|
309 | - throw new \InvalidArgumentException('Requested setting does not exist'); |
|
310 | - } |
|
311 | - |
|
312 | - |
|
313 | - /** |
|
314 | - * @param string $type |
|
315 | - * @param int $id |
|
316 | - */ |
|
317 | - public function setFormattingObject(string $type, int $id): void { |
|
318 | - $this->formattingObjectType = $type; |
|
319 | - $this->formattingObjectId = $id; |
|
320 | - } |
|
321 | - |
|
322 | - /** |
|
323 | - * @return bool |
|
324 | - */ |
|
325 | - public function isFormattingFilteredObject(): bool { |
|
326 | - return $this->formattingObjectType !== null && $this->formattingObjectId !== null |
|
327 | - && $this->formattingObjectType === $this->request->getParam('object_type') |
|
328 | - && $this->formattingObjectId === (int) $this->request->getParam('object_id'); |
|
329 | - } |
|
330 | - |
|
331 | - /** |
|
332 | - * @param bool $status Set to true, when parsing events should not use SVG icons |
|
333 | - */ |
|
334 | - public function setRequirePNG(bool $status): void { |
|
335 | - $this->requirePNG = $status; |
|
336 | - } |
|
337 | - |
|
338 | - /** |
|
339 | - * @return bool |
|
340 | - */ |
|
341 | - public function getRequirePNG(): bool { |
|
342 | - return $this->requirePNG; |
|
343 | - } |
|
344 | - |
|
345 | - /** |
|
346 | - * Set the user we need to use |
|
347 | - * |
|
348 | - * @param string|null $currentUserId |
|
349 | - * @throws \UnexpectedValueException If the user is invalid |
|
350 | - */ |
|
351 | - public function setCurrentUserId(string $currentUserId = null): void { |
|
352 | - if (!is_string($currentUserId) && $currentUserId !== null) { |
|
353 | - throw new \UnexpectedValueException('The given current user is invalid'); |
|
354 | - } |
|
355 | - $this->currentUserId = $currentUserId; |
|
356 | - } |
|
357 | - |
|
358 | - /** |
|
359 | - * Get the user we need to use |
|
360 | - * |
|
361 | - * Either the user is logged in, or we try to get it from the token |
|
362 | - * |
|
363 | - * @return string |
|
364 | - * @throws \UnexpectedValueException If the token is invalid, does not exist or is not unique |
|
365 | - */ |
|
366 | - public function getCurrentUserId(): string { |
|
367 | - if ($this->currentUserId !== null) { |
|
368 | - return $this->currentUserId; |
|
369 | - } |
|
370 | - |
|
371 | - if (!$this->session->isLoggedIn()) { |
|
372 | - return $this->getUserFromToken(); |
|
373 | - } |
|
374 | - |
|
375 | - return $this->session->getUser()->getUID(); |
|
376 | - } |
|
377 | - |
|
378 | - /** |
|
379 | - * Get the user for the token |
|
380 | - * |
|
381 | - * @return string |
|
382 | - * @throws \UnexpectedValueException If the token is invalid, does not exist or is not unique |
|
383 | - */ |
|
384 | - protected function getUserFromToken(): string { |
|
385 | - $token = (string) $this->request->getParam('token', ''); |
|
386 | - if (strlen($token) !== 30) { |
|
387 | - throw new \UnexpectedValueException('The token is invalid'); |
|
388 | - } |
|
389 | - |
|
390 | - $users = $this->config->getUsersForUserValue('activity', 'rsstoken', $token); |
|
391 | - |
|
392 | - if (count($users) !== 1) { |
|
393 | - // No unique user found |
|
394 | - throw new \UnexpectedValueException('The token is invalid'); |
|
395 | - } |
|
396 | - |
|
397 | - // Token found login as that user |
|
398 | - return array_shift($users); |
|
399 | - } |
|
46 | + /** @var IRequest */ |
|
47 | + protected $request; |
|
48 | + |
|
49 | + /** @var IUserSession */ |
|
50 | + protected $session; |
|
51 | + |
|
52 | + /** @var IConfig */ |
|
53 | + protected $config; |
|
54 | + |
|
55 | + /** @var IValidator */ |
|
56 | + protected $validator; |
|
57 | + |
|
58 | + /** @var string */ |
|
59 | + protected $formattingObjectType; |
|
60 | + |
|
61 | + /** @var int */ |
|
62 | + protected $formattingObjectId; |
|
63 | + |
|
64 | + /** @var bool */ |
|
65 | + protected $requirePNG = false; |
|
66 | + |
|
67 | + /** @var string */ |
|
68 | + protected $currentUserId; |
|
69 | + |
|
70 | + protected $l10n; |
|
71 | + |
|
72 | + public function __construct( |
|
73 | + IRequest $request, |
|
74 | + IUserSession $session, |
|
75 | + IConfig $config, |
|
76 | + IValidator $validator, |
|
77 | + IL10N $l10n |
|
78 | + ) { |
|
79 | + $this->request = $request; |
|
80 | + $this->session = $session; |
|
81 | + $this->config = $config; |
|
82 | + $this->validator = $validator; |
|
83 | + $this->l10n = $l10n; |
|
84 | + } |
|
85 | + |
|
86 | + /** @var \Closure[] */ |
|
87 | + private $consumersClosures = []; |
|
88 | + |
|
89 | + /** @var IConsumer[] */ |
|
90 | + private $consumers = []; |
|
91 | + |
|
92 | + /** |
|
93 | + * @return \OCP\Activity\IConsumer[] |
|
94 | + */ |
|
95 | + protected function getConsumers(): array { |
|
96 | + if (!empty($this->consumers)) { |
|
97 | + return $this->consumers; |
|
98 | + } |
|
99 | + |
|
100 | + $this->consumers = []; |
|
101 | + foreach ($this->consumersClosures as $consumer) { |
|
102 | + $c = $consumer(); |
|
103 | + if ($c instanceof IConsumer) { |
|
104 | + $this->consumers[] = $c; |
|
105 | + } else { |
|
106 | + throw new \InvalidArgumentException('The given consumer does not implement the \OCP\Activity\IConsumer interface'); |
|
107 | + } |
|
108 | + } |
|
109 | + |
|
110 | + return $this->consumers; |
|
111 | + } |
|
112 | + |
|
113 | + /** |
|
114 | + * Generates a new IEvent object |
|
115 | + * |
|
116 | + * Make sure to call at least the following methods before sending it to the |
|
117 | + * app with via the publish() method: |
|
118 | + * - setApp() |
|
119 | + * - setType() |
|
120 | + * - setAffectedUser() |
|
121 | + * - setSubject() |
|
122 | + * |
|
123 | + * @return IEvent |
|
124 | + */ |
|
125 | + public function generateEvent(): IEvent { |
|
126 | + return new Event($this->validator); |
|
127 | + } |
|
128 | + |
|
129 | + /** |
|
130 | + * Publish an event to the activity consumers |
|
131 | + * |
|
132 | + * Make sure to call at least the following methods before sending an Event: |
|
133 | + * - setApp() |
|
134 | + * - setType() |
|
135 | + * - setAffectedUser() |
|
136 | + * - setSubject() |
|
137 | + * |
|
138 | + * @param IEvent $event |
|
139 | + * @throws \BadMethodCallException if required values have not been set |
|
140 | + */ |
|
141 | + public function publish(IEvent $event): void { |
|
142 | + if ($event->getAuthor() === '') { |
|
143 | + if ($this->session->getUser() instanceof IUser) { |
|
144 | + $event->setAuthor($this->session->getUser()->getUID()); |
|
145 | + } |
|
146 | + } |
|
147 | + |
|
148 | + if (!$event->getTimestamp()) { |
|
149 | + $event->setTimestamp(time()); |
|
150 | + } |
|
151 | + |
|
152 | + if (!$event->isValid()) { |
|
153 | + throw new \BadMethodCallException('The given event is invalid'); |
|
154 | + } |
|
155 | + |
|
156 | + foreach ($this->getConsumers() as $c) { |
|
157 | + $c->receive($event); |
|
158 | + } |
|
159 | + } |
|
160 | + |
|
161 | + /** |
|
162 | + * In order to improve lazy loading a closure can be registered which will be called in case |
|
163 | + * activity consumers are actually requested |
|
164 | + * |
|
165 | + * $callable has to return an instance of OCA\Activity\IConsumer |
|
166 | + * |
|
167 | + * @param \Closure $callable |
|
168 | + */ |
|
169 | + public function registerConsumer(\Closure $callable): void { |
|
170 | + $this->consumersClosures[] = $callable; |
|
171 | + $this->consumers = []; |
|
172 | + } |
|
173 | + |
|
174 | + /** @var string[] */ |
|
175 | + protected $filterClasses = []; |
|
176 | + |
|
177 | + /** @var IFilter[] */ |
|
178 | + protected $filters = []; |
|
179 | + |
|
180 | + /** |
|
181 | + * @param string $filter Class must implement OCA\Activity\IFilter |
|
182 | + * @return void |
|
183 | + */ |
|
184 | + public function registerFilter(string $filter): void { |
|
185 | + $this->filterClasses[$filter] = false; |
|
186 | + } |
|
187 | + |
|
188 | + /** |
|
189 | + * @return IFilter[] |
|
190 | + * @throws \InvalidArgumentException |
|
191 | + */ |
|
192 | + public function getFilters(): array { |
|
193 | + foreach ($this->filterClasses as $class => $false) { |
|
194 | + /** @var IFilter $filter */ |
|
195 | + $filter = \OC::$server->query($class); |
|
196 | + |
|
197 | + if (!$filter instanceof IFilter) { |
|
198 | + throw new \InvalidArgumentException('Invalid activity filter registered'); |
|
199 | + } |
|
200 | + |
|
201 | + $this->filters[$filter->getIdentifier()] = $filter; |
|
202 | + |
|
203 | + unset($this->filterClasses[$class]); |
|
204 | + } |
|
205 | + return $this->filters; |
|
206 | + } |
|
207 | + |
|
208 | + /** |
|
209 | + * @param string $id |
|
210 | + * @return IFilter |
|
211 | + * @throws \InvalidArgumentException when the filter was not found |
|
212 | + * @since 11.0.0 |
|
213 | + */ |
|
214 | + public function getFilterById(string $id): IFilter { |
|
215 | + $filters = $this->getFilters(); |
|
216 | + |
|
217 | + if (isset($filters[$id])) { |
|
218 | + return $filters[$id]; |
|
219 | + } |
|
220 | + |
|
221 | + throw new \InvalidArgumentException('Requested filter does not exist'); |
|
222 | + } |
|
223 | + |
|
224 | + /** @var string[] */ |
|
225 | + protected $providerClasses = []; |
|
226 | + |
|
227 | + /** @var IProvider[] */ |
|
228 | + protected $providers = []; |
|
229 | + |
|
230 | + /** |
|
231 | + * @param string $provider Class must implement OCA\Activity\IProvider |
|
232 | + * @return void |
|
233 | + */ |
|
234 | + public function registerProvider(string $provider): void { |
|
235 | + $this->providerClasses[$provider] = false; |
|
236 | + } |
|
237 | + |
|
238 | + /** |
|
239 | + * @return IProvider[] |
|
240 | + * @throws \InvalidArgumentException |
|
241 | + */ |
|
242 | + public function getProviders(): array { |
|
243 | + foreach ($this->providerClasses as $class => $false) { |
|
244 | + /** @var IProvider $provider */ |
|
245 | + $provider = \OC::$server->query($class); |
|
246 | + |
|
247 | + if (!$provider instanceof IProvider) { |
|
248 | + throw new \InvalidArgumentException('Invalid activity provider registered'); |
|
249 | + } |
|
250 | + |
|
251 | + $this->providers[] = $provider; |
|
252 | + |
|
253 | + unset($this->providerClasses[$class]); |
|
254 | + } |
|
255 | + return $this->providers; |
|
256 | + } |
|
257 | + |
|
258 | + /** @var string[] */ |
|
259 | + protected $settingsClasses = []; |
|
260 | + |
|
261 | + /** @var ISetting[] */ |
|
262 | + protected $settings = []; |
|
263 | + |
|
264 | + /** |
|
265 | + * @param string $setting Class must implement OCA\Activity\ISetting |
|
266 | + * @return void |
|
267 | + */ |
|
268 | + public function registerSetting(string $setting): void { |
|
269 | + $this->settingsClasses[$setting] = false; |
|
270 | + } |
|
271 | + |
|
272 | + /** |
|
273 | + * @return ActivitySettings[] |
|
274 | + * @throws \InvalidArgumentException |
|
275 | + */ |
|
276 | + public function getSettings(): array { |
|
277 | + foreach ($this->settingsClasses as $class => $false) { |
|
278 | + /** @var ISetting $setting */ |
|
279 | + $setting = \OC::$server->query($class); |
|
280 | + |
|
281 | + if ($setting instanceof ISetting) { |
|
282 | + if (!$setting instanceof ActivitySettings) { |
|
283 | + $setting = new ActivitySettingsAdapter($setting, $this->l10n); |
|
284 | + } |
|
285 | + } else { |
|
286 | + throw new \InvalidArgumentException('Invalid activity filter registered'); |
|
287 | + } |
|
288 | + |
|
289 | + $this->settings[$setting->getIdentifier()] = $setting; |
|
290 | + |
|
291 | + unset($this->settingsClasses[$class]); |
|
292 | + } |
|
293 | + return $this->settings; |
|
294 | + } |
|
295 | + |
|
296 | + /** |
|
297 | + * @param string $id |
|
298 | + * @return ActivitySettings |
|
299 | + * @throws \InvalidArgumentException when the setting was not found |
|
300 | + * @since 11.0.0 |
|
301 | + */ |
|
302 | + public function getSettingById(string $id): ActivitySettings { |
|
303 | + $settings = $this->getSettings(); |
|
304 | + |
|
305 | + if (isset($settings[$id])) { |
|
306 | + return $settings[$id]; |
|
307 | + } |
|
308 | + |
|
309 | + throw new \InvalidArgumentException('Requested setting does not exist'); |
|
310 | + } |
|
311 | + |
|
312 | + |
|
313 | + /** |
|
314 | + * @param string $type |
|
315 | + * @param int $id |
|
316 | + */ |
|
317 | + public function setFormattingObject(string $type, int $id): void { |
|
318 | + $this->formattingObjectType = $type; |
|
319 | + $this->formattingObjectId = $id; |
|
320 | + } |
|
321 | + |
|
322 | + /** |
|
323 | + * @return bool |
|
324 | + */ |
|
325 | + public function isFormattingFilteredObject(): bool { |
|
326 | + return $this->formattingObjectType !== null && $this->formattingObjectId !== null |
|
327 | + && $this->formattingObjectType === $this->request->getParam('object_type') |
|
328 | + && $this->formattingObjectId === (int) $this->request->getParam('object_id'); |
|
329 | + } |
|
330 | + |
|
331 | + /** |
|
332 | + * @param bool $status Set to true, when parsing events should not use SVG icons |
|
333 | + */ |
|
334 | + public function setRequirePNG(bool $status): void { |
|
335 | + $this->requirePNG = $status; |
|
336 | + } |
|
337 | + |
|
338 | + /** |
|
339 | + * @return bool |
|
340 | + */ |
|
341 | + public function getRequirePNG(): bool { |
|
342 | + return $this->requirePNG; |
|
343 | + } |
|
344 | + |
|
345 | + /** |
|
346 | + * Set the user we need to use |
|
347 | + * |
|
348 | + * @param string|null $currentUserId |
|
349 | + * @throws \UnexpectedValueException If the user is invalid |
|
350 | + */ |
|
351 | + public function setCurrentUserId(string $currentUserId = null): void { |
|
352 | + if (!is_string($currentUserId) && $currentUserId !== null) { |
|
353 | + throw new \UnexpectedValueException('The given current user is invalid'); |
|
354 | + } |
|
355 | + $this->currentUserId = $currentUserId; |
|
356 | + } |
|
357 | + |
|
358 | + /** |
|
359 | + * Get the user we need to use |
|
360 | + * |
|
361 | + * Either the user is logged in, or we try to get it from the token |
|
362 | + * |
|
363 | + * @return string |
|
364 | + * @throws \UnexpectedValueException If the token is invalid, does not exist or is not unique |
|
365 | + */ |
|
366 | + public function getCurrentUserId(): string { |
|
367 | + if ($this->currentUserId !== null) { |
|
368 | + return $this->currentUserId; |
|
369 | + } |
|
370 | + |
|
371 | + if (!$this->session->isLoggedIn()) { |
|
372 | + return $this->getUserFromToken(); |
|
373 | + } |
|
374 | + |
|
375 | + return $this->session->getUser()->getUID(); |
|
376 | + } |
|
377 | + |
|
378 | + /** |
|
379 | + * Get the user for the token |
|
380 | + * |
|
381 | + * @return string |
|
382 | + * @throws \UnexpectedValueException If the token is invalid, does not exist or is not unique |
|
383 | + */ |
|
384 | + protected function getUserFromToken(): string { |
|
385 | + $token = (string) $this->request->getParam('token', ''); |
|
386 | + if (strlen($token) !== 30) { |
|
387 | + throw new \UnexpectedValueException('The token is invalid'); |
|
388 | + } |
|
389 | + |
|
390 | + $users = $this->config->getUsersForUserValue('activity', 'rsstoken', $token); |
|
391 | + |
|
392 | + if (count($users) !== 1) { |
|
393 | + // No unique user found |
|
394 | + throw new \UnexpectedValueException('The token is invalid'); |
|
395 | + } |
|
396 | + |
|
397 | + // Token found login as that user |
|
398 | + return array_shift($users); |
|
399 | + } |
|
400 | 400 | } |