From 66ce64ae8cc624e222a9726ead7bf52ca436380e Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Thu, 8 Sep 2011 15:57:38 +0200 Subject: [PATCH] Fixed various clipboard action errors --- com.woltlab.wcf/clipboardaction.xml | 2 +- ...dActionPackageInstallationPlugin.class.php | 46 ++++++++++++++----- 2 files changed, 36 insertions(+), 12 deletions(-) diff --git a/com.woltlab.wcf/clipboardaction.xml b/com.woltlab.wcf/clipboardaction.xml index ced15c163b..6f3702e0d3 100644 --- a/com.woltlab.wcf/clipboardaction.xml +++ b/com.woltlab.wcf/clipboardaction.xml @@ -25,7 +25,7 @@ - + 4 diff --git a/wcfsetup/install/files/lib/system/package/plugin/ClipboardActionPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/ClipboardActionPackageInstallationPlugin.class.php index 161b252210..90f1cefd9b 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/ClipboardActionPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/ClipboardActionPackageInstallationPlugin.class.php @@ -18,6 +18,12 @@ class ClipboardActionPackageInstallationPlugin extends AbstractXMLPackageInstall */ public $className = 'wcf\data\clipboard\action\ClipboardActionEditor'; + /** + * list of pages per action id + * @var array + */ + protected $pages = array(); + /** * @see wcf\system\package\plugin\AbstractPackageInstallationPlugin::$tableName */ @@ -73,6 +79,7 @@ class ClipboardActionPackageInstallationPlugin extends AbstractXMLPackageInstall return array( 'actionClassName' => $data['elements']['actionclassname'], 'actionName' => $data['attributes']['name'], + 'pages' => $data['elements']['pages'], 'showOrder' => $showOrder ); } @@ -100,25 +107,42 @@ class ClipboardActionPackageInstallationPlugin extends AbstractXMLPackageInstall * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::import() */ protected function import(array $row, array $data) { + // extract pages + $pages = $data['pages']; + unset($data['pages']); + + // import or update action $object = parent::import($row, $data); + // store pages for later import + $this->pages[$object->actionID] = $pages; + } + + /** + * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::postImport() + */ + protected function postImport() { // clear pages $sql = "DELETE FROM wcf".WCF_N."_clipboard_page WHERE packageID = ?"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute(array($this->installation->getPackageID())); - // insert pages - $sql = "INSERT INTO wcf".WCF_N."_clipboard_page - (pageClassName, packageID, actionID) - VALUES (?, ?, ?)"; - $statement = WCF::getDB()->prepareStatement($sql); - foreach ($data['pages'] as $pageClassName) { - $statement->execute(array( - $pageClassName, - $this->installation->getPackageID(), - $object->actionID - )); + if (count($this->pages)) { + // insert pages + $sql = "INSERT INTO wcf".WCF_N."_clipboard_page + (pageClassName, packageID, actionID) + VALUES (?, ?, ?)"; + $statement = WCF::getDB()->prepareStatement($sql); + foreach ($this->pages as $actionID => $pages) { + foreach ($pages as $pageClassName) { + $statement->execute(array( + $pageClassName, + $this->installation->getPackageID(), + $actionID + )); + } + } } } } -- 2.20.1