From bc011b0cc46ddebce5ae57f7be14ad15b4798e33 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Mon, 19 Mar 2012 10:38:53 +0100 Subject: [PATCH] Adds objectTypeId parameter to ClipboardHandler::hasMarkedItems() This way, you can check if the user has marked item of the type of objects listed at the current page and not if the user has marked some items of a completely other type you currently don't care about at all. --- .../system/clipboard/ClipboardHandler.class.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/wcfsetup/install/files/lib/system/clipboard/ClipboardHandler.class.php b/wcfsetup/install/files/lib/system/clipboard/ClipboardHandler.class.php index 000b83b2da..601785603f 100644 --- a/wcfsetup/install/files/lib/system/clipboard/ClipboardHandler.class.php +++ b/wcfsetup/install/files/lib/system/clipboard/ClipboardHandler.class.php @@ -300,18 +300,25 @@ class ClipboardHandler extends SingletonFactory { } /** - * Returns true (1) if at least one item is marked. + * Returns true (1) if at least one item (of the given object type) is marked. * + * @param integer $objectTypeID * @return integer */ - public function hasMarkedItems() { + public function hasMarkedItems($objectTypeID = null) { if (!WCF::getUser()->userID) return 0; + $conditionBuilder = new PreparedStatementConditionBuilder(); + $conditionBuilder->add("userID = ?", array(WCF::getUser()->userID)); + if ($objectTypeID !== null) { + $conditionBuilder->add("objectTypeID = ?", array($objectTypeID)); + } + $sql = "SELECT COUNT(*) AS count FROM wcf".WCF_N."_clipboard_item - WHERE userID = ?"; + ".$conditionBuilder; $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute(array(WCF::getUser()->userID)); + $statement->execute($conditionBuilder->getParameters()); $count = $statement->fetchArray(); if ($count['count']) { -- 2.20.1