@@ -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 | } |
@@ -32,157 +32,157 @@ |
||
| 32 | 32 | |
| 33 | 33 | class Provider implements IProvider { |
| 34 | 34 | |
| 35 | - const PASSWORD_CHANGED_BY = 'password_changed_by'; |
|
| 36 | - const PASSWORD_CHANGED_SELF = 'password_changed_self'; |
|
| 37 | - const PASSWORD_RESET = 'password_changed'; |
|
| 38 | - const EMAIL_CHANGED_BY = 'email_changed_by'; |
|
| 39 | - const EMAIL_CHANGED_SELF = 'email_changed_self'; |
|
| 40 | - const EMAIL_CHANGED = 'email_changed'; |
|
| 41 | - |
|
| 42 | - /** @var IFactory */ |
|
| 43 | - protected $languageFactory; |
|
| 44 | - |
|
| 45 | - /** @var IL10N */ |
|
| 46 | - protected $l; |
|
| 47 | - |
|
| 48 | - /** @var IURLGenerator */ |
|
| 49 | - protected $url; |
|
| 50 | - |
|
| 51 | - /** @var IUserManager */ |
|
| 52 | - protected $userManager; |
|
| 53 | - |
|
| 54 | - /** @var IManager */ |
|
| 55 | - private $activityManager; |
|
| 56 | - |
|
| 57 | - /** @var string[] cached displayNames - key is the UID and value the displayname */ |
|
| 58 | - protected $displayNames = []; |
|
| 59 | - |
|
| 60 | - /** |
|
| 61 | - * @param IFactory $languageFactory |
|
| 62 | - * @param IURLGenerator $url |
|
| 63 | - * @param IUserManager $userManager |
|
| 64 | - * @param IManager $activityManager |
|
| 65 | - */ |
|
| 66 | - public function __construct(IFactory $languageFactory, IURLGenerator $url, IUserManager $userManager, IManager $activityManager) { |
|
| 67 | - $this->languageFactory = $languageFactory; |
|
| 68 | - $this->url = $url; |
|
| 69 | - $this->userManager = $userManager; |
|
| 70 | - $this->activityManager = $activityManager; |
|
| 71 | - } |
|
| 72 | - |
|
| 73 | - /** |
|
| 74 | - * @param string $language |
|
| 75 | - * @param IEvent $event |
|
| 76 | - * @param IEvent|null $previousEvent |
|
| 77 | - * @return IEvent |
|
| 78 | - * @throws \InvalidArgumentException |
|
| 79 | - * @since 11.0.0 |
|
| 80 | - */ |
|
| 81 | - public function parse($language, IEvent $event, IEvent $previousEvent = null) { |
|
| 82 | - if ($event->getApp() !== 'settings') { |
|
| 83 | - throw new \InvalidArgumentException(); |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - $this->l = $this->languageFactory->get('settings', $language); |
|
| 87 | - |
|
| 88 | - if ($this->activityManager->getRequirePNG()) { |
|
| 89 | - $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('settings', 'personal.png'))); |
|
| 90 | - } else { |
|
| 91 | - $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('settings', 'personal.svg'))); |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - if ($event->getSubject() === self::PASSWORD_CHANGED_BY) { |
|
| 95 | - $subject = $this->l->t('{actor} changed your password'); |
|
| 96 | - } else if ($event->getSubject() === self::PASSWORD_CHANGED_SELF) { |
|
| 97 | - $subject = $this->l->t('You changed your password'); |
|
| 98 | - } else if ($event->getSubject() === self::PASSWORD_RESET) { |
|
| 99 | - $subject = $this->l->t('Your password was reset by an administrator'); |
|
| 100 | - |
|
| 101 | - } else if ($event->getSubject() === self::EMAIL_CHANGED_BY) { |
|
| 102 | - $subject = $this->l->t('{actor} changed your email address'); |
|
| 103 | - } else if ($event->getSubject() === self::EMAIL_CHANGED_SELF) { |
|
| 104 | - $subject = $this->l->t('You changed your email address'); |
|
| 105 | - } else if ($event->getSubject() === self::EMAIL_CHANGED) { |
|
| 106 | - $subject = $this->l->t('Your email address was changed by an administrator'); |
|
| 107 | - |
|
| 108 | - } else { |
|
| 109 | - throw new \InvalidArgumentException(); |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - $parsedParameters = $this->getParameters($event); |
|
| 113 | - $this->setSubjects($event, $subject, $parsedParameters); |
|
| 114 | - |
|
| 115 | - return $event; |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - /** |
|
| 119 | - * @param IEvent $event |
|
| 120 | - * @return array |
|
| 121 | - * @throws \InvalidArgumentException |
|
| 122 | - */ |
|
| 123 | - protected function getParameters(IEvent $event) { |
|
| 124 | - $subject = $event->getSubject(); |
|
| 125 | - $parameters = $event->getSubjectParameters(); |
|
| 126 | - |
|
| 127 | - switch ($subject) { |
|
| 128 | - case self::PASSWORD_CHANGED_SELF: |
|
| 129 | - case self::PASSWORD_RESET: |
|
| 130 | - case self::EMAIL_CHANGED_SELF: |
|
| 131 | - case self::EMAIL_CHANGED: |
|
| 132 | - return []; |
|
| 133 | - case self::PASSWORD_CHANGED_BY: |
|
| 134 | - case self::EMAIL_CHANGED_BY: |
|
| 135 | - return [ |
|
| 136 | - 'actor' => $this->generateUserParameter($parameters[0]), |
|
| 137 | - ]; |
|
| 138 | - } |
|
| 139 | - |
|
| 140 | - throw new \InvalidArgumentException(); |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - /** |
|
| 144 | - * @param IEvent $event |
|
| 145 | - * @param string $subject |
|
| 146 | - * @param array $parameters |
|
| 147 | - * @throws \InvalidArgumentException |
|
| 148 | - */ |
|
| 149 | - protected function setSubjects(IEvent $event, $subject, array $parameters) { |
|
| 150 | - $placeholders = $replacements = []; |
|
| 151 | - foreach ($parameters as $placeholder => $parameter) { |
|
| 152 | - $placeholders[] = '{' . $placeholder . '}'; |
|
| 153 | - $replacements[] = $parameter['name']; |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - $event->setParsedSubject(str_replace($placeholders, $replacements, $subject)) |
|
| 157 | - ->setRichSubject($subject, $parameters); |
|
| 158 | - } |
|
| 159 | - |
|
| 160 | - /** |
|
| 161 | - * @param string $uid |
|
| 162 | - * @return array |
|
| 163 | - */ |
|
| 164 | - protected function generateUserParameter($uid) { |
|
| 165 | - if (!isset($this->displayNames[$uid])) { |
|
| 166 | - $this->displayNames[$uid] = $this->getDisplayName($uid); |
|
| 167 | - } |
|
| 168 | - |
|
| 169 | - return [ |
|
| 170 | - 'type' => 'user', |
|
| 171 | - 'id' => $uid, |
|
| 172 | - 'name' => $this->displayNames[$uid], |
|
| 173 | - ]; |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - /** |
|
| 177 | - * @param string $uid |
|
| 178 | - * @return string |
|
| 179 | - */ |
|
| 180 | - protected function getDisplayName($uid) { |
|
| 181 | - $user = $this->userManager->get($uid); |
|
| 182 | - if ($user instanceof IUser) { |
|
| 183 | - return $user->getDisplayName(); |
|
| 184 | - } |
|
| 185 | - |
|
| 186 | - return $uid; |
|
| 187 | - } |
|
| 35 | + const PASSWORD_CHANGED_BY = 'password_changed_by'; |
|
| 36 | + const PASSWORD_CHANGED_SELF = 'password_changed_self'; |
|
| 37 | + const PASSWORD_RESET = 'password_changed'; |
|
| 38 | + const EMAIL_CHANGED_BY = 'email_changed_by'; |
|
| 39 | + const EMAIL_CHANGED_SELF = 'email_changed_self'; |
|
| 40 | + const EMAIL_CHANGED = 'email_changed'; |
|
| 41 | + |
|
| 42 | + /** @var IFactory */ |
|
| 43 | + protected $languageFactory; |
|
| 44 | + |
|
| 45 | + /** @var IL10N */ |
|
| 46 | + protected $l; |
|
| 47 | + |
|
| 48 | + /** @var IURLGenerator */ |
|
| 49 | + protected $url; |
|
| 50 | + |
|
| 51 | + /** @var IUserManager */ |
|
| 52 | + protected $userManager; |
|
| 53 | + |
|
| 54 | + /** @var IManager */ |
|
| 55 | + private $activityManager; |
|
| 56 | + |
|
| 57 | + /** @var string[] cached displayNames - key is the UID and value the displayname */ |
|
| 58 | + protected $displayNames = []; |
|
| 59 | + |
|
| 60 | + /** |
|
| 61 | + * @param IFactory $languageFactory |
|
| 62 | + * @param IURLGenerator $url |
|
| 63 | + * @param IUserManager $userManager |
|
| 64 | + * @param IManager $activityManager |
|
| 65 | + */ |
|
| 66 | + public function __construct(IFactory $languageFactory, IURLGenerator $url, IUserManager $userManager, IManager $activityManager) { |
|
| 67 | + $this->languageFactory = $languageFactory; |
|
| 68 | + $this->url = $url; |
|
| 69 | + $this->userManager = $userManager; |
|
| 70 | + $this->activityManager = $activityManager; |
|
| 71 | + } |
|
| 72 | + |
|
| 73 | + /** |
|
| 74 | + * @param string $language |
|
| 75 | + * @param IEvent $event |
|
| 76 | + * @param IEvent|null $previousEvent |
|
| 77 | + * @return IEvent |
|
| 78 | + * @throws \InvalidArgumentException |
|
| 79 | + * @since 11.0.0 |
|
| 80 | + */ |
|
| 81 | + public function parse($language, IEvent $event, IEvent $previousEvent = null) { |
|
| 82 | + if ($event->getApp() !== 'settings') { |
|
| 83 | + throw new \InvalidArgumentException(); |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + $this->l = $this->languageFactory->get('settings', $language); |
|
| 87 | + |
|
| 88 | + if ($this->activityManager->getRequirePNG()) { |
|
| 89 | + $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('settings', 'personal.png'))); |
|
| 90 | + } else { |
|
| 91 | + $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('settings', 'personal.svg'))); |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + if ($event->getSubject() === self::PASSWORD_CHANGED_BY) { |
|
| 95 | + $subject = $this->l->t('{actor} changed your password'); |
|
| 96 | + } else if ($event->getSubject() === self::PASSWORD_CHANGED_SELF) { |
|
| 97 | + $subject = $this->l->t('You changed your password'); |
|
| 98 | + } else if ($event->getSubject() === self::PASSWORD_RESET) { |
|
| 99 | + $subject = $this->l->t('Your password was reset by an administrator'); |
|
| 100 | + |
|
| 101 | + } else if ($event->getSubject() === self::EMAIL_CHANGED_BY) { |
|
| 102 | + $subject = $this->l->t('{actor} changed your email address'); |
|
| 103 | + } else if ($event->getSubject() === self::EMAIL_CHANGED_SELF) { |
|
| 104 | + $subject = $this->l->t('You changed your email address'); |
|
| 105 | + } else if ($event->getSubject() === self::EMAIL_CHANGED) { |
|
| 106 | + $subject = $this->l->t('Your email address was changed by an administrator'); |
|
| 107 | + |
|
| 108 | + } else { |
|
| 109 | + throw new \InvalidArgumentException(); |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + $parsedParameters = $this->getParameters($event); |
|
| 113 | + $this->setSubjects($event, $subject, $parsedParameters); |
|
| 114 | + |
|
| 115 | + return $event; |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + /** |
|
| 119 | + * @param IEvent $event |
|
| 120 | + * @return array |
|
| 121 | + * @throws \InvalidArgumentException |
|
| 122 | + */ |
|
| 123 | + protected function getParameters(IEvent $event) { |
|
| 124 | + $subject = $event->getSubject(); |
|
| 125 | + $parameters = $event->getSubjectParameters(); |
|
| 126 | + |
|
| 127 | + switch ($subject) { |
|
| 128 | + case self::PASSWORD_CHANGED_SELF: |
|
| 129 | + case self::PASSWORD_RESET: |
|
| 130 | + case self::EMAIL_CHANGED_SELF: |
|
| 131 | + case self::EMAIL_CHANGED: |
|
| 132 | + return []; |
|
| 133 | + case self::PASSWORD_CHANGED_BY: |
|
| 134 | + case self::EMAIL_CHANGED_BY: |
|
| 135 | + return [ |
|
| 136 | + 'actor' => $this->generateUserParameter($parameters[0]), |
|
| 137 | + ]; |
|
| 138 | + } |
|
| 139 | + |
|
| 140 | + throw new \InvalidArgumentException(); |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + /** |
|
| 144 | + * @param IEvent $event |
|
| 145 | + * @param string $subject |
|
| 146 | + * @param array $parameters |
|
| 147 | + * @throws \InvalidArgumentException |
|
| 148 | + */ |
|
| 149 | + protected function setSubjects(IEvent $event, $subject, array $parameters) { |
|
| 150 | + $placeholders = $replacements = []; |
|
| 151 | + foreach ($parameters as $placeholder => $parameter) { |
|
| 152 | + $placeholders[] = '{' . $placeholder . '}'; |
|
| 153 | + $replacements[] = $parameter['name']; |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + $event->setParsedSubject(str_replace($placeholders, $replacements, $subject)) |
|
| 157 | + ->setRichSubject($subject, $parameters); |
|
| 158 | + } |
|
| 159 | + |
|
| 160 | + /** |
|
| 161 | + * @param string $uid |
|
| 162 | + * @return array |
|
| 163 | + */ |
|
| 164 | + protected function generateUserParameter($uid) { |
|
| 165 | + if (!isset($this->displayNames[$uid])) { |
|
| 166 | + $this->displayNames[$uid] = $this->getDisplayName($uid); |
|
| 167 | + } |
|
| 168 | + |
|
| 169 | + return [ |
|
| 170 | + 'type' => 'user', |
|
| 171 | + 'id' => $uid, |
|
| 172 | + 'name' => $this->displayNames[$uid], |
|
| 173 | + ]; |
|
| 174 | + } |
|
| 175 | + |
|
| 176 | + /** |
|
| 177 | + * @param string $uid |
|
| 178 | + * @return string |
|
| 179 | + */ |
|
| 180 | + protected function getDisplayName($uid) { |
|
| 181 | + $user = $this->userManager->get($uid); |
|
| 182 | + if ($user instanceof IUser) { |
|
| 183 | + return $user->getDisplayName(); |
|
| 184 | + } |
|
| 185 | + |
|
| 186 | + return $uid; |
|
| 187 | + } |
|
| 188 | 188 | } |
@@ -39,262 +39,262 @@ |
||
| 39 | 39 | * @since 6.0.0 |
| 40 | 40 | */ |
| 41 | 41 | interface IManager { |
| 42 | - /** |
|
| 43 | - * Generates a new IEvent object |
|
| 44 | - * |
|
| 45 | - * Make sure to call at least the following methods before sending it to the |
|
| 46 | - * app with via the publish() method: |
|
| 47 | - * - setApp() |
|
| 48 | - * - setType() |
|
| 49 | - * - setAffectedUser() |
|
| 50 | - * - setSubject() |
|
| 51 | - * |
|
| 52 | - * @return IEvent |
|
| 53 | - * @since 8.2.0 |
|
| 54 | - */ |
|
| 55 | - public function generateEvent(); |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * Publish an event to the activity consumers |
|
| 59 | - * |
|
| 60 | - * Make sure to call at least the following methods before sending an Event: |
|
| 61 | - * - setApp() |
|
| 62 | - * - setType() |
|
| 63 | - * - setAffectedUser() |
|
| 64 | - * - setSubject() |
|
| 65 | - * |
|
| 66 | - * @param IEvent $event |
|
| 67 | - * @throws \BadMethodCallException if required values have not been set |
|
| 68 | - * @since 8.2.0 |
|
| 69 | - */ |
|
| 70 | - public function publish(IEvent $event); |
|
| 71 | - |
|
| 72 | - /** |
|
| 73 | - * @param string $app The app where this event is associated with |
|
| 74 | - * @param string $subject A short description of the event |
|
| 75 | - * @param array $subjectParams Array with parameters that are filled in the subject |
|
| 76 | - * @param string $message A longer description of the event |
|
| 77 | - * @param array $messageParams Array with parameters that are filled in the message |
|
| 78 | - * @param string $file The file including path where this event is associated with |
|
| 79 | - * @param string $link A link where this event is associated with |
|
| 80 | - * @param string $affectedUser Recipient of the activity |
|
| 81 | - * @param string $type Type of the notification |
|
| 82 | - * @param int $priority Priority of the notification |
|
| 83 | - * @since 6.0.0 |
|
| 84 | - * @deprecated 8.2.0 Grab an IEvent from generateEvent() instead and use the publish() method |
|
| 85 | - */ |
|
| 86 | - public function publishActivity($app, $subject, $subjectParams, $message, $messageParams, $file, $link, $affectedUser, $type, $priority); |
|
| 87 | - |
|
| 88 | - /** |
|
| 89 | - * In order to improve lazy loading a closure can be registered which will be called in case |
|
| 90 | - * activity consumers are actually requested |
|
| 91 | - * |
|
| 92 | - * $callable has to return an instance of \OCP\Activity\IConsumer |
|
| 93 | - * |
|
| 94 | - * @param \Closure $callable |
|
| 95 | - * @return void |
|
| 96 | - * @since 6.0.0 |
|
| 97 | - */ |
|
| 98 | - public function registerConsumer(\Closure $callable); |
|
| 99 | - |
|
| 100 | - /** |
|
| 101 | - * In order to improve lazy loading a closure can be registered which will be called in case |
|
| 102 | - * activity consumers are actually requested |
|
| 103 | - * |
|
| 104 | - * $callable has to return an instance of \OCP\Activity\IExtension |
|
| 105 | - * |
|
| 106 | - * @param \Closure $callable |
|
| 107 | - * @return void |
|
| 108 | - * @since 8.0.0 |
|
| 109 | - */ |
|
| 110 | - public function registerExtension(\Closure $callable); |
|
| 111 | - |
|
| 112 | - /** |
|
| 113 | - * @param string $filter Class must implement OCA\Activity\IFilter |
|
| 114 | - * @return void |
|
| 115 | - * @since 11.0.0 |
|
| 116 | - */ |
|
| 117 | - public function registerFilter($filter); |
|
| 118 | - |
|
| 119 | - /** |
|
| 120 | - * @return IFilter[] |
|
| 121 | - * @since 11.0.0 |
|
| 122 | - */ |
|
| 123 | - public function getFilters(); |
|
| 124 | - |
|
| 125 | - /** |
|
| 126 | - * @param string $id |
|
| 127 | - * @return IFilter |
|
| 128 | - * @throws \InvalidArgumentException when the filter was not found |
|
| 129 | - * @since 11.0.0 |
|
| 130 | - */ |
|
| 131 | - public function getFilterById($id); |
|
| 132 | - |
|
| 133 | - /** |
|
| 134 | - * @param string $setting Class must implement OCA\Activity\ISetting |
|
| 135 | - * @return void |
|
| 136 | - * @since 11.0.0 |
|
| 137 | - */ |
|
| 138 | - public function registerSetting($setting); |
|
| 139 | - |
|
| 140 | - /** |
|
| 141 | - * @return ISetting[] |
|
| 142 | - * @since 11.0.0 |
|
| 143 | - */ |
|
| 144 | - public function getSettings(); |
|
| 145 | - |
|
| 146 | - /** |
|
| 147 | - * @param string $provider Class must implement OCA\Activity\IProvider |
|
| 148 | - * @return void |
|
| 149 | - * @since 11.0.0 |
|
| 150 | - */ |
|
| 151 | - public function registerProvider($provider); |
|
| 152 | - |
|
| 153 | - /** |
|
| 154 | - * @return IProvider[] |
|
| 155 | - * @since 11.0.0 |
|
| 156 | - */ |
|
| 157 | - public function getProviders(); |
|
| 158 | - |
|
| 159 | - /** |
|
| 160 | - * @param string $id |
|
| 161 | - * @return ISetting |
|
| 162 | - * @throws \InvalidArgumentException when the setting was not found |
|
| 163 | - * @since 11.0.0 |
|
| 164 | - */ |
|
| 165 | - public function getSettingById($id); |
|
| 166 | - |
|
| 167 | - /** |
|
| 168 | - * Will return additional notification types as specified by other apps |
|
| 169 | - * |
|
| 170 | - * @param string $languageCode |
|
| 171 | - * @return array Array "stringID of the type" => "translated string description for the setting" |
|
| 172 | - * or Array "stringID of the type" => [ |
|
| 173 | - * 'desc' => "translated string description for the setting" |
|
| 174 | - * 'methods' => [\OCP\Activity\IExtension::METHOD_*], |
|
| 175 | - * ] |
|
| 176 | - * @since 8.0.0 - 8.2.0: Added support to allow limiting notifications to certain methods |
|
| 177 | - * @deprecated 11.0.0 - Use getSettings() instead |
|
| 178 | - */ |
|
| 179 | - public function getNotificationTypes($languageCode); |
|
| 180 | - |
|
| 181 | - /** |
|
| 182 | - * @param string $method |
|
| 183 | - * @return array |
|
| 184 | - * @since 8.0.0 |
|
| 185 | - * @deprecated 11.0.0 - Use getSettings()->isDefaulEnabled<method>() instead |
|
| 186 | - */ |
|
| 187 | - public function getDefaultTypes($method); |
|
| 188 | - |
|
| 189 | - /** |
|
| 190 | - * @param string $type |
|
| 191 | - * @return string |
|
| 192 | - * @since 8.0.0 |
|
| 193 | - */ |
|
| 194 | - public function getTypeIcon($type); |
|
| 195 | - |
|
| 196 | - /** |
|
| 197 | - * @param string $type |
|
| 198 | - * @param int $id |
|
| 199 | - * @since 8.2.0 |
|
| 200 | - */ |
|
| 201 | - public function setFormattingObject($type, $id); |
|
| 202 | - |
|
| 203 | - /** |
|
| 204 | - * @return bool |
|
| 205 | - * @since 8.2.0 |
|
| 206 | - */ |
|
| 207 | - public function isFormattingFilteredObject(); |
|
| 208 | - |
|
| 209 | - /** |
|
| 210 | - * @param bool $status Set to true, when parsing events should not use SVG icons |
|
| 211 | - * @since 12.0.1 |
|
| 212 | - */ |
|
| 213 | - public function setRequirePNG($status); |
|
| 214 | - |
|
| 215 | - /** |
|
| 216 | - * @return bool |
|
| 217 | - * @since 12.0.1 |
|
| 218 | - */ |
|
| 219 | - public function getRequirePNG(); |
|
| 220 | - |
|
| 221 | - /** |
|
| 222 | - * @param string $app |
|
| 223 | - * @param string $text |
|
| 224 | - * @param array $params |
|
| 225 | - * @param boolean $stripPath |
|
| 226 | - * @param boolean $highlightParams |
|
| 227 | - * @param string $languageCode |
|
| 228 | - * @return string|false |
|
| 229 | - * @since 8.0.0 |
|
| 230 | - */ |
|
| 231 | - public function translate($app, $text, $params, $stripPath, $highlightParams, $languageCode); |
|
| 232 | - |
|
| 233 | - /** |
|
| 234 | - * @param string $app |
|
| 235 | - * @param string $text |
|
| 236 | - * @return array|false |
|
| 237 | - * @since 8.0.0 |
|
| 238 | - */ |
|
| 239 | - public function getSpecialParameterList($app, $text); |
|
| 240 | - |
|
| 241 | - /** |
|
| 242 | - * @param array $activity |
|
| 243 | - * @return integer|false |
|
| 244 | - * @since 8.0.0 |
|
| 245 | - */ |
|
| 246 | - public function getGroupParameter($activity); |
|
| 247 | - |
|
| 248 | - |
|
| 249 | - /** |
|
| 250 | - * Set the user we need to use |
|
| 251 | - * |
|
| 252 | - * @param string|null $currentUserId |
|
| 253 | - * @throws \UnexpectedValueException If the user is invalid |
|
| 254 | - * @since 9.0.1 |
|
| 255 | - */ |
|
| 256 | - public function setCurrentUserId($currentUserId); |
|
| 257 | - |
|
| 258 | - /** |
|
| 259 | - * Get the user we need to use |
|
| 260 | - * |
|
| 261 | - * Either the user is logged in, or we try to get it from the token |
|
| 262 | - * |
|
| 263 | - * @return string |
|
| 264 | - * @throws \UnexpectedValueException If the token is invalid, does not exist or is not unique |
|
| 265 | - * @since 8.1.0 |
|
| 266 | - */ |
|
| 267 | - public function getCurrentUserId(); |
|
| 268 | - |
|
| 269 | - /** |
|
| 270 | - * @return array |
|
| 271 | - * @since 8.0.0 |
|
| 272 | - * @deprecated 11.0.0 - Use getFilters() instead |
|
| 273 | - */ |
|
| 274 | - public function getNavigation(); |
|
| 275 | - |
|
| 276 | - /** |
|
| 277 | - * @param string $filterValue |
|
| 278 | - * @return boolean |
|
| 279 | - * @since 8.0.0 |
|
| 280 | - * @deprecated 11.0.0 - Use getFilterById() instead |
|
| 281 | - */ |
|
| 282 | - public function isFilterValid($filterValue); |
|
| 283 | - |
|
| 284 | - /** |
|
| 285 | - * @param array $types |
|
| 286 | - * @param string $filter |
|
| 287 | - * @return array |
|
| 288 | - * @since 8.0.0 |
|
| 289 | - * @deprecated 11.0.0 - Use getFilterById()->filterTypes() instead |
|
| 290 | - */ |
|
| 291 | - public function filterNotificationTypes($types, $filter); |
|
| 292 | - |
|
| 293 | - /** |
|
| 294 | - * @param string $filter |
|
| 295 | - * @return array |
|
| 296 | - * @since 8.0.0 |
|
| 297 | - * @deprecated 11.0.0 - Use getFilterById() instead |
|
| 298 | - */ |
|
| 299 | - public function getQueryForFilter($filter); |
|
| 42 | + /** |
|
| 43 | + * Generates a new IEvent object |
|
| 44 | + * |
|
| 45 | + * Make sure to call at least the following methods before sending it to the |
|
| 46 | + * app with via the publish() method: |
|
| 47 | + * - setApp() |
|
| 48 | + * - setType() |
|
| 49 | + * - setAffectedUser() |
|
| 50 | + * - setSubject() |
|
| 51 | + * |
|
| 52 | + * @return IEvent |
|
| 53 | + * @since 8.2.0 |
|
| 54 | + */ |
|
| 55 | + public function generateEvent(); |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * Publish an event to the activity consumers |
|
| 59 | + * |
|
| 60 | + * Make sure to call at least the following methods before sending an Event: |
|
| 61 | + * - setApp() |
|
| 62 | + * - setType() |
|
| 63 | + * - setAffectedUser() |
|
| 64 | + * - setSubject() |
|
| 65 | + * |
|
| 66 | + * @param IEvent $event |
|
| 67 | + * @throws \BadMethodCallException if required values have not been set |
|
| 68 | + * @since 8.2.0 |
|
| 69 | + */ |
|
| 70 | + public function publish(IEvent $event); |
|
| 71 | + |
|
| 72 | + /** |
|
| 73 | + * @param string $app The app where this event is associated with |
|
| 74 | + * @param string $subject A short description of the event |
|
| 75 | + * @param array $subjectParams Array with parameters that are filled in the subject |
|
| 76 | + * @param string $message A longer description of the event |
|
| 77 | + * @param array $messageParams Array with parameters that are filled in the message |
|
| 78 | + * @param string $file The file including path where this event is associated with |
|
| 79 | + * @param string $link A link where this event is associated with |
|
| 80 | + * @param string $affectedUser Recipient of the activity |
|
| 81 | + * @param string $type Type of the notification |
|
| 82 | + * @param int $priority Priority of the notification |
|
| 83 | + * @since 6.0.0 |
|
| 84 | + * @deprecated 8.2.0 Grab an IEvent from generateEvent() instead and use the publish() method |
|
| 85 | + */ |
|
| 86 | + public function publishActivity($app, $subject, $subjectParams, $message, $messageParams, $file, $link, $affectedUser, $type, $priority); |
|
| 87 | + |
|
| 88 | + /** |
|
| 89 | + * In order to improve lazy loading a closure can be registered which will be called in case |
|
| 90 | + * activity consumers are actually requested |
|
| 91 | + * |
|
| 92 | + * $callable has to return an instance of \OCP\Activity\IConsumer |
|
| 93 | + * |
|
| 94 | + * @param \Closure $callable |
|
| 95 | + * @return void |
|
| 96 | + * @since 6.0.0 |
|
| 97 | + */ |
|
| 98 | + public function registerConsumer(\Closure $callable); |
|
| 99 | + |
|
| 100 | + /** |
|
| 101 | + * In order to improve lazy loading a closure can be registered which will be called in case |
|
| 102 | + * activity consumers are actually requested |
|
| 103 | + * |
|
| 104 | + * $callable has to return an instance of \OCP\Activity\IExtension |
|
| 105 | + * |
|
| 106 | + * @param \Closure $callable |
|
| 107 | + * @return void |
|
| 108 | + * @since 8.0.0 |
|
| 109 | + */ |
|
| 110 | + public function registerExtension(\Closure $callable); |
|
| 111 | + |
|
| 112 | + /** |
|
| 113 | + * @param string $filter Class must implement OCA\Activity\IFilter |
|
| 114 | + * @return void |
|
| 115 | + * @since 11.0.0 |
|
| 116 | + */ |
|
| 117 | + public function registerFilter($filter); |
|
| 118 | + |
|
| 119 | + /** |
|
| 120 | + * @return IFilter[] |
|
| 121 | + * @since 11.0.0 |
|
| 122 | + */ |
|
| 123 | + public function getFilters(); |
|
| 124 | + |
|
| 125 | + /** |
|
| 126 | + * @param string $id |
|
| 127 | + * @return IFilter |
|
| 128 | + * @throws \InvalidArgumentException when the filter was not found |
|
| 129 | + * @since 11.0.0 |
|
| 130 | + */ |
|
| 131 | + public function getFilterById($id); |
|
| 132 | + |
|
| 133 | + /** |
|
| 134 | + * @param string $setting Class must implement OCA\Activity\ISetting |
|
| 135 | + * @return void |
|
| 136 | + * @since 11.0.0 |
|
| 137 | + */ |
|
| 138 | + public function registerSetting($setting); |
|
| 139 | + |
|
| 140 | + /** |
|
| 141 | + * @return ISetting[] |
|
| 142 | + * @since 11.0.0 |
|
| 143 | + */ |
|
| 144 | + public function getSettings(); |
|
| 145 | + |
|
| 146 | + /** |
|
| 147 | + * @param string $provider Class must implement OCA\Activity\IProvider |
|
| 148 | + * @return void |
|
| 149 | + * @since 11.0.0 |
|
| 150 | + */ |
|
| 151 | + public function registerProvider($provider); |
|
| 152 | + |
|
| 153 | + /** |
|
| 154 | + * @return IProvider[] |
|
| 155 | + * @since 11.0.0 |
|
| 156 | + */ |
|
| 157 | + public function getProviders(); |
|
| 158 | + |
|
| 159 | + /** |
|
| 160 | + * @param string $id |
|
| 161 | + * @return ISetting |
|
| 162 | + * @throws \InvalidArgumentException when the setting was not found |
|
| 163 | + * @since 11.0.0 |
|
| 164 | + */ |
|
| 165 | + public function getSettingById($id); |
|
| 166 | + |
|
| 167 | + /** |
|
| 168 | + * Will return additional notification types as specified by other apps |
|
| 169 | + * |
|
| 170 | + * @param string $languageCode |
|
| 171 | + * @return array Array "stringID of the type" => "translated string description for the setting" |
|
| 172 | + * or Array "stringID of the type" => [ |
|
| 173 | + * 'desc' => "translated string description for the setting" |
|
| 174 | + * 'methods' => [\OCP\Activity\IExtension::METHOD_*], |
|
| 175 | + * ] |
|
| 176 | + * @since 8.0.0 - 8.2.0: Added support to allow limiting notifications to certain methods |
|
| 177 | + * @deprecated 11.0.0 - Use getSettings() instead |
|
| 178 | + */ |
|
| 179 | + public function getNotificationTypes($languageCode); |
|
| 180 | + |
|
| 181 | + /** |
|
| 182 | + * @param string $method |
|
| 183 | + * @return array |
|
| 184 | + * @since 8.0.0 |
|
| 185 | + * @deprecated 11.0.0 - Use getSettings()->isDefaulEnabled<method>() instead |
|
| 186 | + */ |
|
| 187 | + public function getDefaultTypes($method); |
|
| 188 | + |
|
| 189 | + /** |
|
| 190 | + * @param string $type |
|
| 191 | + * @return string |
|
| 192 | + * @since 8.0.0 |
|
| 193 | + */ |
|
| 194 | + public function getTypeIcon($type); |
|
| 195 | + |
|
| 196 | + /** |
|
| 197 | + * @param string $type |
|
| 198 | + * @param int $id |
|
| 199 | + * @since 8.2.0 |
|
| 200 | + */ |
|
| 201 | + public function setFormattingObject($type, $id); |
|
| 202 | + |
|
| 203 | + /** |
|
| 204 | + * @return bool |
|
| 205 | + * @since 8.2.0 |
|
| 206 | + */ |
|
| 207 | + public function isFormattingFilteredObject(); |
|
| 208 | + |
|
| 209 | + /** |
|
| 210 | + * @param bool $status Set to true, when parsing events should not use SVG icons |
|
| 211 | + * @since 12.0.1 |
|
| 212 | + */ |
|
| 213 | + public function setRequirePNG($status); |
|
| 214 | + |
|
| 215 | + /** |
|
| 216 | + * @return bool |
|
| 217 | + * @since 12.0.1 |
|
| 218 | + */ |
|
| 219 | + public function getRequirePNG(); |
|
| 220 | + |
|
| 221 | + /** |
|
| 222 | + * @param string $app |
|
| 223 | + * @param string $text |
|
| 224 | + * @param array $params |
|
| 225 | + * @param boolean $stripPath |
|
| 226 | + * @param boolean $highlightParams |
|
| 227 | + * @param string $languageCode |
|
| 228 | + * @return string|false |
|
| 229 | + * @since 8.0.0 |
|
| 230 | + */ |
|
| 231 | + public function translate($app, $text, $params, $stripPath, $highlightParams, $languageCode); |
|
| 232 | + |
|
| 233 | + /** |
|
| 234 | + * @param string $app |
|
| 235 | + * @param string $text |
|
| 236 | + * @return array|false |
|
| 237 | + * @since 8.0.0 |
|
| 238 | + */ |
|
| 239 | + public function getSpecialParameterList($app, $text); |
|
| 240 | + |
|
| 241 | + /** |
|
| 242 | + * @param array $activity |
|
| 243 | + * @return integer|false |
|
| 244 | + * @since 8.0.0 |
|
| 245 | + */ |
|
| 246 | + public function getGroupParameter($activity); |
|
| 247 | + |
|
| 248 | + |
|
| 249 | + /** |
|
| 250 | + * Set the user we need to use |
|
| 251 | + * |
|
| 252 | + * @param string|null $currentUserId |
|
| 253 | + * @throws \UnexpectedValueException If the user is invalid |
|
| 254 | + * @since 9.0.1 |
|
| 255 | + */ |
|
| 256 | + public function setCurrentUserId($currentUserId); |
|
| 257 | + |
|
| 258 | + /** |
|
| 259 | + * Get the user we need to use |
|
| 260 | + * |
|
| 261 | + * Either the user is logged in, or we try to get it from the token |
|
| 262 | + * |
|
| 263 | + * @return string |
|
| 264 | + * @throws \UnexpectedValueException If the token is invalid, does not exist or is not unique |
|
| 265 | + * @since 8.1.0 |
|
| 266 | + */ |
|
| 267 | + public function getCurrentUserId(); |
|
| 268 | + |
|
| 269 | + /** |
|
| 270 | + * @return array |
|
| 271 | + * @since 8.0.0 |
|
| 272 | + * @deprecated 11.0.0 - Use getFilters() instead |
|
| 273 | + */ |
|
| 274 | + public function getNavigation(); |
|
| 275 | + |
|
| 276 | + /** |
|
| 277 | + * @param string $filterValue |
|
| 278 | + * @return boolean |
|
| 279 | + * @since 8.0.0 |
|
| 280 | + * @deprecated 11.0.0 - Use getFilterById() instead |
|
| 281 | + */ |
|
| 282 | + public function isFilterValid($filterValue); |
|
| 283 | + |
|
| 284 | + /** |
|
| 285 | + * @param array $types |
|
| 286 | + * @param string $filter |
|
| 287 | + * @return array |
|
| 288 | + * @since 8.0.0 |
|
| 289 | + * @deprecated 11.0.0 - Use getFilterById()->filterTypes() instead |
|
| 290 | + */ |
|
| 291 | + public function filterNotificationTypes($types, $filter); |
|
| 292 | + |
|
| 293 | + /** |
|
| 294 | + * @param string $filter |
|
| 295 | + * @return array |
|
| 296 | + * @since 8.0.0 |
|
| 297 | + * @deprecated 11.0.0 - Use getFilterById() instead |
|
| 298 | + */ |
|
| 299 | + public function getQueryForFilter($filter); |
|
| 300 | 300 | } |
@@ -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 | ?> |
@@ -28,27 +28,27 @@ |
||
| 28 | 28 | use OCP\Util; |
| 29 | 29 | |
| 30 | 30 | class Application extends App { |
| 31 | - public function __construct () { |
|
| 32 | - parent::__construct('twofactor_backupcodes'); |
|
| 33 | - } |
|
| 31 | + public function __construct () { |
|
| 32 | + parent::__construct('twofactor_backupcodes'); |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * Register the different app parts |
|
| 37 | - */ |
|
| 38 | - public function register() { |
|
| 39 | - $this->registerHooksAndEvents(); |
|
| 40 | - } |
|
| 35 | + /** |
|
| 36 | + * Register the different app parts |
|
| 37 | + */ |
|
| 38 | + public function register() { |
|
| 39 | + $this->registerHooksAndEvents(); |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * Register the hooks and events |
|
| 44 | - */ |
|
| 45 | - public function registerHooksAndEvents() { |
|
| 46 | - Util::connectHook('OC_User', 'post_deleteUser', $this, 'deleteUser'); |
|
| 47 | - } |
|
| 42 | + /** |
|
| 43 | + * Register the hooks and events |
|
| 44 | + */ |
|
| 45 | + public function registerHooksAndEvents() { |
|
| 46 | + Util::connectHook('OC_User', 'post_deleteUser', $this, 'deleteUser'); |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - public function deleteUser($params) { |
|
| 50 | - /** @var BackupCodeMapper $mapper */ |
|
| 51 | - $mapper = $this->getContainer()->query(BackupCodeMapper::class); |
|
| 52 | - $mapper->deleteCodesByUserId($params['uid']); |
|
| 53 | - } |
|
| 49 | + public function deleteUser($params) { |
|
| 50 | + /** @var BackupCodeMapper $mapper */ |
|
| 51 | + $mapper = $this->getContainer()->query(BackupCodeMapper::class); |
|
| 52 | + $mapper->deleteCodesByUserId($params['uid']); |
|
| 53 | + } |
|
| 54 | 54 | } |
@@ -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 | } |
@@ -29,63 +29,63 @@ |
||
| 29 | 29 | use OCP\Settings\ISettings; |
| 30 | 30 | |
| 31 | 31 | class Encryption implements ISettings { |
| 32 | - /** @var IManager */ |
|
| 33 | - private $manager; |
|
| 32 | + /** @var IManager */ |
|
| 33 | + private $manager; |
|
| 34 | 34 | |
| 35 | - /** @var IUserManager */ |
|
| 36 | - private $userManager; |
|
| 35 | + /** @var IUserManager */ |
|
| 36 | + private $userManager; |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * @param IManager $manager |
|
| 40 | - * @param IUserManager $userManager |
|
| 41 | - */ |
|
| 42 | - public function __construct(IManager $manager, IUserManager $userManager) { |
|
| 43 | - $this->manager = $manager; |
|
| 44 | - $this->userManager = $userManager; |
|
| 45 | - } |
|
| 38 | + /** |
|
| 39 | + * @param IManager $manager |
|
| 40 | + * @param IUserManager $userManager |
|
| 41 | + */ |
|
| 42 | + public function __construct(IManager $manager, IUserManager $userManager) { |
|
| 43 | + $this->manager = $manager; |
|
| 44 | + $this->userManager = $userManager; |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * @return TemplateResponse |
|
| 49 | - */ |
|
| 50 | - public function getForm() { |
|
| 51 | - $encryptionModules = $this->manager->getEncryptionModules(); |
|
| 52 | - $defaultEncryptionModuleId = $this->manager->getDefaultEncryptionModuleId(); |
|
| 53 | - $encryptionModuleList = []; |
|
| 54 | - foreach ($encryptionModules as $module) { |
|
| 55 | - $encryptionModuleList[$module['id']]['displayName'] = $module['displayName']; |
|
| 56 | - $encryptionModuleList[$module['id']]['default'] = false; |
|
| 57 | - if ($module['id'] === $defaultEncryptionModuleId) { |
|
| 58 | - $encryptionModuleList[$module['id']]['default'] = true; |
|
| 59 | - } |
|
| 60 | - } |
|
| 47 | + /** |
|
| 48 | + * @return TemplateResponse |
|
| 49 | + */ |
|
| 50 | + public function getForm() { |
|
| 51 | + $encryptionModules = $this->manager->getEncryptionModules(); |
|
| 52 | + $defaultEncryptionModuleId = $this->manager->getDefaultEncryptionModuleId(); |
|
| 53 | + $encryptionModuleList = []; |
|
| 54 | + foreach ($encryptionModules as $module) { |
|
| 55 | + $encryptionModuleList[$module['id']]['displayName'] = $module['displayName']; |
|
| 56 | + $encryptionModuleList[$module['id']]['default'] = false; |
|
| 57 | + if ($module['id'] === $defaultEncryptionModuleId) { |
|
| 58 | + $encryptionModuleList[$module['id']]['default'] = true; |
|
| 59 | + } |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - $parameters = [ |
|
| 63 | - // Encryption API |
|
| 64 | - 'encryptionEnabled' => $this->manager->isEnabled(), |
|
| 65 | - 'encryptionReady' => $this->manager->isReady(), |
|
| 66 | - 'externalBackendsEnabled' => count($this->userManager->getBackends()) > 1, |
|
| 67 | - // Modules |
|
| 68 | - 'encryptionModules' => $encryptionModuleList, |
|
| 69 | - ]; |
|
| 62 | + $parameters = [ |
|
| 63 | + // Encryption API |
|
| 64 | + 'encryptionEnabled' => $this->manager->isEnabled(), |
|
| 65 | + 'encryptionReady' => $this->manager->isReady(), |
|
| 66 | + 'externalBackendsEnabled' => count($this->userManager->getBackends()) > 1, |
|
| 67 | + // Modules |
|
| 68 | + 'encryptionModules' => $encryptionModuleList, |
|
| 69 | + ]; |
|
| 70 | 70 | |
| 71 | - return new TemplateResponse('settings', 'settings/admin/encryption', $parameters, ''); |
|
| 72 | - } |
|
| 71 | + return new TemplateResponse('settings', 'settings/admin/encryption', $parameters, ''); |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - /** |
|
| 75 | - * @return string the section ID, e.g. 'sharing' |
|
| 76 | - */ |
|
| 77 | - public function getSection() { |
|
| 78 | - return 'encryption'; |
|
| 79 | - } |
|
| 74 | + /** |
|
| 75 | + * @return string the section ID, e.g. 'sharing' |
|
| 76 | + */ |
|
| 77 | + public function getSection() { |
|
| 78 | + return 'encryption'; |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - /** |
|
| 82 | - * @return int whether the form should be rather on the top or bottom of |
|
| 83 | - * the admin section. The forms are arranged in ascending order of the |
|
| 84 | - * priority values. It is required to return a value between 0 and 100. |
|
| 85 | - * |
|
| 86 | - * E.g.: 70 |
|
| 87 | - */ |
|
| 88 | - public function getPriority() { |
|
| 89 | - return 0; |
|
| 90 | - } |
|
| 81 | + /** |
|
| 82 | + * @return int whether the form should be rather on the top or bottom of |
|
| 83 | + * the admin section. The forms are arranged in ascending order of the |
|
| 84 | + * priority values. It is required to return a value between 0 and 100. |
|
| 85 | + * |
|
| 86 | + * E.g.: 70 |
|
| 87 | + */ |
|
| 88 | + public function getPriority() { |
|
| 89 | + return 0; |
|
| 90 | + } |
|
| 91 | 91 | } |
@@ -28,44 +28,44 @@ |
||
| 28 | 28 | use OCP\Settings\ISettings; |
| 29 | 29 | |
| 30 | 30 | class TipsTricks implements ISettings { |
| 31 | - /** @var IConfig */ |
|
| 32 | - private $config; |
|
| 31 | + /** @var IConfig */ |
|
| 32 | + private $config; |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * @param IConfig $config |
|
| 36 | - */ |
|
| 37 | - public function __construct(IConfig $config) { |
|
| 38 | - $this->config = $config; |
|
| 39 | - } |
|
| 34 | + /** |
|
| 35 | + * @param IConfig $config |
|
| 36 | + */ |
|
| 37 | + public function __construct(IConfig $config) { |
|
| 38 | + $this->config = $config; |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * @return TemplateResponse |
|
| 43 | - */ |
|
| 44 | - public function getForm() { |
|
| 45 | - $databaseOverload = (strpos($this->config->getSystemValue('dbtype'), 'sqlite') !== false); |
|
| 41 | + /** |
|
| 42 | + * @return TemplateResponse |
|
| 43 | + */ |
|
| 44 | + public function getForm() { |
|
| 45 | + $databaseOverload = (strpos($this->config->getSystemValue('dbtype'), 'sqlite') !== false); |
|
| 46 | 46 | |
| 47 | - $parameters = [ |
|
| 48 | - 'databaseOverload' => $databaseOverload, |
|
| 49 | - ]; |
|
| 47 | + $parameters = [ |
|
| 48 | + 'databaseOverload' => $databaseOverload, |
|
| 49 | + ]; |
|
| 50 | 50 | |
| 51 | - return new TemplateResponse('settings', 'settings/admin/tipstricks', $parameters, ''); |
|
| 52 | - } |
|
| 51 | + return new TemplateResponse('settings', 'settings/admin/tipstricks', $parameters, ''); |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * @return string the section ID, e.g. 'sharing' |
|
| 56 | - */ |
|
| 57 | - public function getSection() { |
|
| 58 | - return 'tips-tricks'; |
|
| 59 | - } |
|
| 54 | + /** |
|
| 55 | + * @return string the section ID, e.g. 'sharing' |
|
| 56 | + */ |
|
| 57 | + public function getSection() { |
|
| 58 | + return 'tips-tricks'; |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * @return int whether the form should be rather on the top or bottom of |
|
| 63 | - * the admin section. The forms are arranged in ascending order of the |
|
| 64 | - * priority values. It is required to return a value between 0 and 100. |
|
| 65 | - * |
|
| 66 | - * E.g.: 70 |
|
| 67 | - */ |
|
| 68 | - public function getPriority() { |
|
| 69 | - return 0; |
|
| 70 | - } |
|
| 61 | + /** |
|
| 62 | + * @return int whether the form should be rather on the top or bottom of |
|
| 63 | + * the admin section. The forms are arranged in ascending order of the |
|
| 64 | + * priority values. It is required to return a value between 0 and 100. |
|
| 65 | + * |
|
| 66 | + * E.g.: 70 |
|
| 67 | + */ |
|
| 68 | + public function getPriority() { |
|
| 69 | + return 0; |
|
| 70 | + } |
|
| 71 | 71 | } |
@@ -26,28 +26,28 @@ |
||
| 26 | 26 | use OCP\Settings\ISettings; |
| 27 | 27 | |
| 28 | 28 | class ServerDevNotice implements ISettings { |
| 29 | - /** |
|
| 30 | - * @return TemplateResponse |
|
| 31 | - */ |
|
| 32 | - public function getForm() { |
|
| 33 | - return new TemplateResponse('settings', 'settings/admin/server.development.notice'); |
|
| 34 | - } |
|
| 29 | + /** |
|
| 30 | + * @return TemplateResponse |
|
| 31 | + */ |
|
| 32 | + public function getForm() { |
|
| 33 | + return new TemplateResponse('settings', 'settings/admin/server.development.notice'); |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * @return string the section ID, e.g. 'sharing' |
|
| 38 | - */ |
|
| 39 | - public function getSection() { |
|
| 40 | - return 'server'; |
|
| 41 | - } |
|
| 36 | + /** |
|
| 37 | + * @return string the section ID, e.g. 'sharing' |
|
| 38 | + */ |
|
| 39 | + public function getSection() { |
|
| 40 | + return 'server'; |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * @return int whether the form should be rather on the top or bottom of |
|
| 45 | - * the admin section. The forms are arranged in ascending order of the |
|
| 46 | - * priority values. It is required to return a value between 0 and 100. |
|
| 47 | - * |
|
| 48 | - * E.g.: 70 |
|
| 49 | - */ |
|
| 50 | - public function getPriority() { |
|
| 51 | - return 1000; |
|
| 52 | - } |
|
| 43 | + /** |
|
| 44 | + * @return int whether the form should be rather on the top or bottom of |
|
| 45 | + * the admin section. The forms are arranged in ascending order of the |
|
| 46 | + * priority values. It is required to return a value between 0 and 100. |
|
| 47 | + * |
|
| 48 | + * E.g.: 70 |
|
| 49 | + */ |
|
| 50 | + public function getPriority() { |
|
| 51 | + return 1000; |
|
| 52 | + } |
|
| 53 | 53 | } |