Updates pip file names
authorMatthias Schmidt <gravatronics@live.com>
Wed, 24 Aug 2011 19:34:53 +0000 (21:34 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Wed, 24 Aug 2011 19:34:53 +0000 (21:34 +0200)
18 files changed:
wcfsetup/install/files/lib/system/package/plugin/ACPTemplatePackageInstallationPlugin.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/package/plugin/ACPTemplatesPackageInstallationPlugin.class.php [deleted file]
wcfsetup/install/files/lib/system/package/plugin/CronjobPackageInstallationPlugin.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/package/plugin/CronjobsPackageInstallationPlugin.class.php [deleted file]
wcfsetup/install/files/lib/system/package/plugin/FilePackageInstallationPlugin.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/package/plugin/FilesPackageInstallationPlugin.class.php [deleted file]
wcfsetup/install/files/lib/system/package/plugin/LanguagePackageInstallationPlugin.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/package/plugin/LanguagesPackageInstallationPlugin.class.php [deleted file]
wcfsetup/install/files/lib/system/package/plugin/OptionPackageInstallationPlugin.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/package/plugin/OptionsPackageInstallationPlugin.class.php [deleted file]
wcfsetup/install/files/lib/system/package/plugin/StyleAttributePackageInstallationPlugin.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/package/plugin/StyleAttributesPackageInstallationPlugin.class.php [deleted file]
wcfsetup/install/files/lib/system/package/plugin/TemplatePackageInstallationPlugin.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/package/plugin/TemplatesPackageInstallationPlugin.class.php [deleted file]
wcfsetup/install/files/lib/system/package/plugin/UserGroupOptionPackageInstallationPlugin.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/package/plugin/UserGroupOptionsPackageInstallationPlugin.class.php [deleted file]
wcfsetup/install/files/lib/system/package/plugin/UserOptionPackageInstallationPlugin.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/package/plugin/UserOptionsPackageInstallationPlugin.class.php [deleted file]

diff --git a/wcfsetup/install/files/lib/system/package/plugin/ACPTemplatePackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/ACPTemplatePackageInstallationPlugin.class.php
new file mode 100644 (file)
index 0000000..d63f068
--- /dev/null
@@ -0,0 +1,88 @@
+<?php
+namespace wcf\system\package\plugin;
+use wcf\system\exception\SystemException;
+use wcf\system\io\Tar;
+use wcf\system\package\ACPTemplatesFileHandler;
+use wcf\system\WCF;
+use wcf\util\FileUtil;
+
+/**
+ * This PIP installs, updates or deletes by a package delivered ACP templates.
+ *
+ * @author     Benjamin Kunz
+ * @copyright  2001-2011 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    com.woltlab.wcf
+ * @subpackage system.package.plugin
+ * @category   Community Framework
+ */
+class ACPTemplatePackageInstallationPlugin extends AbstractPackageInstallationPlugin {
+       /**
+        * @see wcf\system\package\plugin\AbstractPackageInstallationPlugin::$tableName
+        */
+       public $tableName = 'acp_template';
+       
+       /**
+        * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::$tagName
+        */     
+       public $tagName = 'acptemplate';
+
+       /**
+        * @see wcf\system\package\plugin\IPackageInstallationPlugin::install()
+        */
+       public function install() {
+               parent::install();
+
+               // extract files.tar to temp folder
+               $sourceFile = $this->installation->getArchive()->extractTar($this->instruction['value'], 'acptemplates_');
+               
+               // create file handler
+               $fileHandler = new ACPTemplatesFileHandler($this->installation);
+               
+               // extract content of files.tar
+               $packageDir = FileUtil::addTrailingSlash(FileUtil::getRealPath(WCF_DIR.$this->installation->getPackage()->packageDir));
+               
+               try {
+                       $fileInstaller = $this->installation->extractFiles($packageDir.'acp/templates/', $sourceFile, $fileHandler);
+               }
+               catch (SystemException $e) {
+                       WCF::getTPL()->assign(array(
+                               'exception' => $e
+                       ));
+                       WCF::getTPL()->display('packageInstallationFileInstallationFailed');
+                       exit;
+               }
+               
+               // delete temporary sourceArchive
+               @unlink($sourceFile);
+       }
+       
+       /**
+        * @see wcf\system\package\plugin\IPackageInstallationPlugin::uninstall()
+        */
+       public function uninstall() {
+               // create ACP-templates list
+               $templates = array();
+               
+               // get ACP-templates from log
+               $sql = "SELECT  *
+                       FROM    wcf".WCF_N."_acp_template
+                       WHERE   packageID = ?";
+               $statement = WCF::getDB()->prepareStatement($sql);
+               $statement->execute(array($this->installation->getPackageID()));
+               while ($row = $statement->fetchArray()) {
+                       // store acp template with suffix (_$packageID)
+                       $templates[] = 'acp/templates/'.$row['templateName'].'.tpl';
+               }
+               
+               if (count($templates) > 0) {
+                       // delete template files
+                       $packageDir = FileUtil::addTrailingSlash(FileUtil::getRealPath(WCF_DIR.$this->installation->getPackage()->packageDir));
+                       $deleteEmptyDirectories = $this->installation->getPackage()->standalone;
+                       $this->installation->deleteFiles($packageDir, $templates, false, $deleteEmptyDirectories);
+                       
+                       // delete log entries
+                       parent::uninstall();
+               }
+       }
+}
diff --git a/wcfsetup/install/files/lib/system/package/plugin/ACPTemplatesPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/ACPTemplatesPackageInstallationPlugin.class.php
deleted file mode 100644 (file)
index 5346708..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-<?php
-namespace wcf\system\package\plugin;
-use wcf\system\exception\SystemException;
-use wcf\system\io\Tar;
-use wcf\system\package\ACPTemplatesFileHandler;
-use wcf\system\WCF;
-use wcf\util\FileUtil;
-
-/**
- * This PIP installs, updates or deletes by a package delivered ACP-templates.
- *
- * @author     Benjamin Kunz
- * @copyright  2001-2011 WoltLab GmbH
- * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package    com.woltlab.wcf
- * @subpackage system.package.plugin
- * @category   Community Framework
- */
-class ACPTemplatesPackageInstallationPlugin extends AbstractPackageInstallationPlugin {
-       /**
-        * @see wcf\system\package\plugin\AbstractPackageInstallationPlugin::$tableName
-        */
-       public $tableName = 'acp_template';
-       
-       /**
-        * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::$tagName
-        */     
-       public $tagName = 'acptemplates';
-
-       /**
-        * @see wcf\system\package\plugin\IPackageInstallationPlugin::install()
-        */
-       public function install() {
-               parent::install();
-
-               // extract files.tar to temp folder
-               $sourceFile = $this->installation->getArchive()->extractTar($this->instruction['value'], 'acptemplates_');
-               
-               // create file handler
-               $fileHandler = new ACPTemplatesFileHandler($this->installation);
-               
-               // extract content of files.tar
-               $packageDir = FileUtil::addTrailingSlash(FileUtil::getRealPath(WCF_DIR.$this->installation->getPackage()->packageDir));
-               
-               try {
-                       $fileInstaller = $this->installation->extractFiles($packageDir.'acp/templates/', $sourceFile, $fileHandler);
-               }
-               catch (SystemException $e) {
-                       WCF::getTPL()->assign(array(
-                               'exception' => $e
-                       ));
-                       WCF::getTPL()->display('packageInstallationFileInstallationFailed');
-                       exit;
-               }
-               
-               // delete temporary sourceArchive
-               @unlink($sourceFile);
-       }
-       
-       /**
-        * @see wcf\system\package\plugin\IPackageInstallationPlugin::uninstall()
-        */
-       public function uninstall() {
-               // create ACP-templates list
-               $templates = array();
-               
-               // get ACP-templates from log
-               $sql = "SELECT  *
-                       FROM    wcf".WCF_N."_acp_template
-                       WHERE   packageID = ?";
-               $statement = WCF::getDB()->prepareStatement($sql);
-               $statement->execute(array($this->installation->getPackageID()));
-               while ($row = $statement->fetchArray()) {
-                       // store acp template with suffix (_$packageID)
-                       $templates[] = 'acp/templates/'.$row['templateName'].'.tpl';
-               }
-               
-               if (count($templates) > 0) {
-                       // delete template files
-                       $packageDir = FileUtil::addTrailingSlash(FileUtil::getRealPath(WCF_DIR.$this->installation->getPackage()->packageDir));
-                       $deleteEmptyDirectories = $this->installation->getPackage()->standalone;
-                       $this->installation->deleteFiles($packageDir, $templates, false, $deleteEmptyDirectories);
-                       
-                       // delete log entries
-                       parent::uninstall();
-               }
-       }
-}
diff --git a/wcfsetup/install/files/lib/system/package/plugin/CronjobPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/CronjobPackageInstallationPlugin.class.php
new file mode 100644 (file)
index 0000000..21b8817
--- /dev/null
@@ -0,0 +1,88 @@
+<?php
+namespace wcf\system\package\plugin;
+use wcf\system\WCF;
+use wcf\util\CronjobUtil;
+
+/**
+ * This PIP installs, updates or deletes cronjobs.
+ * 
+ * @author     Alexander Ebert
+ * @copyright  2001-2011 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    com.woltlab.wcf
+ * @subpackage acp.package.plugin
+ * @category   Community Framework
+ */
+class CronjobPackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin {
+       /**
+        * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::$className
+        */
+       public $className = 'wcf\data\cronjob\CronjobEditor';
+       
+       /**
+        * @see wcf\system\package\plugin\AbstractPackageInstallationPlugin::$tableName
+        */
+       public $tableName = 'cronjob';
+       
+       /**
+        * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::$tagName
+        */     
+       public $tagName = 'cronjob';
+       
+       /**
+        * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::handleDelete()
+        */
+       protected function handleDelete(array $items) {
+               $sql = "DELETE FROM     wcf".WCF_N."_".$this->tableName."
+                       WHERE           className = ?
+                                       AND packageID = ?";
+               $statement = WCF::getDB()->prepareStatement($sql);
+               foreach ($items as $item) {
+                       $statement->execute(array(
+                               $item['attributes']['classname'],
+                               $this->installation->getPackageID()
+                       ));
+               }
+       }
+       
+       /**
+        * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::prepareImport()
+        */
+       protected function prepareImport(array $data) {
+               return array(
+                       'active' => (isset($data['elements']['active'])) ? intval($data['elements']['active']) : 1,
+                       'canBeDisabled' => (isset($data['elements']['canbedisabled'])) ? intval($data['elements']['canbedisabled']) : 1,
+                       'canBeEdited' => (isset($data['elements']['canbeedited'])) ? intval($data['elements']['canbeedited']) : 1,
+                       'className' => (isset($data['elements']['classname'])) ? $data['elements']['classname'] : '',
+                       'description' => (isset($data['elements']['description'])) ? $data['elements']['description'] : '',
+                       'startDom' => $data['elements']['startdom'],
+                       'startDow' => $data['elements']['startdow'],
+                       'startHour' => $data['elements']['starthour'],
+                       'startMinute' => $data['elements']['startminute'],
+                       'startMonth' => $data['elements']['startmonth']
+               );
+       }
+       
+       /**
+        * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::validateImport()
+        */
+       protected function validateImport(array $data) {
+               CronjobUtil::validate($data['startMinute'], $data['startHour'], $data['startDom'], $data['startMonth'], $data['startDow']);
+       }
+       
+       /**
+        * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::findExistingItem()
+        */
+       protected function findExistingItem(array $data) {
+               return null;
+       }
+       
+       /**
+        * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::prepareCreate()
+        */
+       protected function prepareCreate(array &$data) {
+               parent::prepareCreate($data);
+               
+               $data['nextExec'] = TIME_NOW;
+       }
+}
diff --git a/wcfsetup/install/files/lib/system/package/plugin/CronjobsPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/CronjobsPackageInstallationPlugin.class.php
deleted file mode 100644 (file)
index 92c7f58..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-<?php
-namespace wcf\system\package\plugin;
-use wcf\system\WCF;
-use wcf\util\CronjobUtil;
-
-/**
- * This PIP installs, updates or deletes cronjobs.
- * 
- * @author     Alexander Ebert
- * @copyright  2001-2011 WoltLab GmbH
- * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package    com.woltlab.wcf
- * @subpackage acp.package.plugin
- * @category   Community Framework
- */
-class CronjobsPackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin {
-       /**
-        * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::$className
-        */
-       public $className = 'wcf\data\cronjob\CronjobEditor';
-       
-       /**
-        * @see wcf\system\package\plugin\AbstractPackageInstallationPlugin::$tableName
-        */
-       public $tableName = 'cronjob';
-       
-       /**
-        * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::$tagName
-        */     
-       public $tagName = 'cronjob';
-       
-       /**
-        * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::handleDelete()
-        */
-       protected function handleDelete(array $items) {
-               $sql = "DELETE FROM     wcf".WCF_N."_".$this->tableName."
-                       WHERE           className = ?
-                                       AND packageID = ?";
-               $statement = WCF::getDB()->prepareStatement($sql);
-               foreach ($items as $item) {
-                       $statement->execute(array(
-                               $item['attributes']['classname'],
-                               $this->installation->getPackageID()
-                       ));
-               }
-       }
-       
-       /**
-        * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::prepareImport()
-        */
-       protected function prepareImport(array $data) {
-               return array(
-                       'active' => (isset($data['elements']['active'])) ? intval($data['elements']['active']) : 1,
-                       'canBeDisabled' => (isset($data['elements']['canbedisabled'])) ? intval($data['elements']['canbedisabled']) : 1,
-                       'canBeEdited' => (isset($data['elements']['canbeedited'])) ? intval($data['elements']['canbeedited']) : 1,
-                       'className' => (isset($data['elements']['classname'])) ? $data['elements']['classname'] : '',
-                       'description' => (isset($data['elements']['description'])) ? $data['elements']['description'] : '',
-                       'startDom' => $data['elements']['startdom'],
-                       'startDow' => $data['elements']['startdow'],
-                       'startHour' => $data['elements']['starthour'],
-                       'startMinute' => $data['elements']['startminute'],
-                       'startMonth' => $data['elements']['startmonth']
-               );
-       }
-       
-       /**
-        * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::validateImport()
-        */
-       protected function validateImport(array $data) {
-               CronjobUtil::validate($data['startMinute'], $data['startHour'], $data['startDom'], $data['startMonth'], $data['startDow']);
-       }
-       
-       /**
-        * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::findExistingItem()
-        */
-       protected function findExistingItem(array $data) {
-               return null;
-       }
-       
-       /**
-        * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::prepareCreate()
-        */
-       protected function prepareCreate(array &$data) {
-               parent::prepareCreate($data);
-               
-               $data['nextExec'] = TIME_NOW;
-       }
-}
diff --git a/wcfsetup/install/files/lib/system/package/plugin/FilePackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/FilePackageInstallationPlugin.class.php
new file mode 100644 (file)
index 0000000..c6489e7
--- /dev/null
@@ -0,0 +1,121 @@
+<?php
+namespace wcf\system\package\plugin;
+use wcf\system\package\PackageInstallationDispatcher;
+use wcf\data\package\Package;
+use wcf\data\package\PackageEditor;
+use wcf\system\exception\SystemException;
+use wcf\system\package\FilesFileHandler;
+use wcf\system\WCF;
+use wcf\util\FileUtil;
+use wcf\util\StyleUtil;
+
+/**
+ * This PIP installs, updates or deletes files delivered by a package.
+ *
+ * @author     Marcel Werk
+ * @copyright  2001-2011 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    com.woltlab.wcf
+ * @subpackage system.package.plugin
+ * @category   Community Framework
+ */
+class FilePackageInstallationPlugin extends AbstractPackageInstallationPlugin {
+       /**
+        * @see wcf\system\package\plugin\AbstractPackageInstallationPlugin::$tableName
+        */     
+       public $tableName = 'package_installation_file_log';
+       
+       /**
+        * @see wcf\system\package\plugin\IPackageInstallationPlugin::install()
+        */
+       public function install() {
+               parent::install();
+               
+               // get package installation dir
+               $dir = $this->installation->getPackage()->packageDir;
+               if (empty($dir)) {
+                       if ($this->installation->getPackage()->parentPackageID > 0) {
+                               // plugin
+                               // use parents package dir
+                               $dir = $this->installation->getPackage()->getParentPackage()->packageDir;
+                       }
+                       else if ($this->installation->getPackage()->standalone == 1 && $this->installation->getPackage()->package != 'com.woltlab.wcf' && $this->installation->getAction() == 'install') {
+                               // standalone package
+                               // prompt package dir
+                               $dir = $this->promptPackageDir();
+                       }
+                       
+                       // save package dir
+                       if (!empty($dir)) {
+                               $package = new Package($this->installation->getPackageID());
+                               $packageEditor = new PackageEditor($package);
+                               $packageEditor->update(array('packageDir' => $dir));
+                               
+                               $this->installation->getPackage()->packageDir = $dir;
+                       }
+               }
+               
+               // absolute path to package dir
+               $packageDir = FileUtil::addTrailingSlash(FileUtil::getRealPath(WCF_DIR.$dir));
+               
+               // extract files.tar to temp folder
+               $sourceFile = $this->installation->getArchive()->extractTar($this->instruction['value'], 'files_');
+               
+               // create file handler
+               $fileHandler = new FilesFileHandler($this->installation);
+               
+               // extract content of files.tar
+               $fileInstaller = $this->installation->extractFiles($packageDir, $sourceFile, $fileHandler);
+               
+               // if this a standalone package, write config.inc.php for this package
+               if ($this->installation->getPackage()->standalone == 1 && $this->installation->getPackage()->package != 'com.woltlab.wcf' && $this->installation->getAction() == 'install') {
+                       // touch file
+                       $fileInstaller->touchFile(PackageInstallationDispatcher::CONFIG_FILE);
+                       
+                       // create file
+                       Package::writeConfigFile($this->installation->getPackageID());
+                       
+                       // log file
+                       $sql = "INSERT INTO     wcf".WCF_N."_package_installation_file_log
+                                               (packageID, filename)
+                               VALUES          (?, 'config.inc.php')";
+                       $statement = WCF::getDB()->prepareStatement($sql);
+                       $statement->execute(array($this->installation->getPackageID()));
+               }
+               
+               // delete temporary sourceArchive
+               @unlink($sourceFile);
+               
+               // update acp style file
+               StyleUtil::updateStyleFile();
+       }
+       
+       /**
+        * Uninstalls the files of this package.
+        */
+       public function uninstall() {
+               // get absolute package dir
+               $packageDir = FileUtil::addTrailingSlash(FileUtil::unifyDirSeperator(realpath(WCF_DIR.$this->installation->getPackage()->packageDir)));
+               
+               // create file list
+               $files = array();
+               
+               // get files from log
+               $sql = "SELECT  *
+                       FROM    wcf".WCF_N."_package_installation_file_log
+                       WHERE   packageID = ?";
+               $statement = WCF::getDB()->prepareStatement($sql);
+               $statement->execute(array($this->installation->getPackageID()));
+               while ($row = $statement->fetchArray()) {
+                       $files[] = $row['filename'];
+               }
+               
+               if (count($files) > 0) {
+                       // delete files
+                       $this->installation->deleteFiles($packageDir, $files);
+                       
+                       // delete log entries
+                       parent::uninstall();
+               }
+       }
+}
diff --git a/wcfsetup/install/files/lib/system/package/plugin/FilesPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/FilesPackageInstallationPlugin.class.php
deleted file mode 100644 (file)
index 07778e2..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-<?php
-namespace wcf\system\package\plugin;
-use wcf\system\package\PackageInstallationDispatcher;
-
-use wcf\data\package\Package;
-use wcf\data\package\PackageEditor;
-use wcf\system\exception\SystemException;
-use wcf\system\package\FilesFileHandler;
-use wcf\system\WCF;
-use wcf\util\FileUtil;
-use wcf\util\StyleUtil;
-
-/**
- * This PIP installs, updates or deletes by a package delivered files.
- *
- * @author     Marcel Werk
- * @copyright  2001-2011 WoltLab GmbH
- * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package    com.woltlab.wcf
- * @subpackage system.package.plugin
- * @category   Community Framework
- */
-class FilesPackageInstallationPlugin extends AbstractPackageInstallationPlugin {
-       /**
-        * @see wcf\system\package\plugin\AbstractPackageInstallationPlugin::$tableName
-        */     
-       public $tableName = 'package_installation_file_log';
-       
-       /**
-        * @see wcf\system\package\plugin\IPackageInstallationPlugin::install()
-        */
-       public function install() {
-               parent::install();
-               
-               // get package installation dir
-               $dir = $this->installation->getPackage()->packageDir;
-               if (empty($dir)) {
-                       if ($this->installation->getPackage()->parentPackageID > 0) {
-                               // plugin
-                               // use parents package dir
-                               $dir = $this->installation->getPackage()->getParentPackage()->packageDir;
-                       }
-                       else if ($this->installation->getPackage()->standalone == 1 && $this->installation->getPackage()->package != 'com.woltlab.wcf' && $this->installation->getAction() == 'install') {
-                               // standalone package
-                               // prompt package dir
-                               $dir = $this->promptPackageDir();
-                       }
-                       
-                       // save package dir
-                       if (!empty($dir)) {
-                               $package = new Package($this->installation->getPackageID());
-                               $packageEditor = new PackageEditor($package);
-                               $packageEditor->update(array('packageDir' => $dir));
-                               
-                               $this->installation->getPackage()->packageDir = $dir;
-                       }
-               }
-               
-               // absolute path to package dir
-               $packageDir = FileUtil::addTrailingSlash(FileUtil::getRealPath(WCF_DIR.$dir));
-               
-               // extract files.tar to temp folder
-               $sourceFile = $this->installation->getArchive()->extractTar($this->instruction['value'], 'files_');
-               
-               // create file handler
-               $fileHandler = new FilesFileHandler($this->installation);
-               
-               // extract content of files.tar
-               $fileInstaller = $this->installation->extractFiles($packageDir, $sourceFile, $fileHandler);
-               
-               // if this a standalone package, write config.inc.php for this package
-               if ($this->installation->getPackage()->standalone == 1 && $this->installation->getPackage()->package != 'com.woltlab.wcf' && $this->installation->getAction() == 'install') {
-                       // touch file
-                       $fileInstaller->touchFile(PackageInstallationDispatcher::CONFIG_FILE);
-                       
-                       // create file
-                       Package::writeConfigFile($this->installation->getPackageID());
-                       
-                       // log file
-                       $sql = "INSERT INTO     wcf".WCF_N."_package_installation_file_log
-                                               (packageID, filename)
-                               VALUES          (?, 'config.inc.php')";
-                       $statement = WCF::getDB()->prepareStatement($sql);
-                       $statement->execute(array($this->installation->getPackageID()));
-               }
-               
-               // delete temporary sourceArchive
-               @unlink($sourceFile);
-               
-               // update acp style file
-               StyleUtil::updateStyleFile();
-       }
-       
-       /**
-        * Uninstalls the files of this package.
-        */
-       public function uninstall() {
-               // get absolute package dir
-               $packageDir = FileUtil::addTrailingSlash(FileUtil::unifyDirSeperator(realpath(WCF_DIR.$this->installation->getPackage()->packageDir)));
-               
-               // create file list
-               $files = array();
-               
-               // get files from log
-               $sql = "SELECT  *
-                       FROM    wcf".WCF_N."_package_installation_file_log
-                       WHERE   packageID = ?";
-               $statement = WCF::getDB()->prepareStatement($sql);
-               $statement->execute(array($this->installation->getPackageID()));
-               while ($row = $statement->fetchArray()) {
-                       $files[] = $row['filename'];
-               }
-               
-               if (count($files) > 0) {
-                       // delete files
-                       $this->installation->deleteFiles($packageDir, $files);
-                       
-                       // delete log entries
-                       parent::uninstall();
-               }
-       }
-}
diff --git a/wcfsetup/install/files/lib/system/package/plugin/LanguagePackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/LanguagePackageInstallationPlugin.class.php
new file mode 100644 (file)
index 0000000..1f7c7cd
--- /dev/null
@@ -0,0 +1,302 @@
+<?php
+namespace wcf\system\package\plugin;
+use wcf\data\language\LanguageEditor;
+use wcf\system\database\util\PreparedStatementConditionBuilder;
+use wcf\system\exception\SystemException;
+use wcf\system\language\LanguageFactory;
+use wcf\system\WCF;
+use wcf\util\XML;
+
+/**
+ * This PIP installs, updates or deletes language and their categories and items.
+ *
+ * @author     Benjamin Kunz
+ * @copyright  2001-2011 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    com.woltlab.wcf
+ * @subpackage system.package.plugin
+ * @category   Community Framework
+ */
+class LanguagePackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin {
+       /**
+        * @see wcf\system\package\plugin\AbstractPackageInstallationPlugin::$tableName
+        */     
+       public $tableName = 'language_item';
+       
+       /**
+        * @see wcf\system\package\plugin\IPackageInstallationPlugin::install()
+        */
+       public function install() {
+               AbstractPackageInstallationPlugin::install();
+               
+               // get language files
+               $languageFiles = array();
+               $multipleFiles = false;
+               $filename = $this->instruction['value'];
+               if (strpos($filename, '*') !== false) {
+                       // wildcard syntax; import multiple files
+                       $multipleFiles = true;
+                       $files = $this->installation->getArchive()->getTar()->getContentList();
+                       $pattern = str_replace("\*", ".*", preg_quote($filename));
+                       
+                       foreach ($files as $file) {
+                               if (preg_match('!'.$pattern.'!i', $file['filename'])) {
+                                       if (preg_match('~([a-z-]+)\.xml$~i', $file['filename'], $match)) {
+                                               $languageFiles[$match[1]] = $file['filename'];
+                                       }
+                                       else {
+                                               throw new SystemException("Can not determine language code of language file '".$file."'");
+                                       }
+                               }
+                       }
+               }
+               else {
+                       if (!empty($this->instruction['attributes']['languagecode'])) {
+                               $languageCode = $this->instruction['attributes']['languagecode'];
+                       }
+                       else if (!empty($this->instruction['attributes']['language'])) {
+                               $languageCode = $this->instruction['attributes']['language'];
+                       }
+                       else if (preg_match('~([a-z-]+)\.xml$~i', $filename, $match)) {
+                               $languageCode = $match[1];
+                       }
+                       else {
+                               throw new SystemException("Can not determine language code of language file '".$filename."'");
+                       }
+                       
+                       $languageFiles[$languageCode] = $filename;
+               }
+               
+               // get installed languages
+               $installedLanguages = array();
+               $sql = "SELECT          *
+                       FROM            wcf".WCF_N."_language
+                       ORDER BY        isDefault DESC";
+               $statement = WCF::getDB()->prepareStatement($sql);
+               $statement->execute();
+               while ($row = $statement->fetchArray()) {
+                       $installedLanguages[] = $row;
+               }
+               
+               // install language
+               $addedLanguageIDArray = array();
+               foreach ($installedLanguages as $installedLanguage) {
+                       $languageFile = null;
+                       if (isset($languageFiles[$installedLanguage['languageCode']])) {
+                               $languageFile = $languageFiles[$installedLanguage['languageCode']];
+                       }
+                       else if ($multipleFiles) {
+                               // use default language
+                               if (isset($languageFiles[$installedLanguages[0]['languageCode']])) {
+                                       $languageFile = $languageFiles[$installedLanguages[0]['languageCode']];
+                               }
+
+                               // use english (if installed)
+                               else if (isset($languageFiles['en'])) {
+                                       foreach ($installedLanguages as $installedLanguage2) {
+                                               if ($installedLanguage2['languageCode'] == 'en') {
+                                                       $languageFile = $languageFiles['en'];
+                                                       break;
+                                               }
+                                       }
+                               }
+
+                               // use any installed language
+                               if ($languageFile === null) {
+                                       foreach ($installedLanguages as $installedLanguage2) {
+                                               if (isset($languageFiles[$installedLanguage2['languageCode']])) {
+                                                       $languageFile = $languageFiles[$installedLanguage2['languageCode']];
+                                                       break;
+                                               }
+                                       }
+                               }
+
+                               // use first delivered language
+                               if ($languageFile === null) {
+                                       foreach ($languageFiles as $languageFile) break;
+                               }
+                       }
+                       
+                       // save language
+                       if ($languageFile !== null) {
+                               if ($xml = $this->readLanguage($languageFile)) {
+                                       // get language object
+                                       $language = LanguageFactory::getLanguageByCode($installedLanguage['languageCode']);
+                                       $languageEditor = new LanguageEditor($language);
+                                       
+                                       // import xml
+                                       // don't update language files if package is standalone
+                                       $languageEditor->updateFromXML($xml, $this->installation->getPackageID(), !$this->installation->getPackage()->standalone);
+                                       
+                                       // add language to this package
+                                       $addedLanguageIDArray[] = $language->languageID;
+                               }
+                       }
+               }
+               
+               // save package to language
+               if (count($addedLanguageIDArray)) {
+                       $condition = '';
+                       $statementParameters = array($this->installation->getPackageID());
+                       foreach ($addedLanguageIDArray as $languageID) {
+                               if (!empty($condition)) $condition .= ',';
+                               $condition .= '?';
+                               $statementParameters[] = $languageID;
+                       }
+                       $statementParameters[] = $this->installation->getPackageID();
+                       
+                       $sql = "INSERT INTO     wcf".WCF_N."_language_to_package
+                                               (languageID, packageID)
+                               SELECT          languageID, ?
+                               FROM            wcf".WCF_N."_language
+                               WHERE           languageID IN (".$condition.")
+                                               AND languageID NOT IN (
+                                                       SELECT  languageID
+                                                       FROM    wcf".WCF_N."_language_to_package
+                                                       WHERE   packageID = ?
+                                               )";
+                       $statement = WCF::getDB()->prepareStatement($sql);
+                       $statement->execute($statementParameters);
+               }
+       }
+       
+       /**
+        * Returns true if the uninstalling package got to uninstall languages, categories or items.
+        *
+        * @return      boolean                         hasUnistall
+        */
+       public function hasUninstall() {
+               if (parent::hasUninstall()) return true;
+               
+               $sql = "SELECT  COUNT(languageID) AS count
+                       FROM    wcf".WCF_N."_language_to_package
+                       WHERE   packageID = ?";
+               $statement = WCF::getDB()->prepareStatement($sql);
+               $statement->execute(array($this->installation->getPackageID()));
+               $languageCount = $statement->fetchArray();
+               return $languageCount['count'] > 0;
+       }
+       
+       /**
+        * Deletes languages, categories or items which where installed by the package.
+        */
+       public function uninstall() {
+               parent::uninstall();
+               
+               // delete language to package relation
+               $sql = "DELETE FROM     wcf".WCF_N."_language_to_package
+                       WHERE           packageID = ?";
+               $statement = WCF::getDB()->prepareStatement($sql);
+               $statement->execute(array($this->installation->getPackageID()));
+               
+               // delete language items
+               // Get all items and their categories
+               // which where installed from this package.
+               $sql = "SELECT  languageItemID, languageCategoryID, languageID
+                       FROM    wcf".WCF_N."_language_item
+                       WHERE   packageID = ?";
+               $statement = WCF::getDB()->prepareStatement($sql);
+               $statement->execute(array($this->installation->getPackageID()));
+               $itemIDs = array();
+               $categoryIDs = array();
+               while ($row = $statement->fetchArray()) {
+                       $itemIDs[] = $row['languageItemID'];
+                       
+                       // Store categories
+                       $categoryIDs[$row['languageCategoryID']] = true;
+               }
+               
+               if (count($itemIDs) > 0) {
+                       $sql = "DELETE FROM     wcf".WCF_N."_".$this->tableName."
+                               WHERE           languageItemID = ?
+                                               AND packageID = ?";
+                       $statement = WCF::getDB()->prepareStatement($sql);
+                       
+                       foreach ($itemIDs as $itemID) {
+                               $statement->execute(array(
+                                       $itemID,
+                                       $this->installation->getPackageID()
+                               ));
+                       }
+                       
+                       $this->deleteEmptyCategories(array_keys($categoryIDs), $this->installation->getPackageID());
+               }
+       }
+       
+       /**
+        * Extracts the language file and parses it with
+        * SimpleXML. If the specified language file
+        * was not found, an error message is thrown.
+        *
+        * @param       string          $filename
+        * @return      wcf\util\XML    xml
+        */
+       protected function readLanguage($filename) {
+               // search language files in package archive
+               // throw error message if not found
+               if (($fileIndex = $this->installation->getArchive()->getTar()->getIndexByFilename($filename)) === false) {
+                       throw new SystemException("language file '".$filename."' not found.");
+               }
+               
+               // extract language file and parse with DOMDocument
+               $xml = new XML();
+               $xml->loadXML($filename, $this->installation->getArchive()->getTar()->extractToString($fileIndex));
+               return $xml;
+       }
+       
+       /**
+        * Deletes categories which where changed by an update or deinstallation in case they are now empty.
+        *
+        * @param       array           $categoryIDs
+        * @param       integer         $packageID
+        */
+       protected function deleteEmptyCategories(array $categoryIDs, $packageID) {
+               // Get empty categories which where changed by this package.
+               $conditions = new PreparedStatementConditionBuilder();
+               $conditions->add("language_category.languageCategoryID IN (?)", array($categoryIDs));
+               
+               $sql = "SELECT          COUNT(item.languageItemID) AS count,
+                                       language_category.languageCategoryID,
+                                       language_category.languageCategory
+                       FROM            wcf".WCF_N."_language_category language_category
+                       LEFT JOIN       wcf".WCF_N."_language_item item
+                       ON              (item.languageCategoryID = language_category.languageCategoryID)
+                       ".$conditions."
+                       GROUP BY        language_category.languageCategoryID ASC,
+                                       language_category.languageCategory ASC";
+               $statement = WCF::getDB()->prepareStatement($sql);
+               $statement->execute($conditions->getParameters());
+               $categoriesToDelete = array();
+               while ($row = $statement->fetchArray()) {
+                       if ($row['count'] == 0) {
+                               $categoriesToDelete[$row['languageCategoryID']] = $row['languageCategory'];
+                       }
+               }
+               
+               // Delete categories from DB.
+               if (count($categoriesToDelete) > 0) {
+                       $sql = "DELETE FROM     wcf".WCF_N."_language_category
+                               WHERE           languageCategory = ?";
+                       $statement = WCF::getDB()->prepareStatement($sql);
+                       
+                       foreach ($categoriesToDelete as $category) {
+                               $statement->execute(array($category));
+                       }
+               }
+       }
+       
+       /**
+        * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::handleDelete()
+        */
+       protected function handleDelete(array $items) { }
+       
+       /**
+        * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::prepareImport()
+        */
+       protected function prepareImport(array $data) { }
+       
+       /**
+        * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::findExistingItem()
+        */
+       protected function findExistingItem(array $data) { }
+}
diff --git a/wcfsetup/install/files/lib/system/package/plugin/LanguagesPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/LanguagesPackageInstallationPlugin.class.php
deleted file mode 100644 (file)
index c7fa6b2..0000000
+++ /dev/null
@@ -1,302 +0,0 @@
-<?php
-namespace wcf\system\package\plugin;
-use wcf\data\language\LanguageEditor;
-use wcf\system\database\util\PreparedStatementConditionBuilder;
-use wcf\system\exception\SystemException;
-use wcf\system\language\LanguageFactory;
-use wcf\system\WCF;
-use wcf\util\XML;
-
-/**
- * This PIP installs, updates or deletes language and their categories and items.
- *
- * @author     Benjamin Kunz
- * @copyright  2001-2011 WoltLab GmbH
- * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package    com.woltlab.wcf
- * @subpackage system.package.plugin
- * @category   Community Framework
- */
-class LanguagesPackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin {
-       /**
-        * @see wcf\system\package\plugin\AbstractPackageInstallationPlugin::$tableName
-        */     
-       public $tableName = 'language_item';
-       
-       /**
-        * @see wcf\system\package\plugin\IPackageInstallationPlugin::install()
-        */
-       public function install() {
-               AbstractPackageInstallationPlugin::install();
-               
-               // get language files
-               $languageFiles = array();
-               $multipleFiles = false;
-               $filename = $this->instruction['value'];
-               if (strpos($filename, '*') !== false) {
-                       // wildcard syntax; import multiple files
-                       $multipleFiles = true;
-                       $files = $this->installation->getArchive()->getTar()->getContentList();
-                       $pattern = str_replace("\*", ".*", preg_quote($filename));
-                       
-                       foreach ($files as $file) {
-                               if (preg_match('!'.$pattern.'!i', $file['filename'])) {
-                                       if (preg_match('~([a-z-]+)\.xml$~i', $file['filename'], $match)) {
-                                               $languageFiles[$match[1]] = $file['filename'];
-                                       }
-                                       else {
-                                               throw new SystemException("Can not determine language code of language file '".$file."'");
-                                       }
-                               }
-                       }
-               }
-               else {
-                       if (!empty($this->instruction['attributes']['languagecode'])) {
-                               $languageCode = $this->instruction['attributes']['languagecode'];
-                       }
-                       else if (!empty($this->instruction['attributes']['language'])) {
-                               $languageCode = $this->instruction['attributes']['language'];
-                       }
-                       else if (preg_match('~([a-z-]+)\.xml$~i', $filename, $match)) {
-                               $languageCode = $match[1];
-                       }
-                       else {
-                               throw new SystemException("Can not determine language code of language file '".$filename."'");
-                       }
-                       
-                       $languageFiles[$languageCode] = $filename;
-               }
-               
-               // get installed languages
-               $installedLanguages = array();
-               $sql = "SELECT          *
-                       FROM            wcf".WCF_N."_language
-                       ORDER BY        isDefault DESC";
-               $statement = WCF::getDB()->prepareStatement($sql);
-               $statement->execute();
-               while ($row = $statement->fetchArray()) {
-                       $installedLanguages[] = $row;
-               }
-               
-               // install language
-               $addedLanguageIDArray = array();
-               foreach ($installedLanguages as $installedLanguage) {
-                       $languageFile = null;
-                       if (isset($languageFiles[$installedLanguage['languageCode']])) {
-                               $languageFile = $languageFiles[$installedLanguage['languageCode']];
-                       }
-                       else if ($multipleFiles) {
-                               // use default language
-                               if (isset($languageFiles[$installedLanguages[0]['languageCode']])) {
-                                       $languageFile = $languageFiles[$installedLanguages[0]['languageCode']];
-                               }
-
-                               // use english (if installed)
-                               else if (isset($languageFiles['en'])) {
-                                       foreach ($installedLanguages as $installedLanguage2) {
-                                               if ($installedLanguage2['languageCode'] == 'en') {
-                                                       $languageFile = $languageFiles['en'];
-                                                       break;
-                                               }
-                                       }
-                               }
-
-                               // use any installed language
-                               if ($languageFile === null) {
-                                       foreach ($installedLanguages as $installedLanguage2) {
-                                               if (isset($languageFiles[$installedLanguage2['languageCode']])) {
-                                                       $languageFile = $languageFiles[$installedLanguage2['languageCode']];
-                                                       break;
-                                               }
-                                       }
-                               }
-
-                               // use first delivered language
-                               if ($languageFile === null) {
-                                       foreach ($languageFiles as $languageFile) break;
-                               }
-                       }
-                       
-                       // save language
-                       if ($languageFile !== null) {
-                               if ($xml = $this->readLanguage($languageFile)) {
-                                       // get language object
-                                       $language = LanguageFactory::getLanguageByCode($installedLanguage['languageCode']);
-                                       $languageEditor = new LanguageEditor($language);
-                                       
-                                       // import xml
-                                       // don't update language files if package is standalone
-                                       $languageEditor->updateFromXML($xml, $this->installation->getPackageID(), !$this->installation->getPackage()->standalone);
-                                       
-                                       // add language to this package
-                                       $addedLanguageIDArray[] = $language->languageID;
-                               }
-                       }
-               }
-               
-               // save package to language
-               if (count($addedLanguageIDArray)) {
-                       $condition = '';
-                       $statementParameters = array($this->installation->getPackageID());
-                       foreach ($addedLanguageIDArray as $languageID) {
-                               if (!empty($condition)) $condition .= ',';
-                               $condition .= '?';
-                               $statementParameters[] = $languageID;
-                       }
-                       $statementParameters[] = $this->installation->getPackageID();
-                       
-                       $sql = "INSERT INTO     wcf".WCF_N."_language_to_package
-                                               (languageID, packageID)
-                               SELECT          languageID, ?
-                               FROM            wcf".WCF_N."_language
-                               WHERE           languageID IN (".$condition.")
-                                               AND languageID NOT IN (
-                                                       SELECT  languageID
-                                                       FROM    wcf".WCF_N."_language_to_package
-                                                       WHERE   packageID = ?
-                                               )";
-                       $statement = WCF::getDB()->prepareStatement($sql);
-                       $statement->execute($statementParameters);
-               }
-       }
-       
-       /**
-        * Returns true if the uninstalling package got to uninstall languages, categories or items.
-        *
-        * @return      boolean                         hasUnistall
-        */
-       public function hasUninstall() {
-               if (parent::hasUninstall()) return true;
-               
-               $sql = "SELECT  COUNT(languageID) AS count
-                       FROM    wcf".WCF_N."_language_to_package
-                       WHERE   packageID = ?";
-               $statement = WCF::getDB()->prepareStatement($sql);
-               $statement->execute(array($this->installation->getPackageID()));
-               $languageCount = $statement->fetchArray();
-               return $languageCount['count'] > 0;
-       }
-       
-       /**
-        * Deletes languages, categories or items which where installed by the package.
-        */
-       public function uninstall() {
-               parent::uninstall();
-               
-               // delete language to package relation
-               $sql = "DELETE FROM     wcf".WCF_N."_language_to_package
-                       WHERE           packageID = ?";
-               $statement = WCF::getDB()->prepareStatement($sql);
-               $statement->execute(array($this->installation->getPackageID()));
-               
-               // delete language items
-               // Get all items and their categories
-               // which where installed from this package.
-               $sql = "SELECT  languageItemID, languageCategoryID, languageID
-                       FROM    wcf".WCF_N."_language_item
-                       WHERE   packageID = ?";
-               $statement = WCF::getDB()->prepareStatement($sql);
-               $statement->execute(array($this->installation->getPackageID()));
-               $itemIDs = array();
-               $categoryIDs = array();
-               while ($row = $statement->fetchArray()) {
-                       $itemIDs[] = $row['languageItemID'];
-                       
-                       // Store categories
-                       $categoryIDs[$row['languageCategoryID']] = true;
-               }
-               
-               if (count($itemIDs) > 0) {
-                       $sql = "DELETE FROM     wcf".WCF_N."_".$this->tableName."
-                               WHERE           languageItemID = ?
-                                               AND packageID = ?";
-                       $statement = WCF::getDB()->prepareStatement($sql);
-                       
-                       foreach ($itemIDs as $itemID) {
-                               $statement->execute(array(
-                                       $itemID,
-                                       $this->installation->getPackageID()
-                               ));
-                       }
-                       
-                       $this->deleteEmptyCategories(array_keys($categoryIDs), $this->installation->getPackageID());
-               }
-       }
-       
-       /**
-        * Extracts the language file and parses it with
-        * SimpleXML. If the specified language file
-        * was not found, an error message is thrown.
-        *
-        * @param       string          $filename
-        * @return      wcf\util\XML    xml
-        */
-       protected function readLanguage($filename) {
-               // search language files in package archive
-               // throw error message if not found
-               if (($fileIndex = $this->installation->getArchive()->getTar()->getIndexByFilename($filename)) === false) {
-                       throw new SystemException("language file '".$filename."' not found.");
-               }
-               
-               // extract language file and parse with DOMDocument
-               $xml = new XML();
-               $xml->loadXML($filename, $this->installation->getArchive()->getTar()->extractToString($fileIndex));
-               return $xml;
-       }
-       
-       /**
-        * Deletes categories which where changed by an update or deinstallation in case they are now empty.
-        *
-        * @param       array           $categoryIDs
-        * @param       integer         $packageID
-        */
-       protected function deleteEmptyCategories(array $categoryIDs, $packageID) {
-               // Get empty categories which where changed by this package.
-               $conditions = new PreparedStatementConditionBuilder();
-               $conditions->add("language_category.languageCategoryID IN (?)", array($categoryIDs));
-               
-               $sql = "SELECT          COUNT(item.languageItemID) AS count,
-                                       language_category.languageCategoryID,
-                                       language_category.languageCategory
-                       FROM            wcf".WCF_N."_language_category language_category
-                       LEFT JOIN       wcf".WCF_N."_language_item item
-                       ON              (item.languageCategoryID = language_category.languageCategoryID)
-                       ".$conditions."
-                       GROUP BY        language_category.languageCategoryID ASC,
-                                       language_category.languageCategory ASC";
-               $statement = WCF::getDB()->prepareStatement($sql);
-               $statement->execute($conditions->getParameters());
-               $categoriesToDelete = array();
-               while ($row = $statement->fetchArray()) {
-                       if ($row['count'] == 0) {
-                               $categoriesToDelete[$row['languageCategoryID']] = $row['languageCategory'];
-                       }
-               }
-               
-               // Delete categories from DB.
-               if (count($categoriesToDelete) > 0) {
-                       $sql = "DELETE FROM     wcf".WCF_N."_language_category
-                               WHERE           languageCategory = ?";
-                       $statement = WCF::getDB()->prepareStatement($sql);
-                       
-                       foreach ($categoriesToDelete as $category) {
-                               $statement->execute(array($category));
-                       }
-               }
-       }
-       
-       /**
-        * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::handleDelete()
-        */
-       protected function handleDelete(array $items) { }
-       
-       /**
-        * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::prepareImport()
-        */
-       protected function prepareImport(array $data) { }
-       
-       /**
-        * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::findExistingItem()
-        */
-       protected function findExistingItem(array $data) { }
-}
diff --git a/wcfsetup/install/files/lib/system/package/plugin/OptionPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/OptionPackageInstallationPlugin.class.php
new file mode 100644 (file)
index 0000000..0702b3e
--- /dev/null
@@ -0,0 +1,101 @@
+<?php
+namespace wcf\system\package\plugin;
+use wcf\data\option\Option;
+use wcf\data\option\OptionEditor;
+use wcf\system\WCF;
+use wcf\util\StringUtil;
+
+/**
+ * This PIP installs, updates or deletes options.
+ *
+ * @author     Benjamin Kunz
+ * @copyright  2001-2011 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    com.woltlab.wcf
+ * @subpackage system.package.plugin
+ * @category   Community Framework
+ */
+class OptionPackageInstallationPlugin extends AbstractOptionPackageInstallationPlugin {
+       /**
+        * @see wcf\system\package\plugin\AbstractPackageInstallationPlugin::$tableName
+        */     
+       public $tableName = 'option';
+
+       public static $reservedTags = array('name', 'optiontype', 'defaultvalue', 'validationpattern', 'enableoptions', 'showorder', 'hidden', 'selectoptions', 'categoryname', 'permissions', 'options', 'attrs', 'cdata');
+       
+       /**
+        * @see wcf\system\package\plugin\AbstractOptionPackageInstallationPlugin::saveOption()
+        */
+       protected function saveOption($option, $categoryName, $existingOptionID = 0) {
+               // default values
+               $optionName = $optionType = $defaultValue = $validationPattern = $selectOptions = $enableOptions = $permissions = $options = '';
+               $showOrder = null;
+               $hidden = 0;
+               
+               // get values
+               if (isset($option['name'])) $optionName = $option['name'];
+               if (isset($option['optiontype'])) $optionType = $option['optiontype'];
+               if (isset($option['defaultvalue'])) $defaultValue = WCF::getLanguage()->get($option['defaultvalue']);
+               if (isset($option['validationpattern'])) $validationPattern = $option['validationpattern'];
+               if (isset($option['enableoptions'])) $enableOptions = $option['enableoptions'];
+               if (isset($option['showorder'])) $showOrder = intval($option['showorder']);
+               if (isset($option['hidden'])) $hidden = intval($option['hidden']);
+               $showOrder = $this->getShowOrder($showOrder, $categoryName, 'categoryName');
+               if (isset($option['selectoptions'])) $selectOptions = $option['selectoptions'];
+               if (isset($option['permissions'])) $permissions = $option['permissions'];
+               if (isset($option['options'])) $options = $option['options'];
+               
+               // check if optionType exists
+               $className = 'wcf\system\option\\'.StringUtil::firstCharToUpperCase($optionType).'OptionType';
+               if (!class_exists($className)) {
+                       throw new SystemException("unable to find class '".$className."'");
+               }
+               
+               // collect additional tags and their values
+               $additionalData = array();
+               foreach ($option as $tag => $value) {
+                       if (!in_array($tag, self::$reservedTags)) $additionalData[$tag] = $value;
+               }
+               
+               // build update or create data
+               $data = array(
+                       'categoryName' => $categoryName,
+                       'optionType' => $optionType,
+                       'validationPattern' => $validationPattern,
+                       'selectOptions' => $selectOptions,
+                       'showOrder' => $showOrder,
+                       'enableOptions' => $enableOptions,
+                       'hidden' => $hidden,
+                       'permissions' => $permissions,
+                       'options' => $options,
+                       'additionalData' => serialize($additionalData)
+               );
+               
+               // try to find an existing option for updating
+               $sql = "SELECT  *
+                       FROM    wcf".WCF_N."_".$this->tableName."
+                       WHERE   optionName = ?
+                               AND packageID = ?";
+               $statement = WCF::getDB()->prepareStatement($sql);
+               $statement->execute(array(
+                       $optionName,
+                       $this->installation->getPackageID()
+               ));
+               $row = $statement->fetchArray();
+               
+               // result was 'false' thus create a new item
+               if (!$row) {
+                       $data['optionName'] = $optionName;
+                       $data['packageID'] = $this->installation->getPackageID();
+                       $data['optionValue'] = $defaultValue;
+                       
+                       OptionEditor::create($data);
+               }
+               else {
+                       // update existing item
+                       $optionObj = new Option(null, $row);
+                       $optionEditor = new OptionEditor($optionObj);
+                       $optionEditor->update($data);
+               }
+       }
+}
diff --git a/wcfsetup/install/files/lib/system/package/plugin/OptionsPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/OptionsPackageInstallationPlugin.class.php
deleted file mode 100644 (file)
index f5b03fd..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-<?php
-namespace wcf\system\package\plugin;
-use wcf\data\option\Option;
-use wcf\data\option\OptionEditor;
-use wcf\system\WCF;
-use wcf\util\StringUtil;
-
-/**
- * This PIP installs, updates or deletes options.
- *
- * @author     Benjamin Kunz
- * @copyright  2001-2011 WoltLab GmbH
- * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package    com.woltlab.wcf
- * @subpackage system.package.plugin
- * @category   Community Framework
- */
-class OptionsPackageInstallationPlugin extends AbstractOptionPackageInstallationPlugin {
-       /**
-        * @see wcf\system\package\plugin\AbstractPackageInstallationPlugin::$tableName
-        */     
-       public $tableName = 'option';
-
-       public static $reservedTags = array('name', 'optiontype', 'defaultvalue', 'validationpattern', 'enableoptions', 'showorder', 'hidden', 'selectoptions', 'categoryname', 'permissions', 'options', 'attrs', 'cdata');
-       
-       /**
-        * @see wcf\system\package\plugin\AbstractOptionPackageInstallationPlugin::saveOption()
-        */
-       protected function saveOption($option, $categoryName, $existingOptionID = 0) {
-               // default values
-               $optionName = $optionType = $defaultValue = $validationPattern = $selectOptions = $enableOptions = $permissions = $options = '';
-               $showOrder = null;
-               $hidden = 0;
-               
-               // get values
-               if (isset($option['name'])) $optionName = $option['name'];
-               if (isset($option['optiontype'])) $optionType = $option['optiontype'];
-               if (isset($option['defaultvalue'])) $defaultValue = WCF::getLanguage()->get($option['defaultvalue']);
-               if (isset($option['validationpattern'])) $validationPattern = $option['validationpattern'];
-               if (isset($option['enableoptions'])) $enableOptions = $option['enableoptions'];
-               if (isset($option['showorder'])) $showOrder = intval($option['showorder']);
-               if (isset($option['hidden'])) $hidden = intval($option['hidden']);
-               $showOrder = $this->getShowOrder($showOrder, $categoryName, 'categoryName');
-               if (isset($option['selectoptions'])) $selectOptions = $option['selectoptions'];
-               if (isset($option['permissions'])) $permissions = $option['permissions'];
-               if (isset($option['options'])) $options = $option['options'];
-               
-               // check if optionType exists
-               $className = 'wcf\system\option\\'.StringUtil::firstCharToUpperCase($optionType).'OptionType';
-               if (!class_exists($className)) {
-                       throw new SystemException("unable to find class '".$className."'");
-               }
-               
-               // collect additional tags and their values
-               $additionalData = array();
-               foreach ($option as $tag => $value) {
-                       if (!in_array($tag, self::$reservedTags)) $additionalData[$tag] = $value;
-               }
-               
-               // build update or create data
-               $data = array(
-                       'categoryName' => $categoryName,
-                       'optionType' => $optionType,
-                       'validationPattern' => $validationPattern,
-                       'selectOptions' => $selectOptions,
-                       'showOrder' => $showOrder,
-                       'enableOptions' => $enableOptions,
-                       'hidden' => $hidden,
-                       'permissions' => $permissions,
-                       'options' => $options,
-                       'additionalData' => serialize($additionalData)
-               );
-               
-               // try to find an existing option for updating
-               $sql = "SELECT  *
-                       FROM    wcf".WCF_N."_".$this->tableName."
-                       WHERE   optionName = ?
-                               AND packageID = ?";
-               $statement = WCF::getDB()->prepareStatement($sql);
-               $statement->execute(array(
-                       $optionName,
-                       $this->installation->getPackageID()
-               ));
-               $row = $statement->fetchArray();
-               
-               // result was 'false' thus create a new item
-               if (!$row) {
-                       $data['optionName'] = $optionName;
-                       $data['packageID'] = $this->installation->getPackageID();
-                       $data['optionValue'] = $defaultValue;
-                       
-                       OptionEditor::create($data);
-               }
-               else {
-                       // update existing item
-                       $optionObj = new Option(null, $row);
-                       $optionEditor = new OptionEditor($optionObj);
-                       $optionEditor->update($data);
-               }
-       }
-}
diff --git a/wcfsetup/install/files/lib/system/package/plugin/StyleAttributePackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/StyleAttributePackageInstallationPlugin.class.php
new file mode 100644 (file)
index 0000000..bb7c335
--- /dev/null
@@ -0,0 +1,144 @@
+<?php
+namespace wcf\system\package\plugin;
+use wcf\data\style\StyleEditor;
+use wcf\data\style\StyleList;
+use wcf\system\WCF;
+
+/**
+ * This PIP installs, updates or deletes style attributes.
+ * 
+ * @author     Marcel Werk
+ * @copyright  2001-2011 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    com.woltlab.wcf
+ * @subpackage system.package.plugin
+ * @category   Community Framework
+ */
+class StyleAttributePackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin {
+       /**
+        * list of updated or new style variables
+        * @var array
+        */     
+       protected $styleVariables = array();
+       
+       /**
+        * @see wcf\system\package\plugin\AbstractPackageInstallationPlugin::$tableName
+        */     
+       public $tableName = 'style_variable_to_attribute';
+       
+       /**
+        * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::$tagName
+        */
+       public $tagName = 'styleattribute';
+       
+       /**
+        * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::handleDelete()
+        */
+       protected function handleDelete(array $items) {
+               $sql = "DELETE FROM     wcf".WCF_N."_".$this->tableName."
+                       WHERE           packageID = ?
+                                       AND cssSelector = ?
+                                       AND attributeName = ?
+                                       AND variableName = ?";
+               $statement = WCF::getDB()->prepareStatement($sql);
+               
+               foreach ($items as $item) {
+                       $statement->execute(array(
+                               $this->installation->getPackageID(),
+                               $item['elements']['selector'],
+                               $item['elements']['name'],
+                               $item['elements']['value']
+                       ));
+               }
+       }
+       
+       /**
+        * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::prepareImport()
+        */
+       protected function prepareImport(array $data) {
+               return array(
+                       'cssSelector' => $data['elements']['selector'],
+                       'attributeName' => $data['elements']['name'],
+                       'variableName' => $data['elements']['value']
+               );
+       }
+       
+       /**
+        * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::findExistingItem()
+        */
+       protected function findExistingItem(array $data) {
+               return null;
+       }
+       
+       /**
+        * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::import()
+        */     
+       protected function import(array $row, array $data) {
+               $this->styleVariables[] = $data;
+       }
+       
+       /**
+        * It is not possible to properly update and insert values without
+        * spamming loads of queries for each import, thus delete all
+        * matching variables first and insert them afterwards.
+        * 
+        * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::postImport()
+        */
+       protected function postImport() {
+               if (!count($this->styleVariables)) return;
+               
+               // delete items first
+               $sql = "DELETE FROM     wcf".WCF_N."_".$this->tableName."
+                       WHERE           packageID = ?
+                                       AND cssSelector = ?
+                                       AND attributeName = ?
+                                       AND variableName = ?";
+               $statement = WCF::getDB()->prepareStatement($sql);
+               foreach ($this->styleVariables as $variable) {
+                       $statement->execute(array(
+                               $this->installation->getPackageID(),
+                               $variable['cssSelector'],
+                               $variable['attributeName'],
+                               $variable['variableName']
+                       ));
+               }
+               
+               // insert items
+               $sql = "INSERT INTO     wcf".WCF_N."_".$this->tableName."
+                                       (packageID, cssSelector, attributeName, variableName)
+                       VALUES          (?, ?, ?, ?)";
+               $statement = WCF::getDB()->prepareStatement($sql);
+               foreach ($this->styleVariables as $variable) {
+                       $statement->execute(array(
+                               $this->installation->getPackageID(),
+                               $variable['cssSelector'],
+                               $variable['attributeName'],
+                               $variable['variableName']
+                       ));
+               }
+       }
+       
+       /**
+        * @see wcf\system\package\plugin\IPackageInstallationPlugin::uninstall()
+        */
+       public function uninstall() {
+               parent::uninstall();
+               
+               $this->cleanup();
+       }
+       
+       /**
+        * Updates styles files of all styles.
+        */
+       protected function cleanup() {
+               // get all styles
+               $styleList = new StyleList();
+               $styleList->sqlLimit = 0;
+               $styleList->readObjects();
+               
+               foreach ($styleList->getObjects() as $style) {
+                       $styleEditor = new StyleEditor($style);
+                       $style->writeStyleFile();
+               }
+       }
+}
diff --git a/wcfsetup/install/files/lib/system/package/plugin/StyleAttributesPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/StyleAttributesPackageInstallationPlugin.class.php
deleted file mode 100644 (file)
index b56b2da..0000000
+++ /dev/null
@@ -1,144 +0,0 @@
-<?php
-namespace wcf\system\package\plugin;
-use wcf\data\style\StyleEditor;
-use wcf\data\style\StyleList;
-use wcf\system\WCF;
-
-/**
- * This PIP installs, updates or deletes style attributes.
- * 
- * @author     Marcel Werk
- * @copyright  2001-2011 WoltLab GmbH
- * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package    com.woltlab.wcf
- * @subpackage system.package.plugin
- * @category   Community Framework
- */
-class StyleAttributesPackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin {
-       /**
-        * list of updated or new style variables
-        * @var array
-        */     
-       protected $styleVariables = array();
-       
-       /**
-        * @see wcf\system\package\plugin\AbstractPackageInstallationPlugin::$tableName
-        */     
-       public $tableName = 'style_variable_to_attribute';
-       
-       /**
-        * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::$tagName
-        */
-       public $tagName = 'styleattribute';
-       
-       /**
-        * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::handleDelete()
-        */
-       protected function handleDelete(array $items) {
-               $sql = "DELETE FROM     wcf".WCF_N."_".$this->tableName."
-                       WHERE           packageID = ?
-                                       AND cssSelector = ?
-                                       AND attributeName = ?
-                                       AND variableName = ?";
-               $statement = WCF::getDB()->prepareStatement($sql);
-               
-               foreach ($items as $item) {
-                       $statement->execute(array(
-                               $this->installation->getPackageID(),
-                               $item['elements']['selector'],
-                               $item['elements']['name'],
-                               $item['elements']['value']
-                       ));
-               }
-       }
-       
-       /**
-        * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::prepareImport()
-        */
-       protected function prepareImport(array $data) {
-               return array(
-                       'cssSelector' => $data['elements']['selector'],
-                       'attributeName' => $data['elements']['name'],
-                       'variableName' => $data['elements']['value']
-               );
-       }
-       
-       /**
-        * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::findExistingItem()
-        */
-       protected function findExistingItem(array $data) {
-               return null;
-       }
-       
-       /**
-        * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::import()
-        */     
-       protected function import(array $row, array $data) {
-               $this->styleVariables[] = $data;
-       }
-       
-       /**
-        * It is not possible to properly update and insert values without
-        * spamming loads of queries for each import, thus delete all
-        * matching variables first and insert them afterwards.
-        * 
-        * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::postImport()
-        */
-       protected function postImport() {
-               if (!count($this->styleVariables)) return;
-               
-               // delete items first
-               $sql = "DELETE FROM     wcf".WCF_N."_".$this->tableName."
-                       WHERE           packageID = ?
-                                       AND cssSelector = ?
-                                       AND attributeName = ?
-                                       AND variableName = ?";
-               $statement = WCF::getDB()->prepareStatement($sql);
-               foreach ($this->styleVariables as $variable) {
-                       $statement->execute(array(
-                               $this->installation->getPackageID(),
-                               $variable['cssSelector'],
-                               $variable['attributeName'],
-                               $variable['variableName']
-                       ));
-               }
-               
-               // insert items
-               $sql = "INSERT INTO     wcf".WCF_N."_".$this->tableName."
-                                       (packageID, cssSelector, attributeName, variableName)
-                       VALUES          (?, ?, ?, ?)";
-               $statement = WCF::getDB()->prepareStatement($sql);
-               foreach ($this->styleVariables as $variable) {
-                       $statement->execute(array(
-                               $this->installation->getPackageID(),
-                               $variable['cssSelector'],
-                               $variable['attributeName'],
-                               $variable['variableName']
-                       ));
-               }
-       }
-       
-       /**
-        * @see wcf\system\package\plugin\IPackageInstallationPlugin::uninstall()
-        */
-       public function uninstall() {
-               parent::uninstall();
-               
-               $this->cleanup();
-       }
-       
-       /**
-        * Updates styles files of all styles.
-        */
-       protected function cleanup() {
-               // get all styles
-               $styleList = new StyleList();
-               $styleList->sqlLimit = 0;
-               $styleList->readObjects();
-               
-               foreach ($styleList->getObjects() as $style) {
-                       $styleEditor = new StyleEditor($style);
-                       $style->writeStyleFile();
-               }
-       }
-}
diff --git a/wcfsetup/install/files/lib/system/package/plugin/TemplatePackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/TemplatePackageInstallationPlugin.class.php
new file mode 100644 (file)
index 0000000..b77bc45
--- /dev/null
@@ -0,0 +1,73 @@
+<?php
+namespace wcf\system\package\plugin;
+use wcf\system\exception\SystemException;
+use wcf\system\io\Tar;
+use wcf\system\package\TemplatesFileHandler;
+use wcf\system\WCF;
+use wcf\util\FileUtil;
+
+/**
+ * This PIP installs, updates or deletes by a package delivered templates.
+ *
+ * @author     Benjamin Kunz
+ * @copyright  2001-2011 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    com.woltlab.wcf
+ * @subpackage system.package.plugin
+ * @category   Community Framework
+ */
+class TemplatePackageInstallationPlugin extends AbstractPackageInstallationPlugin {
+       /**
+        * @see wcf\system\package\plugin\AbstractPackageInstallationPlugin::$tableName
+        */     
+       public $tableName = 'template';
+       
+       /**
+        * @see wcf\system\package\plugin\IPackageInstallationPlugin::install()
+        */
+       public function install() {
+               parent::install();
+
+               // extract files.tar to temp folder
+               $sourceFile = $this->installation->getArchive()->extractTar($this->instruction['value'], 'templates_');
+               
+               // create file handler
+               $fileHandler = new TemplatesFileHandler($this->installation);
+               
+               // extract content of files.tar
+               $packageDir = FileUtil::addTrailingSlash(FileUtil::getRealPath(WCF_DIR.$this->installation->getPackage()->packageDir));
+               
+               $fileInstaller = $this->installation->extractFiles($packageDir.'templates/', $sourceFile, $fileHandler);
+               
+               // delete temporary sourceArchive
+               @unlink($sourceFile);
+       }
+       
+       /**
+        * Uninstalls the templates of this package.
+        */
+       public function uninstall() {
+               // create templates list
+               $templates = array();
+               
+               // get templates from log
+               $sql = "SELECT  templateName
+                       FROM    wcf".WCF_N."_template
+                       WHERE   packageID = ?";
+               $statement = WCF::getDB()->prepareStatement($sql);
+               $statement->execute(array($this->installation->getPackageID()));
+               while ($row = $statement->fetchArray()) {
+                       $templates[] = 'templates/'.$row['templateName'].'.tpl';
+               }
+               
+               if (count($templates) > 0) {
+                       // delete template files
+                       $packageDir = FileUtil::addTrailingSlash(FileUtil::getRealPath(WCF_DIR.$this->installation->getPackage()->packageDir));
+                       $deleteEmptyDirectories = $this->installation->getPackage()->standalone;
+                       $this->installation->deleteFiles($packageDir, $templates, false, $deleteEmptyDirectories);
+                       
+                       // delete log entries
+                       parent::uninstall();
+               }
+       }
+}
diff --git a/wcfsetup/install/files/lib/system/package/plugin/TemplatesPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/TemplatesPackageInstallationPlugin.class.php
deleted file mode 100644 (file)
index b7c499f..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-<?php
-namespace wcf\system\package\plugin;
-use wcf\system\exception\SystemException;
-use wcf\system\io\Tar;
-use wcf\system\package\TemplatesFileHandler;
-use wcf\system\WCF;
-use wcf\util\FileUtil;
-
-/**
- * This PIP installs, updates or deletes by a package delivered templates.
- *
- * @author     Benjamin Kunz
- * @copyright  2001-2011 WoltLab GmbH
- * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package    com.woltlab.wcf
- * @subpackage system.package.plugin
- * @category   Community Framework
- */
-class TemplatesPackageInstallationPlugin extends AbstractPackageInstallationPlugin {
-       /**
-        * @see wcf\system\package\plugin\AbstractPackageInstallationPlugin::$tableName
-        */     
-       public $tableName = 'template';
-       
-       /**
-        * @see wcf\system\package\plugin\IPackageInstallationPlugin::install()
-        */
-       public function install() {
-               parent::install();
-
-               // extract files.tar to temp folder
-               $sourceFile = $this->installation->getArchive()->extractTar($this->instruction['value'], 'templates_');
-               
-               // create file handler
-               $fileHandler = new TemplatesFileHandler($this->installation);
-               
-               // extract content of files.tar
-               $packageDir = FileUtil::addTrailingSlash(FileUtil::getRealPath(WCF_DIR.$this->installation->getPackage()->packageDir));
-               
-               $fileInstaller = $this->installation->extractFiles($packageDir.'templates/', $sourceFile, $fileHandler);
-               
-               // delete temporary sourceArchive
-               @unlink($sourceFile);
-       }
-       
-       /**
-        * Uninstalls the templates of this package.
-        */
-       public function uninstall() {
-               // create templates list
-               $templates = array();
-               
-               // get templates from log
-               $sql = "SELECT  templateName
-                       FROM    wcf".WCF_N."_template
-                       WHERE   packageID = ?";
-               $statement = WCF::getDB()->prepareStatement($sql);
-               $statement->execute(array($this->installation->getPackageID()));
-               while ($row = $statement->fetchArray()) {
-                       $templates[] = 'templates/'.$row['templateName'].'.tpl';
-               }
-               
-               if (count($templates) > 0) {
-                       // delete template files
-                       $packageDir = FileUtil::addTrailingSlash(FileUtil::getRealPath(WCF_DIR.$this->installation->getPackage()->packageDir));
-                       $deleteEmptyDirectories = $this->installation->getPackage()->standalone;
-                       $this->installation->deleteFiles($packageDir, $templates, false, $deleteEmptyDirectories);
-                       
-                       // delete log entries
-                       parent::uninstall();
-               }
-       }
-}
diff --git a/wcfsetup/install/files/lib/system/package/plugin/UserGroupOptionPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/UserGroupOptionPackageInstallationPlugin.class.php
new file mode 100644 (file)
index 0000000..dae6441
--- /dev/null
@@ -0,0 +1,165 @@
+<?php
+namespace wcf\system\package\plugin;
+use wcf\data\user\group\option\UserGroupOption;
+use wcf\data\user\group\option\UserGroupOptionEditor;
+use wcf\data\user\group\UserGroup;
+use wcf\system\WCF;
+use wcf\util\StringUtil;
+
+/**
+ * This PIP installs, updates or deletes user group permissions.
+ *
+ * @author     Benjamin Kunz
+ * @copyright  2001-2011 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    com.woltlab.wcf
+ * @subpackage system.package.plugin
+ * @category   Community Framework
+ */
+class UserGroupOptionPackageInstallationPlugin extends AbstractOptionPackageInstallationPlugin {
+       /**
+        * @see wcf\system\package\plugin\AbstractPackageInstallationPlugin::$tableName
+        */     
+       public $tableName = 'user_group_option';
+
+       public static $reservedTags = array('name', 'optiontype', 'defaultvalue', 'admindefaultvalue', 'validationpattern', 'showorder', 'categoryname', 'selectoptions', 'enableoptions', 'permissions', 'options', 'attrs', 'cdata');
+       
+       /**
+        * Deletes group-option-categories and/or group-options which where installed by the package.
+        */
+       public function uninstall() {
+               // Delete value-entries using categories or options
+               // which will be deleted.
+               $sql = "DELETE FROM     wcf".WCF_N."_user_group_option_value
+                       WHERE           optionID IN (
+                                               SELECT  optionID
+                                               FROM    wcf".WCF_N."_user_group_option
+                                               WHERE   packageID = ?
+                                       )";
+               $statement = WCF::getDB()->prepareStatement($sql);
+               $statement->execute(array($this->installation->getPackageID()));
+                       
+               parent::uninstall();
+       }
+       
+       /**
+        * @see wcf\system\package\plugin\AbstractOptionPackageInstallationPlugin::saveOption()
+        */
+       protected function saveOption($option, $categoryName, $existingOptionID = 0) {
+               // default values
+               $optionName = $optionType = $defaultValue = $adminDefaultValue = $validationPattern = $enableOptions = $permissions = $options = '';
+               $showOrder = null;
+               
+               // get values
+               if (isset($option['name'])) $optionName = $option['name'];
+               if (isset($option['optiontype'])) $optionType = $option['optiontype'];
+               if (isset($option['defaultvalue'])) $defaultValue = $option['defaultvalue'];
+               if (isset($option['admindefaultvalue'])) $adminDefaultValue = $option['admindefaultvalue'];
+               if (isset($option['validationpattern'])) $validationPattern = $option['validationpattern'];
+               if (!empty($option['showorder'])) $showOrder = intval($option['showorder']);
+               $showOrder = $this->getShowOrder($showOrder, $categoryName, 'categoryName');
+               if (isset($option['enableoptions'])) $enableOptions = $option['enableoptions'];
+               if (isset($option['permissions'])) $permissions = $option['permissions'];
+               if (isset($option['options'])) $options = $option['options'];
+               
+               // check if optionType exists
+               $className = 'wcf\system\option\user\group\\'.StringUtil::firstCharToUpperCase($optionType).'UserGroupOptionType';
+               if (!class_exists($className)) {
+                       throw new SystemException("unable to find class '".$className."'");
+               }
+               
+               // collect additional tags and their values
+               $additionalData = array();
+               foreach ($option as $tag => $value) {
+                       if (!in_array($tag, self::$reservedTags)) $additionalData[$tag] = $value;
+               }
+               
+               // check if the otion exist already and was installed by this package
+               $sql = "SELECT  optionID
+                       FROM    wcf".WCF_N."_user_group_option
+                       WHERE   optionName = ?
+                       AND     packageID = ?";
+               $statement = WCF::getDB()->prepareStatement($sql);
+               $statement->execute(array(
+                       $optionName,
+                       $this->installation->getPackageID()
+               ));
+               $row = $statement->fetchArray();
+               
+               $data = array(
+                       'categoryName' => $categoryName,
+                       'optionType' => $optionType,
+                       'defaultValue' => $defaultValue,
+                       'adminDefaultValue' => $adminDefaultValue,
+                       'validationPattern' => $validationPattern,
+                       'showOrder' => $showOrder,
+                       'enableOptions' => $enableOptions,
+                       'permissions' => $permissions,
+                       'options' => $options,
+                       'additionalData' => serialize($additionalData)
+               );
+               
+               if (!empty($row['optionID'])) {
+                       // update existing option
+                       $optionID = $row['optionID'];
+                       
+                       $groupOption = new UserGroupOption(null, $row);
+                       $groupOptionEditor = new UserGroupOptionEditor($groupOption);
+                       $groupOptionEditor->update($data);
+               }
+               else {
+                       // add new option
+                       $data['packageID'] = $this->installation->getPackageID();
+                       $data['optionName'] = $optionName;
+                       
+                       $groupOptionEditor = UserGroupOptionEditor::create($data);
+                       $optionID = $groupOptionEditor->optionID;
+                       
+                       // get default group ("everyone")
+                       $sql = "SELECT  groupID
+                               FROM    wcf".WCF_N."_user_group
+                               WHERE   groupType = ?";
+                       $statement = WCF::getDB()->prepareStatement($sql);
+                       $statement->execute(array(UserGroup::EVERYONE));
+                       $row = $statement->fetchArray();
+                       
+                       // save default value
+                       $sql = "INSERT INTO     wcf".WCF_N."_user_group_option_value
+                                               (groupID, optionID, optionValue)
+                               VALUES          (?, ?, ?)";
+                       $statement = WCF::getDB()->prepareStatement($sql);
+                       $statement->execute(array($row['groupID'], $optionID, $defaultValue));
+                       
+                       if ($adminDefaultValue && $defaultValue != $adminDefaultValue) {
+                               $sql = "SELECT  groupID
+                                       FROM    wcf".WCF_N."_user_group_option_value
+                                       WHERE   optionID = (
+                                                       SELECT  optionID
+                                                       FROM    wcf".WCF_N."_user_group_option
+                                                       WHERE   optionName = ?
+                                               )
+                                               AND optionValue = '1'";
+                               $statement2 = WCF::getDB()->prepareStatement($sql);
+                               $statement2->execute(array('admin.general.canUseAcp'));
+                               
+                               $acpGroups = array();
+                               while ($row = $statement2->fetchArray()) {
+                                       $acpGroups[] = $row['groupID'];
+                               }
+                               
+                               $statement2->execute(array('admin.user.canEditGroup'));
+                               while ($row = $statement2->fetchArray()) {
+                                       if (!in_array($row['groupID'], $acpGroups)) {
+                                               continue;
+                                       }
+                                       
+                                       $statement->execute(array(
+                                               $row['groupID'],
+                                               $optionID,
+                                               $adminDefaultValue
+                                       ));
+                               }
+                       }
+               }
+       }
+}
diff --git a/wcfsetup/install/files/lib/system/package/plugin/UserGroupOptionsPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/UserGroupOptionsPackageInstallationPlugin.class.php
deleted file mode 100644 (file)
index 1c34e03..0000000
+++ /dev/null
@@ -1,165 +0,0 @@
-<?php
-namespace wcf\system\package\plugin;
-use wcf\data\user\group\option\UserGroupOption;
-use wcf\data\user\group\option\UserGroupOptionEditor;
-use wcf\data\user\group\UserGroup;
-use wcf\system\WCF;
-use wcf\util\StringUtil;
-
-/**
- * This PIP installs, updates or deletes user group permissions.
- *
- * @author     Benjamin Kunz
- * @copyright  2001-2011 WoltLab GmbH
- * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package    com.woltlab.wcf
- * @subpackage system.package.plugin
- * @category   Community Framework
- */
-class UserGroupOptionsPackageInstallationPlugin extends AbstractOptionPackageInstallationPlugin {
-       /**
-        * @see wcf\system\package\plugin\AbstractPackageInstallationPlugin::$tableName
-        */     
-       public $tableName = 'user_group_option';
-
-       public static $reservedTags = array('name', 'optiontype', 'defaultvalue', 'admindefaultvalue', 'validationpattern', 'showorder', 'categoryname', 'selectoptions', 'enableoptions', 'permissions', 'options', 'attrs', 'cdata');
-       
-       /**
-        * Deletes group-option-categories and/or group-options which where installed by the package.
-        */
-       public function uninstall() {
-               // Delete value-entries using categories or options
-               // which will be deleted.
-               $sql = "DELETE FROM     wcf".WCF_N."_user_group_option_value
-                       WHERE           optionID IN (
-                                               SELECT  optionID
-                                               FROM    wcf".WCF_N."_user_group_option
-                                               WHERE   packageID = ?
-                                       )";
-               $statement = WCF::getDB()->prepareStatement($sql);
-               $statement->execute(array($this->installation->getPackageID()));
-                       
-               parent::uninstall();
-       }
-       
-       /**
-        * @see wcf\system\package\plugin\AbstractOptionPackageInstallationPlugin::saveOption()
-        */
-       protected function saveOption($option, $categoryName, $existingOptionID = 0) {
-               // default values
-               $optionName = $optionType = $defaultValue = $adminDefaultValue = $validationPattern = $enableOptions = $permissions = $options = '';
-               $showOrder = null;
-               
-               // get values
-               if (isset($option['name'])) $optionName = $option['name'];
-               if (isset($option['optiontype'])) $optionType = $option['optiontype'];
-               if (isset($option['defaultvalue'])) $defaultValue = $option['defaultvalue'];
-               if (isset($option['admindefaultvalue'])) $adminDefaultValue = $option['admindefaultvalue'];
-               if (isset($option['validationpattern'])) $validationPattern = $option['validationpattern'];
-               if (!empty($option['showorder'])) $showOrder = intval($option['showorder']);
-               $showOrder = $this->getShowOrder($showOrder, $categoryName, 'categoryName');
-               if (isset($option['enableoptions'])) $enableOptions = $option['enableoptions'];
-               if (isset($option['permissions'])) $permissions = $option['permissions'];
-               if (isset($option['options'])) $options = $option['options'];
-               
-               // check if optionType exists
-               $className = 'wcf\system\option\user\group\\'.StringUtil::firstCharToUpperCase($optionType).'UserGroupOptionType';
-               if (!class_exists($className)) {
-                       throw new SystemException("unable to find class '".$className."'");
-               }
-               
-               // collect additional tags and their values
-               $additionalData = array();
-               foreach ($option as $tag => $value) {
-                       if (!in_array($tag, self::$reservedTags)) $additionalData[$tag] = $value;
-               }
-               
-               // check if the otion exist already and was installed by this package
-               $sql = "SELECT  optionID
-                       FROM    wcf".WCF_N."_user_group_option
-                       WHERE   optionName = ?
-                       AND     packageID = ?";
-               $statement = WCF::getDB()->prepareStatement($sql);
-               $statement->execute(array(
-                       $optionName,
-                       $this->installation->getPackageID()
-               ));
-               $row = $statement->fetchArray();
-               
-               $data = array(
-                       'categoryName' => $categoryName,
-                       'optionType' => $optionType,
-                       'defaultValue' => $defaultValue,
-                       'adminDefaultValue' => $adminDefaultValue,
-                       'validationPattern' => $validationPattern,
-                       'showOrder' => $showOrder,
-                       'enableOptions' => $enableOptions,
-                       'permissions' => $permissions,
-                       'options' => $options,
-                       'additionalData' => serialize($additionalData)
-               );
-               
-               if (!empty($row['optionID'])) {
-                       // update existing option
-                       $optionID = $row['optionID'];
-                       
-                       $groupOption = new UserGroupOption(null, $row);
-                       $groupOptionEditor = new UserGroupOptionEditor($groupOption);
-                       $groupOptionEditor->update($data);
-               }
-               else {
-                       // add new option
-                       $data['packageID'] = $this->installation->getPackageID();
-                       $data['optionName'] = $optionName;
-                       
-                       $groupOptionEditor = UserGroupOptionEditor::create($data);
-                       $optionID = $groupOptionEditor->optionID;
-                       
-                       // get default group ("everyone")
-                       $sql = "SELECT  groupID
-                               FROM    wcf".WCF_N."_user_group
-                               WHERE   groupType = ?";
-                       $statement = WCF::getDB()->prepareStatement($sql);
-                       $statement->execute(array(UserGroup::EVERYONE));
-                       $row = $statement->fetchArray();
-                       
-                       // save default value
-                       $sql = "INSERT INTO     wcf".WCF_N."_user_group_option_value
-                                               (groupID, optionID, optionValue)
-                               VALUES          (?, ?, ?)";
-                       $statement = WCF::getDB()->prepareStatement($sql);
-                       $statement->execute(array($row['groupID'], $optionID, $defaultValue));
-                       
-                       if ($adminDefaultValue && $defaultValue != $adminDefaultValue) {
-                               $sql = "SELECT  groupID
-                                       FROM    wcf".WCF_N."_user_group_option_value
-                                       WHERE   optionID = (
-                                                       SELECT  optionID
-                                                       FROM    wcf".WCF_N."_user_group_option
-                                                       WHERE   optionName = ?
-                                               )
-                                               AND optionValue = '1'";
-                               $statement2 = WCF::getDB()->prepareStatement($sql);
-                               $statement2->execute(array('admin.general.canUseAcp'));
-                               
-                               $acpGroups = array();
-                               while ($row = $statement2->fetchArray()) {
-                                       $acpGroups[] = $row['groupID'];
-                               }
-                               
-                               $statement2->execute(array('admin.user.canEditGroup'));
-                               while ($row = $statement2->fetchArray()) {
-                                       if (!in_array($row['groupID'], $acpGroups)) {
-                                               continue;
-                                       }
-                                       
-                                       $statement->execute(array(
-                                               $row['groupID'],
-                                               $optionID,
-                                               $adminDefaultValue
-                                       ));
-                               }
-                       }
-               }
-       }
-}
diff --git a/wcfsetup/install/files/lib/system/package/plugin/UserOptionPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/UserOptionPackageInstallationPlugin.class.php
new file mode 100644 (file)
index 0000000..633d5d3
--- /dev/null
@@ -0,0 +1,173 @@
+<?php
+namespace wcf\system\package\plugin;
+use wcf\data\user\option\category\UserOptionCategory;
+use wcf\data\user\option\category\UserOptionCategoryEditor;
+use wcf\data\user\option\UserOption;
+use wcf\data\user\option\UserOptionEditor;
+use wcf\system\exception\SystemException;
+use wcf\system\WCF;
+use wcf\util\StringUtil;
+
+/**
+ * This PIP installs, updates or deletes user fields.
+ *
+ * @author     Benjamin Kunz
+ * @copyright  2001-2011 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    com.woltlab.wcf
+ * @subpackage system.package.plugin
+ * @category   Community Framework
+ */
+class UserOptionPackageInstallationPlugin extends AbstractOptionPackageInstallationPlugin {
+       /**
+        * @see wcf\system\package\plugin\AbstractPackageInstallationPlugin::$tableName
+        */     
+       public $tableName = 'user_option';
+
+       public static $reservedTags = array('name', 'optiontype', 'defaultvalue', 'validationpattern', 'required', 'editable', 'visible', 'searchable', 'showorder', 'outputclass', 'selectoptions', 'enableoptions', 'disabled', 'categoryname', 'permissions', 'options', 'attrs', 'cdata');
+       
+       /**
+        * Installs user option categories.
+        *
+        * @param       array           $category
+        * @param       array           $categoryXML
+        */
+       protected function saveCategory($category, $categoryXML = null) {
+               $icon = $menuIcon = '';
+               if (isset($categoryXML['icon'])) $icon = $categoryXML['icon'];
+               if (isset($categoryXML['menuicon'])) $menuIcon = $categoryXML['menuicon'];
+               
+               // use for create and update
+               $data = array(
+                       'parentCategoryName' => $category['parentCategoryName'],
+                       'categoryIconS' => $menuIcon,
+                       'categoryIconM' => $icon,
+                       'permissions' => $category['permissions'],
+                       'options' => $category['options']
+               );
+               // append show order if explicitly stated
+               if ($category['showOrder'] !== null) $data['showOrder'] = $category['showOrder'];
+               
+               $userOptionCategory = UserOptionCategory::getCategoryByName($category['categoryName'], $this->installation->getPackageID());
+               if ($userOptionCategory->categoryID) {
+                       $categoryEditor = new UserOptionCategoryEditor($userOptionCategory);
+                       $categoryEditor->update($data);
+               }
+               else {
+                       // append data fields for create
+                       $data['packageID'] = $this->installation->getPackageID();
+                       $data['categoryName'] = $category['categoryName'];
+                       
+                       UserOptionCategoryEditor::create($data);
+               }
+       }
+       
+       /**
+        * @see wcf\system\package\plugin\AbstractOptionPackageInstallationPlugin::saveOption()
+        */
+       protected function saveOption($option, $categoryName, $existingOptionID = 0) {
+               // default values
+               $optionName = $optionType = $defaultValue = $validationPattern = $outputClass = $selectOptions = $enableOptions = $permissions = $options = '';
+               $required = $editable = $visible = $searchable = $disabled = $askDuringRegistration = 0;
+               $showOrder = null;
+               
+               // get values
+               if (isset($option['name'])) $optionName                         = $option['name'];
+               if (isset($option['optiontype'])) $optionType                   = $option['optiontype'];
+               if (isset($option['defaultvalue'])) $defaultValue               = $option['defaultvalue'];
+               if (isset($option['validationpattern'])) $validationPattern     = $option['validationpattern'];
+               if (isset($option['required'])) $required                       = intval($option['required']);
+               if (isset($option['askduringregistration'])) $askDuringRegistration = intval($option['askduringregistration']);
+               if (isset($option['editable'])) $editable                       = intval($option['editable']);
+               if (isset($option['visible'])) $visible                         = intval($option['visible']);
+               if (isset($option['searchable'])) $searchable                   = intval($option['searchable']);
+               if (isset($option['showorder'])) $showOrder                     = intval($option['showorder']);
+               if (isset($option['outputclass'])) $outputClass                 = $option['outputclass'];
+               if (isset($option['selectoptions'])) $selectOptions             = $option['selectoptions'];
+               if (isset($option['enableoptions'])) $enableOptions             = $option['enableoptions'];
+               if (isset($option['disabled'])) $disabled                       = intval($option['disabled']);
+               $showOrder = $this->getShowOrder($showOrder, $categoryName, 'categoryName');
+               if (isset($option['permissions'])) $permissions                 = $option['permissions'];
+               if (isset($option['options'])) $options                         = $option['options'];
+               
+               
+               // check if optionType exists
+               $className = 'wcf\system\option\\'.StringUtil::firstCharToUpperCase($optionType).'OptionType';
+               if (!class_exists($className)) {
+                       throw new SystemException("unable to find class '".$className."'");
+               }
+               
+               // collect additional tags and their values
+               $additionalData = array();
+               foreach ($option as $tag => $value) {
+                       if (!in_array($tag, self::$reservedTags)) $additionalData[$tag] = $value;
+               }
+               
+               // get optionID if it was installed by this package already
+               $sql = "SELECT  *
+                       FROM    wcf".WCF_N."_".$this->tableName."
+                       WHERE   optionName = ?
+                       AND     packageID = ?";
+               $statement = WCF::getDB()->prepareStatement($sql);
+               $statement->execute(array(
+                       $optionName,
+                       $this->installation->getPackageID()
+               ));
+               $result = $statement->fetchArray();
+               
+               // build data array
+               $data = array(
+                       'categoryName' => $categoryName,
+                       'optionType' => $optionType,
+                       'defaultValue' => $defaultValue,
+                       'validationPattern' => $validationPattern,
+                       'selectOptions' => $selectOptions,
+                       'enableOptions' => $enableOptions,
+                       'required' => $required,
+                       'askDuringRegistration' => $askDuringRegistration,
+                       'editable' => $editable,
+                       'visible' => $visible,
+                       'outputClass' => $outputClass,
+                       'searchable' => $searchable,
+                       'showOrder' => $showOrder,
+                       'disabled' => $disabled,
+                       'permissions' => $permissions,
+                       'options' => $options,
+                       'additionalData' => serialize($additionalData)
+               );
+               
+               // update option
+               if (!empty($result['optionID']) && $this->installation->getAction() == 'update') {
+                       $userOption = new UserOption(null, $result);
+                       $userOptionEditor = new UserOptionEditor($userOption);
+                       $userOptionEditor->update($data);
+               }
+               // insert new option
+               else {
+                       // append option name
+                       $data['optionName'] = $optionName;
+                       $data['packageID'] = $this->installation->getPackageID();
+                       UserOptionEditor::create($data);
+               }
+        }
+       
+       /**
+        * Drops the columns from user option value table from options
+        * installed by this package.
+        */
+       public function uninstall() {
+               // get optionsIDs from package
+               $sql = "SELECT  optionID
+                       FROM    wcf".WCF_N."_user_option
+                       WHERE   packageID = ?";
+               $statement = WCF::getDB()->prepareStatement($sql);
+               $statement->execute(array($this->installation->getPackageID()));
+               $optionIDs = array();
+               while ($row = $statement->fetchArray()) {
+                       WCF::getDB()->getEditor()->dropColumn('wcf'.WCF_N.'_user_option_value', 'userOption'.$row['optionID']);
+               }
+               
+               // uninstall options and categories
+               parent::uninstall();
+       }
+}
diff --git a/wcfsetup/install/files/lib/system/package/plugin/UserOptionsPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/UserOptionsPackageInstallationPlugin.class.php
deleted file mode 100644 (file)
index 2b4d161..0000000
+++ /dev/null
@@ -1,173 +0,0 @@
-<?php
-namespace wcf\system\package\plugin;
-use wcf\data\user\option\category\UserOptionCategory;
-use wcf\data\user\option\category\UserOptionCategoryEditor;
-use wcf\data\user\option\UserOption;
-use wcf\data\user\option\UserOptionEditor;
-use wcf\system\exception\SystemException;
-use wcf\system\WCF;
-use wcf\util\StringUtil;
-
-/**
- * This PIP installs, updates or deletes user fields.
- *
- * @author     Benjamin Kunz
- * @copyright  2001-2011 WoltLab GmbH
- * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package    com.woltlab.wcf
- * @subpackage system.package.plugin
- * @category   Community Framework
- */
-class UserOptionsPackageInstallationPlugin extends AbstractOptionPackageInstallationPlugin {
-       /**
-        * @see wcf\system\package\plugin\AbstractPackageInstallationPlugin::$tableName
-        */     
-       public $tableName = 'user_option';
-
-       public static $reservedTags = array('name', 'optiontype', 'defaultvalue', 'validationpattern', 'required', 'editable', 'visible', 'searchable', 'showorder', 'outputclass', 'selectoptions', 'enableoptions', 'disabled', 'categoryname', 'permissions', 'options', 'attrs', 'cdata');
-       
-       /**
-        * Installs user option categories.
-        *
-        * @param       array           $category
-        * @param       array           $categoryXML
-        */
-       protected function saveCategory($category, $categoryXML = null) {
-               $icon = $menuIcon = '';
-               if (isset($categoryXML['icon'])) $icon = $categoryXML['icon'];
-               if (isset($categoryXML['menuicon'])) $menuIcon = $categoryXML['menuicon'];
-               
-               // use for create and update
-               $data = array(
-                       'parentCategoryName' => $category['parentCategoryName'],
-                       'categoryIconS' => $menuIcon,
-                       'categoryIconM' => $icon,
-                       'permissions' => $category['permissions'],
-                       'options' => $category['options']
-               );
-               // append show order if explicitly stated
-               if ($category['showOrder'] !== null) $data['showOrder'] = $category['showOrder'];
-               
-               $userOptionCategory = UserOptionCategory::getCategoryByName($category['categoryName'], $this->installation->getPackageID());
-               if ($userOptionCategory->categoryID) {
-                       $categoryEditor = new UserOptionCategoryEditor($userOptionCategory);
-                       $categoryEditor->update($data);
-               }
-               else {
-                       // append data fields for create
-                       $data['packageID'] = $this->installation->getPackageID();
-                       $data['categoryName'] = $category['categoryName'];
-                       
-                       UserOptionCategoryEditor::create($data);
-               }
-       }
-       
-       /**
-        * @see wcf\system\package\plugin\AbstractOptionPackageInstallationPlugin::saveOption()
-        */
-       protected function saveOption($option, $categoryName, $existingOptionID = 0) {
-               // default values
-               $optionName = $optionType = $defaultValue = $validationPattern = $outputClass = $selectOptions = $enableOptions = $permissions = $options = '';
-               $required = $editable = $visible = $searchable = $disabled = $askDuringRegistration = 0;
-               $showOrder = null;
-               
-               // get values
-               if (isset($option['name'])) $optionName                         = $option['name'];
-               if (isset($option['optiontype'])) $optionType                   = $option['optiontype'];
-               if (isset($option['defaultvalue'])) $defaultValue               = $option['defaultvalue'];
-               if (isset($option['validationpattern'])) $validationPattern     = $option['validationpattern'];
-               if (isset($option['required'])) $required                       = intval($option['required']);
-               if (isset($option['askduringregistration'])) $askDuringRegistration = intval($option['askduringregistration']);
-               if (isset($option['editable'])) $editable                       = intval($option['editable']);
-               if (isset($option['visible'])) $visible                         = intval($option['visible']);
-               if (isset($option['searchable'])) $searchable                   = intval($option['searchable']);
-               if (isset($option['showorder'])) $showOrder                     = intval($option['showorder']);
-               if (isset($option['outputclass'])) $outputClass                 = $option['outputclass'];
-               if (isset($option['selectoptions'])) $selectOptions             = $option['selectoptions'];
-               if (isset($option['enableoptions'])) $enableOptions             = $option['enableoptions'];
-               if (isset($option['disabled'])) $disabled                       = intval($option['disabled']);
-               $showOrder = $this->getShowOrder($showOrder, $categoryName, 'categoryName');
-               if (isset($option['permissions'])) $permissions                 = $option['permissions'];
-               if (isset($option['options'])) $options                         = $option['options'];
-               
-               
-               // check if optionType exists
-               $className = 'wcf\system\option\\'.StringUtil::firstCharToUpperCase($optionType).'OptionType';
-               if (!class_exists($className)) {
-                       throw new SystemException("unable to find class '".$className."'");
-               }
-               
-               // collect additional tags and their values
-               $additionalData = array();
-               foreach ($option as $tag => $value) {
-                       if (!in_array($tag, self::$reservedTags)) $additionalData[$tag] = $value;
-               }
-               
-               // get optionID if it was installed by this package already
-               $sql = "SELECT  *
-                       FROM    wcf".WCF_N."_".$this->tableName."
-                       WHERE   optionName = ?
-                       AND     packageID = ?";
-               $statement = WCF::getDB()->prepareStatement($sql);
-               $statement->execute(array(
-                       $optionName,
-                       $this->installation->getPackageID()
-               ));
-               $result = $statement->fetchArray();
-               
-               // build data array
-               $data = array(
-                       'categoryName' => $categoryName,
-                       'optionType' => $optionType,
-                       'defaultValue' => $defaultValue,
-                       'validationPattern' => $validationPattern,
-                       'selectOptions' => $selectOptions,
-                       'enableOptions' => $enableOptions,
-                       'required' => $required,
-                       'askDuringRegistration' => $askDuringRegistration,
-                       'editable' => $editable,
-                       'visible' => $visible,
-                       'outputClass' => $outputClass,
-                       'searchable' => $searchable,
-                       'showOrder' => $showOrder,
-                       'disabled' => $disabled,
-                       'permissions' => $permissions,
-                       'options' => $options,
-                       'additionalData' => serialize($additionalData)
-               );
-               
-               // update option
-               if (!empty($result['optionID']) && $this->installation->getAction() == 'update') {
-                       $userOption = new UserOption(null, $result);
-                       $userOptionEditor = new UserOptionEditor($userOption);
-                       $userOptionEditor->update($data);
-               }
-               // insert new option
-               else {
-                       // append option name
-                       $data['optionName'] = $optionName;
-                       $data['packageID'] = $this->installation->getPackageID();
-                       UserOptionEditor::create($data);
-               }
-        }
-       
-       /**
-        * Drops the columns from user option value table from options
-        * installed by this package.
-        */
-       public function uninstall() {
-               // get optionsIDs from package
-               $sql = "SELECT  optionID
-                       FROM    wcf".WCF_N."_user_option
-                       WHERE   packageID = ?";
-               $statement = WCF::getDB()->prepareStatement($sql);
-               $statement->execute(array($this->installation->getPackageID()));
-               $optionIDs = array();
-               while ($row = $statement->fetchArray()) {
-                       WCF::getDB()->getEditor()->dropColumn('wcf'.WCF_N.'_user_option_value', 'userOption'.$row['optionID']);
-               }
-               
-               // uninstall options and categories
-               parent::uninstall();
-       }
-}