@@ -30,28 +30,28 @@ |
||
30 | 30 | */ |
31 | 31 | class TagNotFoundException extends \RuntimeException { |
32 | 32 | |
33 | - /** @var string[] */ |
|
34 | - protected $tags; |
|
33 | + /** @var string[] */ |
|
34 | + protected $tags; |
|
35 | 35 | |
36 | - /** |
|
37 | - * TagNotFoundException constructor. |
|
38 | - * |
|
39 | - * @param string $message |
|
40 | - * @param int $code |
|
41 | - * @param \Exception $previous |
|
42 | - * @param string[] $tags |
|
43 | - * @since 9.0.0 |
|
44 | - */ |
|
45 | - public function __construct($message = '', $code = 0, \Exception $previous = null, array $tags = []) { |
|
46 | - parent::__construct($message, $code, $previous); |
|
47 | - $this->tags = $tags; |
|
48 | - } |
|
36 | + /** |
|
37 | + * TagNotFoundException constructor. |
|
38 | + * |
|
39 | + * @param string $message |
|
40 | + * @param int $code |
|
41 | + * @param \Exception $previous |
|
42 | + * @param string[] $tags |
|
43 | + * @since 9.0.0 |
|
44 | + */ |
|
45 | + public function __construct($message = '', $code = 0, \Exception $previous = null, array $tags = []) { |
|
46 | + parent::__construct($message, $code, $previous); |
|
47 | + $this->tags = $tags; |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * @return string[] |
|
52 | - * @since 9.0.0 |
|
53 | - */ |
|
54 | - public function getMissingTags() { |
|
55 | - return $this->tags; |
|
56 | - } |
|
50 | + /** |
|
51 | + * @return string[] |
|
52 | + * @since 9.0.0 |
|
53 | + */ |
|
54 | + public function getMissingTags() { |
|
55 | + return $this->tags; |
|
56 | + } |
|
57 | 57 | } |
@@ -32,63 +32,63 @@ |
||
32 | 32 | */ |
33 | 33 | class MapperEvent extends Event { |
34 | 34 | |
35 | - const EVENT_ASSIGN = 'OCP\SystemTag\ISystemTagObjectMapper::assignTags'; |
|
36 | - const EVENT_UNASSIGN = 'OCP\SystemTag\ISystemTagObjectMapper::unassignTags'; |
|
35 | + const EVENT_ASSIGN = 'OCP\SystemTag\ISystemTagObjectMapper::assignTags'; |
|
36 | + const EVENT_UNASSIGN = 'OCP\SystemTag\ISystemTagObjectMapper::unassignTags'; |
|
37 | 37 | |
38 | - /** @var string */ |
|
39 | - protected $event; |
|
40 | - /** @var string */ |
|
41 | - protected $objectType; |
|
42 | - /** @var string */ |
|
43 | - protected $objectId; |
|
44 | - /** @var int[] */ |
|
45 | - protected $tags; |
|
38 | + /** @var string */ |
|
39 | + protected $event; |
|
40 | + /** @var string */ |
|
41 | + protected $objectType; |
|
42 | + /** @var string */ |
|
43 | + protected $objectId; |
|
44 | + /** @var int[] */ |
|
45 | + protected $tags; |
|
46 | 46 | |
47 | - /** |
|
48 | - * DispatcherEvent constructor. |
|
49 | - * |
|
50 | - * @param string $event |
|
51 | - * @param string $objectType |
|
52 | - * @param string $objectId |
|
53 | - * @param int[] $tags |
|
54 | - * @since 9.0.0 |
|
55 | - */ |
|
56 | - public function __construct($event, $objectType, $objectId, array $tags) { |
|
57 | - $this->event = $event; |
|
58 | - $this->objectType = $objectType; |
|
59 | - $this->objectId = $objectId; |
|
60 | - $this->tags = $tags; |
|
61 | - } |
|
47 | + /** |
|
48 | + * DispatcherEvent constructor. |
|
49 | + * |
|
50 | + * @param string $event |
|
51 | + * @param string $objectType |
|
52 | + * @param string $objectId |
|
53 | + * @param int[] $tags |
|
54 | + * @since 9.0.0 |
|
55 | + */ |
|
56 | + public function __construct($event, $objectType, $objectId, array $tags) { |
|
57 | + $this->event = $event; |
|
58 | + $this->objectType = $objectType; |
|
59 | + $this->objectId = $objectId; |
|
60 | + $this->tags = $tags; |
|
61 | + } |
|
62 | 62 | |
63 | - /** |
|
64 | - * @return string |
|
65 | - * @since 9.0.0 |
|
66 | - */ |
|
67 | - public function getEvent() { |
|
68 | - return $this->event; |
|
69 | - } |
|
63 | + /** |
|
64 | + * @return string |
|
65 | + * @since 9.0.0 |
|
66 | + */ |
|
67 | + public function getEvent() { |
|
68 | + return $this->event; |
|
69 | + } |
|
70 | 70 | |
71 | - /** |
|
72 | - * @return string |
|
73 | - * @since 9.0.0 |
|
74 | - */ |
|
75 | - public function getObjectType() { |
|
76 | - return $this->objectType; |
|
77 | - } |
|
71 | + /** |
|
72 | + * @return string |
|
73 | + * @since 9.0.0 |
|
74 | + */ |
|
75 | + public function getObjectType() { |
|
76 | + return $this->objectType; |
|
77 | + } |
|
78 | 78 | |
79 | - /** |
|
80 | - * @return string |
|
81 | - * @since 9.0.0 |
|
82 | - */ |
|
83 | - public function getObjectId() { |
|
84 | - return $this->objectId; |
|
85 | - } |
|
79 | + /** |
|
80 | + * @return string |
|
81 | + * @since 9.0.0 |
|
82 | + */ |
|
83 | + public function getObjectId() { |
|
84 | + return $this->objectId; |
|
85 | + } |
|
86 | 86 | |
87 | - /** |
|
88 | - * @return int[] |
|
89 | - * @since 9.0.0 |
|
90 | - */ |
|
91 | - public function getTags() { |
|
92 | - return $this->tags; |
|
93 | - } |
|
87 | + /** |
|
88 | + * @return int[] |
|
89 | + * @since 9.0.0 |
|
90 | + */ |
|
91 | + public function getTags() { |
|
92 | + return $this->tags; |
|
93 | + } |
|
94 | 94 | } |
@@ -32,55 +32,55 @@ |
||
32 | 32 | */ |
33 | 33 | class ManagerEvent extends Event { |
34 | 34 | |
35 | - const EVENT_CREATE = 'OCP\SystemTag\ISystemTagManager::createTag'; |
|
36 | - const EVENT_UPDATE = 'OCP\SystemTag\ISystemTagManager::updateTag'; |
|
37 | - const EVENT_DELETE = 'OCP\SystemTag\ISystemTagManager::deleteTag'; |
|
35 | + const EVENT_CREATE = 'OCP\SystemTag\ISystemTagManager::createTag'; |
|
36 | + const EVENT_UPDATE = 'OCP\SystemTag\ISystemTagManager::updateTag'; |
|
37 | + const EVENT_DELETE = 'OCP\SystemTag\ISystemTagManager::deleteTag'; |
|
38 | 38 | |
39 | - /** @var string */ |
|
40 | - protected $event; |
|
41 | - /** @var ISystemTag */ |
|
42 | - protected $tag; |
|
43 | - /** @var ISystemTag */ |
|
44 | - protected $beforeTag; |
|
39 | + /** @var string */ |
|
40 | + protected $event; |
|
41 | + /** @var ISystemTag */ |
|
42 | + protected $tag; |
|
43 | + /** @var ISystemTag */ |
|
44 | + protected $beforeTag; |
|
45 | 45 | |
46 | - /** |
|
47 | - * DispatcherEvent constructor. |
|
48 | - * |
|
49 | - * @param string $event |
|
50 | - * @param ISystemTag $tag |
|
51 | - * @param ISystemTag $beforeTag |
|
52 | - * @since 9.0.0 |
|
53 | - */ |
|
54 | - public function __construct($event, ISystemTag $tag, ISystemTag $beforeTag = null) { |
|
55 | - $this->event = $event; |
|
56 | - $this->tag = $tag; |
|
57 | - $this->beforeTag = $beforeTag; |
|
58 | - } |
|
46 | + /** |
|
47 | + * DispatcherEvent constructor. |
|
48 | + * |
|
49 | + * @param string $event |
|
50 | + * @param ISystemTag $tag |
|
51 | + * @param ISystemTag $beforeTag |
|
52 | + * @since 9.0.0 |
|
53 | + */ |
|
54 | + public function __construct($event, ISystemTag $tag, ISystemTag $beforeTag = null) { |
|
55 | + $this->event = $event; |
|
56 | + $this->tag = $tag; |
|
57 | + $this->beforeTag = $beforeTag; |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * @return string |
|
62 | - * @since 9.0.0 |
|
63 | - */ |
|
64 | - public function getEvent() { |
|
65 | - return $this->event; |
|
66 | - } |
|
60 | + /** |
|
61 | + * @return string |
|
62 | + * @since 9.0.0 |
|
63 | + */ |
|
64 | + public function getEvent() { |
|
65 | + return $this->event; |
|
66 | + } |
|
67 | 67 | |
68 | - /** |
|
69 | - * @return ISystemTag |
|
70 | - * @since 9.0.0 |
|
71 | - */ |
|
72 | - public function getTag() { |
|
73 | - return $this->tag; |
|
74 | - } |
|
68 | + /** |
|
69 | + * @return ISystemTag |
|
70 | + * @since 9.0.0 |
|
71 | + */ |
|
72 | + public function getTag() { |
|
73 | + return $this->tag; |
|
74 | + } |
|
75 | 75 | |
76 | - /** |
|
77 | - * @return ISystemTag |
|
78 | - * @since 9.0.0 |
|
79 | - */ |
|
80 | - public function getTagBefore() { |
|
81 | - if ($this->event !== self::EVENT_UPDATE) { |
|
82 | - throw new \BadMethodCallException('getTagBefore is only available on the update Event'); |
|
83 | - } |
|
84 | - return $this->beforeTag; |
|
85 | - } |
|
76 | + /** |
|
77 | + * @return ISystemTag |
|
78 | + * @since 9.0.0 |
|
79 | + */ |
|
80 | + public function getTagBefore() { |
|
81 | + if ($this->event !== self::EVENT_UPDATE) { |
|
82 | + throw new \BadMethodCallException('getTagBefore is only available on the update Event'); |
|
83 | + } |
|
84 | + return $this->beforeTag; |
|
85 | + } |
|
86 | 86 | } |
@@ -33,28 +33,28 @@ |
||
33 | 33 | */ |
34 | 34 | interface ISystemTagManagerFactory { |
35 | 35 | |
36 | - /** |
|
37 | - * Constructor for the system tag manager factory |
|
38 | - * |
|
39 | - * @param IServerContainer $serverContainer server container |
|
40 | - * @since 9.0.0 |
|
41 | - */ |
|
42 | - public function __construct(IServerContainer $serverContainer); |
|
36 | + /** |
|
37 | + * Constructor for the system tag manager factory |
|
38 | + * |
|
39 | + * @param IServerContainer $serverContainer server container |
|
40 | + * @since 9.0.0 |
|
41 | + */ |
|
42 | + public function __construct(IServerContainer $serverContainer); |
|
43 | 43 | |
44 | - /** |
|
45 | - * creates and returns an instance of the system tag manager |
|
46 | - * |
|
47 | - * @return ISystemTagManager |
|
48 | - * @since 9.0.0 |
|
49 | - */ |
|
50 | - public function getManager(); |
|
44 | + /** |
|
45 | + * creates and returns an instance of the system tag manager |
|
46 | + * |
|
47 | + * @return ISystemTagManager |
|
48 | + * @since 9.0.0 |
|
49 | + */ |
|
50 | + public function getManager(); |
|
51 | 51 | |
52 | - /** |
|
53 | - * creates and returns an instance of the system tag object |
|
54 | - * mapper |
|
55 | - * |
|
56 | - * @return ISystemTagObjectMapper |
|
57 | - * @since 9.0.0 |
|
58 | - */ |
|
59 | - public function getObjectMapper(); |
|
52 | + /** |
|
53 | + * creates and returns an instance of the system tag object |
|
54 | + * mapper |
|
55 | + * |
|
56 | + * @return ISystemTagObjectMapper |
|
57 | + * @since 9.0.0 |
|
58 | + */ |
|
59 | + public function getObjectMapper(); |
|
60 | 60 | } |
@@ -30,102 +30,102 @@ |
||
30 | 30 | */ |
31 | 31 | interface ISystemTagObjectMapper { |
32 | 32 | |
33 | - /** |
|
34 | - * Get a list of tag ids for the given object ids. |
|
35 | - * |
|
36 | - * This returns an array that maps object id to tag ids |
|
37 | - * [ |
|
38 | - * 1 => array('id1', 'id2'), |
|
39 | - * 2 => array('id3', 'id2'), |
|
40 | - * 3 => array('id5'), |
|
41 | - * 4 => array() |
|
42 | - * ] |
|
43 | - * |
|
44 | - * Untagged objects will have an empty array associated. |
|
45 | - * |
|
46 | - * @param string|array $objIds object ids |
|
47 | - * @param string $objectType object type |
|
48 | - * |
|
49 | - * @return array with object id as key and an array |
|
50 | - * of tag ids as value |
|
51 | - * |
|
52 | - * @since 9.0.0 |
|
53 | - */ |
|
54 | - public function getTagIdsForObjects($objIds, $objectType); |
|
33 | + /** |
|
34 | + * Get a list of tag ids for the given object ids. |
|
35 | + * |
|
36 | + * This returns an array that maps object id to tag ids |
|
37 | + * [ |
|
38 | + * 1 => array('id1', 'id2'), |
|
39 | + * 2 => array('id3', 'id2'), |
|
40 | + * 3 => array('id5'), |
|
41 | + * 4 => array() |
|
42 | + * ] |
|
43 | + * |
|
44 | + * Untagged objects will have an empty array associated. |
|
45 | + * |
|
46 | + * @param string|array $objIds object ids |
|
47 | + * @param string $objectType object type |
|
48 | + * |
|
49 | + * @return array with object id as key and an array |
|
50 | + * of tag ids as value |
|
51 | + * |
|
52 | + * @since 9.0.0 |
|
53 | + */ |
|
54 | + public function getTagIdsForObjects($objIds, $objectType); |
|
55 | 55 | |
56 | - /** |
|
57 | - * Get a list of objects tagged with $tagIds. |
|
58 | - * |
|
59 | - * @param string|array $tagIds Tag id or array of tag ids. |
|
60 | - * @param string $objectType object type |
|
61 | - * @param int $limit Count of object ids you want to get |
|
62 | - * @param string $offset The last object id you already received |
|
63 | - * |
|
64 | - * @return string[] array of object ids or empty array if none found |
|
65 | - * |
|
66 | - * @throws \OCP\SystemTag\TagNotFoundException if at least one of the |
|
67 | - * given tags does not exist |
|
68 | - * @throws \InvalidArgumentException When a limit is specified together with |
|
69 | - * multiple tag ids |
|
70 | - * |
|
71 | - * @since 9.0.0 |
|
72 | - */ |
|
73 | - public function getObjectIdsForTags($tagIds, $objectType, $limit = 0, $offset = ''); |
|
56 | + /** |
|
57 | + * Get a list of objects tagged with $tagIds. |
|
58 | + * |
|
59 | + * @param string|array $tagIds Tag id or array of tag ids. |
|
60 | + * @param string $objectType object type |
|
61 | + * @param int $limit Count of object ids you want to get |
|
62 | + * @param string $offset The last object id you already received |
|
63 | + * |
|
64 | + * @return string[] array of object ids or empty array if none found |
|
65 | + * |
|
66 | + * @throws \OCP\SystemTag\TagNotFoundException if at least one of the |
|
67 | + * given tags does not exist |
|
68 | + * @throws \InvalidArgumentException When a limit is specified together with |
|
69 | + * multiple tag ids |
|
70 | + * |
|
71 | + * @since 9.0.0 |
|
72 | + */ |
|
73 | + public function getObjectIdsForTags($tagIds, $objectType, $limit = 0, $offset = ''); |
|
74 | 74 | |
75 | - /** |
|
76 | - * Assign the given tags to the given object. |
|
77 | - * |
|
78 | - * If at least one of the given tag ids doesn't exist, none of the tags |
|
79 | - * will be assigned. |
|
80 | - * |
|
81 | - * If the relationship already existed, fail silently. |
|
82 | - * |
|
83 | - * @param string $objId object id |
|
84 | - * @param string $objectType object type |
|
85 | - * @param string|array $tagIds tag id or array of tag ids to assign |
|
86 | - * |
|
87 | - * @throws \OCP\SystemTag\TagNotFoundException if at least one of the |
|
88 | - * given tags does not exist |
|
89 | - * |
|
90 | - * @since 9.0.0 |
|
91 | - */ |
|
92 | - public function assignTags($objId, $objectType, $tagIds); |
|
75 | + /** |
|
76 | + * Assign the given tags to the given object. |
|
77 | + * |
|
78 | + * If at least one of the given tag ids doesn't exist, none of the tags |
|
79 | + * will be assigned. |
|
80 | + * |
|
81 | + * If the relationship already existed, fail silently. |
|
82 | + * |
|
83 | + * @param string $objId object id |
|
84 | + * @param string $objectType object type |
|
85 | + * @param string|array $tagIds tag id or array of tag ids to assign |
|
86 | + * |
|
87 | + * @throws \OCP\SystemTag\TagNotFoundException if at least one of the |
|
88 | + * given tags does not exist |
|
89 | + * |
|
90 | + * @since 9.0.0 |
|
91 | + */ |
|
92 | + public function assignTags($objId, $objectType, $tagIds); |
|
93 | 93 | |
94 | - /** |
|
95 | - * Unassign the given tags from the given object. |
|
96 | - * |
|
97 | - * If at least one of the given tag ids doesn't exist, none of the tags |
|
98 | - * will be unassigned. |
|
99 | - * |
|
100 | - * If the relationship did not exist in the first place, fail silently. |
|
101 | - * |
|
102 | - * @param string $objId object id |
|
103 | - * @param string $objectType object type |
|
104 | - * @param string|array $tagIds tag id or array of tag ids to unassign |
|
105 | - * |
|
106 | - * @throws \OCP\SystemTag\TagNotFoundException if at least one of the |
|
107 | - * given tags does not exist |
|
108 | - * |
|
109 | - * @since 9.0.0 |
|
110 | - */ |
|
111 | - public function unassignTags($objId, $objectType, $tagIds); |
|
94 | + /** |
|
95 | + * Unassign the given tags from the given object. |
|
96 | + * |
|
97 | + * If at least one of the given tag ids doesn't exist, none of the tags |
|
98 | + * will be unassigned. |
|
99 | + * |
|
100 | + * If the relationship did not exist in the first place, fail silently. |
|
101 | + * |
|
102 | + * @param string $objId object id |
|
103 | + * @param string $objectType object type |
|
104 | + * @param string|array $tagIds tag id or array of tag ids to unassign |
|
105 | + * |
|
106 | + * @throws \OCP\SystemTag\TagNotFoundException if at least one of the |
|
107 | + * given tags does not exist |
|
108 | + * |
|
109 | + * @since 9.0.0 |
|
110 | + */ |
|
111 | + public function unassignTags($objId, $objectType, $tagIds); |
|
112 | 112 | |
113 | - /** |
|
114 | - * Checks whether the given objects have the given tag. |
|
115 | - * |
|
116 | - * @param string|array $objIds object ids |
|
117 | - * @param string $objectType object type |
|
118 | - * @param string $tagId tag id to check |
|
119 | - * @param bool $all true to check that ALL objects have the tag assigned, |
|
120 | - * false to check that at least ONE object has the tag. |
|
121 | - * |
|
122 | - * @return bool true if the condition set by $all is matched, false |
|
123 | - * otherwise |
|
124 | - * |
|
125 | - * @throws \OCP\SystemTag\TagNotFoundException if the tag does not exist |
|
126 | - * |
|
127 | - * @since 9.0.0 |
|
128 | - */ |
|
129 | - public function haveTag($objIds, $objectType, $tagId, $all = true); |
|
113 | + /** |
|
114 | + * Checks whether the given objects have the given tag. |
|
115 | + * |
|
116 | + * @param string|array $objIds object ids |
|
117 | + * @param string $objectType object type |
|
118 | + * @param string $tagId tag id to check |
|
119 | + * @param bool $all true to check that ALL objects have the tag assigned, |
|
120 | + * false to check that at least ONE object has the tag. |
|
121 | + * |
|
122 | + * @return bool true if the condition set by $all is matched, false |
|
123 | + * otherwise |
|
124 | + * |
|
125 | + * @throws \OCP\SystemTag\TagNotFoundException if the tag does not exist |
|
126 | + * |
|
127 | + * @since 9.0.0 |
|
128 | + */ |
|
129 | + public function haveTag($objIds, $objectType, $tagId, $all = true); |
|
130 | 130 | |
131 | 131 | } |
@@ -32,46 +32,46 @@ |
||
32 | 32 | */ |
33 | 33 | class SystemTagsEntityEvent extends Event { |
34 | 34 | |
35 | - const EVENT_ENTITY = 'OCP\SystemTag\ISystemTagManager::registerEntity'; |
|
35 | + const EVENT_ENTITY = 'OCP\SystemTag\ISystemTagManager::registerEntity'; |
|
36 | 36 | |
37 | - /** @var string */ |
|
38 | - protected $event; |
|
39 | - /** @var \Closure[] */ |
|
40 | - protected $collections; |
|
37 | + /** @var string */ |
|
38 | + protected $event; |
|
39 | + /** @var \Closure[] */ |
|
40 | + protected $collections; |
|
41 | 41 | |
42 | - /** |
|
43 | - * SystemTagsEntityEvent constructor. |
|
44 | - * |
|
45 | - * @param string $event |
|
46 | - * @since 9.1.0 |
|
47 | - */ |
|
48 | - public function __construct($event) { |
|
49 | - $this->event = $event; |
|
50 | - $this->collections = []; |
|
51 | - } |
|
42 | + /** |
|
43 | + * SystemTagsEntityEvent constructor. |
|
44 | + * |
|
45 | + * @param string $event |
|
46 | + * @since 9.1.0 |
|
47 | + */ |
|
48 | + public function __construct($event) { |
|
49 | + $this->event = $event; |
|
50 | + $this->collections = []; |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * @param string $name |
|
55 | - * @param \Closure $entityExistsFunction The closure should take one |
|
56 | - * argument, which is the id of the entity, that tags |
|
57 | - * should be handled for. The return should then be bool, |
|
58 | - * depending on whether tags are allowed (true) or not. |
|
59 | - * @throws \OutOfBoundsException when the entity name is already taken |
|
60 | - * @since 9.1.0 |
|
61 | - */ |
|
62 | - public function addEntityCollection($name, \Closure $entityExistsFunction) { |
|
63 | - if (isset($this->collections[$name])) { |
|
64 | - throw new \OutOfBoundsException('Duplicate entity name "' . $name . '"'); |
|
65 | - } |
|
53 | + /** |
|
54 | + * @param string $name |
|
55 | + * @param \Closure $entityExistsFunction The closure should take one |
|
56 | + * argument, which is the id of the entity, that tags |
|
57 | + * should be handled for. The return should then be bool, |
|
58 | + * depending on whether tags are allowed (true) or not. |
|
59 | + * @throws \OutOfBoundsException when the entity name is already taken |
|
60 | + * @since 9.1.0 |
|
61 | + */ |
|
62 | + public function addEntityCollection($name, \Closure $entityExistsFunction) { |
|
63 | + if (isset($this->collections[$name])) { |
|
64 | + throw new \OutOfBoundsException('Duplicate entity name "' . $name . '"'); |
|
65 | + } |
|
66 | 66 | |
67 | - $this->collections[$name] = $entityExistsFunction; |
|
68 | - } |
|
67 | + $this->collections[$name] = $entityExistsFunction; |
|
68 | + } |
|
69 | 69 | |
70 | - /** |
|
71 | - * @return \Closure[] |
|
72 | - * @since 9.1.0 |
|
73 | - */ |
|
74 | - public function getEntityCollections() { |
|
75 | - return $this->collections; |
|
76 | - } |
|
70 | + /** |
|
71 | + * @return \Closure[] |
|
72 | + * @since 9.1.0 |
|
73 | + */ |
|
74 | + public function getEntityCollections() { |
|
75 | + return $this->collections; |
|
76 | + } |
|
77 | 77 | } |
@@ -33,133 +33,133 @@ |
||
33 | 33 | */ |
34 | 34 | interface ISystemTagManager { |
35 | 35 | |
36 | - /** |
|
37 | - * Returns the tag objects matching the given tag ids. |
|
38 | - * |
|
39 | - * @param array|string $tagIds id or array of unique ids of the tag to retrieve |
|
40 | - * |
|
41 | - * @return \OCP\SystemTag\ISystemTag[] array of system tags with tag id as key |
|
42 | - * |
|
43 | - * @throws \InvalidArgumentException if at least one given tag ids is invalid (string instead of integer, etc.) |
|
44 | - * @throws \OCP\SystemTag\TagNotFoundException if at least one given tag ids did no exist |
|
45 | - * The message contains a json_encoded array of the ids that could not be found |
|
46 | - * |
|
47 | - * @since 9.0.0 |
|
48 | - */ |
|
49 | - public function getTagsByIds($tagIds); |
|
36 | + /** |
|
37 | + * Returns the tag objects matching the given tag ids. |
|
38 | + * |
|
39 | + * @param array|string $tagIds id or array of unique ids of the tag to retrieve |
|
40 | + * |
|
41 | + * @return \OCP\SystemTag\ISystemTag[] array of system tags with tag id as key |
|
42 | + * |
|
43 | + * @throws \InvalidArgumentException if at least one given tag ids is invalid (string instead of integer, etc.) |
|
44 | + * @throws \OCP\SystemTag\TagNotFoundException if at least one given tag ids did no exist |
|
45 | + * The message contains a json_encoded array of the ids that could not be found |
|
46 | + * |
|
47 | + * @since 9.0.0 |
|
48 | + */ |
|
49 | + public function getTagsByIds($tagIds); |
|
50 | 50 | |
51 | - /** |
|
52 | - * Returns the tag object matching the given attributes. |
|
53 | - * |
|
54 | - * @param string $tagName tag name |
|
55 | - * @param bool $userVisible whether the tag is visible by users |
|
56 | - * @param bool $userAssignable whether the tag is assignable by users |
|
57 | - * |
|
58 | - * @return \OCP\SystemTag\ISystemTag system tag |
|
59 | - * |
|
60 | - * @throws \OCP\SystemTag\TagNotFoundException if tag does not exist |
|
61 | - * |
|
62 | - * @since 9.0.0 |
|
63 | - */ |
|
64 | - public function getTag($tagName, $userVisible, $userAssignable); |
|
51 | + /** |
|
52 | + * Returns the tag object matching the given attributes. |
|
53 | + * |
|
54 | + * @param string $tagName tag name |
|
55 | + * @param bool $userVisible whether the tag is visible by users |
|
56 | + * @param bool $userAssignable whether the tag is assignable by users |
|
57 | + * |
|
58 | + * @return \OCP\SystemTag\ISystemTag system tag |
|
59 | + * |
|
60 | + * @throws \OCP\SystemTag\TagNotFoundException if tag does not exist |
|
61 | + * |
|
62 | + * @since 9.0.0 |
|
63 | + */ |
|
64 | + public function getTag($tagName, $userVisible, $userAssignable); |
|
65 | 65 | |
66 | - /** |
|
67 | - * Creates the tag object using the given attributes. |
|
68 | - * |
|
69 | - * @param string $tagName tag name |
|
70 | - * @param bool $userVisible whether the tag is visible by users |
|
71 | - * @param bool $userAssignable whether the tag is assignable by users |
|
72 | - * |
|
73 | - * @return \OCP\SystemTag\ISystemTag system tag |
|
74 | - * |
|
75 | - * @throws \OCP\SystemTag\TagAlreadyExistsException if tag already exists |
|
76 | - * |
|
77 | - * @since 9.0.0 |
|
78 | - */ |
|
79 | - public function createTag($tagName, $userVisible, $userAssignable); |
|
66 | + /** |
|
67 | + * Creates the tag object using the given attributes. |
|
68 | + * |
|
69 | + * @param string $tagName tag name |
|
70 | + * @param bool $userVisible whether the tag is visible by users |
|
71 | + * @param bool $userAssignable whether the tag is assignable by users |
|
72 | + * |
|
73 | + * @return \OCP\SystemTag\ISystemTag system tag |
|
74 | + * |
|
75 | + * @throws \OCP\SystemTag\TagAlreadyExistsException if tag already exists |
|
76 | + * |
|
77 | + * @since 9.0.0 |
|
78 | + */ |
|
79 | + public function createTag($tagName, $userVisible, $userAssignable); |
|
80 | 80 | |
81 | - /** |
|
82 | - * Returns all known tags, optionally filtered by visibility. |
|
83 | - * |
|
84 | - * @param bool|null $visibilityFilter filter by visibility if non-null |
|
85 | - * @param string $nameSearchPattern optional search pattern for the tag name |
|
86 | - * |
|
87 | - * @return \OCP\SystemTag\ISystemTag[] array of system tags or empty array if none found |
|
88 | - * |
|
89 | - * @since 9.0.0 |
|
90 | - */ |
|
91 | - public function getAllTags($visibilityFilter = null, $nameSearchPattern = null); |
|
81 | + /** |
|
82 | + * Returns all known tags, optionally filtered by visibility. |
|
83 | + * |
|
84 | + * @param bool|null $visibilityFilter filter by visibility if non-null |
|
85 | + * @param string $nameSearchPattern optional search pattern for the tag name |
|
86 | + * |
|
87 | + * @return \OCP\SystemTag\ISystemTag[] array of system tags or empty array if none found |
|
88 | + * |
|
89 | + * @since 9.0.0 |
|
90 | + */ |
|
91 | + public function getAllTags($visibilityFilter = null, $nameSearchPattern = null); |
|
92 | 92 | |
93 | - /** |
|
94 | - * Updates the given tag |
|
95 | - * |
|
96 | - * @param string $tagId tag id |
|
97 | - * @param string $newName the new tag name |
|
98 | - * @param bool $userVisible whether the tag is visible by users |
|
99 | - * @param bool $userAssignable whether the tag is assignable by users |
|
100 | - * |
|
101 | - * @throws \OCP\SystemTag\TagNotFoundException if tag with the given id does not exist |
|
102 | - * @throws \OCP\SystemTag\TagAlreadyExistsException if there is already another tag |
|
103 | - * with the same attributes |
|
104 | - * |
|
105 | - * @since 9.0.0 |
|
106 | - */ |
|
107 | - public function updateTag($tagId, $newName, $userVisible, $userAssignable); |
|
93 | + /** |
|
94 | + * Updates the given tag |
|
95 | + * |
|
96 | + * @param string $tagId tag id |
|
97 | + * @param string $newName the new tag name |
|
98 | + * @param bool $userVisible whether the tag is visible by users |
|
99 | + * @param bool $userAssignable whether the tag is assignable by users |
|
100 | + * |
|
101 | + * @throws \OCP\SystemTag\TagNotFoundException if tag with the given id does not exist |
|
102 | + * @throws \OCP\SystemTag\TagAlreadyExistsException if there is already another tag |
|
103 | + * with the same attributes |
|
104 | + * |
|
105 | + * @since 9.0.0 |
|
106 | + */ |
|
107 | + public function updateTag($tagId, $newName, $userVisible, $userAssignable); |
|
108 | 108 | |
109 | - /** |
|
110 | - * Delete the given tags from the database and all their relationships. |
|
111 | - * |
|
112 | - * @param string|array $tagIds array of tag ids |
|
113 | - * |
|
114 | - * @throws \OCP\SystemTag\TagNotFoundException if at least one tag did not exist |
|
115 | - * |
|
116 | - * @since 9.0.0 |
|
117 | - */ |
|
118 | - public function deleteTags($tagIds); |
|
109 | + /** |
|
110 | + * Delete the given tags from the database and all their relationships. |
|
111 | + * |
|
112 | + * @param string|array $tagIds array of tag ids |
|
113 | + * |
|
114 | + * @throws \OCP\SystemTag\TagNotFoundException if at least one tag did not exist |
|
115 | + * |
|
116 | + * @since 9.0.0 |
|
117 | + */ |
|
118 | + public function deleteTags($tagIds); |
|
119 | 119 | |
120 | - /** |
|
121 | - * Checks whether the given user is allowed to assign/unassign the tag with the |
|
122 | - * given id. |
|
123 | - * |
|
124 | - * @param ISystemTag $tag tag to check permission for |
|
125 | - * @param IUser $user user to check permission for |
|
126 | - * |
|
127 | - * @return true if the user is allowed to assign/unassign the tag, false otherwise |
|
128 | - * |
|
129 | - * @since 9.1.0 |
|
130 | - */ |
|
131 | - public function canUserAssignTag(ISystemTag $tag, IUser $user); |
|
120 | + /** |
|
121 | + * Checks whether the given user is allowed to assign/unassign the tag with the |
|
122 | + * given id. |
|
123 | + * |
|
124 | + * @param ISystemTag $tag tag to check permission for |
|
125 | + * @param IUser $user user to check permission for |
|
126 | + * |
|
127 | + * @return true if the user is allowed to assign/unassign the tag, false otherwise |
|
128 | + * |
|
129 | + * @since 9.1.0 |
|
130 | + */ |
|
131 | + public function canUserAssignTag(ISystemTag $tag, IUser $user); |
|
132 | 132 | |
133 | - /** |
|
134 | - * Checks whether the given user is allowed to see the tag with the given id. |
|
135 | - * |
|
136 | - * @param ISystemTag $tag tag to check permission for |
|
137 | - * @param IUser $user user to check permission for |
|
138 | - * |
|
139 | - * @return true if the user can see the tag, false otherwise |
|
140 | - * |
|
141 | - * @since 9.1.0 |
|
142 | - */ |
|
143 | - public function canUserSeeTag(ISystemTag $tag, IUser $userId); |
|
133 | + /** |
|
134 | + * Checks whether the given user is allowed to see the tag with the given id. |
|
135 | + * |
|
136 | + * @param ISystemTag $tag tag to check permission for |
|
137 | + * @param IUser $user user to check permission for |
|
138 | + * |
|
139 | + * @return true if the user can see the tag, false otherwise |
|
140 | + * |
|
141 | + * @since 9.1.0 |
|
142 | + */ |
|
143 | + public function canUserSeeTag(ISystemTag $tag, IUser $userId); |
|
144 | 144 | |
145 | - /** |
|
146 | - * Set groups that can assign a given tag. |
|
147 | - * |
|
148 | - * @param ISystemTag $tag tag for group assignment |
|
149 | - * @param string[] $groupIds group ids of groups that can assign/unassign the tag |
|
150 | - * |
|
151 | - * @since 9.1.0 |
|
152 | - */ |
|
153 | - public function setTagGroups(ISystemTag $tag, $groupIds); |
|
145 | + /** |
|
146 | + * Set groups that can assign a given tag. |
|
147 | + * |
|
148 | + * @param ISystemTag $tag tag for group assignment |
|
149 | + * @param string[] $groupIds group ids of groups that can assign/unassign the tag |
|
150 | + * |
|
151 | + * @since 9.1.0 |
|
152 | + */ |
|
153 | + public function setTagGroups(ISystemTag $tag, $groupIds); |
|
154 | 154 | |
155 | - /** |
|
156 | - * Get groups that can assign a given tag. |
|
157 | - * |
|
158 | - * @param ISystemTag $tag tag for group assignment |
|
159 | - * |
|
160 | - * @return string[] group ids of groups that can assign/unassign the tag |
|
161 | - * |
|
162 | - * @since 9.1.0 |
|
163 | - */ |
|
164 | - public function getTagGroups(ISystemTag $tag); |
|
155 | + /** |
|
156 | + * Get groups that can assign a given tag. |
|
157 | + * |
|
158 | + * @param ISystemTag $tag tag for group assignment |
|
159 | + * |
|
160 | + * @return string[] group ids of groups that can assign/unassign the tag |
|
161 | + * |
|
162 | + * @since 9.1.0 |
|
163 | + */ |
|
164 | + public function getTagGroups(ISystemTag $tag); |
|
165 | 165 | } |
@@ -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 | } |