From: Matthias Schmidt Date: Mon, 19 Mar 2012 09:38:53 +0000 (+0100) Subject: Adds objectTypeId parameter to ClipboardHandler::hasMarkedItems() X-Git-Tag: 2.0.0_Beta_1~1204^2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=bc011b0cc46ddebce5ae57f7be14ad15b4798e33;p=GitHub%2FWoltLab%2FWCF.git 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. --- 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']) {