From: Marcel Werk Date: Tue, 9 Jul 2013 21:25:51 +0000 (+0200) Subject: Added ACL importer X-Git-Tag: 2.0.0_Beta_5~84 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=fd6bb9005fd6b15dea036f57b202760a6826403a;p=GitHub%2FWoltLab%2FWCF.git Added ACL importer --- diff --git a/wcfsetup/install/files/lib/system/importer/AbstractACLImporter.class.php b/wcfsetup/install/files/lib/system/importer/AbstractACLImporter.class.php new file mode 100644 index 0000000000..a89e1b9705 --- /dev/null +++ b/wcfsetup/install/files/lib/system/importer/AbstractACLImporter.class.php @@ -0,0 +1,84 @@ + + * @package com.woltlab.wcf + * @subpackage system.importer + * @category Community Framework + */ +class AbstractACLImporter implements IImporter { + /** + * object type id for options + * @var integer + */ + protected $objectTypeID = 0; + + /** + * object type name + * @var integer + */ + protected $objectTypeName = ''; + + /** + * available options + * @var array + */ + protected $options = array(); + + /** + * Creates an AbstractACLImporter object. + */ + public function __construct() { + // get options + $sql = "SELECT optionName, optionID + FROM wcf".WCF_N."_acl_option + WHERE objectTypeID = ?"; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute(array($this->objectTypeID)); + while ($row = $statement->fetchArray()) { + $this->options[$row['optionName']] = $row['optionID']; + } + } + + /** + * @see wcf\system\importer\IImporter::import() + */ + public function import($oldID, array $data, array $additionalData = array()) { + if (!isset($this->options[$additionalData['optionName']])) return 0; + $data['optionID'] = $this->options[$additionalData['optionName']]; + + $data['objectID'] = ImportHandler::getInstance()->getNewID($this->objectTypeName, $data['objectID']); + if (!$data['objectID']) return 0; + + if (!empty($data['groupID'])) { + $data['groupID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.user.group', $data['groupID']); + if (!$data['groupID']) return 0; + + $sql = "INSERT INTO wcf".WCF_N."_acl_option_to_group + (optionID, objectID, groupID, optionValue) + VALUES (?, ?, ?, ?)"; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute(array($data['optionID'], $data['objectID'], $data['groupID'], $data['optionValue'])); + + return 1; + } + else if (!empty($data['userID'])) { + $data['userID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.user', $data['userID']); + if (!$data['userID']) return 0; + + $sql = "INSERT INTO wcf".WCF_N."_acl_option_to_user + (optionID, objectID, userID, optionValue) + VALUES (?, ?, ?, ?)"; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute(array($data['optionID'], $data['objectID'], $data['userID'], $data['optionValue'])); + + return 1; + } + } +}