From 1aba7b59795983ac4cc575d2abbf9ea22125267d Mon Sep 17 00:00:00 2001 From: cdujeu Date: Mon, 8 Sep 2014 17:33:01 +0200 Subject: [PATCH] MetaComments: Fix comments inheritance when filenames are similar (e.g; doc / docx) --- .../feed.sql/class.AJXP_SqlFeedStore.php | 17 ++++++++++++----- .../meta.comments/class.CommentsMetaManager.php | 13 ++++++++++++- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/core/src/plugins/feed.sql/class.AJXP_SqlFeedStore.php b/core/src/plugins/feed.sql/class.AJXP_SqlFeedStore.php index ebd18bc6db..4b5a5611a1 100644 --- a/core/src/plugins/feed.sql/class.AJXP_SqlFeedStore.php +++ b/core/src/plugins/feed.sql/class.AJXP_SqlFeedStore.php @@ -281,15 +281,22 @@ public function persistMetaObject($indexPath, $data, $repositoryId, $repositoryS } } - public function findMetaObjectsByIndexPath($repositoryId, $indexPath, $userId, $userGroup, $offset = 0, $limit = 20, $orderBy = "date", $orderDir = "desc") + public function findMetaObjectsByIndexPath($repositoryId, $indexPath, $userId, $userGroup, $offset = 0, $limit = 20, $orderBy = "date", $orderDir = "desc", $recurring = true) { if($this->sqlDriver["password"] == "XXXX") return array(); require_once(AJXP_BIN_FOLDER."/dibi.compact.php"); dibi::connect($this->sqlDriver); - $res = dibi::query("SELECT * FROM [ajxp_feed] - WHERE [etype] = %s AND [repository_id] = %s AND [index_path] LIKE %like~ - ORDER BY %by %lmt %ofs - ", "meta", $repositoryId, $indexPath, array('edate' => $orderDir), $limit, $offset); + if($recurring){ + $res = dibi::query("SELECT * FROM [ajxp_feed] + WHERE [etype] = %s AND [repository_id] = %s AND [index_path] LIKE %like~ + ORDER BY %by %lmt %ofs + ", "meta", $repositoryId, $indexPath, array('edate' => $orderDir), $limit, $offset); + }else{ + $res = dibi::query("SELECT * FROM [ajxp_feed] + WHERE [etype] = %s AND [repository_id] = %s AND [index_path] = %s + ORDER BY %by %lmt %ofs + ", "meta", $repositoryId, $indexPath, array('edate' => $orderDir), $limit, $offset); + } $data = array(); foreach ($res as $n => $row) { diff --git a/core/src/plugins/meta.comments/class.CommentsMetaManager.php b/core/src/plugins/meta.comments/class.CommentsMetaManager.php index 971170049b..0d21365ff7 100644 --- a/core/src/plugins/meta.comments/class.CommentsMetaManager.php +++ b/core/src/plugins/meta.comments/class.CommentsMetaManager.php @@ -146,7 +146,18 @@ public function switchActions($actionName, $httpVars, $fileVars) $sortDir = isSet($httpVars["sort_dir"])?AJXP_Utils::decodeSecureMagic($httpVars["sort_dir"]):"asc"; $offset = isSet($httpVars["offset"]) ? intval($httpVars["offset"]) : 0; $limit = isSet($httpVars["limit"]) ? intval($httpVars["limit"]) : 100; - $data = $feedStore->findMetaObjectsByIndexPath($this->accessDriver->repository->getId(), $uniqNode->getPath(), AuthService::getLoggedUser()->getId(), AuthService::getLoggedUser()->getGroupPath(), $offset, $limit, $sortBy, $sortDir); + $uniqNode->loadNodeInfo(); + $data = $feedStore->findMetaObjectsByIndexPath( + $this->accessDriver->repository->getId(), + $uniqNode->getPath(), + AuthService::getLoggedUser()->getId(), + AuthService::getLoggedUser()->getGroupPath(), + $offset, + $limit, + $sortBy, + $sortDir, + !$uniqNode->isLeaf() + ); $theFeed = array(); foreach ($data as $stdObject) { $rPath = substr($stdObject->path, strlen($uniqNode->getPath()));