@@ -28,123 +28,123 @@ |
||
| 28 | 28 | class Users extends Base { |
| 29 | 29 | |
| 30 | 30 | |
| 31 | - const SUBJECT_SHARED_USER_SELF = 'shared_user_self'; |
|
| 32 | - const SUBJECT_RESHARED_USER_BY = 'reshared_user_by'; |
|
| 33 | - const SUBJECT_UNSHARED_USER_SELF = 'unshared_user_self'; |
|
| 34 | - const SUBJECT_UNSHARED_USER_BY = 'unshared_user_by'; |
|
| 35 | - |
|
| 36 | - const SUBJECT_SHARED_WITH_BY = 'shared_with_by'; |
|
| 37 | - const SUBJECT_UNSHARED_BY = 'unshared_by'; |
|
| 38 | - const SUBJECT_SELF_UNSHARED = 'self_unshared'; |
|
| 39 | - const SUBJECT_SELF_UNSHARED_BY = 'self_unshared_by'; |
|
| 40 | - |
|
| 41 | - /** |
|
| 42 | - * @param IEvent $event |
|
| 43 | - * @return IEvent |
|
| 44 | - * @throws \InvalidArgumentException |
|
| 45 | - * @since 11.0.0 |
|
| 46 | - */ |
|
| 47 | - public function parseShortVersion(IEvent $event) { |
|
| 48 | - $parsedParameters = $this->getParsedParameters($event); |
|
| 49 | - |
|
| 50 | - if ($event->getSubject() === self::SUBJECT_SHARED_USER_SELF) { |
|
| 51 | - $subject = $this->l->t('Shared with {user}'); |
|
| 52 | - } else if ($event->getSubject() === self::SUBJECT_UNSHARED_USER_SELF) { |
|
| 53 | - $subject = $this->l->t('Removed share for {user}'); |
|
| 54 | - } else if ($event->getSubject() === self::SUBJECT_SELF_UNSHARED) { |
|
| 55 | - $subject = $this->l->t('You removed yourself'); |
|
| 56 | - } else if ($event->getSubject() === self::SUBJECT_SELF_UNSHARED_BY) { |
|
| 57 | - $subject = $this->l->t('{actor} removed themselves'); |
|
| 58 | - } else if ($event->getSubject() === self::SUBJECT_RESHARED_USER_BY) { |
|
| 59 | - $subject = $this->l->t('{actor} shared with {user}'); |
|
| 60 | - } else if ($event->getSubject() === self::SUBJECT_UNSHARED_USER_BY) { |
|
| 61 | - $subject = $this->l->t('{actor} removed share for {user}'); |
|
| 62 | - } else if ($event->getSubject() === self::SUBJECT_SHARED_WITH_BY) { |
|
| 63 | - $subject = $this->l->t('Shared by {actor}'); |
|
| 64 | - } else if ($event->getSubject() === self::SUBJECT_UNSHARED_BY) { |
|
| 65 | - $subject = $this->l->t('{actor} removed share'); |
|
| 66 | - |
|
| 67 | - } else { |
|
| 68 | - throw new \InvalidArgumentException(); |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - if ($this->activityManager->getRequirePNG()) { |
|
| 72 | - $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.png'))); |
|
| 73 | - } else { |
|
| 74 | - $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg'))); |
|
| 75 | - } |
|
| 76 | - $this->setSubjects($event, $subject, $parsedParameters); |
|
| 77 | - |
|
| 78 | - return $event; |
|
| 79 | - } |
|
| 80 | - |
|
| 81 | - /** |
|
| 82 | - * @param IEvent $event |
|
| 83 | - * @return IEvent |
|
| 84 | - * @throws \InvalidArgumentException |
|
| 85 | - * @since 11.0.0 |
|
| 86 | - */ |
|
| 87 | - public function parseLongVersion(IEvent $event) { |
|
| 88 | - $parsedParameters = $this->getParsedParameters($event); |
|
| 89 | - |
|
| 90 | - if ($event->getSubject() === self::SUBJECT_SHARED_USER_SELF) { |
|
| 91 | - $subject = $this->l->t('You shared {file} with {user}'); |
|
| 92 | - } else if ($event->getSubject() === self::SUBJECT_UNSHARED_USER_SELF) { |
|
| 93 | - $subject = $this->l->t('You removed {user} from {file}'); |
|
| 94 | - } else if ($event->getSubject() === self::SUBJECT_SELF_UNSHARED) { |
|
| 95 | - $subject = $this->l->t('You removed yourself from {file}'); |
|
| 96 | - } else if ($event->getSubject() === self::SUBJECT_SELF_UNSHARED_BY) { |
|
| 97 | - $subject = $this->l->t('{actor} removed themselves from {file}'); |
|
| 98 | - } else if ($event->getSubject() === self::SUBJECT_RESHARED_USER_BY) { |
|
| 99 | - $subject = $this->l->t('{actor} shared {file} with {user}'); |
|
| 100 | - } else if ($event->getSubject() === self::SUBJECT_UNSHARED_USER_BY) { |
|
| 101 | - $subject = $this->l->t('{actor} removed {user} from {file}'); |
|
| 102 | - } else if ($event->getSubject() === self::SUBJECT_SHARED_WITH_BY) { |
|
| 103 | - $subject = $this->l->t('{actor} shared {file} with you'); |
|
| 104 | - } else if ($event->getSubject() === self::SUBJECT_UNSHARED_BY) { |
|
| 105 | - $subject = $this->l->t('{actor} removed you from the share named {file}'); |
|
| 106 | - |
|
| 107 | - } else { |
|
| 108 | - throw new \InvalidArgumentException(); |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - if ($this->activityManager->getRequirePNG()) { |
|
| 112 | - $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.png'))); |
|
| 113 | - } else { |
|
| 114 | - $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg'))); |
|
| 115 | - } |
|
| 116 | - $this->setSubjects($event, $subject, $parsedParameters); |
|
| 117 | - |
|
| 118 | - return $event; |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - protected function getParsedParameters(IEvent $event) { |
|
| 122 | - $subject = $event->getSubject(); |
|
| 123 | - $parameters = $event->getSubjectParameters(); |
|
| 124 | - |
|
| 125 | - switch ($subject) { |
|
| 126 | - case self::SUBJECT_SHARED_USER_SELF: |
|
| 127 | - case self::SUBJECT_UNSHARED_USER_SELF: |
|
| 128 | - return [ |
|
| 129 | - 'file' => $this->getFile($parameters[0], $event), |
|
| 130 | - 'user' => $this->getUser($parameters[1]), |
|
| 131 | - ]; |
|
| 132 | - case self::SUBJECT_SHARED_WITH_BY: |
|
| 133 | - case self::SUBJECT_UNSHARED_BY: |
|
| 134 | - case self::SUBJECT_SELF_UNSHARED: |
|
| 135 | - case self::SUBJECT_SELF_UNSHARED_BY: |
|
| 136 | - return [ |
|
| 137 | - 'file' => $this->getFile($parameters[0], $event), |
|
| 138 | - 'actor' => $this->getUser($parameters[1]), |
|
| 139 | - ]; |
|
| 140 | - case self::SUBJECT_RESHARED_USER_BY: |
|
| 141 | - case self::SUBJECT_UNSHARED_USER_BY: |
|
| 142 | - return [ |
|
| 143 | - 'file' => $this->getFile($parameters[0], $event), |
|
| 144 | - 'user' => $this->getUser($parameters[2]), |
|
| 145 | - 'actor' => $this->getUser($parameters[1]), |
|
| 146 | - ]; |
|
| 147 | - } |
|
| 148 | - return []; |
|
| 149 | - } |
|
| 31 | + const SUBJECT_SHARED_USER_SELF = 'shared_user_self'; |
|
| 32 | + const SUBJECT_RESHARED_USER_BY = 'reshared_user_by'; |
|
| 33 | + const SUBJECT_UNSHARED_USER_SELF = 'unshared_user_self'; |
|
| 34 | + const SUBJECT_UNSHARED_USER_BY = 'unshared_user_by'; |
|
| 35 | + |
|
| 36 | + const SUBJECT_SHARED_WITH_BY = 'shared_with_by'; |
|
| 37 | + const SUBJECT_UNSHARED_BY = 'unshared_by'; |
|
| 38 | + const SUBJECT_SELF_UNSHARED = 'self_unshared'; |
|
| 39 | + const SUBJECT_SELF_UNSHARED_BY = 'self_unshared_by'; |
|
| 40 | + |
|
| 41 | + /** |
|
| 42 | + * @param IEvent $event |
|
| 43 | + * @return IEvent |
|
| 44 | + * @throws \InvalidArgumentException |
|
| 45 | + * @since 11.0.0 |
|
| 46 | + */ |
|
| 47 | + public function parseShortVersion(IEvent $event) { |
|
| 48 | + $parsedParameters = $this->getParsedParameters($event); |
|
| 49 | + |
|
| 50 | + if ($event->getSubject() === self::SUBJECT_SHARED_USER_SELF) { |
|
| 51 | + $subject = $this->l->t('Shared with {user}'); |
|
| 52 | + } else if ($event->getSubject() === self::SUBJECT_UNSHARED_USER_SELF) { |
|
| 53 | + $subject = $this->l->t('Removed share for {user}'); |
|
| 54 | + } else if ($event->getSubject() === self::SUBJECT_SELF_UNSHARED) { |
|
| 55 | + $subject = $this->l->t('You removed yourself'); |
|
| 56 | + } else if ($event->getSubject() === self::SUBJECT_SELF_UNSHARED_BY) { |
|
| 57 | + $subject = $this->l->t('{actor} removed themselves'); |
|
| 58 | + } else if ($event->getSubject() === self::SUBJECT_RESHARED_USER_BY) { |
|
| 59 | + $subject = $this->l->t('{actor} shared with {user}'); |
|
| 60 | + } else if ($event->getSubject() === self::SUBJECT_UNSHARED_USER_BY) { |
|
| 61 | + $subject = $this->l->t('{actor} removed share for {user}'); |
|
| 62 | + } else if ($event->getSubject() === self::SUBJECT_SHARED_WITH_BY) { |
|
| 63 | + $subject = $this->l->t('Shared by {actor}'); |
|
| 64 | + } else if ($event->getSubject() === self::SUBJECT_UNSHARED_BY) { |
|
| 65 | + $subject = $this->l->t('{actor} removed share'); |
|
| 66 | + |
|
| 67 | + } else { |
|
| 68 | + throw new \InvalidArgumentException(); |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + if ($this->activityManager->getRequirePNG()) { |
|
| 72 | + $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.png'))); |
|
| 73 | + } else { |
|
| 74 | + $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg'))); |
|
| 75 | + } |
|
| 76 | + $this->setSubjects($event, $subject, $parsedParameters); |
|
| 77 | + |
|
| 78 | + return $event; |
|
| 79 | + } |
|
| 80 | + |
|
| 81 | + /** |
|
| 82 | + * @param IEvent $event |
|
| 83 | + * @return IEvent |
|
| 84 | + * @throws \InvalidArgumentException |
|
| 85 | + * @since 11.0.0 |
|
| 86 | + */ |
|
| 87 | + public function parseLongVersion(IEvent $event) { |
|
| 88 | + $parsedParameters = $this->getParsedParameters($event); |
|
| 89 | + |
|
| 90 | + if ($event->getSubject() === self::SUBJECT_SHARED_USER_SELF) { |
|
| 91 | + $subject = $this->l->t('You shared {file} with {user}'); |
|
| 92 | + } else if ($event->getSubject() === self::SUBJECT_UNSHARED_USER_SELF) { |
|
| 93 | + $subject = $this->l->t('You removed {user} from {file}'); |
|
| 94 | + } else if ($event->getSubject() === self::SUBJECT_SELF_UNSHARED) { |
|
| 95 | + $subject = $this->l->t('You removed yourself from {file}'); |
|
| 96 | + } else if ($event->getSubject() === self::SUBJECT_SELF_UNSHARED_BY) { |
|
| 97 | + $subject = $this->l->t('{actor} removed themselves from {file}'); |
|
| 98 | + } else if ($event->getSubject() === self::SUBJECT_RESHARED_USER_BY) { |
|
| 99 | + $subject = $this->l->t('{actor} shared {file} with {user}'); |
|
| 100 | + } else if ($event->getSubject() === self::SUBJECT_UNSHARED_USER_BY) { |
|
| 101 | + $subject = $this->l->t('{actor} removed {user} from {file}'); |
|
| 102 | + } else if ($event->getSubject() === self::SUBJECT_SHARED_WITH_BY) { |
|
| 103 | + $subject = $this->l->t('{actor} shared {file} with you'); |
|
| 104 | + } else if ($event->getSubject() === self::SUBJECT_UNSHARED_BY) { |
|
| 105 | + $subject = $this->l->t('{actor} removed you from the share named {file}'); |
|
| 106 | + |
|
| 107 | + } else { |
|
| 108 | + throw new \InvalidArgumentException(); |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + if ($this->activityManager->getRequirePNG()) { |
|
| 112 | + $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.png'))); |
|
| 113 | + } else { |
|
| 114 | + $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg'))); |
|
| 115 | + } |
|
| 116 | + $this->setSubjects($event, $subject, $parsedParameters); |
|
| 117 | + |
|
| 118 | + return $event; |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + protected function getParsedParameters(IEvent $event) { |
|
| 122 | + $subject = $event->getSubject(); |
|
| 123 | + $parameters = $event->getSubjectParameters(); |
|
| 124 | + |
|
| 125 | + switch ($subject) { |
|
| 126 | + case self::SUBJECT_SHARED_USER_SELF: |
|
| 127 | + case self::SUBJECT_UNSHARED_USER_SELF: |
|
| 128 | + return [ |
|
| 129 | + 'file' => $this->getFile($parameters[0], $event), |
|
| 130 | + 'user' => $this->getUser($parameters[1]), |
|
| 131 | + ]; |
|
| 132 | + case self::SUBJECT_SHARED_WITH_BY: |
|
| 133 | + case self::SUBJECT_UNSHARED_BY: |
|
| 134 | + case self::SUBJECT_SELF_UNSHARED: |
|
| 135 | + case self::SUBJECT_SELF_UNSHARED_BY: |
|
| 136 | + return [ |
|
| 137 | + 'file' => $this->getFile($parameters[0], $event), |
|
| 138 | + 'actor' => $this->getUser($parameters[1]), |
|
| 139 | + ]; |
|
| 140 | + case self::SUBJECT_RESHARED_USER_BY: |
|
| 141 | + case self::SUBJECT_UNSHARED_USER_BY: |
|
| 142 | + return [ |
|
| 143 | + 'file' => $this->getFile($parameters[0], $event), |
|
| 144 | + 'user' => $this->getUser($parameters[2]), |
|
| 145 | + 'actor' => $this->getUser($parameters[1]), |
|
| 146 | + ]; |
|
| 147 | + } |
|
| 148 | + return []; |
|
| 149 | + } |
|
| 150 | 150 | } |