From 6235175b6dba4ab416db60a21559a69db2defa83 Mon Sep 17 00:00:00 2001 From: Daniel Kesselberg Date: Tue, 11 Feb 2020 21:40:01 +0100 Subject: Make TAG_FAVORITE public Signed-off-by: Daniel Kesselberg --- lib/private/Tags.php | 19 +++++++++---------- lib/public/ITags.php | 4 ++++ 2 files changed, 13 insertions(+), 10 deletions(-) (limited to 'lib') diff --git a/lib/private/Tags.php b/lib/private/Tags.php index 0aa37161eb2..fe24391a1a5 100644 --- a/lib/private/Tags.php +++ b/lib/private/Tags.php @@ -48,8 +48,9 @@ use OC\Tagging\Tag; use OC\Tagging\TagMapper; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\ILogger; +use OCP\ITags; -class Tags implements \OCP\ITags { +class Tags implements ITags { /** * Tags @@ -112,8 +113,6 @@ class Tags implements \OCP\ITags { const TAG_TABLE = '*PREFIX*vcategory'; const RELATION_TABLE = '*PREFIX*vcategory_to_object'; - const TAG_FAVORITE = '_$!!$_'; - /** * Constructor. * @@ -186,7 +185,7 @@ class Tags implements \OCP\ITags { $tagMap = array(); foreach($this->tags as $tag) { - if($tag->getName() !== self::TAG_FAVORITE) { + if($tag->getName() !== ITags::TAG_FAVORITE) { $tagMap[] = $this->tagMap($tag); } } @@ -624,12 +623,12 @@ class Tags implements \OCP\ITags { * @return array|false An array of object ids. */ public function getFavorites() { - if(!$this->userHasTag(self::TAG_FAVORITE, $this->user)) { + if(!$this->userHasTag(ITags::TAG_FAVORITE, $this->user)) { return []; } try { - return $this->getIdsForTag(self::TAG_FAVORITE); + return $this->getIdsForTag(ITags::TAG_FAVORITE); } catch(\Exception $e) { \OC::$server->getLogger()->logException($e, [ 'message' => __METHOD__, @@ -647,10 +646,10 @@ class Tags implements \OCP\ITags { * @return boolean */ public function addToFavorites($objid) { - if(!$this->userHasTag(self::TAG_FAVORITE, $this->user)) { - $this->add(self::TAG_FAVORITE); + if(!$this->userHasTag(ITags::TAG_FAVORITE, $this->user)) { + $this->add(ITags::TAG_FAVORITE); } - return $this->tagAs($objid, self::TAG_FAVORITE); + return $this->tagAs($objid, ITags::TAG_FAVORITE); } /** @@ -660,7 +659,7 @@ class Tags implements \OCP\ITags { * @return boolean */ public function removeFromFavorites($objid) { - return $this->unTag($objid, self::TAG_FAVORITE); + return $this->unTag($objid, ITags::TAG_FAVORITE); } /** diff --git a/lib/public/ITags.php b/lib/public/ITags.php index 27b274f4dd6..35469f4f804 100644 --- a/lib/public/ITags.php +++ b/lib/public/ITags.php @@ -53,6 +53,10 @@ use OC\Tags; */ interface ITags { + /** + * @since 19.0.0 + */ + public const TAG_FAVORITE = '_$!!$_'; /** * Check if any tags are saved for this type and user. -- cgit v1.2.3