@@ -25,105 +25,105 @@ |
||
25 | 25 | |
26 | 26 | class PublicLinks extends Base { |
27 | 27 | |
28 | - const SUBJECT_SHARED_LINK_SELF = 'shared_link_self'; |
|
29 | - const SUBJECT_RESHARED_LINK_BY = 'reshared_link_by'; |
|
30 | - const SUBJECT_UNSHARED_LINK_SELF = 'unshared_link_self'; |
|
31 | - const SUBJECT_UNSHARED_LINK_BY = 'unshared_link_by'; |
|
32 | - const SUBJECT_LINK_EXPIRED = 'link_expired'; |
|
33 | - const SUBJECT_LINK_BY_EXPIRED = 'link_by_expired'; |
|
34 | - |
|
35 | - /** |
|
36 | - * @param IEvent $event |
|
37 | - * @return IEvent |
|
38 | - * @throws \InvalidArgumentException |
|
39 | - * @since 11.0.0 |
|
40 | - */ |
|
41 | - public function parseShortVersion(IEvent $event) { |
|
42 | - $parsedParameters = $this->getParsedParameters($event); |
|
43 | - |
|
44 | - if ($event->getSubject() === self::SUBJECT_SHARED_LINK_SELF) { |
|
45 | - $subject = $this->l->t('Shared as public link'); |
|
46 | - } else if ($event->getSubject() === self::SUBJECT_UNSHARED_LINK_SELF) { |
|
47 | - $subject = $this->l->t('Removed public link'); |
|
48 | - } else if ($event->getSubject() === self::SUBJECT_LINK_EXPIRED) { |
|
49 | - $subject = $this->l->t('Public link expired'); |
|
50 | - } else if ($event->getSubject() === self::SUBJECT_RESHARED_LINK_BY) { |
|
51 | - $subject = $this->l->t('{actor} shared as public link'); |
|
52 | - } else if ($event->getSubject() === self::SUBJECT_UNSHARED_LINK_BY) { |
|
53 | - $subject = $this->l->t('{actor} removed public link'); |
|
54 | - } else if ($event->getSubject() === self::SUBJECT_LINK_BY_EXPIRED) { |
|
55 | - $subject = $this->l->t('Public link of {actor} expired'); |
|
56 | - |
|
57 | - } else { |
|
58 | - throw new \InvalidArgumentException(); |
|
59 | - } |
|
60 | - |
|
61 | - if ($this->activityManager->getRequirePNG()) { |
|
62 | - $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.png'))); |
|
63 | - } else { |
|
64 | - $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg'))); |
|
65 | - } |
|
66 | - $this->setSubjects($event, $subject, $parsedParameters); |
|
67 | - |
|
68 | - return $event; |
|
69 | - } |
|
70 | - |
|
71 | - /** |
|
72 | - * @param IEvent $event |
|
73 | - * @return IEvent |
|
74 | - * @throws \InvalidArgumentException |
|
75 | - * @since 11.0.0 |
|
76 | - */ |
|
77 | - public function parseLongVersion(IEvent $event) { |
|
78 | - $parsedParameters = $this->getParsedParameters($event); |
|
79 | - |
|
80 | - if ($event->getSubject() === self::SUBJECT_SHARED_LINK_SELF) { |
|
81 | - $subject = $this->l->t('You shared {file} as public link'); |
|
82 | - } else if ($event->getSubject() === self::SUBJECT_UNSHARED_LINK_SELF) { |
|
83 | - $subject = $this->l->t('You removed public link for {file}'); |
|
84 | - } else if ($event->getSubject() === self::SUBJECT_LINK_EXPIRED) { |
|
85 | - $subject = $this->l->t('Public link expired for {file}'); |
|
86 | - } else if ($event->getSubject() === self::SUBJECT_RESHARED_LINK_BY) { |
|
87 | - $subject = $this->l->t('{actor} shared {file} as public link'); |
|
88 | - } else if ($event->getSubject() === self::SUBJECT_UNSHARED_LINK_BY) { |
|
89 | - $subject = $this->l->t('{actor} removed public link for {file}'); |
|
90 | - } else if ($event->getSubject() === self::SUBJECT_LINK_BY_EXPIRED) { |
|
91 | - $subject = $this->l->t('Public link of {actor} for {file} expired'); |
|
92 | - |
|
93 | - } else { |
|
94 | - throw new \InvalidArgumentException(); |
|
95 | - } |
|
96 | - |
|
97 | - if ($this->activityManager->getRequirePNG()) { |
|
98 | - $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.png'))); |
|
99 | - } else { |
|
100 | - $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg'))); |
|
101 | - } |
|
102 | - $this->setSubjects($event, $subject, $parsedParameters); |
|
103 | - |
|
104 | - return $event; |
|
105 | - } |
|
106 | - |
|
107 | - protected function getParsedParameters(IEvent $event) { |
|
108 | - $subject = $event->getSubject(); |
|
109 | - $parameters = $event->getSubjectParameters(); |
|
110 | - |
|
111 | - switch ($subject) { |
|
112 | - case self::SUBJECT_SHARED_LINK_SELF: |
|
113 | - case self::SUBJECT_UNSHARED_LINK_SELF: |
|
114 | - case self::SUBJECT_LINK_EXPIRED: |
|
115 | - return [ |
|
116 | - 'file' => $this->getFile($parameters[0], $event), |
|
117 | - ]; |
|
118 | - case self::SUBJECT_RESHARED_LINK_BY: |
|
119 | - case self::SUBJECT_UNSHARED_LINK_BY: |
|
120 | - case self::SUBJECT_LINK_BY_EXPIRED: |
|
121 | - return [ |
|
122 | - 'file' => $this->getFile($parameters[0], $event), |
|
123 | - 'actor' => $this->getUser($parameters[1]), |
|
124 | - ]; |
|
125 | - } |
|
126 | - return []; |
|
127 | - } |
|
28 | + const SUBJECT_SHARED_LINK_SELF = 'shared_link_self'; |
|
29 | + const SUBJECT_RESHARED_LINK_BY = 'reshared_link_by'; |
|
30 | + const SUBJECT_UNSHARED_LINK_SELF = 'unshared_link_self'; |
|
31 | + const SUBJECT_UNSHARED_LINK_BY = 'unshared_link_by'; |
|
32 | + const SUBJECT_LINK_EXPIRED = 'link_expired'; |
|
33 | + const SUBJECT_LINK_BY_EXPIRED = 'link_by_expired'; |
|
34 | + |
|
35 | + /** |
|
36 | + * @param IEvent $event |
|
37 | + * @return IEvent |
|
38 | + * @throws \InvalidArgumentException |
|
39 | + * @since 11.0.0 |
|
40 | + */ |
|
41 | + public function parseShortVersion(IEvent $event) { |
|
42 | + $parsedParameters = $this->getParsedParameters($event); |
|
43 | + |
|
44 | + if ($event->getSubject() === self::SUBJECT_SHARED_LINK_SELF) { |
|
45 | + $subject = $this->l->t('Shared as public link'); |
|
46 | + } else if ($event->getSubject() === self::SUBJECT_UNSHARED_LINK_SELF) { |
|
47 | + $subject = $this->l->t('Removed public link'); |
|
48 | + } else if ($event->getSubject() === self::SUBJECT_LINK_EXPIRED) { |
|
49 | + $subject = $this->l->t('Public link expired'); |
|
50 | + } else if ($event->getSubject() === self::SUBJECT_RESHARED_LINK_BY) { |
|
51 | + $subject = $this->l->t('{actor} shared as public link'); |
|
52 | + } else if ($event->getSubject() === self::SUBJECT_UNSHARED_LINK_BY) { |
|
53 | + $subject = $this->l->t('{actor} removed public link'); |
|
54 | + } else if ($event->getSubject() === self::SUBJECT_LINK_BY_EXPIRED) { |
|
55 | + $subject = $this->l->t('Public link of {actor} expired'); |
|
56 | + |
|
57 | + } else { |
|
58 | + throw new \InvalidArgumentException(); |
|
59 | + } |
|
60 | + |
|
61 | + if ($this->activityManager->getRequirePNG()) { |
|
62 | + $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.png'))); |
|
63 | + } else { |
|
64 | + $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg'))); |
|
65 | + } |
|
66 | + $this->setSubjects($event, $subject, $parsedParameters); |
|
67 | + |
|
68 | + return $event; |
|
69 | + } |
|
70 | + |
|
71 | + /** |
|
72 | + * @param IEvent $event |
|
73 | + * @return IEvent |
|
74 | + * @throws \InvalidArgumentException |
|
75 | + * @since 11.0.0 |
|
76 | + */ |
|
77 | + public function parseLongVersion(IEvent $event) { |
|
78 | + $parsedParameters = $this->getParsedParameters($event); |
|
79 | + |
|
80 | + if ($event->getSubject() === self::SUBJECT_SHARED_LINK_SELF) { |
|
81 | + $subject = $this->l->t('You shared {file} as public link'); |
|
82 | + } else if ($event->getSubject() === self::SUBJECT_UNSHARED_LINK_SELF) { |
|
83 | + $subject = $this->l->t('You removed public link for {file}'); |
|
84 | + } else if ($event->getSubject() === self::SUBJECT_LINK_EXPIRED) { |
|
85 | + $subject = $this->l->t('Public link expired for {file}'); |
|
86 | + } else if ($event->getSubject() === self::SUBJECT_RESHARED_LINK_BY) { |
|
87 | + $subject = $this->l->t('{actor} shared {file} as public link'); |
|
88 | + } else if ($event->getSubject() === self::SUBJECT_UNSHARED_LINK_BY) { |
|
89 | + $subject = $this->l->t('{actor} removed public link for {file}'); |
|
90 | + } else if ($event->getSubject() === self::SUBJECT_LINK_BY_EXPIRED) { |
|
91 | + $subject = $this->l->t('Public link of {actor} for {file} expired'); |
|
92 | + |
|
93 | + } else { |
|
94 | + throw new \InvalidArgumentException(); |
|
95 | + } |
|
96 | + |
|
97 | + if ($this->activityManager->getRequirePNG()) { |
|
98 | + $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.png'))); |
|
99 | + } else { |
|
100 | + $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg'))); |
|
101 | + } |
|
102 | + $this->setSubjects($event, $subject, $parsedParameters); |
|
103 | + |
|
104 | + return $event; |
|
105 | + } |
|
106 | + |
|
107 | + protected function getParsedParameters(IEvent $event) { |
|
108 | + $subject = $event->getSubject(); |
|
109 | + $parameters = $event->getSubjectParameters(); |
|
110 | + |
|
111 | + switch ($subject) { |
|
112 | + case self::SUBJECT_SHARED_LINK_SELF: |
|
113 | + case self::SUBJECT_UNSHARED_LINK_SELF: |
|
114 | + case self::SUBJECT_LINK_EXPIRED: |
|
115 | + return [ |
|
116 | + 'file' => $this->getFile($parameters[0], $event), |
|
117 | + ]; |
|
118 | + case self::SUBJECT_RESHARED_LINK_BY: |
|
119 | + case self::SUBJECT_UNSHARED_LINK_BY: |
|
120 | + case self::SUBJECT_LINK_BY_EXPIRED: |
|
121 | + return [ |
|
122 | + 'file' => $this->getFile($parameters[0], $event), |
|
123 | + 'actor' => $this->getUser($parameters[1]), |
|
124 | + ]; |
|
125 | + } |
|
126 | + return []; |
|
127 | + } |
|
128 | 128 | |
129 | 129 | } |
@@ -26,97 +26,97 @@ |
||
26 | 26 | class Downloads extends Base { |
27 | 27 | |
28 | 28 | |
29 | - const SUBJECT_PUBLIC_SHARED_FILE_DOWNLOADED = 'public_shared_file_downloaded'; |
|
30 | - const SUBJECT_PUBLIC_SHARED_FOLDER_DOWNLOADED = 'public_shared_folder_downloaded'; |
|
31 | - |
|
32 | - const SUBJECT_SHARED_FILE_BY_EMAIL_DOWNLOADED = 'file_shared_with_email_downloaded'; |
|
33 | - const SUBJECT_SHARED_FOLDER_BY_EMAIL_DOWNLOADED = 'folder_shared_with_email_downloaded'; |
|
34 | - |
|
35 | - /** |
|
36 | - * @param IEvent $event |
|
37 | - * @return IEvent |
|
38 | - * @throws \InvalidArgumentException |
|
39 | - * @since 11.0.0 |
|
40 | - */ |
|
41 | - public function parseShortVersion(IEvent $event) { |
|
42 | - $parsedParameters = $this->getParsedParameters($event); |
|
43 | - |
|
44 | - if ($event->getSubject() === self::SUBJECT_PUBLIC_SHARED_FILE_DOWNLOADED || |
|
45 | - $event->getSubject() === self::SUBJECT_PUBLIC_SHARED_FOLDER_DOWNLOADED) { |
|
46 | - $subject = $this->l->t('Downloaded via public link'); |
|
47 | - } else if ($event->getSubject() === self::SUBJECT_SHARED_FILE_BY_EMAIL_DOWNLOADED || |
|
48 | - $event->getSubject() === self::SUBJECT_SHARED_FOLDER_BY_EMAIL_DOWNLOADED) { |
|
49 | - $subject = $this->l->t('Downloaded by {email}'); |
|
50 | - } else { |
|
51 | - throw new \InvalidArgumentException(); |
|
52 | - } |
|
53 | - |
|
54 | - if ($this->activityManager->getRequirePNG()) { |
|
55 | - $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/download.png'))); |
|
56 | - } else { |
|
57 | - $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/download.svg'))); |
|
58 | - } |
|
59 | - $this->setSubjects($event, $subject, $parsedParameters); |
|
60 | - |
|
61 | - return $event; |
|
62 | - } |
|
63 | - |
|
64 | - /** |
|
65 | - * @param IEvent $event |
|
66 | - * @return IEvent |
|
67 | - * @throws \InvalidArgumentException |
|
68 | - * @since 11.0.0 |
|
69 | - */ |
|
70 | - public function parseLongVersion(IEvent $event) { |
|
71 | - $parsedParameters = $this->getParsedParameters($event); |
|
72 | - |
|
73 | - if ($event->getSubject() === self::SUBJECT_PUBLIC_SHARED_FILE_DOWNLOADED || |
|
74 | - $event->getSubject() === self::SUBJECT_PUBLIC_SHARED_FOLDER_DOWNLOADED) { |
|
75 | - $subject = $this->l->t('{file} downloaded via public link'); |
|
76 | - } else if ($event->getSubject() === self::SUBJECT_SHARED_FILE_BY_EMAIL_DOWNLOADED || |
|
77 | - $event->getSubject() === self::SUBJECT_SHARED_FOLDER_BY_EMAIL_DOWNLOADED) { |
|
78 | - $subject = $this->l->t('{email} downloaded {file}'); |
|
79 | - } else { |
|
80 | - throw new \InvalidArgumentException(); |
|
81 | - } |
|
82 | - |
|
83 | - if ($this->activityManager->getRequirePNG()) { |
|
84 | - $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/download.png'))); |
|
85 | - } else { |
|
86 | - $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/download.svg'))); |
|
87 | - } |
|
88 | - $this->setSubjects($event, $subject, $parsedParameters); |
|
89 | - |
|
90 | - return $event; |
|
91 | - } |
|
92 | - |
|
93 | - /** |
|
94 | - * @param IEvent $event |
|
95 | - * @return array |
|
96 | - * @throws \InvalidArgumentException |
|
97 | - */ |
|
98 | - protected function getParsedParameters(IEvent $event) { |
|
99 | - $subject = $event->getSubject(); |
|
100 | - $parameters = $event->getSubjectParameters(); |
|
101 | - |
|
102 | - switch ($subject) { |
|
103 | - case self::SUBJECT_PUBLIC_SHARED_FILE_DOWNLOADED: |
|
104 | - case self::SUBJECT_PUBLIC_SHARED_FOLDER_DOWNLOADED: |
|
105 | - return [ |
|
106 | - 'file' => $this->getFile($parameters[0], $event), |
|
107 | - ]; |
|
108 | - case self::SUBJECT_SHARED_FILE_BY_EMAIL_DOWNLOADED: |
|
109 | - case self::SUBJECT_SHARED_FOLDER_BY_EMAIL_DOWNLOADED: |
|
110 | - return [ |
|
111 | - 'file' => $this->getFile($parameters[0], $event), |
|
112 | - 'email' => [ |
|
113 | - 'type' => 'email', |
|
114 | - 'id' => $parameters[1], |
|
115 | - 'name' => $parameters[1], |
|
116 | - ], |
|
117 | - ]; |
|
118 | - } |
|
119 | - |
|
120 | - throw new \InvalidArgumentException(); |
|
121 | - } |
|
29 | + const SUBJECT_PUBLIC_SHARED_FILE_DOWNLOADED = 'public_shared_file_downloaded'; |
|
30 | + const SUBJECT_PUBLIC_SHARED_FOLDER_DOWNLOADED = 'public_shared_folder_downloaded'; |
|
31 | + |
|
32 | + const SUBJECT_SHARED_FILE_BY_EMAIL_DOWNLOADED = 'file_shared_with_email_downloaded'; |
|
33 | + const SUBJECT_SHARED_FOLDER_BY_EMAIL_DOWNLOADED = 'folder_shared_with_email_downloaded'; |
|
34 | + |
|
35 | + /** |
|
36 | + * @param IEvent $event |
|
37 | + * @return IEvent |
|
38 | + * @throws \InvalidArgumentException |
|
39 | + * @since 11.0.0 |
|
40 | + */ |
|
41 | + public function parseShortVersion(IEvent $event) { |
|
42 | + $parsedParameters = $this->getParsedParameters($event); |
|
43 | + |
|
44 | + if ($event->getSubject() === self::SUBJECT_PUBLIC_SHARED_FILE_DOWNLOADED || |
|
45 | + $event->getSubject() === self::SUBJECT_PUBLIC_SHARED_FOLDER_DOWNLOADED) { |
|
46 | + $subject = $this->l->t('Downloaded via public link'); |
|
47 | + } else if ($event->getSubject() === self::SUBJECT_SHARED_FILE_BY_EMAIL_DOWNLOADED || |
|
48 | + $event->getSubject() === self::SUBJECT_SHARED_FOLDER_BY_EMAIL_DOWNLOADED) { |
|
49 | + $subject = $this->l->t('Downloaded by {email}'); |
|
50 | + } else { |
|
51 | + throw new \InvalidArgumentException(); |
|
52 | + } |
|
53 | + |
|
54 | + if ($this->activityManager->getRequirePNG()) { |
|
55 | + $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/download.png'))); |
|
56 | + } else { |
|
57 | + $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/download.svg'))); |
|
58 | + } |
|
59 | + $this->setSubjects($event, $subject, $parsedParameters); |
|
60 | + |
|
61 | + return $event; |
|
62 | + } |
|
63 | + |
|
64 | + /** |
|
65 | + * @param IEvent $event |
|
66 | + * @return IEvent |
|
67 | + * @throws \InvalidArgumentException |
|
68 | + * @since 11.0.0 |
|
69 | + */ |
|
70 | + public function parseLongVersion(IEvent $event) { |
|
71 | + $parsedParameters = $this->getParsedParameters($event); |
|
72 | + |
|
73 | + if ($event->getSubject() === self::SUBJECT_PUBLIC_SHARED_FILE_DOWNLOADED || |
|
74 | + $event->getSubject() === self::SUBJECT_PUBLIC_SHARED_FOLDER_DOWNLOADED) { |
|
75 | + $subject = $this->l->t('{file} downloaded via public link'); |
|
76 | + } else if ($event->getSubject() === self::SUBJECT_SHARED_FILE_BY_EMAIL_DOWNLOADED || |
|
77 | + $event->getSubject() === self::SUBJECT_SHARED_FOLDER_BY_EMAIL_DOWNLOADED) { |
|
78 | + $subject = $this->l->t('{email} downloaded {file}'); |
|
79 | + } else { |
|
80 | + throw new \InvalidArgumentException(); |
|
81 | + } |
|
82 | + |
|
83 | + if ($this->activityManager->getRequirePNG()) { |
|
84 | + $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/download.png'))); |
|
85 | + } else { |
|
86 | + $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/download.svg'))); |
|
87 | + } |
|
88 | + $this->setSubjects($event, $subject, $parsedParameters); |
|
89 | + |
|
90 | + return $event; |
|
91 | + } |
|
92 | + |
|
93 | + /** |
|
94 | + * @param IEvent $event |
|
95 | + * @return array |
|
96 | + * @throws \InvalidArgumentException |
|
97 | + */ |
|
98 | + protected function getParsedParameters(IEvent $event) { |
|
99 | + $subject = $event->getSubject(); |
|
100 | + $parameters = $event->getSubjectParameters(); |
|
101 | + |
|
102 | + switch ($subject) { |
|
103 | + case self::SUBJECT_PUBLIC_SHARED_FILE_DOWNLOADED: |
|
104 | + case self::SUBJECT_PUBLIC_SHARED_FOLDER_DOWNLOADED: |
|
105 | + return [ |
|
106 | + 'file' => $this->getFile($parameters[0], $event), |
|
107 | + ]; |
|
108 | + case self::SUBJECT_SHARED_FILE_BY_EMAIL_DOWNLOADED: |
|
109 | + case self::SUBJECT_SHARED_FOLDER_BY_EMAIL_DOWNLOADED: |
|
110 | + return [ |
|
111 | + 'file' => $this->getFile($parameters[0], $event), |
|
112 | + 'email' => [ |
|
113 | + 'type' => 'email', |
|
114 | + 'id' => $parameters[1], |
|
115 | + 'name' => $parameters[1], |
|
116 | + ], |
|
117 | + ]; |
|
118 | + } |
|
119 | + |
|
120 | + throw new \InvalidArgumentException(); |
|
121 | + } |
|
122 | 122 | } |
@@ -31,147 +31,147 @@ |
||
31 | 31 | |
32 | 32 | class FavoriteProvider implements IProvider { |
33 | 33 | |
34 | - const SUBJECT_ADDED = 'added_favorite'; |
|
35 | - const SUBJECT_REMOVED = 'removed_favorite'; |
|
36 | - |
|
37 | - /** @var IFactory */ |
|
38 | - protected $languageFactory; |
|
39 | - |
|
40 | - /** @var IL10N */ |
|
41 | - protected $l; |
|
42 | - |
|
43 | - /** @var IURLGenerator */ |
|
44 | - protected $url; |
|
45 | - |
|
46 | - /** @var IManager */ |
|
47 | - protected $activityManager; |
|
48 | - |
|
49 | - /** @var IEventMerger */ |
|
50 | - protected $eventMerger; |
|
51 | - |
|
52 | - /** |
|
53 | - * @param IFactory $languageFactory |
|
54 | - * @param IURLGenerator $url |
|
55 | - * @param IManager $activityManager |
|
56 | - * @param IEventMerger $eventMerger |
|
57 | - */ |
|
58 | - public function __construct(IFactory $languageFactory, IURLGenerator $url, IManager $activityManager, IEventMerger $eventMerger) { |
|
59 | - $this->languageFactory = $languageFactory; |
|
60 | - $this->url = $url; |
|
61 | - $this->activityManager = $activityManager; |
|
62 | - $this->eventMerger = $eventMerger; |
|
63 | - } |
|
64 | - |
|
65 | - /** |
|
66 | - * @param string $language |
|
67 | - * @param IEvent $event |
|
68 | - * @param IEvent|null $previousEvent |
|
69 | - * @return IEvent |
|
70 | - * @throws \InvalidArgumentException |
|
71 | - * @since 11.0.0 |
|
72 | - */ |
|
73 | - public function parse($language, IEvent $event, IEvent $previousEvent = null) { |
|
74 | - if ($event->getApp() !== 'files' || $event->getType() !== 'favorite') { |
|
75 | - throw new \InvalidArgumentException(); |
|
76 | - } |
|
77 | - |
|
78 | - $this->l = $this->languageFactory->get('files', $language); |
|
79 | - |
|
80 | - if ($this->activityManager->isFormattingFilteredObject()) { |
|
81 | - try { |
|
82 | - return $this->parseShortVersion($event); |
|
83 | - } catch (\InvalidArgumentException $e) { |
|
84 | - // Ignore and simply use the long version... |
|
85 | - } |
|
86 | - } |
|
87 | - |
|
88 | - return $this->parseLongVersion($event, $previousEvent); |
|
89 | - } |
|
90 | - |
|
91 | - /** |
|
92 | - * @param IEvent $event |
|
93 | - * @return IEvent |
|
94 | - * @throws \InvalidArgumentException |
|
95 | - * @since 11.0.0 |
|
96 | - */ |
|
97 | - public function parseShortVersion(IEvent $event) { |
|
98 | - |
|
99 | - if ($event->getSubject() === self::SUBJECT_ADDED) { |
|
100 | - $event->setParsedSubject($this->l->t('Added to favorites')); |
|
101 | - if ($this->activityManager->getRequirePNG()) { |
|
102 | - $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/starred.png'))); |
|
103 | - } else { |
|
104 | - $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/starred.svg'))); |
|
105 | - } |
|
106 | - } else if ($event->getSubject() === self::SUBJECT_REMOVED) { |
|
107 | - $event->setParsedSubject($this->l->t('Removed from favorites')); |
|
108 | - if ($this->activityManager->getRequirePNG()) { |
|
109 | - $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/star.png'))); |
|
110 | - } else { |
|
111 | - $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/star.svg'))); |
|
112 | - } |
|
113 | - } else { |
|
114 | - throw new \InvalidArgumentException(); |
|
115 | - } |
|
116 | - |
|
117 | - return $event; |
|
118 | - } |
|
119 | - |
|
120 | - /** |
|
121 | - * @param IEvent $event |
|
122 | - * @param IEvent|null $previousEvent |
|
123 | - * @return IEvent |
|
124 | - * @throws \InvalidArgumentException |
|
125 | - * @since 11.0.0 |
|
126 | - */ |
|
127 | - public function parseLongVersion(IEvent $event, IEvent $previousEvent = null) { |
|
128 | - |
|
129 | - if ($event->getSubject() === self::SUBJECT_ADDED) { |
|
130 | - $subject = $this->l->t('You added {file} to your favorites'); |
|
131 | - if ($this->activityManager->getRequirePNG()) { |
|
132 | - $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/starred.png'))); |
|
133 | - } else { |
|
134 | - $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/starred.svg'))); |
|
135 | - } |
|
136 | - } else if ($event->getSubject() === self::SUBJECT_REMOVED) { |
|
137 | - $subject = $this->l->t('You removed {file} from your favorites'); |
|
138 | - if ($this->activityManager->getRequirePNG()) { |
|
139 | - $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/star.png'))); |
|
140 | - } else { |
|
141 | - $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/star.svg'))); |
|
142 | - } |
|
143 | - } else { |
|
144 | - throw new \InvalidArgumentException(); |
|
145 | - } |
|
146 | - |
|
147 | - $this->setSubjects($event, $subject); |
|
148 | - $event = $this->eventMerger->mergeEvents('file', $event, $previousEvent); |
|
149 | - return $event; |
|
150 | - } |
|
151 | - |
|
152 | - /** |
|
153 | - * @param IEvent $event |
|
154 | - * @param string $subject |
|
155 | - */ |
|
156 | - protected function setSubjects(IEvent $event, $subject) { |
|
157 | - $subjectParams = $event->getSubjectParameters(); |
|
158 | - if (empty($subjectParams)) { |
|
159 | - // Try to fall back to the old way, but this does not work for emails. |
|
160 | - // But at least old activities still work. |
|
161 | - $subjectParams = [ |
|
162 | - 'id' => $event->getObjectId(), |
|
163 | - 'path' => $event->getObjectName(), |
|
164 | - ]; |
|
165 | - } |
|
166 | - $parameter = [ |
|
167 | - 'type' => 'file', |
|
168 | - 'id' => $subjectParams['id'], |
|
169 | - 'name' => basename($subjectParams['path']), |
|
170 | - 'path' => trim($subjectParams['path'], '/'), |
|
171 | - 'link' => $this->url->linkToRouteAbsolute('files.viewcontroller.showFile', ['fileid' => $subjectParams['id']]), |
|
172 | - ]; |
|
173 | - |
|
174 | - $event->setParsedSubject(str_replace('{file}', $parameter['path'], $subject)) |
|
175 | - ->setRichSubject($subject, ['file' => $parameter]); |
|
176 | - } |
|
34 | + const SUBJECT_ADDED = 'added_favorite'; |
|
35 | + const SUBJECT_REMOVED = 'removed_favorite'; |
|
36 | + |
|
37 | + /** @var IFactory */ |
|
38 | + protected $languageFactory; |
|
39 | + |
|
40 | + /** @var IL10N */ |
|
41 | + protected $l; |
|
42 | + |
|
43 | + /** @var IURLGenerator */ |
|
44 | + protected $url; |
|
45 | + |
|
46 | + /** @var IManager */ |
|
47 | + protected $activityManager; |
|
48 | + |
|
49 | + /** @var IEventMerger */ |
|
50 | + protected $eventMerger; |
|
51 | + |
|
52 | + /** |
|
53 | + * @param IFactory $languageFactory |
|
54 | + * @param IURLGenerator $url |
|
55 | + * @param IManager $activityManager |
|
56 | + * @param IEventMerger $eventMerger |
|
57 | + */ |
|
58 | + public function __construct(IFactory $languageFactory, IURLGenerator $url, IManager $activityManager, IEventMerger $eventMerger) { |
|
59 | + $this->languageFactory = $languageFactory; |
|
60 | + $this->url = $url; |
|
61 | + $this->activityManager = $activityManager; |
|
62 | + $this->eventMerger = $eventMerger; |
|
63 | + } |
|
64 | + |
|
65 | + /** |
|
66 | + * @param string $language |
|
67 | + * @param IEvent $event |
|
68 | + * @param IEvent|null $previousEvent |
|
69 | + * @return IEvent |
|
70 | + * @throws \InvalidArgumentException |
|
71 | + * @since 11.0.0 |
|
72 | + */ |
|
73 | + public function parse($language, IEvent $event, IEvent $previousEvent = null) { |
|
74 | + if ($event->getApp() !== 'files' || $event->getType() !== 'favorite') { |
|
75 | + throw new \InvalidArgumentException(); |
|
76 | + } |
|
77 | + |
|
78 | + $this->l = $this->languageFactory->get('files', $language); |
|
79 | + |
|
80 | + if ($this->activityManager->isFormattingFilteredObject()) { |
|
81 | + try { |
|
82 | + return $this->parseShortVersion($event); |
|
83 | + } catch (\InvalidArgumentException $e) { |
|
84 | + // Ignore and simply use the long version... |
|
85 | + } |
|
86 | + } |
|
87 | + |
|
88 | + return $this->parseLongVersion($event, $previousEvent); |
|
89 | + } |
|
90 | + |
|
91 | + /** |
|
92 | + * @param IEvent $event |
|
93 | + * @return IEvent |
|
94 | + * @throws \InvalidArgumentException |
|
95 | + * @since 11.0.0 |
|
96 | + */ |
|
97 | + public function parseShortVersion(IEvent $event) { |
|
98 | + |
|
99 | + if ($event->getSubject() === self::SUBJECT_ADDED) { |
|
100 | + $event->setParsedSubject($this->l->t('Added to favorites')); |
|
101 | + if ($this->activityManager->getRequirePNG()) { |
|
102 | + $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/starred.png'))); |
|
103 | + } else { |
|
104 | + $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/starred.svg'))); |
|
105 | + } |
|
106 | + } else if ($event->getSubject() === self::SUBJECT_REMOVED) { |
|
107 | + $event->setParsedSubject($this->l->t('Removed from favorites')); |
|
108 | + if ($this->activityManager->getRequirePNG()) { |
|
109 | + $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/star.png'))); |
|
110 | + } else { |
|
111 | + $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/star.svg'))); |
|
112 | + } |
|
113 | + } else { |
|
114 | + throw new \InvalidArgumentException(); |
|
115 | + } |
|
116 | + |
|
117 | + return $event; |
|
118 | + } |
|
119 | + |
|
120 | + /** |
|
121 | + * @param IEvent $event |
|
122 | + * @param IEvent|null $previousEvent |
|
123 | + * @return IEvent |
|
124 | + * @throws \InvalidArgumentException |
|
125 | + * @since 11.0.0 |
|
126 | + */ |
|
127 | + public function parseLongVersion(IEvent $event, IEvent $previousEvent = null) { |
|
128 | + |
|
129 | + if ($event->getSubject() === self::SUBJECT_ADDED) { |
|
130 | + $subject = $this->l->t('You added {file} to your favorites'); |
|
131 | + if ($this->activityManager->getRequirePNG()) { |
|
132 | + $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/starred.png'))); |
|
133 | + } else { |
|
134 | + $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/starred.svg'))); |
|
135 | + } |
|
136 | + } else if ($event->getSubject() === self::SUBJECT_REMOVED) { |
|
137 | + $subject = $this->l->t('You removed {file} from your favorites'); |
|
138 | + if ($this->activityManager->getRequirePNG()) { |
|
139 | + $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/star.png'))); |
|
140 | + } else { |
|
141 | + $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/star.svg'))); |
|
142 | + } |
|
143 | + } else { |
|
144 | + throw new \InvalidArgumentException(); |
|
145 | + } |
|
146 | + |
|
147 | + $this->setSubjects($event, $subject); |
|
148 | + $event = $this->eventMerger->mergeEvents('file', $event, $previousEvent); |
|
149 | + return $event; |
|
150 | + } |
|
151 | + |
|
152 | + /** |
|
153 | + * @param IEvent $event |
|
154 | + * @param string $subject |
|
155 | + */ |
|
156 | + protected function setSubjects(IEvent $event, $subject) { |
|
157 | + $subjectParams = $event->getSubjectParameters(); |
|
158 | + if (empty($subjectParams)) { |
|
159 | + // Try to fall back to the old way, but this does not work for emails. |
|
160 | + // But at least old activities still work. |
|
161 | + $subjectParams = [ |
|
162 | + 'id' => $event->getObjectId(), |
|
163 | + 'path' => $event->getObjectName(), |
|
164 | + ]; |
|
165 | + } |
|
166 | + $parameter = [ |
|
167 | + 'type' => 'file', |
|
168 | + 'id' => $subjectParams['id'], |
|
169 | + 'name' => basename($subjectParams['path']), |
|
170 | + 'path' => trim($subjectParams['path'], '/'), |
|
171 | + 'link' => $this->url->linkToRouteAbsolute('files.viewcontroller.showFile', ['fileid' => $subjectParams['id']]), |
|
172 | + ]; |
|
173 | + |
|
174 | + $event->setParsedSubject(str_replace('{file}', $parameter['path'], $subject)) |
|
175 | + ->setRichSubject($subject, ['file' => $parameter]); |
|
176 | + } |
|
177 | 177 | } |
@@ -64,7 +64,7 @@ |
||
64 | 64 | */ |
65 | 65 | public function getForm() { |
66 | 66 | $cloudID = $this->userSession->getUser()->getCloudId(); |
67 | - $url = 'https://nextcloud.com/federation#' . $cloudID; |
|
67 | + $url = 'https://nextcloud.com/federation#'.$cloudID; |
|
68 | 68 | |
69 | 69 | $parameters = [ |
70 | 70 | 'outgoingServer2serverShareEnabled' => $this->federatedShareProvider->isOutgoingServer2serverShareEnabled(), |
@@ -33,65 +33,65 @@ |
||
33 | 33 | |
34 | 34 | class Personal implements ISettings { |
35 | 35 | |
36 | - /** @var FederatedShareProvider */ |
|
37 | - private $federatedShareProvider; |
|
38 | - /** @var IUserSession */ |
|
39 | - private $userSession; |
|
40 | - /** @var IL10N */ |
|
41 | - private $l; |
|
42 | - /** @var \OC_Defaults */ |
|
43 | - private $defaults; |
|
36 | + /** @var FederatedShareProvider */ |
|
37 | + private $federatedShareProvider; |
|
38 | + /** @var IUserSession */ |
|
39 | + private $userSession; |
|
40 | + /** @var IL10N */ |
|
41 | + private $l; |
|
42 | + /** @var \OC_Defaults */ |
|
43 | + private $defaults; |
|
44 | 44 | |
45 | - public function __construct( |
|
46 | - FederatedShareProvider $federatedShareProvider, # |
|
47 | - IUserSession $userSession, |
|
48 | - IL10N $l, |
|
49 | - \OC_Defaults $defaults |
|
50 | - ) { |
|
51 | - $this->federatedShareProvider = $federatedShareProvider; |
|
52 | - $this->userSession = $userSession; |
|
53 | - $this->l = $l; |
|
54 | - $this->defaults = $defaults; |
|
55 | - } |
|
45 | + public function __construct( |
|
46 | + FederatedShareProvider $federatedShareProvider, # |
|
47 | + IUserSession $userSession, |
|
48 | + IL10N $l, |
|
49 | + \OC_Defaults $defaults |
|
50 | + ) { |
|
51 | + $this->federatedShareProvider = $federatedShareProvider; |
|
52 | + $this->userSession = $userSession; |
|
53 | + $this->l = $l; |
|
54 | + $this->defaults = $defaults; |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * @return TemplateResponse returns the instance with all parameters set, ready to be rendered |
|
59 | - * @since 9.1 |
|
60 | - */ |
|
61 | - public function getForm() { |
|
62 | - $cloudID = $this->userSession->getUser()->getCloudId(); |
|
63 | - $url = 'https://nextcloud.com/federation#' . $cloudID; |
|
57 | + /** |
|
58 | + * @return TemplateResponse returns the instance with all parameters set, ready to be rendered |
|
59 | + * @since 9.1 |
|
60 | + */ |
|
61 | + public function getForm() { |
|
62 | + $cloudID = $this->userSession->getUser()->getCloudId(); |
|
63 | + $url = 'https://nextcloud.com/federation#' . $cloudID; |
|
64 | 64 | |
65 | - $parameters = [ |
|
66 | - 'outgoingServer2serverShareEnabled' => $this->federatedShareProvider->isOutgoingServer2serverShareEnabled(), |
|
67 | - 'message_with_URL' => $this->l->t('Share with me through my #Nextcloud Federated Cloud ID, see %s', [$url]), |
|
68 | - 'message_without_URL' => $this->l->t('Share with me through my #Nextcloud Federated Cloud ID', [$cloudID]), |
|
69 | - 'logoPath' => $this->defaults->getLogo(), |
|
70 | - 'reference' => $url, |
|
71 | - 'cloudId' => $cloudID, |
|
72 | - 'color' => $this->defaults->getColorPrimary(), |
|
73 | - 'textColor' => "#ffffff", |
|
74 | - ]; |
|
75 | - return new TemplateResponse('federatedfilesharing', 'settings-personal', $parameters, ''); |
|
76 | - } |
|
65 | + $parameters = [ |
|
66 | + 'outgoingServer2serverShareEnabled' => $this->federatedShareProvider->isOutgoingServer2serverShareEnabled(), |
|
67 | + 'message_with_URL' => $this->l->t('Share with me through my #Nextcloud Federated Cloud ID, see %s', [$url]), |
|
68 | + 'message_without_URL' => $this->l->t('Share with me through my #Nextcloud Federated Cloud ID', [$cloudID]), |
|
69 | + 'logoPath' => $this->defaults->getLogo(), |
|
70 | + 'reference' => $url, |
|
71 | + 'cloudId' => $cloudID, |
|
72 | + 'color' => $this->defaults->getColorPrimary(), |
|
73 | + 'textColor' => "#ffffff", |
|
74 | + ]; |
|
75 | + return new TemplateResponse('federatedfilesharing', 'settings-personal', $parameters, ''); |
|
76 | + } |
|
77 | 77 | |
78 | - /** |
|
79 | - * @return string the section ID, e.g. 'sharing' |
|
80 | - * @since 9.1 |
|
81 | - */ |
|
82 | - public function getSection() { |
|
83 | - return 'sharing'; |
|
84 | - } |
|
78 | + /** |
|
79 | + * @return string the section ID, e.g. 'sharing' |
|
80 | + * @since 9.1 |
|
81 | + */ |
|
82 | + public function getSection() { |
|
83 | + return 'sharing'; |
|
84 | + } |
|
85 | 85 | |
86 | - /** |
|
87 | - * @return int whether the form should be rather on the top or bottom of |
|
88 | - * the admin section. The forms are arranged in ascending order of the |
|
89 | - * priority values. It is required to return a value between 0 and 100. |
|
90 | - * |
|
91 | - * E.g.: 70 |
|
92 | - * @since 9.1 |
|
93 | - */ |
|
94 | - public function getPriority() { |
|
95 | - return 40; |
|
96 | - } |
|
86 | + /** |
|
87 | + * @return int whether the form should be rather on the top or bottom of |
|
88 | + * the admin section. The forms are arranged in ascending order of the |
|
89 | + * priority values. It is required to return a value between 0 and 100. |
|
90 | + * |
|
91 | + * E.g.: 70 |
|
92 | + * @since 9.1 |
|
93 | + */ |
|
94 | + public function getPriority() { |
|
95 | + return 40; |
|
96 | + } |
|
97 | 97 | } |
@@ -21,5 +21,5 @@ |
||
21 | 21 | * |
22 | 22 | */ |
23 | 23 | |
24 | - # used for Personal/Additional settings as fallback for legacy settings |
|
24 | + # used for Personal/Additional settings as fallback for legacy settings |
|
25 | 25 | ?> |
@@ -29,58 +29,58 @@ |
||
29 | 29 | use OCP\Settings\IIconSection; |
30 | 30 | |
31 | 31 | class PersonalSection implements IIconSection { |
32 | - /** @var IURLGenerator */ |
|
33 | - private $urlGenerator; |
|
34 | - /** @var IL10N */ |
|
35 | - private $l; |
|
32 | + /** @var IURLGenerator */ |
|
33 | + private $urlGenerator; |
|
34 | + /** @var IL10N */ |
|
35 | + private $l; |
|
36 | 36 | |
37 | - public function __construct(IURLGenerator $urlGenerator, IL10N $l) { |
|
38 | - $this->urlGenerator = $urlGenerator; |
|
39 | - $this->l = $l; |
|
40 | - } |
|
37 | + public function __construct(IURLGenerator $urlGenerator, IL10N $l) { |
|
38 | + $this->urlGenerator = $urlGenerator; |
|
39 | + $this->l = $l; |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * returns the relative path to an 16*16 icon describing the section. |
|
44 | - * e.g. '/core/img/places/files.svg' |
|
45 | - * |
|
46 | - * @returns string |
|
47 | - * @since 13.0.0 |
|
48 | - */ |
|
49 | - public function getIcon() { |
|
50 | - return $this->urlGenerator->imagePath('core', 'actions/share.svg'); |
|
51 | - } |
|
42 | + /** |
|
43 | + * returns the relative path to an 16*16 icon describing the section. |
|
44 | + * e.g. '/core/img/places/files.svg' |
|
45 | + * |
|
46 | + * @returns string |
|
47 | + * @since 13.0.0 |
|
48 | + */ |
|
49 | + public function getIcon() { |
|
50 | + return $this->urlGenerator->imagePath('core', 'actions/share.svg'); |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * returns the ID of the section. It is supposed to be a lower case string, |
|
55 | - * e.g. 'ldap' |
|
56 | - * |
|
57 | - * @returns string |
|
58 | - * @since 9.1 |
|
59 | - */ |
|
60 | - public function getID() { |
|
61 | - return 'sharing'; |
|
62 | - } |
|
53 | + /** |
|
54 | + * returns the ID of the section. It is supposed to be a lower case string, |
|
55 | + * e.g. 'ldap' |
|
56 | + * |
|
57 | + * @returns string |
|
58 | + * @since 9.1 |
|
59 | + */ |
|
60 | + public function getID() { |
|
61 | + return 'sharing'; |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * returns the translated name as it should be displayed, e.g. 'LDAP / AD |
|
66 | - * integration'. Use the L10N service to translate it. |
|
67 | - * |
|
68 | - * @return string |
|
69 | - * @since 9.1 |
|
70 | - */ |
|
71 | - public function getName() { |
|
72 | - return $this->l->t('Sharing'); |
|
73 | - } |
|
64 | + /** |
|
65 | + * returns the translated name as it should be displayed, e.g. 'LDAP / AD |
|
66 | + * integration'. Use the L10N service to translate it. |
|
67 | + * |
|
68 | + * @return string |
|
69 | + * @since 9.1 |
|
70 | + */ |
|
71 | + public function getName() { |
|
72 | + return $this->l->t('Sharing'); |
|
73 | + } |
|
74 | 74 | |
75 | - /** |
|
76 | - * @return int whether the form should be rather on the top or bottom of |
|
77 | - * the settings navigation. The sections are arranged in ascending order of |
|
78 | - * the priority values. It is required to return a value between 0 and 99. |
|
79 | - * |
|
80 | - * E.g.: 70 |
|
81 | - * @since 9.1 |
|
82 | - */ |
|
83 | - public function getPriority() { |
|
84 | - return 15; |
|
85 | - } |
|
75 | + /** |
|
76 | + * @return int whether the form should be rather on the top or bottom of |
|
77 | + * the settings navigation. The sections are arranged in ascending order of |
|
78 | + * the priority values. It is required to return a value between 0 and 99. |
|
79 | + * |
|
80 | + * E.g.: 70 |
|
81 | + * @since 9.1 |
|
82 | + */ |
|
83 | + public function getPriority() { |
|
84 | + return 15; |
|
85 | + } |
|
86 | 86 | } |
@@ -33,63 +33,63 @@ |
||
33 | 33 | |
34 | 34 | class Personal implements ISettings { |
35 | 35 | |
36 | - /** @var IConfig */ |
|
37 | - private $config; |
|
38 | - /** @var Session */ |
|
39 | - private $session; |
|
40 | - /** @var Util */ |
|
41 | - private $util; |
|
42 | - /** @var IUserSession */ |
|
43 | - private $userSession; |
|
36 | + /** @var IConfig */ |
|
37 | + private $config; |
|
38 | + /** @var Session */ |
|
39 | + private $session; |
|
40 | + /** @var Util */ |
|
41 | + private $util; |
|
42 | + /** @var IUserSession */ |
|
43 | + private $userSession; |
|
44 | 44 | |
45 | - public function __construct(IConfig $config, Session $session, Util $util, IUserSession $userSession) { |
|
46 | - $this->config = $config; |
|
47 | - $this->session = $session; |
|
48 | - $this->util = $util; |
|
49 | - $this->userSession = $userSession; |
|
50 | - } |
|
45 | + public function __construct(IConfig $config, Session $session, Util $util, IUserSession $userSession) { |
|
46 | + $this->config = $config; |
|
47 | + $this->session = $session; |
|
48 | + $this->util = $util; |
|
49 | + $this->userSession = $userSession; |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * @return TemplateResponse returns the instance with all parameters set, ready to be rendered |
|
54 | - * @since 9.1 |
|
55 | - */ |
|
56 | - public function getForm() { |
|
57 | - $recoveryAdminEnabled = $this->config->getAppValue('encryption', 'recoveryAdminEnabled'); |
|
58 | - $privateKeySet = $this->session->isPrivateKeySet(); |
|
52 | + /** |
|
53 | + * @return TemplateResponse returns the instance with all parameters set, ready to be rendered |
|
54 | + * @since 9.1 |
|
55 | + */ |
|
56 | + public function getForm() { |
|
57 | + $recoveryAdminEnabled = $this->config->getAppValue('encryption', 'recoveryAdminEnabled'); |
|
58 | + $privateKeySet = $this->session->isPrivateKeySet(); |
|
59 | 59 | |
60 | - if (!$recoveryAdminEnabled && $privateKeySet) { |
|
61 | - return new TemplateResponse('settings', 'settings/empty', [], ''); |
|
62 | - } |
|
60 | + if (!$recoveryAdminEnabled && $privateKeySet) { |
|
61 | + return new TemplateResponse('settings', 'settings/empty', [], ''); |
|
62 | + } |
|
63 | 63 | |
64 | - $userId = $this->userSession->getUser()->getUID(); |
|
65 | - $recoveryEnabledForUser = $this->util->isRecoveryEnabledForUser($userId); |
|
64 | + $userId = $this->userSession->getUser()->getUID(); |
|
65 | + $recoveryEnabledForUser = $this->util->isRecoveryEnabledForUser($userId); |
|
66 | 66 | |
67 | - $parameters = [ |
|
68 | - 'recoveryEnabled' => $recoveryAdminEnabled, |
|
69 | - 'recoveryEnabledForUser' => $recoveryEnabledForUser, |
|
70 | - 'privateKeySet' => $privateKeySet, |
|
71 | - 'initialized' => $this->session->getStatus(), |
|
72 | - ]; |
|
73 | - return new TemplateResponse('encryption', 'settings-personal', $parameters, ''); |
|
74 | - } |
|
67 | + $parameters = [ |
|
68 | + 'recoveryEnabled' => $recoveryAdminEnabled, |
|
69 | + 'recoveryEnabledForUser' => $recoveryEnabledForUser, |
|
70 | + 'privateKeySet' => $privateKeySet, |
|
71 | + 'initialized' => $this->session->getStatus(), |
|
72 | + ]; |
|
73 | + return new TemplateResponse('encryption', 'settings-personal', $parameters, ''); |
|
74 | + } |
|
75 | 75 | |
76 | - /** |
|
77 | - * @return string the section ID, e.g. 'sharing' |
|
78 | - * @since 9.1 |
|
79 | - */ |
|
80 | - public function getSection() { |
|
81 | - return 'security'; |
|
82 | - } |
|
76 | + /** |
|
77 | + * @return string the section ID, e.g. 'sharing' |
|
78 | + * @since 9.1 |
|
79 | + */ |
|
80 | + public function getSection() { |
|
81 | + return 'security'; |
|
82 | + } |
|
83 | 83 | |
84 | - /** |
|
85 | - * @return int whether the form should be rather on the top or bottom of |
|
86 | - * the admin section. The forms are arranged in ascending order of the |
|
87 | - * priority values. It is required to return a value between 0 and 100. |
|
88 | - * |
|
89 | - * E.g.: 70 |
|
90 | - * @since 9.1 |
|
91 | - */ |
|
92 | - public function getPriority() { |
|
93 | - return 80; |
|
94 | - } |
|
84 | + /** |
|
85 | + * @return int whether the form should be rather on the top or bottom of |
|
86 | + * the admin section. The forms are arranged in ascending order of the |
|
87 | + * priority values. It is required to return a value between 0 and 100. |
|
88 | + * |
|
89 | + * E.g.: 70 |
|
90 | + * @since 9.1 |
|
91 | + */ |
|
92 | + public function getPriority() { |
|
93 | + return 80; |
|
94 | + } |
|
95 | 95 | } |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | 'edition' => '', |
96 | 96 | ); |
97 | 97 | |
98 | - if($this->userSession->isLoggedIn()) { |
|
98 | + if ($this->userSession->isLoggedIn()) { |
|
99 | 99 | $result['capabilities'] = $this->capabilitiesManager->getCapabilities(); |
100 | 100 | } else { |
101 | 101 | $result['capabilities'] = $this->capabilitiesManager->getCapabilities(true); |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | public function getIdentityProof($cloudId) { |
139 | 139 | $userObject = $this->userManager->get($cloudId); |
140 | 140 | |
141 | - if($userObject !== null) { |
|
141 | + if ($userObject !== null) { |
|
142 | 142 | $key = $this->keyManager->getKey($userObject); |
143 | 143 | $data = [ |
144 | 144 | 'public' => $key->getPublic(), |
@@ -30,122 +30,122 @@ |
||
30 | 30 | |
31 | 31 | class OCSController extends \OCP\AppFramework\OCSController { |
32 | 32 | |
33 | - /** @var CapabilitiesManager */ |
|
34 | - private $capabilitiesManager; |
|
35 | - /** @var IUserSession */ |
|
36 | - private $userSession; |
|
37 | - /** @var IUserManager */ |
|
38 | - private $userManager; |
|
39 | - /** @var Manager */ |
|
40 | - private $keyManager; |
|
33 | + /** @var CapabilitiesManager */ |
|
34 | + private $capabilitiesManager; |
|
35 | + /** @var IUserSession */ |
|
36 | + private $userSession; |
|
37 | + /** @var IUserManager */ |
|
38 | + private $userManager; |
|
39 | + /** @var Manager */ |
|
40 | + private $keyManager; |
|
41 | 41 | |
42 | - /** |
|
43 | - * OCSController constructor. |
|
44 | - * |
|
45 | - * @param string $appName |
|
46 | - * @param IRequest $request |
|
47 | - * @param CapabilitiesManager $capabilitiesManager |
|
48 | - * @param IUserSession $userSession |
|
49 | - * @param IUserManager $userManager |
|
50 | - * @param Manager $keyManager |
|
51 | - */ |
|
52 | - public function __construct($appName, |
|
53 | - IRequest $request, |
|
54 | - CapabilitiesManager $capabilitiesManager, |
|
55 | - IUserSession $userSession, |
|
56 | - IUserManager $userManager, |
|
57 | - Manager $keyManager) { |
|
58 | - parent::__construct($appName, $request); |
|
59 | - $this->capabilitiesManager = $capabilitiesManager; |
|
60 | - $this->userSession = $userSession; |
|
61 | - $this->userManager = $userManager; |
|
62 | - $this->keyManager = $keyManager; |
|
63 | - } |
|
42 | + /** |
|
43 | + * OCSController constructor. |
|
44 | + * |
|
45 | + * @param string $appName |
|
46 | + * @param IRequest $request |
|
47 | + * @param CapabilitiesManager $capabilitiesManager |
|
48 | + * @param IUserSession $userSession |
|
49 | + * @param IUserManager $userManager |
|
50 | + * @param Manager $keyManager |
|
51 | + */ |
|
52 | + public function __construct($appName, |
|
53 | + IRequest $request, |
|
54 | + CapabilitiesManager $capabilitiesManager, |
|
55 | + IUserSession $userSession, |
|
56 | + IUserManager $userManager, |
|
57 | + Manager $keyManager) { |
|
58 | + parent::__construct($appName, $request); |
|
59 | + $this->capabilitiesManager = $capabilitiesManager; |
|
60 | + $this->userSession = $userSession; |
|
61 | + $this->userManager = $userManager; |
|
62 | + $this->keyManager = $keyManager; |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * @PublicPage |
|
67 | - * |
|
68 | - * @return DataResponse |
|
69 | - */ |
|
70 | - public function getConfig() { |
|
71 | - $data = [ |
|
72 | - 'version' => '1.7', |
|
73 | - 'website' => 'Nextcloud', |
|
74 | - 'host' => $this->request->getServerHost(), |
|
75 | - 'contact' => '', |
|
76 | - 'ssl' => 'false', |
|
77 | - ]; |
|
65 | + /** |
|
66 | + * @PublicPage |
|
67 | + * |
|
68 | + * @return DataResponse |
|
69 | + */ |
|
70 | + public function getConfig() { |
|
71 | + $data = [ |
|
72 | + 'version' => '1.7', |
|
73 | + 'website' => 'Nextcloud', |
|
74 | + 'host' => $this->request->getServerHost(), |
|
75 | + 'contact' => '', |
|
76 | + 'ssl' => 'false', |
|
77 | + ]; |
|
78 | 78 | |
79 | - return new DataResponse($data); |
|
80 | - } |
|
79 | + return new DataResponse($data); |
|
80 | + } |
|
81 | 81 | |
82 | - /** |
|
83 | - * @PublicPage |
|
84 | - * |
|
85 | - * @return DataResponse |
|
86 | - */ |
|
87 | - public function getCapabilities() { |
|
88 | - $result = []; |
|
89 | - list($major, $minor, $micro) = \OCP\Util::getVersion(); |
|
90 | - $result['version'] = array( |
|
91 | - 'major' => $major, |
|
92 | - 'minor' => $minor, |
|
93 | - 'micro' => $micro, |
|
94 | - 'string' => \OC_Util::getVersionString(), |
|
95 | - 'edition' => '', |
|
96 | - ); |
|
82 | + /** |
|
83 | + * @PublicPage |
|
84 | + * |
|
85 | + * @return DataResponse |
|
86 | + */ |
|
87 | + public function getCapabilities() { |
|
88 | + $result = []; |
|
89 | + list($major, $minor, $micro) = \OCP\Util::getVersion(); |
|
90 | + $result['version'] = array( |
|
91 | + 'major' => $major, |
|
92 | + 'minor' => $minor, |
|
93 | + 'micro' => $micro, |
|
94 | + 'string' => \OC_Util::getVersionString(), |
|
95 | + 'edition' => '', |
|
96 | + ); |
|
97 | 97 | |
98 | - if($this->userSession->isLoggedIn()) { |
|
99 | - $result['capabilities'] = $this->capabilitiesManager->getCapabilities(); |
|
100 | - } else { |
|
101 | - $result['capabilities'] = $this->capabilitiesManager->getCapabilities(true); |
|
102 | - } |
|
98 | + if($this->userSession->isLoggedIn()) { |
|
99 | + $result['capabilities'] = $this->capabilitiesManager->getCapabilities(); |
|
100 | + } else { |
|
101 | + $result['capabilities'] = $this->capabilitiesManager->getCapabilities(true); |
|
102 | + } |
|
103 | 103 | |
104 | - return new DataResponse($result); |
|
105 | - } |
|
104 | + return new DataResponse($result); |
|
105 | + } |
|
106 | 106 | |
107 | - /** |
|
108 | - * @PublicPage |
|
109 | - * @BruteForceProtection(action=login) |
|
110 | - * |
|
111 | - * @param string $login |
|
112 | - * @param string $password |
|
113 | - * @return DataResponse |
|
114 | - */ |
|
115 | - public function personCheck($login = '', $password = '') { |
|
116 | - if ($login !== '' && $password !== '') { |
|
117 | - if ($this->userManager->checkPassword($login, $password)) { |
|
118 | - return new DataResponse([ |
|
119 | - 'person' => [ |
|
120 | - 'personid' => $login |
|
121 | - ] |
|
122 | - ]); |
|
123 | - } |
|
107 | + /** |
|
108 | + * @PublicPage |
|
109 | + * @BruteForceProtection(action=login) |
|
110 | + * |
|
111 | + * @param string $login |
|
112 | + * @param string $password |
|
113 | + * @return DataResponse |
|
114 | + */ |
|
115 | + public function personCheck($login = '', $password = '') { |
|
116 | + if ($login !== '' && $password !== '') { |
|
117 | + if ($this->userManager->checkPassword($login, $password)) { |
|
118 | + return new DataResponse([ |
|
119 | + 'person' => [ |
|
120 | + 'personid' => $login |
|
121 | + ] |
|
122 | + ]); |
|
123 | + } |
|
124 | 124 | |
125 | - $response = new DataResponse([], 102); |
|
126 | - $response->throttle(); |
|
127 | - return $response; |
|
128 | - } |
|
129 | - return new DataResponse([], 101); |
|
130 | - } |
|
125 | + $response = new DataResponse([], 102); |
|
126 | + $response->throttle(); |
|
127 | + return $response; |
|
128 | + } |
|
129 | + return new DataResponse([], 101); |
|
130 | + } |
|
131 | 131 | |
132 | - /** |
|
133 | - * @PublicPage |
|
134 | - * |
|
135 | - * @param string $cloudId |
|
136 | - * @return DataResponse |
|
137 | - */ |
|
138 | - public function getIdentityProof($cloudId) { |
|
139 | - $userObject = $this->userManager->get($cloudId); |
|
132 | + /** |
|
133 | + * @PublicPage |
|
134 | + * |
|
135 | + * @param string $cloudId |
|
136 | + * @return DataResponse |
|
137 | + */ |
|
138 | + public function getIdentityProof($cloudId) { |
|
139 | + $userObject = $this->userManager->get($cloudId); |
|
140 | 140 | |
141 | - if($userObject !== null) { |
|
142 | - $key = $this->keyManager->getKey($userObject); |
|
143 | - $data = [ |
|
144 | - 'public' => $key->getPublic(), |
|
145 | - ]; |
|
146 | - return new DataResponse($data); |
|
147 | - } |
|
141 | + if($userObject !== null) { |
|
142 | + $key = $this->keyManager->getKey($userObject); |
|
143 | + $data = [ |
|
144 | + 'public' => $key->getPublic(), |
|
145 | + ]; |
|
146 | + return new DataResponse($data); |
|
147 | + } |
|
148 | 148 | |
149 | - return new DataResponse(['User not found'], 404); |
|
150 | - } |
|
149 | + return new DataResponse(['User not found'], 404); |
|
150 | + } |
|
151 | 151 | } |
@@ -38,71 +38,71 @@ |
||
38 | 38 | */ |
39 | 39 | class GroupManagement extends Action { |
40 | 40 | |
41 | - /** |
|
42 | - * log add user to group event |
|
43 | - * |
|
44 | - * @param IGroup $group |
|
45 | - * @param IUser $user |
|
46 | - */ |
|
47 | - public function addUser(IGroup $group, IUser $user) { |
|
48 | - $this->log('User "%s" added to group "%s"', |
|
49 | - [ |
|
50 | - 'group' => $group->getGID(), |
|
51 | - 'user' => $user->getUID() |
|
52 | - ], |
|
53 | - [ |
|
54 | - 'user', 'group' |
|
55 | - ] |
|
56 | - ); |
|
57 | - } |
|
41 | + /** |
|
42 | + * log add user to group event |
|
43 | + * |
|
44 | + * @param IGroup $group |
|
45 | + * @param IUser $user |
|
46 | + */ |
|
47 | + public function addUser(IGroup $group, IUser $user) { |
|
48 | + $this->log('User "%s" added to group "%s"', |
|
49 | + [ |
|
50 | + 'group' => $group->getGID(), |
|
51 | + 'user' => $user->getUID() |
|
52 | + ], |
|
53 | + [ |
|
54 | + 'user', 'group' |
|
55 | + ] |
|
56 | + ); |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * log remove user from group event |
|
61 | - * |
|
62 | - * @param IGroup $group |
|
63 | - * @param IUser $user |
|
64 | - */ |
|
65 | - public function removeUser(IGroup $group, IUser $user) { |
|
66 | - $this->log('User "%s" removed from group "%s"', |
|
67 | - [ |
|
68 | - 'group' => $group->getGID(), |
|
69 | - 'user' => $user->getUID() |
|
70 | - ], |
|
71 | - [ |
|
72 | - 'user', 'group' |
|
73 | - ] |
|
74 | - ); |
|
75 | - } |
|
59 | + /** |
|
60 | + * log remove user from group event |
|
61 | + * |
|
62 | + * @param IGroup $group |
|
63 | + * @param IUser $user |
|
64 | + */ |
|
65 | + public function removeUser(IGroup $group, IUser $user) { |
|
66 | + $this->log('User "%s" removed from group "%s"', |
|
67 | + [ |
|
68 | + 'group' => $group->getGID(), |
|
69 | + 'user' => $user->getUID() |
|
70 | + ], |
|
71 | + [ |
|
72 | + 'user', 'group' |
|
73 | + ] |
|
74 | + ); |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * log create group to group event |
|
79 | - * |
|
80 | - * @param IGroup $group |
|
81 | - */ |
|
82 | - public function createGroup(IGroup $group) { |
|
83 | - $this->log('Group created: "%s"', |
|
84 | - [ |
|
85 | - 'group' => $group->getGID() |
|
86 | - ], |
|
87 | - [ |
|
88 | - 'group' |
|
89 | - ] |
|
90 | - ); |
|
91 | - } |
|
77 | + /** |
|
78 | + * log create group to group event |
|
79 | + * |
|
80 | + * @param IGroup $group |
|
81 | + */ |
|
82 | + public function createGroup(IGroup $group) { |
|
83 | + $this->log('Group created: "%s"', |
|
84 | + [ |
|
85 | + 'group' => $group->getGID() |
|
86 | + ], |
|
87 | + [ |
|
88 | + 'group' |
|
89 | + ] |
|
90 | + ); |
|
91 | + } |
|
92 | 92 | |
93 | - /** |
|
94 | - * log delete group to group event |
|
95 | - * |
|
96 | - * @param IGroup $group |
|
97 | - */ |
|
98 | - public function deleteGroup(IGroup $group) { |
|
99 | - $this->log('Group deleted: "%s"', |
|
100 | - [ |
|
101 | - 'group' => $group->getGID() |
|
102 | - ], |
|
103 | - [ |
|
104 | - 'group' |
|
105 | - ] |
|
106 | - ); |
|
107 | - } |
|
93 | + /** |
|
94 | + * log delete group to group event |
|
95 | + * |
|
96 | + * @param IGroup $group |
|
97 | + */ |
|
98 | + public function deleteGroup(IGroup $group) { |
|
99 | + $this->log('Group deleted: "%s"', |
|
100 | + [ |
|
101 | + 'group' => $group->getGID() |
|
102 | + ], |
|
103 | + [ |
|
104 | + 'group' |
|
105 | + ] |
|
106 | + ); |
|
107 | + } |
|
108 | 108 | } |