Fixed various clipboard action errors
authorAlexander Ebert <ebert@woltlab.com>
Thu, 8 Sep 2011 13:57:38 +0000 (15:57 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 8 Sep 2011 13:57:38 +0000 (15:57 +0200)
com.woltlab.wcf/clipboardaction.xml
wcfsetup/install/files/lib/system/package/plugin/ClipboardActionPackageInstallationPlugin.class.php

index ced15c163b8eeb4b4e75fca0a4a5d2e6c653aa65..6f3702e0d333a1ce2b904bbe67aedd6c970eb3f7 100644 (file)
@@ -25,7 +25,7 @@
                        </pages>
                </action>
 
-               <action name="exportMailAdress">
+               <action name="exportMailAddress">
                        <actionclassname><![CDATA[wcf\system\clipboard\action\UserClipboardAction]]></actionclassname>
                        <showorder>4</showorder>
                        <pages>
index 161b252210f741171442a39c48a04789ce74ce75..90f1cefd9be8d53318c56012cdec8c4ce6aadd73 100644 (file)
@@ -18,6 +18,12 @@ class ClipboardActionPackageInstallationPlugin extends AbstractXMLPackageInstall
         */
        public $className = 'wcf\data\clipboard\action\ClipboardActionEditor';
        
+       /**
+        * list of pages per action id
+        * @var array<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
+                                       ));
+                               }
+                       }
                }
        }
 }