From b3aac5244953f22d63cefdb77861b63f15cfb143 Mon Sep 17 00:00:00 2001 From: korelstar Date: Fri, 21 Feb 2020 20:59:47 +0100 Subject: [PATCH] TAG_FAVORITE was moved in NC19 --- lib/Db/Note.php | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/lib/Db/Note.php b/lib/Db/Note.php index d636757ca..69411de1e 100644 --- a/lib/Db/Note.php +++ b/lib/Db/Note.php @@ -38,8 +38,6 @@ class Note extends Entity { public $error = false; public $errorMessage=''; - private const TAG_FAVORITE = \OC\Tags::TAG_FAVORITE; // @phan-suppress-current-line PhanUndeclaredClassConstant - public function __construct() { $this->addType('modified', 'integer'); $this->addType('favorite', 'boolean'); @@ -84,15 +82,30 @@ private static function convertEncoding($str) { return $str; } + // TODO NC19: replace this by OCP\ITags::TAG_FAVORITE + // OCP\ITags::TAG_FAVORITE was introduced in NC19 + // https://github.com/nextcloud/server/pull/19412 + /** + * @suppress PhanUndeclaredClassConstant + * @suppress PhanUndeclaredConstant + * @suppress PhanUndeclaredConstantOfClass + */ + private static function getTagFavorite() { + if (defined('OCP\ITags::TAG_FAVORITE')) { + return \OCP\ITags::TAG_FAVORITE; + } else { + return \OC\Tags::TAG_FAVORITE; + } + } + private function initCommonBaseFields(File $file, Folder $notesFolder, $tags) { $this->setId($file->getId()); $this->setTitle(pathinfo($file->getName(), PATHINFO_FILENAME)); // remove extension $this->setModified($file->getMTime()); $subdir = substr(dirname($file->getPath()), strlen($notesFolder->getPath())+1); $this->setCategory($subdir ? $subdir : ''); - if (is_array($tags) && in_array(self::TAG_FAVORITE, $tags)) { + if (is_array($tags) && in_array(self::getTagFavorite(), $tags)) { $this->setFavorite(true); - //unset($tags[array_search(self::TAG_FAVORITE, $tags)]); } }