@@ -29,31 +29,31 @@ |
||
| 29 | 29 | * @since 8.1.0 |
| 30 | 30 | */ |
| 31 | 31 | interface IProvider { |
| 32 | - /** |
|
| 33 | - * @return string Regex with the mimetypes that are supported by this provider |
|
| 34 | - * @since 8.1.0 |
|
| 35 | - */ |
|
| 36 | - public function getMimeType(); |
|
| 32 | + /** |
|
| 33 | + * @return string Regex with the mimetypes that are supported by this provider |
|
| 34 | + * @since 8.1.0 |
|
| 35 | + */ |
|
| 36 | + public function getMimeType(); |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * Check if a preview can be generated for $path |
|
| 40 | - * |
|
| 41 | - * @param \OCP\Files\FileInfo $file |
|
| 42 | - * @return bool |
|
| 43 | - * @since 8.1.0 |
|
| 44 | - */ |
|
| 45 | - public function isAvailable(\OCP\Files\FileInfo $file); |
|
| 38 | + /** |
|
| 39 | + * Check if a preview can be generated for $path |
|
| 40 | + * |
|
| 41 | + * @param \OCP\Files\FileInfo $file |
|
| 42 | + * @return bool |
|
| 43 | + * @since 8.1.0 |
|
| 44 | + */ |
|
| 45 | + public function isAvailable(\OCP\Files\FileInfo $file); |
|
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * get thumbnail for file at path $path |
|
| 49 | - * |
|
| 50 | - * @param string $path Path of file |
|
| 51 | - * @param int $maxX The maximum X size of the thumbnail. It can be smaller depending on the shape of the image |
|
| 52 | - * @param int $maxY The maximum Y size of the thumbnail. It can be smaller depending on the shape of the image |
|
| 53 | - * @param bool $scalingup Disable/Enable upscaling of previews |
|
| 54 | - * @param \OC\Files\View $fileview fileview object of user folder |
|
| 55 | - * @return bool|\OCP\IImage false if no preview was generated |
|
| 56 | - * @since 8.1.0 |
|
| 57 | - */ |
|
| 58 | - public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview); |
|
| 47 | + /** |
|
| 48 | + * get thumbnail for file at path $path |
|
| 49 | + * |
|
| 50 | + * @param string $path Path of file |
|
| 51 | + * @param int $maxX The maximum X size of the thumbnail. It can be smaller depending on the shape of the image |
|
| 52 | + * @param int $maxY The maximum Y size of the thumbnail. It can be smaller depending on the shape of the image |
|
| 53 | + * @param bool $scalingup Disable/Enable upscaling of previews |
|
| 54 | + * @param \OC\Files\View $fileview fileview object of user folder |
|
| 55 | + * @return bool|\OCP\IImage false if no preview was generated |
|
| 56 | + * @since 8.1.0 |
|
| 57 | + */ |
|
| 58 | + public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview); |
|
| 59 | 59 | } |
@@ -37,55 +37,55 @@ |
||
| 37 | 37 | * @since 8.1.0 |
| 38 | 38 | */ |
| 39 | 39 | interface IMemcache extends ICache { |
| 40 | - /** |
|
| 41 | - * Set a value in the cache if it's not already stored |
|
| 42 | - * |
|
| 43 | - * @param string $key |
|
| 44 | - * @param mixed $value |
|
| 45 | - * @param int $ttl Time To Live in seconds. Defaults to 60*60*24 |
|
| 46 | - * @return bool |
|
| 47 | - * @since 8.1.0 |
|
| 48 | - */ |
|
| 49 | - public function add($key, $value, $ttl = 0); |
|
| 40 | + /** |
|
| 41 | + * Set a value in the cache if it's not already stored |
|
| 42 | + * |
|
| 43 | + * @param string $key |
|
| 44 | + * @param mixed $value |
|
| 45 | + * @param int $ttl Time To Live in seconds. Defaults to 60*60*24 |
|
| 46 | + * @return bool |
|
| 47 | + * @since 8.1.0 |
|
| 48 | + */ |
|
| 49 | + public function add($key, $value, $ttl = 0); |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * Increase a stored number |
|
| 53 | - * |
|
| 54 | - * @param string $key |
|
| 55 | - * @param int $step |
|
| 56 | - * @return int | bool |
|
| 57 | - * @since 8.1.0 |
|
| 58 | - */ |
|
| 59 | - public function inc($key, $step = 1); |
|
| 51 | + /** |
|
| 52 | + * Increase a stored number |
|
| 53 | + * |
|
| 54 | + * @param string $key |
|
| 55 | + * @param int $step |
|
| 56 | + * @return int | bool |
|
| 57 | + * @since 8.1.0 |
|
| 58 | + */ |
|
| 59 | + public function inc($key, $step = 1); |
|
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * Decrease a stored number |
|
| 63 | - * |
|
| 64 | - * @param string $key |
|
| 65 | - * @param int $step |
|
| 66 | - * @return int | bool |
|
| 67 | - * @since 8.1.0 |
|
| 68 | - */ |
|
| 69 | - public function dec($key, $step = 1); |
|
| 61 | + /** |
|
| 62 | + * Decrease a stored number |
|
| 63 | + * |
|
| 64 | + * @param string $key |
|
| 65 | + * @param int $step |
|
| 66 | + * @return int | bool |
|
| 67 | + * @since 8.1.0 |
|
| 68 | + */ |
|
| 69 | + public function dec($key, $step = 1); |
|
| 70 | 70 | |
| 71 | - /** |
|
| 72 | - * Compare and set |
|
| 73 | - * |
|
| 74 | - * @param string $key |
|
| 75 | - * @param mixed $old |
|
| 76 | - * @param mixed $new |
|
| 77 | - * @return bool |
|
| 78 | - * @since 8.1.0 |
|
| 79 | - */ |
|
| 80 | - public function cas($key, $old, $new); |
|
| 71 | + /** |
|
| 72 | + * Compare and set |
|
| 73 | + * |
|
| 74 | + * @param string $key |
|
| 75 | + * @param mixed $old |
|
| 76 | + * @param mixed $new |
|
| 77 | + * @return bool |
|
| 78 | + * @since 8.1.0 |
|
| 79 | + */ |
|
| 80 | + public function cas($key, $old, $new); |
|
| 81 | 81 | |
| 82 | - /** |
|
| 83 | - * Compare and delete |
|
| 84 | - * |
|
| 85 | - * @param string $key |
|
| 86 | - * @param mixed $old |
|
| 87 | - * @return bool |
|
| 88 | - * @since 8.1.0 |
|
| 89 | - */ |
|
| 90 | - public function cad($key, $old); |
|
| 82 | + /** |
|
| 83 | + * Compare and delete |
|
| 84 | + * |
|
| 85 | + * @param string $key |
|
| 86 | + * @param mixed $old |
|
| 87 | + * @return bool |
|
| 88 | + * @since 8.1.0 |
|
| 89 | + */ |
|
| 90 | + public function cad($key, $old); |
|
| 91 | 91 | } |
@@ -32,13 +32,13 @@ |
||
| 32 | 32 | */ |
| 33 | 33 | interface IFile { |
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * get list of users with access to the file |
|
| 37 | - * |
|
| 38 | - * @param string $path to the file |
|
| 39 | - * @return array |
|
| 40 | - * @since 8.1.0 |
|
| 41 | - */ |
|
| 42 | - public function getAccessList($path); |
|
| 35 | + /** |
|
| 36 | + * get list of users with access to the file |
|
| 37 | + * |
|
| 38 | + * @param string $path to the file |
|
| 39 | + * @return array |
|
| 40 | + * @since 8.1.0 |
|
| 41 | + */ |
|
| 42 | + public function getAccessList($path); |
|
| 43 | 43 | |
| 44 | 44 | } |
@@ -34,67 +34,67 @@ |
||
| 34 | 34 | */ |
| 35 | 35 | interface IManager { |
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * Check if encryption is available (at least one encryption module needs to be enabled) |
|
| 39 | - * |
|
| 40 | - * @return bool true if enabled, false if not |
|
| 41 | - * @since 8.1.0 |
|
| 42 | - */ |
|
| 43 | - public function isEnabled(); |
|
| 37 | + /** |
|
| 38 | + * Check if encryption is available (at least one encryption module needs to be enabled) |
|
| 39 | + * |
|
| 40 | + * @return bool true if enabled, false if not |
|
| 41 | + * @since 8.1.0 |
|
| 42 | + */ |
|
| 43 | + public function isEnabled(); |
|
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * Registers an callback function which must return an encryption module instance |
|
| 47 | - * |
|
| 48 | - * @param string $id |
|
| 49 | - * @param string $displayName |
|
| 50 | - * @param callable $callback |
|
| 51 | - * @throws ModuleAlreadyExistsException |
|
| 52 | - * @since 8.1.0 |
|
| 53 | - */ |
|
| 54 | - public function registerEncryptionModule($id, $displayName, callable $callback); |
|
| 45 | + /** |
|
| 46 | + * Registers an callback function which must return an encryption module instance |
|
| 47 | + * |
|
| 48 | + * @param string $id |
|
| 49 | + * @param string $displayName |
|
| 50 | + * @param callable $callback |
|
| 51 | + * @throws ModuleAlreadyExistsException |
|
| 52 | + * @since 8.1.0 |
|
| 53 | + */ |
|
| 54 | + public function registerEncryptionModule($id, $displayName, callable $callback); |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * Unregisters an encryption module |
|
| 58 | - * |
|
| 59 | - * @param string $moduleId |
|
| 60 | - * @since 8.1.0 |
|
| 61 | - */ |
|
| 62 | - public function unregisterEncryptionModule($moduleId); |
|
| 56 | + /** |
|
| 57 | + * Unregisters an encryption module |
|
| 58 | + * |
|
| 59 | + * @param string $moduleId |
|
| 60 | + * @since 8.1.0 |
|
| 61 | + */ |
|
| 62 | + public function unregisterEncryptionModule($moduleId); |
|
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * get a list of all encryption modules |
|
| 66 | - * |
|
| 67 | - * @return array [id => ['id' => $id, 'displayName' => $displayName, 'callback' => callback]] |
|
| 68 | - * @since 8.1.0 |
|
| 69 | - */ |
|
| 70 | - public function getEncryptionModules(); |
|
| 64 | + /** |
|
| 65 | + * get a list of all encryption modules |
|
| 66 | + * |
|
| 67 | + * @return array [id => ['id' => $id, 'displayName' => $displayName, 'callback' => callback]] |
|
| 68 | + * @since 8.1.0 |
|
| 69 | + */ |
|
| 70 | + public function getEncryptionModules(); |
|
| 71 | 71 | |
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * get a specific encryption module |
|
| 75 | - * |
|
| 76 | - * @param string $moduleId Empty to get the default module |
|
| 77 | - * @return IEncryptionModule |
|
| 78 | - * @throws ModuleDoesNotExistsException |
|
| 79 | - * @since 8.1.0 |
|
| 80 | - */ |
|
| 81 | - public function getEncryptionModule($moduleId = ''); |
|
| 73 | + /** |
|
| 74 | + * get a specific encryption module |
|
| 75 | + * |
|
| 76 | + * @param string $moduleId Empty to get the default module |
|
| 77 | + * @return IEncryptionModule |
|
| 78 | + * @throws ModuleDoesNotExistsException |
|
| 79 | + * @since 8.1.0 |
|
| 80 | + */ |
|
| 81 | + public function getEncryptionModule($moduleId = ''); |
|
| 82 | 82 | |
| 83 | - /** |
|
| 84 | - * get default encryption module Id |
|
| 85 | - * |
|
| 86 | - * @return string |
|
| 87 | - * @since 8.1.0 |
|
| 88 | - */ |
|
| 89 | - public function getDefaultEncryptionModuleId(); |
|
| 83 | + /** |
|
| 84 | + * get default encryption module Id |
|
| 85 | + * |
|
| 86 | + * @return string |
|
| 87 | + * @since 8.1.0 |
|
| 88 | + */ |
|
| 89 | + public function getDefaultEncryptionModuleId(); |
|
| 90 | 90 | |
| 91 | - /** |
|
| 92 | - * set default encryption module Id |
|
| 93 | - * |
|
| 94 | - * @param string $moduleId |
|
| 95 | - * @return string |
|
| 96 | - * @since 8.1.0 |
|
| 97 | - */ |
|
| 98 | - public function setDefaultEncryptionModule($moduleId); |
|
| 91 | + /** |
|
| 92 | + * set default encryption module Id |
|
| 93 | + * |
|
| 94 | + * @param string $moduleId |
|
| 95 | + * @return string |
|
| 96 | + * @since 8.1.0 |
|
| 97 | + */ |
|
| 98 | + public function setDefaultEncryptionModule($moduleId); |
|
| 99 | 99 | |
| 100 | 100 | } |
@@ -33,151 +33,151 @@ |
||
| 33 | 33 | */ |
| 34 | 34 | interface IStorage { |
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * get user specific key |
|
| 38 | - * |
|
| 39 | - * @param string $uid ID if the user for whom we want the key |
|
| 40 | - * @param string $keyId id of the key |
|
| 41 | - * @param string $encryptionModuleId |
|
| 42 | - * |
|
| 43 | - * @return mixed key |
|
| 44 | - * @since 8.1.0 |
|
| 45 | - */ |
|
| 46 | - public function getUserKey($uid, $keyId, $encryptionModuleId); |
|
| 36 | + /** |
|
| 37 | + * get user specific key |
|
| 38 | + * |
|
| 39 | + * @param string $uid ID if the user for whom we want the key |
|
| 40 | + * @param string $keyId id of the key |
|
| 41 | + * @param string $encryptionModuleId |
|
| 42 | + * |
|
| 43 | + * @return mixed key |
|
| 44 | + * @since 8.1.0 |
|
| 45 | + */ |
|
| 46 | + public function getUserKey($uid, $keyId, $encryptionModuleId); |
|
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * get file specific key |
|
| 50 | - * |
|
| 51 | - * @param string $path path to file |
|
| 52 | - * @param string $keyId id of the key |
|
| 53 | - * @param string $encryptionModuleId |
|
| 54 | - * |
|
| 55 | - * @return mixed key |
|
| 56 | - * @since 8.1.0 |
|
| 57 | - */ |
|
| 58 | - public function getFileKey($path, $keyId, $encryptionModuleId); |
|
| 48 | + /** |
|
| 49 | + * get file specific key |
|
| 50 | + * |
|
| 51 | + * @param string $path path to file |
|
| 52 | + * @param string $keyId id of the key |
|
| 53 | + * @param string $encryptionModuleId |
|
| 54 | + * |
|
| 55 | + * @return mixed key |
|
| 56 | + * @since 8.1.0 |
|
| 57 | + */ |
|
| 58 | + public function getFileKey($path, $keyId, $encryptionModuleId); |
|
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * get system-wide encryption keys not related to a specific user, |
|
| 62 | - * e.g something like a key for public link shares |
|
| 63 | - * |
|
| 64 | - * @param string $keyId id of the key |
|
| 65 | - * @param string $encryptionModuleId |
|
| 66 | - * |
|
| 67 | - * @return mixed key |
|
| 68 | - * @since 8.1.0 |
|
| 69 | - */ |
|
| 70 | - public function getSystemUserKey($keyId, $encryptionModuleId); |
|
| 60 | + /** |
|
| 61 | + * get system-wide encryption keys not related to a specific user, |
|
| 62 | + * e.g something like a key for public link shares |
|
| 63 | + * |
|
| 64 | + * @param string $keyId id of the key |
|
| 65 | + * @param string $encryptionModuleId |
|
| 66 | + * |
|
| 67 | + * @return mixed key |
|
| 68 | + * @since 8.1.0 |
|
| 69 | + */ |
|
| 70 | + public function getSystemUserKey($keyId, $encryptionModuleId); |
|
| 71 | 71 | |
| 72 | - /** |
|
| 73 | - * set user specific key |
|
| 74 | - * |
|
| 75 | - * @param string $uid ID if the user for whom we want the key |
|
| 76 | - * @param string $keyId id of the key |
|
| 77 | - * @param mixed $key |
|
| 78 | - * @param string $encryptionModuleId |
|
| 79 | - * @since 8.1.0 |
|
| 80 | - */ |
|
| 81 | - public function setUserKey($uid, $keyId, $key, $encryptionModuleId); |
|
| 72 | + /** |
|
| 73 | + * set user specific key |
|
| 74 | + * |
|
| 75 | + * @param string $uid ID if the user for whom we want the key |
|
| 76 | + * @param string $keyId id of the key |
|
| 77 | + * @param mixed $key |
|
| 78 | + * @param string $encryptionModuleId |
|
| 79 | + * @since 8.1.0 |
|
| 80 | + */ |
|
| 81 | + public function setUserKey($uid, $keyId, $key, $encryptionModuleId); |
|
| 82 | 82 | |
| 83 | - /** |
|
| 84 | - * set file specific key |
|
| 85 | - * |
|
| 86 | - * @param string $path path to file |
|
| 87 | - * @param string $keyId id of the key |
|
| 88 | - * @param mixed $key |
|
| 89 | - * @param string $encryptionModuleId |
|
| 90 | - * @since 8.1.0 |
|
| 91 | - */ |
|
| 92 | - public function setFileKey($path, $keyId, $key, $encryptionModuleId); |
|
| 83 | + /** |
|
| 84 | + * set file specific key |
|
| 85 | + * |
|
| 86 | + * @param string $path path to file |
|
| 87 | + * @param string $keyId id of the key |
|
| 88 | + * @param mixed $key |
|
| 89 | + * @param string $encryptionModuleId |
|
| 90 | + * @since 8.1.0 |
|
| 91 | + */ |
|
| 92 | + public function setFileKey($path, $keyId, $key, $encryptionModuleId); |
|
| 93 | 93 | |
| 94 | - /** |
|
| 95 | - * set system-wide encryption keys not related to a specific user, |
|
| 96 | - * e.g something like a key for public link shares |
|
| 97 | - * |
|
| 98 | - * @param string $keyId id of the key |
|
| 99 | - * @param mixed $key |
|
| 100 | - * @param string $encryptionModuleId |
|
| 101 | - * |
|
| 102 | - * @return mixed key |
|
| 103 | - * @since 8.1.0 |
|
| 104 | - */ |
|
| 105 | - public function setSystemUserKey($keyId, $key, $encryptionModuleId); |
|
| 94 | + /** |
|
| 95 | + * set system-wide encryption keys not related to a specific user, |
|
| 96 | + * e.g something like a key for public link shares |
|
| 97 | + * |
|
| 98 | + * @param string $keyId id of the key |
|
| 99 | + * @param mixed $key |
|
| 100 | + * @param string $encryptionModuleId |
|
| 101 | + * |
|
| 102 | + * @return mixed key |
|
| 103 | + * @since 8.1.0 |
|
| 104 | + */ |
|
| 105 | + public function setSystemUserKey($keyId, $key, $encryptionModuleId); |
|
| 106 | 106 | |
| 107 | - /** |
|
| 108 | - * delete user specific key |
|
| 109 | - * |
|
| 110 | - * @param string $uid ID if the user for whom we want to delete the key |
|
| 111 | - * @param string $keyId id of the key |
|
| 112 | - * @param string $encryptionModuleId |
|
| 113 | - * |
|
| 114 | - * @return boolean False when the key could not be deleted |
|
| 115 | - * @since 8.1.0 |
|
| 116 | - */ |
|
| 117 | - public function deleteUserKey($uid, $keyId, $encryptionModuleId); |
|
| 107 | + /** |
|
| 108 | + * delete user specific key |
|
| 109 | + * |
|
| 110 | + * @param string $uid ID if the user for whom we want to delete the key |
|
| 111 | + * @param string $keyId id of the key |
|
| 112 | + * @param string $encryptionModuleId |
|
| 113 | + * |
|
| 114 | + * @return boolean False when the key could not be deleted |
|
| 115 | + * @since 8.1.0 |
|
| 116 | + */ |
|
| 117 | + public function deleteUserKey($uid, $keyId, $encryptionModuleId); |
|
| 118 | 118 | |
| 119 | - /** |
|
| 120 | - * delete file specific key |
|
| 121 | - * |
|
| 122 | - * @param string $path path to file |
|
| 123 | - * @param string $keyId id of the key |
|
| 124 | - * @param string $encryptionModuleId |
|
| 125 | - * |
|
| 126 | - * @return boolean False when the key could not be deleted |
|
| 127 | - * @since 8.1.0 |
|
| 128 | - */ |
|
| 129 | - public function deleteFileKey($path, $keyId, $encryptionModuleId); |
|
| 119 | + /** |
|
| 120 | + * delete file specific key |
|
| 121 | + * |
|
| 122 | + * @param string $path path to file |
|
| 123 | + * @param string $keyId id of the key |
|
| 124 | + * @param string $encryptionModuleId |
|
| 125 | + * |
|
| 126 | + * @return boolean False when the key could not be deleted |
|
| 127 | + * @since 8.1.0 |
|
| 128 | + */ |
|
| 129 | + public function deleteFileKey($path, $keyId, $encryptionModuleId); |
|
| 130 | 130 | |
| 131 | - /** |
|
| 132 | - * delete all file keys for a given file |
|
| 133 | - * |
|
| 134 | - * @param string $path to the file |
|
| 135 | - * |
|
| 136 | - * @return boolean False when the keys could not be deleted |
|
| 137 | - * @since 8.1.0 |
|
| 138 | - */ |
|
| 139 | - public function deleteAllFileKeys($path); |
|
| 131 | + /** |
|
| 132 | + * delete all file keys for a given file |
|
| 133 | + * |
|
| 134 | + * @param string $path to the file |
|
| 135 | + * |
|
| 136 | + * @return boolean False when the keys could not be deleted |
|
| 137 | + * @since 8.1.0 |
|
| 138 | + */ |
|
| 139 | + public function deleteAllFileKeys($path); |
|
| 140 | 140 | |
| 141 | - /** |
|
| 142 | - * delete system-wide encryption keys not related to a specific user, |
|
| 143 | - * e.g something like a key for public link shares |
|
| 144 | - * |
|
| 145 | - * @param string $keyId id of the key |
|
| 146 | - * @param string $encryptionModuleId |
|
| 147 | - * |
|
| 148 | - * @return boolean False when the key could not be deleted |
|
| 149 | - * @since 8.1.0 |
|
| 150 | - */ |
|
| 151 | - public function deleteSystemUserKey($keyId, $encryptionModuleId); |
|
| 141 | + /** |
|
| 142 | + * delete system-wide encryption keys not related to a specific user, |
|
| 143 | + * e.g something like a key for public link shares |
|
| 144 | + * |
|
| 145 | + * @param string $keyId id of the key |
|
| 146 | + * @param string $encryptionModuleId |
|
| 147 | + * |
|
| 148 | + * @return boolean False when the key could not be deleted |
|
| 149 | + * @since 8.1.0 |
|
| 150 | + */ |
|
| 151 | + public function deleteSystemUserKey($keyId, $encryptionModuleId); |
|
| 152 | 152 | |
| 153 | - /** |
|
| 154 | - * copy keys if a file was renamed |
|
| 155 | - * |
|
| 156 | - * @param string $source |
|
| 157 | - * @param string $target |
|
| 158 | - * @return boolean |
|
| 159 | - * @since 8.1.0 |
|
| 160 | - */ |
|
| 161 | - public function renameKeys($source, $target); |
|
| 153 | + /** |
|
| 154 | + * copy keys if a file was renamed |
|
| 155 | + * |
|
| 156 | + * @param string $source |
|
| 157 | + * @param string $target |
|
| 158 | + * @return boolean |
|
| 159 | + * @since 8.1.0 |
|
| 160 | + */ |
|
| 161 | + public function renameKeys($source, $target); |
|
| 162 | 162 | |
| 163 | - /** |
|
| 164 | - * move keys if a file was renamed |
|
| 165 | - * |
|
| 166 | - * @param string $source |
|
| 167 | - * @param string $target |
|
| 168 | - * @return boolean |
|
| 169 | - * @since 8.1.0 |
|
| 170 | - */ |
|
| 171 | - public function copyKeys($source, $target); |
|
| 163 | + /** |
|
| 164 | + * move keys if a file was renamed |
|
| 165 | + * |
|
| 166 | + * @param string $source |
|
| 167 | + * @param string $target |
|
| 168 | + * @return boolean |
|
| 169 | + * @since 8.1.0 |
|
| 170 | + */ |
|
| 171 | + public function copyKeys($source, $target); |
|
| 172 | 172 | |
| 173 | - /** |
|
| 174 | - * backup keys of a given encryption module |
|
| 175 | - * |
|
| 176 | - * @param string $encryptionModuleId |
|
| 177 | - * @param string $purpose |
|
| 178 | - * @param string $uid |
|
| 179 | - * @return bool |
|
| 180 | - * @since 12.0.0 |
|
| 181 | - */ |
|
| 182 | - public function backupUserKeys($encryptionModuleId, $purpose, $uid); |
|
| 173 | + /** |
|
| 174 | + * backup keys of a given encryption module |
|
| 175 | + * |
|
| 176 | + * @param string $encryptionModuleId |
|
| 177 | + * @param string $purpose |
|
| 178 | + * @param string $uid |
|
| 179 | + * @return bool |
|
| 180 | + * @since 12.0.0 |
|
| 181 | + */ |
|
| 182 | + public function backupUserKeys($encryptionModuleId, $purpose, $uid); |
|
| 183 | 183 | } |
@@ -28,45 +28,45 @@ |
||
| 28 | 28 | |
| 29 | 29 | class Credentials implements ICredentials { |
| 30 | 30 | |
| 31 | - /** @var string */ |
|
| 32 | - private $uid; |
|
| 31 | + /** @var string */ |
|
| 32 | + private $uid; |
|
| 33 | 33 | |
| 34 | - /** @var string */ |
|
| 35 | - private $loginName; |
|
| 34 | + /** @var string */ |
|
| 35 | + private $loginName; |
|
| 36 | 36 | |
| 37 | - /** @var string */ |
|
| 38 | - private $password; |
|
| 37 | + /** @var string */ |
|
| 38 | + private $password; |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * @param string $uid |
|
| 42 | - * @param string $loginName |
|
| 43 | - * @param string $password |
|
| 44 | - */ |
|
| 45 | - public function __construct($uid, $loginName, $password) { |
|
| 46 | - $this->uid = $uid; |
|
| 47 | - $this->loginName = $loginName; |
|
| 48 | - $this->password = $password; |
|
| 49 | - } |
|
| 40 | + /** |
|
| 41 | + * @param string $uid |
|
| 42 | + * @param string $loginName |
|
| 43 | + * @param string $password |
|
| 44 | + */ |
|
| 45 | + public function __construct($uid, $loginName, $password) { |
|
| 46 | + $this->uid = $uid; |
|
| 47 | + $this->loginName = $loginName; |
|
| 48 | + $this->password = $password; |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * @return string |
|
| 53 | - */ |
|
| 54 | - public function getUID() { |
|
| 55 | - return $this->uid; |
|
| 56 | - } |
|
| 51 | + /** |
|
| 52 | + * @return string |
|
| 53 | + */ |
|
| 54 | + public function getUID() { |
|
| 55 | + return $this->uid; |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - /** |
|
| 59 | - * @return string |
|
| 60 | - */ |
|
| 61 | - public function getLoginName() { |
|
| 62 | - return $this->loginName; |
|
| 63 | - } |
|
| 58 | + /** |
|
| 59 | + * @return string |
|
| 60 | + */ |
|
| 61 | + public function getLoginName() { |
|
| 62 | + return $this->loginName; |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - /** |
|
| 66 | - * @return string |
|
| 67 | - */ |
|
| 68 | - public function getPassword() { |
|
| 69 | - return $this->password; |
|
| 70 | - } |
|
| 65 | + /** |
|
| 66 | + * @return string |
|
| 67 | + */ |
|
| 68 | + public function getPassword() { |
|
| 69 | + return $this->password; |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | 72 | } |
@@ -37,84 +37,84 @@ |
||
| 37 | 37 | |
| 38 | 38 | class Store implements IStore { |
| 39 | 39 | |
| 40 | - /** @var ISession */ |
|
| 41 | - private $session; |
|
| 42 | - |
|
| 43 | - /** @var ILogger */ |
|
| 44 | - private $logger; |
|
| 45 | - |
|
| 46 | - /** @var IProvider|null */ |
|
| 47 | - private $tokenProvider; |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * @param ISession $session |
|
| 51 | - * @param ILogger $logger |
|
| 52 | - * @param IProvider $tokenProvider |
|
| 53 | - */ |
|
| 54 | - public function __construct(ISession $session, ILogger $logger, IProvider $tokenProvider = null) { |
|
| 55 | - $this->session = $session; |
|
| 56 | - $this->logger = $logger; |
|
| 57 | - $this->tokenProvider = $tokenProvider; |
|
| 58 | - |
|
| 59 | - Util::connectHook('OC_User', 'post_login', $this, 'authenticate'); |
|
| 60 | - } |
|
| 61 | - |
|
| 62 | - /** |
|
| 63 | - * Hook listener on post login |
|
| 64 | - * |
|
| 65 | - * @param array $params |
|
| 66 | - */ |
|
| 67 | - public function authenticate(array $params) { |
|
| 68 | - $this->session->set('login_credentials', json_encode($params)); |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - /** |
|
| 72 | - * Replace the session implementation |
|
| 73 | - * |
|
| 74 | - * @param ISession $session |
|
| 75 | - */ |
|
| 76 | - public function setSession(ISession $session) { |
|
| 77 | - $this->session = $session; |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - /** |
|
| 81 | - * @since 12 |
|
| 82 | - * |
|
| 83 | - * @return ICredentials the login credentials of the current user |
|
| 84 | - * @throws CredentialsUnavailableException |
|
| 85 | - */ |
|
| 86 | - public function getLoginCredentials() { |
|
| 87 | - if (is_null($this->tokenProvider)) { |
|
| 88 | - throw new CredentialsUnavailableException(); |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - $trySession = false; |
|
| 92 | - try { |
|
| 93 | - $sessionId = $this->session->getId(); |
|
| 94 | - $token = $this->tokenProvider->getToken($sessionId); |
|
| 95 | - |
|
| 96 | - $uid = $token->getUID(); |
|
| 97 | - $user = $token->getLoginName(); |
|
| 98 | - $password = $this->tokenProvider->getPassword($token, $sessionId); |
|
| 99 | - |
|
| 100 | - return new Credentials($uid, $user, $password); |
|
| 101 | - } catch (SessionNotAvailableException $ex) { |
|
| 102 | - $this->logger->debug('could not get login credentials because session is unavailable', ['app' => 'core']); |
|
| 103 | - } catch (InvalidTokenException $ex) { |
|
| 104 | - $this->logger->debug('could not get login credentials because the token is invalid', ['app' => 'core']); |
|
| 105 | - $trySession = true; |
|
| 106 | - } catch (PasswordlessTokenException $ex) { |
|
| 107 | - $this->logger->debug('could not get login credentials because the token has no password', ['app' => 'core']); |
|
| 108 | - $trySession = true; |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - if ($trySession && $this->session->exists('login_credentials')) { |
|
| 112 | - $creds = json_decode($this->session->get('login_credentials')); |
|
| 113 | - return new Credentials($creds->uid, $creds->uid, $creds->password); |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - // If we reach this line, an exception was thrown. |
|
| 117 | - throw new CredentialsUnavailableException(); |
|
| 118 | - } |
|
| 40 | + /** @var ISession */ |
|
| 41 | + private $session; |
|
| 42 | + |
|
| 43 | + /** @var ILogger */ |
|
| 44 | + private $logger; |
|
| 45 | + |
|
| 46 | + /** @var IProvider|null */ |
|
| 47 | + private $tokenProvider; |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * @param ISession $session |
|
| 51 | + * @param ILogger $logger |
|
| 52 | + * @param IProvider $tokenProvider |
|
| 53 | + */ |
|
| 54 | + public function __construct(ISession $session, ILogger $logger, IProvider $tokenProvider = null) { |
|
| 55 | + $this->session = $session; |
|
| 56 | + $this->logger = $logger; |
|
| 57 | + $this->tokenProvider = $tokenProvider; |
|
| 58 | + |
|
| 59 | + Util::connectHook('OC_User', 'post_login', $this, 'authenticate'); |
|
| 60 | + } |
|
| 61 | + |
|
| 62 | + /** |
|
| 63 | + * Hook listener on post login |
|
| 64 | + * |
|
| 65 | + * @param array $params |
|
| 66 | + */ |
|
| 67 | + public function authenticate(array $params) { |
|
| 68 | + $this->session->set('login_credentials', json_encode($params)); |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + /** |
|
| 72 | + * Replace the session implementation |
|
| 73 | + * |
|
| 74 | + * @param ISession $session |
|
| 75 | + */ |
|
| 76 | + public function setSession(ISession $session) { |
|
| 77 | + $this->session = $session; |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + /** |
|
| 81 | + * @since 12 |
|
| 82 | + * |
|
| 83 | + * @return ICredentials the login credentials of the current user |
|
| 84 | + * @throws CredentialsUnavailableException |
|
| 85 | + */ |
|
| 86 | + public function getLoginCredentials() { |
|
| 87 | + if (is_null($this->tokenProvider)) { |
|
| 88 | + throw new CredentialsUnavailableException(); |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + $trySession = false; |
|
| 92 | + try { |
|
| 93 | + $sessionId = $this->session->getId(); |
|
| 94 | + $token = $this->tokenProvider->getToken($sessionId); |
|
| 95 | + |
|
| 96 | + $uid = $token->getUID(); |
|
| 97 | + $user = $token->getLoginName(); |
|
| 98 | + $password = $this->tokenProvider->getPassword($token, $sessionId); |
|
| 99 | + |
|
| 100 | + return new Credentials($uid, $user, $password); |
|
| 101 | + } catch (SessionNotAvailableException $ex) { |
|
| 102 | + $this->logger->debug('could not get login credentials because session is unavailable', ['app' => 'core']); |
|
| 103 | + } catch (InvalidTokenException $ex) { |
|
| 104 | + $this->logger->debug('could not get login credentials because the token is invalid', ['app' => 'core']); |
|
| 105 | + $trySession = true; |
|
| 106 | + } catch (PasswordlessTokenException $ex) { |
|
| 107 | + $this->logger->debug('could not get login credentials because the token has no password', ['app' => 'core']); |
|
| 108 | + $trySession = true; |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + if ($trySession && $this->session->exists('login_credentials')) { |
|
| 112 | + $creds = json_decode($this->session->get('login_credentials')); |
|
| 113 | + return new Credentials($creds->uid, $creds->uid, $creds->password); |
|
| 114 | + } |
|
| 115 | + |
|
| 116 | + // If we reach this line, an exception was thrown. |
|
| 117 | + throw new CredentialsUnavailableException(); |
|
| 118 | + } |
|
| 119 | 119 | |
| 120 | 120 | } |
@@ -30,523 +30,523 @@ |
||
| 30 | 30 | |
| 31 | 31 | class Event implements IEvent { |
| 32 | 32 | |
| 33 | - /** @var string */ |
|
| 34 | - protected $app = ''; |
|
| 35 | - /** @var string */ |
|
| 36 | - protected $type = ''; |
|
| 37 | - /** @var string */ |
|
| 38 | - protected $affectedUser = ''; |
|
| 39 | - /** @var string */ |
|
| 40 | - protected $author = ''; |
|
| 41 | - /** @var int */ |
|
| 42 | - protected $timestamp = 0; |
|
| 43 | - /** @var string */ |
|
| 44 | - protected $subject = ''; |
|
| 45 | - /** @var array */ |
|
| 46 | - protected $subjectParameters = []; |
|
| 47 | - /** @var string */ |
|
| 48 | - protected $subjectParsed; |
|
| 49 | - /** @var string */ |
|
| 50 | - protected $subjectRich; |
|
| 51 | - /** @var array */ |
|
| 52 | - protected $subjectRichParameters; |
|
| 53 | - /** @var string */ |
|
| 54 | - protected $message = ''; |
|
| 55 | - /** @var array */ |
|
| 56 | - protected $messageParameters = []; |
|
| 57 | - /** @var string */ |
|
| 58 | - protected $messageParsed; |
|
| 59 | - /** @var string */ |
|
| 60 | - protected $messageRich; |
|
| 61 | - /** @var array */ |
|
| 62 | - protected $messageRichParameters; |
|
| 63 | - /** @var string */ |
|
| 64 | - protected $objectType = ''; |
|
| 65 | - /** @var int */ |
|
| 66 | - protected $objectId = 0; |
|
| 67 | - /** @var string */ |
|
| 68 | - protected $objectName = ''; |
|
| 69 | - /** @var string */ |
|
| 70 | - protected $link = ''; |
|
| 71 | - /** @var string */ |
|
| 72 | - protected $icon = ''; |
|
| 73 | - |
|
| 74 | - /** @var IEvent */ |
|
| 75 | - protected $child = null; |
|
| 76 | - /** @var IValidator */ |
|
| 77 | - protected $richValidator; |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * @param IValidator $richValidator |
|
| 81 | - */ |
|
| 82 | - public function __construct(IValidator $richValidator) { |
|
| 83 | - $this->richValidator = $richValidator; |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - /** |
|
| 87 | - * Set the app of the activity |
|
| 88 | - * |
|
| 89 | - * @param string $app |
|
| 90 | - * @return IEvent |
|
| 91 | - * @throws \InvalidArgumentException if the app id is invalid |
|
| 92 | - * @since 8.2.0 |
|
| 93 | - */ |
|
| 94 | - public function setApp($app) { |
|
| 95 | - if (!is_string($app) || $app === '' || isset($app[32])) { |
|
| 96 | - throw new \InvalidArgumentException('The given app is invalid'); |
|
| 97 | - } |
|
| 98 | - $this->app = (string) $app; |
|
| 99 | - return $this; |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - /** |
|
| 103 | - * @return string |
|
| 104 | - */ |
|
| 105 | - public function getApp() { |
|
| 106 | - return $this->app; |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - /** |
|
| 110 | - * Set the type of the activity |
|
| 111 | - * |
|
| 112 | - * @param string $type |
|
| 113 | - * @return IEvent |
|
| 114 | - * @throws \InvalidArgumentException if the type is invalid |
|
| 115 | - * @since 8.2.0 |
|
| 116 | - */ |
|
| 117 | - public function setType($type) { |
|
| 118 | - if (!is_string($type) || $type === '' || isset($type[255])) { |
|
| 119 | - throw new \InvalidArgumentException('The given type is invalid'); |
|
| 120 | - } |
|
| 121 | - $this->type = (string) $type; |
|
| 122 | - return $this; |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - /** |
|
| 126 | - * @return string |
|
| 127 | - */ |
|
| 128 | - public function getType() { |
|
| 129 | - return $this->type; |
|
| 130 | - } |
|
| 131 | - |
|
| 132 | - /** |
|
| 133 | - * Set the affected user of the activity |
|
| 134 | - * |
|
| 135 | - * @param string $affectedUser |
|
| 136 | - * @return IEvent |
|
| 137 | - * @throws \InvalidArgumentException if the affected user is invalid |
|
| 138 | - * @since 8.2.0 |
|
| 139 | - */ |
|
| 140 | - public function setAffectedUser($affectedUser) { |
|
| 141 | - if (!is_string($affectedUser) || $affectedUser === '' || isset($affectedUser[64])) { |
|
| 142 | - throw new \InvalidArgumentException('The given affected user is invalid'); |
|
| 143 | - } |
|
| 144 | - $this->affectedUser = (string) $affectedUser; |
|
| 145 | - return $this; |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - /** |
|
| 149 | - * @return string |
|
| 150 | - */ |
|
| 151 | - public function getAffectedUser() { |
|
| 152 | - return $this->affectedUser; |
|
| 153 | - } |
|
| 154 | - |
|
| 155 | - /** |
|
| 156 | - * Set the author of the activity |
|
| 157 | - * |
|
| 158 | - * @param string $author |
|
| 159 | - * @return IEvent |
|
| 160 | - * @throws \InvalidArgumentException if the author is invalid |
|
| 161 | - * @since 8.2.0 |
|
| 162 | - */ |
|
| 163 | - public function setAuthor($author) { |
|
| 164 | - if (!is_string($author) || isset($author[64])) { |
|
| 165 | - throw new \InvalidArgumentException('The given author user is invalid'. serialize($author)); |
|
| 166 | - } |
|
| 167 | - $this->author = (string) $author; |
|
| 168 | - return $this; |
|
| 169 | - } |
|
| 170 | - |
|
| 171 | - /** |
|
| 172 | - * @return string |
|
| 173 | - */ |
|
| 174 | - public function getAuthor() { |
|
| 175 | - return $this->author; |
|
| 176 | - } |
|
| 177 | - |
|
| 178 | - /** |
|
| 179 | - * Set the timestamp of the activity |
|
| 180 | - * |
|
| 181 | - * @param int $timestamp |
|
| 182 | - * @return IEvent |
|
| 183 | - * @throws \InvalidArgumentException if the timestamp is invalid |
|
| 184 | - * @since 8.2.0 |
|
| 185 | - */ |
|
| 186 | - public function setTimestamp($timestamp) { |
|
| 187 | - if (!is_int($timestamp)) { |
|
| 188 | - throw new \InvalidArgumentException('The given timestamp is invalid'); |
|
| 189 | - } |
|
| 190 | - $this->timestamp = (int) $timestamp; |
|
| 191 | - return $this; |
|
| 192 | - } |
|
| 193 | - |
|
| 194 | - /** |
|
| 195 | - * @return int |
|
| 196 | - */ |
|
| 197 | - public function getTimestamp() { |
|
| 198 | - return $this->timestamp; |
|
| 199 | - } |
|
| 200 | - |
|
| 201 | - /** |
|
| 202 | - * Set the subject of the activity |
|
| 203 | - * |
|
| 204 | - * @param string $subject |
|
| 205 | - * @param array $parameters |
|
| 206 | - * @return IEvent |
|
| 207 | - * @throws \InvalidArgumentException if the subject or parameters are invalid |
|
| 208 | - * @since 8.2.0 |
|
| 209 | - */ |
|
| 210 | - public function setSubject($subject, array $parameters = []) { |
|
| 211 | - if (!is_string($subject) || isset($subject[255])) { |
|
| 212 | - throw new \InvalidArgumentException('The given subject is invalid'); |
|
| 213 | - } |
|
| 214 | - $this->subject = (string) $subject; |
|
| 215 | - $this->subjectParameters = $parameters; |
|
| 216 | - return $this; |
|
| 217 | - } |
|
| 218 | - |
|
| 219 | - /** |
|
| 220 | - * @return string |
|
| 221 | - */ |
|
| 222 | - public function getSubject() { |
|
| 223 | - return $this->subject; |
|
| 224 | - } |
|
| 225 | - |
|
| 226 | - /** |
|
| 227 | - * @return array |
|
| 228 | - */ |
|
| 229 | - public function getSubjectParameters() { |
|
| 230 | - return $this->subjectParameters; |
|
| 231 | - } |
|
| 232 | - |
|
| 233 | - /** |
|
| 234 | - * @param string $subject |
|
| 235 | - * @return $this |
|
| 236 | - * @throws \InvalidArgumentException if the subject is invalid |
|
| 237 | - * @since 11.0.0 |
|
| 238 | - */ |
|
| 239 | - public function setParsedSubject($subject) { |
|
| 240 | - if (!is_string($subject) || $subject === '') { |
|
| 241 | - throw new \InvalidArgumentException('The given parsed subject is invalid'); |
|
| 242 | - } |
|
| 243 | - $this->subjectParsed = $subject; |
|
| 244 | - return $this; |
|
| 245 | - } |
|
| 246 | - |
|
| 247 | - /** |
|
| 248 | - * @return string |
|
| 249 | - * @since 11.0.0 |
|
| 250 | - */ |
|
| 251 | - public function getParsedSubject() { |
|
| 252 | - return $this->subjectParsed; |
|
| 253 | - } |
|
| 254 | - |
|
| 255 | - /** |
|
| 256 | - * @param string $subject |
|
| 257 | - * @param array $parameters |
|
| 258 | - * @return $this |
|
| 259 | - * @throws \InvalidArgumentException if the subject or parameters are invalid |
|
| 260 | - * @since 11.0.0 |
|
| 261 | - */ |
|
| 262 | - public function setRichSubject($subject, array $parameters = []) { |
|
| 263 | - if (!is_string($subject) || $subject === '') { |
|
| 264 | - throw new \InvalidArgumentException('The given parsed subject is invalid'); |
|
| 265 | - } |
|
| 266 | - $this->subjectRich = $subject; |
|
| 267 | - |
|
| 268 | - if (!is_array($parameters)) { |
|
| 269 | - throw new \InvalidArgumentException('The given subject parameters are invalid'); |
|
| 270 | - } |
|
| 271 | - $this->subjectRichParameters = $parameters; |
|
| 272 | - |
|
| 273 | - return $this; |
|
| 274 | - } |
|
| 275 | - |
|
| 276 | - /** |
|
| 277 | - * @return string |
|
| 278 | - * @since 11.0.0 |
|
| 279 | - */ |
|
| 280 | - public function getRichSubject() { |
|
| 281 | - return $this->subjectRich; |
|
| 282 | - } |
|
| 283 | - |
|
| 284 | - /** |
|
| 285 | - * @return array[] |
|
| 286 | - * @since 11.0.0 |
|
| 287 | - */ |
|
| 288 | - public function getRichSubjectParameters() { |
|
| 289 | - return $this->subjectRichParameters; |
|
| 290 | - } |
|
| 291 | - |
|
| 292 | - /** |
|
| 293 | - * Set the message of the activity |
|
| 294 | - * |
|
| 295 | - * @param string $message |
|
| 296 | - * @param array $parameters |
|
| 297 | - * @return IEvent |
|
| 298 | - * @throws \InvalidArgumentException if the message or parameters are invalid |
|
| 299 | - * @since 8.2.0 |
|
| 300 | - */ |
|
| 301 | - public function setMessage($message, array $parameters = []) { |
|
| 302 | - if (!is_string($message) || isset($message[255])) { |
|
| 303 | - throw new \InvalidArgumentException('The given message is invalid'); |
|
| 304 | - } |
|
| 305 | - $this->message = (string) $message; |
|
| 306 | - $this->messageParameters = $parameters; |
|
| 307 | - return $this; |
|
| 308 | - } |
|
| 309 | - |
|
| 310 | - /** |
|
| 311 | - * @return string |
|
| 312 | - */ |
|
| 313 | - public function getMessage() { |
|
| 314 | - return $this->message; |
|
| 315 | - } |
|
| 316 | - |
|
| 317 | - /** |
|
| 318 | - * @return array |
|
| 319 | - */ |
|
| 320 | - public function getMessageParameters() { |
|
| 321 | - return $this->messageParameters; |
|
| 322 | - } |
|
| 323 | - |
|
| 324 | - /** |
|
| 325 | - * @param string $message |
|
| 326 | - * @return $this |
|
| 327 | - * @throws \InvalidArgumentException if the message is invalid |
|
| 328 | - * @since 11.0.0 |
|
| 329 | - */ |
|
| 330 | - public function setParsedMessage($message) { |
|
| 331 | - if (!is_string($message)) { |
|
| 332 | - throw new \InvalidArgumentException('The given parsed message is invalid'); |
|
| 333 | - } |
|
| 334 | - $this->messageParsed = $message; |
|
| 335 | - return $this; |
|
| 336 | - } |
|
| 337 | - |
|
| 338 | - /** |
|
| 339 | - * @return string |
|
| 340 | - * @since 11.0.0 |
|
| 341 | - */ |
|
| 342 | - public function getParsedMessage() { |
|
| 343 | - return $this->messageParsed; |
|
| 344 | - } |
|
| 345 | - |
|
| 346 | - /** |
|
| 347 | - * @param string $message |
|
| 348 | - * @param array $parameters |
|
| 349 | - * @return $this |
|
| 350 | - * @throws \InvalidArgumentException if the subject or parameters are invalid |
|
| 351 | - * @since 11.0.0 |
|
| 352 | - */ |
|
| 353 | - public function setRichMessage($message, array $parameters = []) { |
|
| 354 | - if (!is_string($message)) { |
|
| 355 | - throw new \InvalidArgumentException('The given parsed message is invalid'); |
|
| 356 | - } |
|
| 357 | - $this->messageRich = $message; |
|
| 358 | - |
|
| 359 | - if (!is_array($parameters)) { |
|
| 360 | - throw new \InvalidArgumentException('The given message parameters are invalid'); |
|
| 361 | - } |
|
| 362 | - $this->messageRichParameters = $parameters; |
|
| 363 | - |
|
| 364 | - return $this; |
|
| 365 | - } |
|
| 366 | - |
|
| 367 | - /** |
|
| 368 | - * @return string |
|
| 369 | - * @since 11.0.0 |
|
| 370 | - */ |
|
| 371 | - public function getRichMessage() { |
|
| 372 | - return $this->messageRich; |
|
| 373 | - } |
|
| 374 | - |
|
| 375 | - /** |
|
| 376 | - * @return array[] |
|
| 377 | - * @since 11.0.0 |
|
| 378 | - */ |
|
| 379 | - public function getRichMessageParameters() { |
|
| 380 | - return $this->messageRichParameters; |
|
| 381 | - } |
|
| 382 | - |
|
| 383 | - /** |
|
| 384 | - * Set the object of the activity |
|
| 385 | - * |
|
| 386 | - * @param string $objectType |
|
| 387 | - * @param int $objectId |
|
| 388 | - * @param string $objectName |
|
| 389 | - * @return IEvent |
|
| 390 | - * @throws \InvalidArgumentException if the object is invalid |
|
| 391 | - * @since 8.2.0 |
|
| 392 | - */ |
|
| 393 | - public function setObject($objectType, $objectId, $objectName = '') { |
|
| 394 | - if (!is_string($objectType) || isset($objectType[255])) { |
|
| 395 | - throw new \InvalidArgumentException('The given object type is invalid'); |
|
| 396 | - } |
|
| 397 | - if (!is_int($objectId)) { |
|
| 398 | - throw new \InvalidArgumentException('The given object id is invalid'); |
|
| 399 | - } |
|
| 400 | - if (!is_string($objectName) || isset($objectName[4000])) { |
|
| 401 | - throw new \InvalidArgumentException('The given object name is invalid'); |
|
| 402 | - } |
|
| 403 | - $this->objectType = (string) $objectType; |
|
| 404 | - $this->objectId = (int) $objectId; |
|
| 405 | - $this->objectName = (string) $objectName; |
|
| 406 | - return $this; |
|
| 407 | - } |
|
| 408 | - |
|
| 409 | - /** |
|
| 410 | - * @return string |
|
| 411 | - */ |
|
| 412 | - public function getObjectType() { |
|
| 413 | - return $this->objectType; |
|
| 414 | - } |
|
| 415 | - |
|
| 416 | - /** |
|
| 417 | - * @return string |
|
| 418 | - */ |
|
| 419 | - public function getObjectId() { |
|
| 420 | - return $this->objectId; |
|
| 421 | - } |
|
| 422 | - |
|
| 423 | - /** |
|
| 424 | - * @return string |
|
| 425 | - */ |
|
| 426 | - public function getObjectName() { |
|
| 427 | - return $this->objectName; |
|
| 428 | - } |
|
| 429 | - |
|
| 430 | - /** |
|
| 431 | - * Set the link of the activity |
|
| 432 | - * |
|
| 433 | - * @param string $link |
|
| 434 | - * @return IEvent |
|
| 435 | - * @throws \InvalidArgumentException if the link is invalid |
|
| 436 | - * @since 8.2.0 |
|
| 437 | - */ |
|
| 438 | - public function setLink($link) { |
|
| 439 | - if (!is_string($link) || isset($link[4000])) { |
|
| 440 | - throw new \InvalidArgumentException('The given link is invalid'); |
|
| 441 | - } |
|
| 442 | - $this->link = (string) $link; |
|
| 443 | - return $this; |
|
| 444 | - } |
|
| 445 | - |
|
| 446 | - /** |
|
| 447 | - * @return string |
|
| 448 | - */ |
|
| 449 | - public function getLink() { |
|
| 450 | - return $this->link; |
|
| 451 | - } |
|
| 452 | - |
|
| 453 | - /** |
|
| 454 | - * @param string $icon |
|
| 455 | - * @return $this |
|
| 456 | - * @throws \InvalidArgumentException if the icon is invalid |
|
| 457 | - * @since 11.0.0 |
|
| 458 | - */ |
|
| 459 | - public function setIcon($icon) { |
|
| 460 | - if (!is_string($icon) || isset($icon[4000])) { |
|
| 461 | - throw new \InvalidArgumentException('The given icon is invalid'); |
|
| 462 | - } |
|
| 463 | - $this->icon = $icon; |
|
| 464 | - return $this; |
|
| 465 | - } |
|
| 466 | - |
|
| 467 | - /** |
|
| 468 | - * @return string |
|
| 469 | - * @since 11.0.0 |
|
| 470 | - */ |
|
| 471 | - public function getIcon() { |
|
| 472 | - return $this->icon; |
|
| 473 | - } |
|
| 474 | - |
|
| 475 | - /** |
|
| 476 | - * @param IEvent $child |
|
| 477 | - * @since 11.0.0 |
|
| 478 | - */ |
|
| 479 | - public function setChildEvent(IEvent $child) { |
|
| 480 | - $this->child = $child; |
|
| 481 | - } |
|
| 482 | - |
|
| 483 | - /** |
|
| 484 | - * @return IEvent|null |
|
| 485 | - * @since 11.0.0 |
|
| 486 | - */ |
|
| 487 | - public function getChildEvent() { |
|
| 488 | - return $this->child; |
|
| 489 | - } |
|
| 490 | - |
|
| 491 | - /** |
|
| 492 | - * @return bool |
|
| 493 | - * @since 8.2.0 |
|
| 494 | - */ |
|
| 495 | - public function isValid() { |
|
| 496 | - return |
|
| 497 | - $this->isValidCommon() |
|
| 498 | - && |
|
| 499 | - $this->getSubject() !== '' |
|
| 500 | - ; |
|
| 501 | - } |
|
| 502 | - |
|
| 503 | - /** |
|
| 504 | - * @return bool |
|
| 505 | - * @since 8.2.0 |
|
| 506 | - */ |
|
| 507 | - public function isValidParsed() { |
|
| 508 | - if ($this->getRichSubject() !== '' || !empty($this->getRichSubjectParameters())) { |
|
| 509 | - try { |
|
| 510 | - $this->richValidator->validate($this->getRichSubject(), $this->getRichSubjectParameters()); |
|
| 511 | - } catch (InvalidObjectExeption $e) { |
|
| 512 | - return false; |
|
| 513 | - } |
|
| 514 | - } |
|
| 515 | - |
|
| 516 | - if ($this->getRichMessage() !== '' || !empty($this->getRichMessageParameters())) { |
|
| 517 | - try { |
|
| 518 | - $this->richValidator->validate($this->getRichMessage(), $this->getRichMessageParameters()); |
|
| 519 | - } catch (InvalidObjectExeption $e) { |
|
| 520 | - return false; |
|
| 521 | - } |
|
| 522 | - } |
|
| 523 | - |
|
| 524 | - return |
|
| 525 | - $this->isValidCommon() |
|
| 526 | - && |
|
| 527 | - $this->getParsedSubject() !== '' |
|
| 528 | - ; |
|
| 529 | - } |
|
| 530 | - |
|
| 531 | - /** |
|
| 532 | - * @return bool |
|
| 533 | - */ |
|
| 534 | - protected function isValidCommon() { |
|
| 535 | - return |
|
| 536 | - $this->getApp() !== '' |
|
| 537 | - && |
|
| 538 | - $this->getType() !== '' |
|
| 539 | - && |
|
| 540 | - $this->getAffectedUser() !== '' |
|
| 541 | - && |
|
| 542 | - $this->getTimestamp() !== 0 |
|
| 543 | - /** |
|
| 544 | - * Disabled for BC with old activities |
|
| 33 | + /** @var string */ |
|
| 34 | + protected $app = ''; |
|
| 35 | + /** @var string */ |
|
| 36 | + protected $type = ''; |
|
| 37 | + /** @var string */ |
|
| 38 | + protected $affectedUser = ''; |
|
| 39 | + /** @var string */ |
|
| 40 | + protected $author = ''; |
|
| 41 | + /** @var int */ |
|
| 42 | + protected $timestamp = 0; |
|
| 43 | + /** @var string */ |
|
| 44 | + protected $subject = ''; |
|
| 45 | + /** @var array */ |
|
| 46 | + protected $subjectParameters = []; |
|
| 47 | + /** @var string */ |
|
| 48 | + protected $subjectParsed; |
|
| 49 | + /** @var string */ |
|
| 50 | + protected $subjectRich; |
|
| 51 | + /** @var array */ |
|
| 52 | + protected $subjectRichParameters; |
|
| 53 | + /** @var string */ |
|
| 54 | + protected $message = ''; |
|
| 55 | + /** @var array */ |
|
| 56 | + protected $messageParameters = []; |
|
| 57 | + /** @var string */ |
|
| 58 | + protected $messageParsed; |
|
| 59 | + /** @var string */ |
|
| 60 | + protected $messageRich; |
|
| 61 | + /** @var array */ |
|
| 62 | + protected $messageRichParameters; |
|
| 63 | + /** @var string */ |
|
| 64 | + protected $objectType = ''; |
|
| 65 | + /** @var int */ |
|
| 66 | + protected $objectId = 0; |
|
| 67 | + /** @var string */ |
|
| 68 | + protected $objectName = ''; |
|
| 69 | + /** @var string */ |
|
| 70 | + protected $link = ''; |
|
| 71 | + /** @var string */ |
|
| 72 | + protected $icon = ''; |
|
| 73 | + |
|
| 74 | + /** @var IEvent */ |
|
| 75 | + protected $child = null; |
|
| 76 | + /** @var IValidator */ |
|
| 77 | + protected $richValidator; |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * @param IValidator $richValidator |
|
| 81 | + */ |
|
| 82 | + public function __construct(IValidator $richValidator) { |
|
| 83 | + $this->richValidator = $richValidator; |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + /** |
|
| 87 | + * Set the app of the activity |
|
| 88 | + * |
|
| 89 | + * @param string $app |
|
| 90 | + * @return IEvent |
|
| 91 | + * @throws \InvalidArgumentException if the app id is invalid |
|
| 92 | + * @since 8.2.0 |
|
| 93 | + */ |
|
| 94 | + public function setApp($app) { |
|
| 95 | + if (!is_string($app) || $app === '' || isset($app[32])) { |
|
| 96 | + throw new \InvalidArgumentException('The given app is invalid'); |
|
| 97 | + } |
|
| 98 | + $this->app = (string) $app; |
|
| 99 | + return $this; |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + /** |
|
| 103 | + * @return string |
|
| 104 | + */ |
|
| 105 | + public function getApp() { |
|
| 106 | + return $this->app; |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + /** |
|
| 110 | + * Set the type of the activity |
|
| 111 | + * |
|
| 112 | + * @param string $type |
|
| 113 | + * @return IEvent |
|
| 114 | + * @throws \InvalidArgumentException if the type is invalid |
|
| 115 | + * @since 8.2.0 |
|
| 116 | + */ |
|
| 117 | + public function setType($type) { |
|
| 118 | + if (!is_string($type) || $type === '' || isset($type[255])) { |
|
| 119 | + throw new \InvalidArgumentException('The given type is invalid'); |
|
| 120 | + } |
|
| 121 | + $this->type = (string) $type; |
|
| 122 | + return $this; |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + /** |
|
| 126 | + * @return string |
|
| 127 | + */ |
|
| 128 | + public function getType() { |
|
| 129 | + return $this->type; |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + /** |
|
| 133 | + * Set the affected user of the activity |
|
| 134 | + * |
|
| 135 | + * @param string $affectedUser |
|
| 136 | + * @return IEvent |
|
| 137 | + * @throws \InvalidArgumentException if the affected user is invalid |
|
| 138 | + * @since 8.2.0 |
|
| 139 | + */ |
|
| 140 | + public function setAffectedUser($affectedUser) { |
|
| 141 | + if (!is_string($affectedUser) || $affectedUser === '' || isset($affectedUser[64])) { |
|
| 142 | + throw new \InvalidArgumentException('The given affected user is invalid'); |
|
| 143 | + } |
|
| 144 | + $this->affectedUser = (string) $affectedUser; |
|
| 145 | + return $this; |
|
| 146 | + } |
|
| 147 | + |
|
| 148 | + /** |
|
| 149 | + * @return string |
|
| 150 | + */ |
|
| 151 | + public function getAffectedUser() { |
|
| 152 | + return $this->affectedUser; |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + /** |
|
| 156 | + * Set the author of the activity |
|
| 157 | + * |
|
| 158 | + * @param string $author |
|
| 159 | + * @return IEvent |
|
| 160 | + * @throws \InvalidArgumentException if the author is invalid |
|
| 161 | + * @since 8.2.0 |
|
| 162 | + */ |
|
| 163 | + public function setAuthor($author) { |
|
| 164 | + if (!is_string($author) || isset($author[64])) { |
|
| 165 | + throw new \InvalidArgumentException('The given author user is invalid'. serialize($author)); |
|
| 166 | + } |
|
| 167 | + $this->author = (string) $author; |
|
| 168 | + return $this; |
|
| 169 | + } |
|
| 170 | + |
|
| 171 | + /** |
|
| 172 | + * @return string |
|
| 173 | + */ |
|
| 174 | + public function getAuthor() { |
|
| 175 | + return $this->author; |
|
| 176 | + } |
|
| 177 | + |
|
| 178 | + /** |
|
| 179 | + * Set the timestamp of the activity |
|
| 180 | + * |
|
| 181 | + * @param int $timestamp |
|
| 182 | + * @return IEvent |
|
| 183 | + * @throws \InvalidArgumentException if the timestamp is invalid |
|
| 184 | + * @since 8.2.0 |
|
| 185 | + */ |
|
| 186 | + public function setTimestamp($timestamp) { |
|
| 187 | + if (!is_int($timestamp)) { |
|
| 188 | + throw new \InvalidArgumentException('The given timestamp is invalid'); |
|
| 189 | + } |
|
| 190 | + $this->timestamp = (int) $timestamp; |
|
| 191 | + return $this; |
|
| 192 | + } |
|
| 193 | + |
|
| 194 | + /** |
|
| 195 | + * @return int |
|
| 196 | + */ |
|
| 197 | + public function getTimestamp() { |
|
| 198 | + return $this->timestamp; |
|
| 199 | + } |
|
| 200 | + |
|
| 201 | + /** |
|
| 202 | + * Set the subject of the activity |
|
| 203 | + * |
|
| 204 | + * @param string $subject |
|
| 205 | + * @param array $parameters |
|
| 206 | + * @return IEvent |
|
| 207 | + * @throws \InvalidArgumentException if the subject or parameters are invalid |
|
| 208 | + * @since 8.2.0 |
|
| 209 | + */ |
|
| 210 | + public function setSubject($subject, array $parameters = []) { |
|
| 211 | + if (!is_string($subject) || isset($subject[255])) { |
|
| 212 | + throw new \InvalidArgumentException('The given subject is invalid'); |
|
| 213 | + } |
|
| 214 | + $this->subject = (string) $subject; |
|
| 215 | + $this->subjectParameters = $parameters; |
|
| 216 | + return $this; |
|
| 217 | + } |
|
| 218 | + |
|
| 219 | + /** |
|
| 220 | + * @return string |
|
| 221 | + */ |
|
| 222 | + public function getSubject() { |
|
| 223 | + return $this->subject; |
|
| 224 | + } |
|
| 225 | + |
|
| 226 | + /** |
|
| 227 | + * @return array |
|
| 228 | + */ |
|
| 229 | + public function getSubjectParameters() { |
|
| 230 | + return $this->subjectParameters; |
|
| 231 | + } |
|
| 232 | + |
|
| 233 | + /** |
|
| 234 | + * @param string $subject |
|
| 235 | + * @return $this |
|
| 236 | + * @throws \InvalidArgumentException if the subject is invalid |
|
| 237 | + * @since 11.0.0 |
|
| 238 | + */ |
|
| 239 | + public function setParsedSubject($subject) { |
|
| 240 | + if (!is_string($subject) || $subject === '') { |
|
| 241 | + throw new \InvalidArgumentException('The given parsed subject is invalid'); |
|
| 242 | + } |
|
| 243 | + $this->subjectParsed = $subject; |
|
| 244 | + return $this; |
|
| 245 | + } |
|
| 246 | + |
|
| 247 | + /** |
|
| 248 | + * @return string |
|
| 249 | + * @since 11.0.0 |
|
| 250 | + */ |
|
| 251 | + public function getParsedSubject() { |
|
| 252 | + return $this->subjectParsed; |
|
| 253 | + } |
|
| 254 | + |
|
| 255 | + /** |
|
| 256 | + * @param string $subject |
|
| 257 | + * @param array $parameters |
|
| 258 | + * @return $this |
|
| 259 | + * @throws \InvalidArgumentException if the subject or parameters are invalid |
|
| 260 | + * @since 11.0.0 |
|
| 261 | + */ |
|
| 262 | + public function setRichSubject($subject, array $parameters = []) { |
|
| 263 | + if (!is_string($subject) || $subject === '') { |
|
| 264 | + throw new \InvalidArgumentException('The given parsed subject is invalid'); |
|
| 265 | + } |
|
| 266 | + $this->subjectRich = $subject; |
|
| 267 | + |
|
| 268 | + if (!is_array($parameters)) { |
|
| 269 | + throw new \InvalidArgumentException('The given subject parameters are invalid'); |
|
| 270 | + } |
|
| 271 | + $this->subjectRichParameters = $parameters; |
|
| 272 | + |
|
| 273 | + return $this; |
|
| 274 | + } |
|
| 275 | + |
|
| 276 | + /** |
|
| 277 | + * @return string |
|
| 278 | + * @since 11.0.0 |
|
| 279 | + */ |
|
| 280 | + public function getRichSubject() { |
|
| 281 | + return $this->subjectRich; |
|
| 282 | + } |
|
| 283 | + |
|
| 284 | + /** |
|
| 285 | + * @return array[] |
|
| 286 | + * @since 11.0.0 |
|
| 287 | + */ |
|
| 288 | + public function getRichSubjectParameters() { |
|
| 289 | + return $this->subjectRichParameters; |
|
| 290 | + } |
|
| 291 | + |
|
| 292 | + /** |
|
| 293 | + * Set the message of the activity |
|
| 294 | + * |
|
| 295 | + * @param string $message |
|
| 296 | + * @param array $parameters |
|
| 297 | + * @return IEvent |
|
| 298 | + * @throws \InvalidArgumentException if the message or parameters are invalid |
|
| 299 | + * @since 8.2.0 |
|
| 300 | + */ |
|
| 301 | + public function setMessage($message, array $parameters = []) { |
|
| 302 | + if (!is_string($message) || isset($message[255])) { |
|
| 303 | + throw new \InvalidArgumentException('The given message is invalid'); |
|
| 304 | + } |
|
| 305 | + $this->message = (string) $message; |
|
| 306 | + $this->messageParameters = $parameters; |
|
| 307 | + return $this; |
|
| 308 | + } |
|
| 309 | + |
|
| 310 | + /** |
|
| 311 | + * @return string |
|
| 312 | + */ |
|
| 313 | + public function getMessage() { |
|
| 314 | + return $this->message; |
|
| 315 | + } |
|
| 316 | + |
|
| 317 | + /** |
|
| 318 | + * @return array |
|
| 319 | + */ |
|
| 320 | + public function getMessageParameters() { |
|
| 321 | + return $this->messageParameters; |
|
| 322 | + } |
|
| 323 | + |
|
| 324 | + /** |
|
| 325 | + * @param string $message |
|
| 326 | + * @return $this |
|
| 327 | + * @throws \InvalidArgumentException if the message is invalid |
|
| 328 | + * @since 11.0.0 |
|
| 329 | + */ |
|
| 330 | + public function setParsedMessage($message) { |
|
| 331 | + if (!is_string($message)) { |
|
| 332 | + throw new \InvalidArgumentException('The given parsed message is invalid'); |
|
| 333 | + } |
|
| 334 | + $this->messageParsed = $message; |
|
| 335 | + return $this; |
|
| 336 | + } |
|
| 337 | + |
|
| 338 | + /** |
|
| 339 | + * @return string |
|
| 340 | + * @since 11.0.0 |
|
| 341 | + */ |
|
| 342 | + public function getParsedMessage() { |
|
| 343 | + return $this->messageParsed; |
|
| 344 | + } |
|
| 345 | + |
|
| 346 | + /** |
|
| 347 | + * @param string $message |
|
| 348 | + * @param array $parameters |
|
| 349 | + * @return $this |
|
| 350 | + * @throws \InvalidArgumentException if the subject or parameters are invalid |
|
| 351 | + * @since 11.0.0 |
|
| 352 | + */ |
|
| 353 | + public function setRichMessage($message, array $parameters = []) { |
|
| 354 | + if (!is_string($message)) { |
|
| 355 | + throw new \InvalidArgumentException('The given parsed message is invalid'); |
|
| 356 | + } |
|
| 357 | + $this->messageRich = $message; |
|
| 358 | + |
|
| 359 | + if (!is_array($parameters)) { |
|
| 360 | + throw new \InvalidArgumentException('The given message parameters are invalid'); |
|
| 361 | + } |
|
| 362 | + $this->messageRichParameters = $parameters; |
|
| 363 | + |
|
| 364 | + return $this; |
|
| 365 | + } |
|
| 366 | + |
|
| 367 | + /** |
|
| 368 | + * @return string |
|
| 369 | + * @since 11.0.0 |
|
| 370 | + */ |
|
| 371 | + public function getRichMessage() { |
|
| 372 | + return $this->messageRich; |
|
| 373 | + } |
|
| 374 | + |
|
| 375 | + /** |
|
| 376 | + * @return array[] |
|
| 377 | + * @since 11.0.0 |
|
| 378 | + */ |
|
| 379 | + public function getRichMessageParameters() { |
|
| 380 | + return $this->messageRichParameters; |
|
| 381 | + } |
|
| 382 | + |
|
| 383 | + /** |
|
| 384 | + * Set the object of the activity |
|
| 385 | + * |
|
| 386 | + * @param string $objectType |
|
| 387 | + * @param int $objectId |
|
| 388 | + * @param string $objectName |
|
| 389 | + * @return IEvent |
|
| 390 | + * @throws \InvalidArgumentException if the object is invalid |
|
| 391 | + * @since 8.2.0 |
|
| 392 | + */ |
|
| 393 | + public function setObject($objectType, $objectId, $objectName = '') { |
|
| 394 | + if (!is_string($objectType) || isset($objectType[255])) { |
|
| 395 | + throw new \InvalidArgumentException('The given object type is invalid'); |
|
| 396 | + } |
|
| 397 | + if (!is_int($objectId)) { |
|
| 398 | + throw new \InvalidArgumentException('The given object id is invalid'); |
|
| 399 | + } |
|
| 400 | + if (!is_string($objectName) || isset($objectName[4000])) { |
|
| 401 | + throw new \InvalidArgumentException('The given object name is invalid'); |
|
| 402 | + } |
|
| 403 | + $this->objectType = (string) $objectType; |
|
| 404 | + $this->objectId = (int) $objectId; |
|
| 405 | + $this->objectName = (string) $objectName; |
|
| 406 | + return $this; |
|
| 407 | + } |
|
| 408 | + |
|
| 409 | + /** |
|
| 410 | + * @return string |
|
| 411 | + */ |
|
| 412 | + public function getObjectType() { |
|
| 413 | + return $this->objectType; |
|
| 414 | + } |
|
| 415 | + |
|
| 416 | + /** |
|
| 417 | + * @return string |
|
| 418 | + */ |
|
| 419 | + public function getObjectId() { |
|
| 420 | + return $this->objectId; |
|
| 421 | + } |
|
| 422 | + |
|
| 423 | + /** |
|
| 424 | + * @return string |
|
| 425 | + */ |
|
| 426 | + public function getObjectName() { |
|
| 427 | + return $this->objectName; |
|
| 428 | + } |
|
| 429 | + |
|
| 430 | + /** |
|
| 431 | + * Set the link of the activity |
|
| 432 | + * |
|
| 433 | + * @param string $link |
|
| 434 | + * @return IEvent |
|
| 435 | + * @throws \InvalidArgumentException if the link is invalid |
|
| 436 | + * @since 8.2.0 |
|
| 437 | + */ |
|
| 438 | + public function setLink($link) { |
|
| 439 | + if (!is_string($link) || isset($link[4000])) { |
|
| 440 | + throw new \InvalidArgumentException('The given link is invalid'); |
|
| 441 | + } |
|
| 442 | + $this->link = (string) $link; |
|
| 443 | + return $this; |
|
| 444 | + } |
|
| 445 | + |
|
| 446 | + /** |
|
| 447 | + * @return string |
|
| 448 | + */ |
|
| 449 | + public function getLink() { |
|
| 450 | + return $this->link; |
|
| 451 | + } |
|
| 452 | + |
|
| 453 | + /** |
|
| 454 | + * @param string $icon |
|
| 455 | + * @return $this |
|
| 456 | + * @throws \InvalidArgumentException if the icon is invalid |
|
| 457 | + * @since 11.0.0 |
|
| 458 | + */ |
|
| 459 | + public function setIcon($icon) { |
|
| 460 | + if (!is_string($icon) || isset($icon[4000])) { |
|
| 461 | + throw new \InvalidArgumentException('The given icon is invalid'); |
|
| 462 | + } |
|
| 463 | + $this->icon = $icon; |
|
| 464 | + return $this; |
|
| 465 | + } |
|
| 466 | + |
|
| 467 | + /** |
|
| 468 | + * @return string |
|
| 469 | + * @since 11.0.0 |
|
| 470 | + */ |
|
| 471 | + public function getIcon() { |
|
| 472 | + return $this->icon; |
|
| 473 | + } |
|
| 474 | + |
|
| 475 | + /** |
|
| 476 | + * @param IEvent $child |
|
| 477 | + * @since 11.0.0 |
|
| 478 | + */ |
|
| 479 | + public function setChildEvent(IEvent $child) { |
|
| 480 | + $this->child = $child; |
|
| 481 | + } |
|
| 482 | + |
|
| 483 | + /** |
|
| 484 | + * @return IEvent|null |
|
| 485 | + * @since 11.0.0 |
|
| 486 | + */ |
|
| 487 | + public function getChildEvent() { |
|
| 488 | + return $this->child; |
|
| 489 | + } |
|
| 490 | + |
|
| 491 | + /** |
|
| 492 | + * @return bool |
|
| 493 | + * @since 8.2.0 |
|
| 494 | + */ |
|
| 495 | + public function isValid() { |
|
| 496 | + return |
|
| 497 | + $this->isValidCommon() |
|
| 498 | + && |
|
| 499 | + $this->getSubject() !== '' |
|
| 500 | + ; |
|
| 501 | + } |
|
| 502 | + |
|
| 503 | + /** |
|
| 504 | + * @return bool |
|
| 505 | + * @since 8.2.0 |
|
| 506 | + */ |
|
| 507 | + public function isValidParsed() { |
|
| 508 | + if ($this->getRichSubject() !== '' || !empty($this->getRichSubjectParameters())) { |
|
| 509 | + try { |
|
| 510 | + $this->richValidator->validate($this->getRichSubject(), $this->getRichSubjectParameters()); |
|
| 511 | + } catch (InvalidObjectExeption $e) { |
|
| 512 | + return false; |
|
| 513 | + } |
|
| 514 | + } |
|
| 515 | + |
|
| 516 | + if ($this->getRichMessage() !== '' || !empty($this->getRichMessageParameters())) { |
|
| 517 | + try { |
|
| 518 | + $this->richValidator->validate($this->getRichMessage(), $this->getRichMessageParameters()); |
|
| 519 | + } catch (InvalidObjectExeption $e) { |
|
| 520 | + return false; |
|
| 521 | + } |
|
| 522 | + } |
|
| 523 | + |
|
| 524 | + return |
|
| 525 | + $this->isValidCommon() |
|
| 526 | + && |
|
| 527 | + $this->getParsedSubject() !== '' |
|
| 528 | + ; |
|
| 529 | + } |
|
| 530 | + |
|
| 531 | + /** |
|
| 532 | + * @return bool |
|
| 533 | + */ |
|
| 534 | + protected function isValidCommon() { |
|
| 535 | + return |
|
| 536 | + $this->getApp() !== '' |
|
| 537 | + && |
|
| 538 | + $this->getType() !== '' |
|
| 539 | + && |
|
| 540 | + $this->getAffectedUser() !== '' |
|
| 541 | + && |
|
| 542 | + $this->getTimestamp() !== 0 |
|
| 543 | + /** |
|
| 544 | + * Disabled for BC with old activities |
|
| 545 | 545 | && |
| 546 | 546 | $this->getObjectType() !== '' |
| 547 | 547 | && |
| 548 | 548 | $this->getObjectId() !== 0 |
| 549 | - */ |
|
| 550 | - ; |
|
| 551 | - } |
|
| 549 | + */ |
|
| 550 | + ; |
|
| 551 | + } |
|
| 552 | 552 | } |
@@ -26,83 +26,83 @@ |
||
| 26 | 26 | |
| 27 | 27 | class LegacyFilter implements IFilter { |
| 28 | 28 | |
| 29 | - /** @var IManager */ |
|
| 30 | - protected $manager; |
|
| 31 | - /** @var string */ |
|
| 32 | - protected $identifier; |
|
| 33 | - /** @var string */ |
|
| 34 | - protected $name; |
|
| 35 | - /** @var bool */ |
|
| 36 | - protected $isTopFilter; |
|
| 29 | + /** @var IManager */ |
|
| 30 | + protected $manager; |
|
| 31 | + /** @var string */ |
|
| 32 | + protected $identifier; |
|
| 33 | + /** @var string */ |
|
| 34 | + protected $name; |
|
| 35 | + /** @var bool */ |
|
| 36 | + protected $isTopFilter; |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * LegacySetting constructor. |
|
| 40 | - * |
|
| 41 | - * @param IManager $manager |
|
| 42 | - * @param string $identifier |
|
| 43 | - * @param string $name |
|
| 44 | - * @param bool $isTopFilter |
|
| 45 | - */ |
|
| 46 | - public function __construct(IManager $manager, |
|
| 47 | - $identifier, |
|
| 48 | - $name, |
|
| 49 | - $isTopFilter) { |
|
| 50 | - $this->manager = $manager; |
|
| 51 | - $this->identifier = $identifier; |
|
| 52 | - $this->name = $name; |
|
| 53 | - $this->isTopFilter = $isTopFilter; |
|
| 54 | - } |
|
| 38 | + /** |
|
| 39 | + * LegacySetting constructor. |
|
| 40 | + * |
|
| 41 | + * @param IManager $manager |
|
| 42 | + * @param string $identifier |
|
| 43 | + * @param string $name |
|
| 44 | + * @param bool $isTopFilter |
|
| 45 | + */ |
|
| 46 | + public function __construct(IManager $manager, |
|
| 47 | + $identifier, |
|
| 48 | + $name, |
|
| 49 | + $isTopFilter) { |
|
| 50 | + $this->manager = $manager; |
|
| 51 | + $this->identifier = $identifier; |
|
| 52 | + $this->name = $name; |
|
| 53 | + $this->isTopFilter = $isTopFilter; |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * @return string Lowercase a-z and underscore only identifier |
|
| 58 | - * @since 11.0.0 |
|
| 59 | - */ |
|
| 60 | - public function getIdentifier() { |
|
| 61 | - return $this->identifier; |
|
| 62 | - } |
|
| 56 | + /** |
|
| 57 | + * @return string Lowercase a-z and underscore only identifier |
|
| 58 | + * @since 11.0.0 |
|
| 59 | + */ |
|
| 60 | + public function getIdentifier() { |
|
| 61 | + return $this->identifier; |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * @return string A translated string |
|
| 66 | - * @since 11.0.0 |
|
| 67 | - */ |
|
| 68 | - public function getName() { |
|
| 69 | - return $this->name; |
|
| 70 | - } |
|
| 64 | + /** |
|
| 65 | + * @return string A translated string |
|
| 66 | + * @since 11.0.0 |
|
| 67 | + */ |
|
| 68 | + public function getName() { |
|
| 69 | + return $this->name; |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | - /** |
|
| 73 | - * @return int whether the filter should be rather on the top or bottom of |
|
| 74 | - * the admin section. The filters are arranged in ascending order of the |
|
| 75 | - * priority values. It is required to return a value between 0 and 100. |
|
| 76 | - * @since 11.0.0 |
|
| 77 | - */ |
|
| 78 | - public function getPriority() { |
|
| 79 | - return $this->isTopFilter ? 40 : 50; |
|
| 80 | - } |
|
| 72 | + /** |
|
| 73 | + * @return int whether the filter should be rather on the top or bottom of |
|
| 74 | + * the admin section. The filters are arranged in ascending order of the |
|
| 75 | + * priority values. It is required to return a value between 0 and 100. |
|
| 76 | + * @since 11.0.0 |
|
| 77 | + */ |
|
| 78 | + public function getPriority() { |
|
| 79 | + return $this->isTopFilter ? 40 : 50; |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | - /** |
|
| 83 | - * @return string Full URL to an icon, empty string when none is given |
|
| 84 | - * @since 11.0.0 |
|
| 85 | - */ |
|
| 86 | - public function getIcon() { |
|
| 87 | - // Old API was CSS class, so we can not use this... |
|
| 88 | - return ''; |
|
| 89 | - } |
|
| 82 | + /** |
|
| 83 | + * @return string Full URL to an icon, empty string when none is given |
|
| 84 | + * @since 11.0.0 |
|
| 85 | + */ |
|
| 86 | + public function getIcon() { |
|
| 87 | + // Old API was CSS class, so we can not use this... |
|
| 88 | + return ''; |
|
| 89 | + } |
|
| 90 | 90 | |
| 91 | - /** |
|
| 92 | - * @param string[] $types |
|
| 93 | - * @return string[] An array of allowed apps from which activities should be displayed |
|
| 94 | - * @since 11.0.0 |
|
| 95 | - */ |
|
| 96 | - public function filterTypes(array $types) { |
|
| 97 | - return $this->manager->filterNotificationTypes($types, $this->getIdentifier()); |
|
| 98 | - } |
|
| 91 | + /** |
|
| 92 | + * @param string[] $types |
|
| 93 | + * @return string[] An array of allowed apps from which activities should be displayed |
|
| 94 | + * @since 11.0.0 |
|
| 95 | + */ |
|
| 96 | + public function filterTypes(array $types) { |
|
| 97 | + return $this->manager->filterNotificationTypes($types, $this->getIdentifier()); |
|
| 98 | + } |
|
| 99 | 99 | |
| 100 | - /** |
|
| 101 | - * @return string[] An array of allowed apps from which activities should be displayed |
|
| 102 | - * @since 11.0.0 |
|
| 103 | - */ |
|
| 104 | - public function allowedApps() { |
|
| 105 | - return []; |
|
| 106 | - } |
|
| 100 | + /** |
|
| 101 | + * @return string[] An array of allowed apps from which activities should be displayed |
|
| 102 | + * @since 11.0.0 |
|
| 103 | + */ |
|
| 104 | + public function allowedApps() { |
|
| 105 | + return []; |
|
| 106 | + } |
|
| 107 | 107 | } |
| 108 | 108 | |