From: Marcel Werk Date: Tue, 27 Dec 2016 16:28:49 +0000 (+0100) Subject: Merge remote-tracking branch 'refs/remotes/origin/2.1' X-Git-Tag: 3.0.0_RC_3~25 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=1e238e579a5d538062be77283bfc3a956c6a855e;p=GitHub%2FWoltLab%2FWCF.git Merge remote-tracking branch 'refs/remotes/origin/2.1' # Conflicts: # wcfsetup/install/files/lib/system/package/plugin/UserNotificationEventPackageInstallationPlugin.class.php --- 1e238e579a5d538062be77283bfc3a956c6a855e diff --cc wcfsetup/install/files/lib/system/package/plugin/UserNotificationEventPackageInstallationPlugin.class.php index a0fb33aa26,d835a5a9b9..8eb6108ef0 --- a/wcfsetup/install/files/lib/system/package/plugin/UserNotificationEventPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/UserNotificationEventPackageInstallationPlugin.class.php @@@ -44,46 -45,32 +45,32 @@@ class UserNotificationEventPackageInsta AND eventName = ?"; $statement = WCF::getDB()->prepareStatement($sql); foreach ($items as $item) { - $statement->execute(array( + $statement->execute([ $this->installation->getPackageID(), + $this->getObjectTypeID($item['elements']['objecttype']), $item['elements']['name'] - )); + ]); } } /** - * @see \wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::prepareImport() + * @inheritDoc */ protected function prepareImport(array $data) { - // get object type id - $sql = "SELECT object_type.objectTypeID - FROM wcf".WCF_N."_object_type object_type - WHERE object_type.objectType = ? - AND object_type.definitionID IN ( - SELECT definitionID - FROM wcf".WCF_N."_object_type_definition - WHERE definitionName = 'com.woltlab.wcf.notification.objectType' - )"; - $statement = WCF::getDB()->prepareStatement($sql, 1); - $statement->execute([$data['elements']['objecttype']]); - $row = $statement->fetchArray(); - if (empty($row['objectTypeID'])) throw new SystemException("unknown notification object type '".$data['elements']['objecttype']."' given"); - $objectTypeID = $row['objectTypeID']; - $presetMailNotificationType = 'none'; if (isset($data['elements']['presetmailnotificationtype']) && ($data['elements']['presetmailnotificationtype'] == 'instant' || $data['elements']['presetmailnotificationtype'] == 'daily')) { $presetMailNotificationType = $data['elements']['presetmailnotificationtype']; } - return array( + return [ 'eventName' => $data['elements']['name'], 'className' => $data['elements']['classname'], - 'objectTypeID' => $objectTypeID, + 'objectTypeID' => $this->getObjectTypeID($data['elements']['objecttype']), - 'permissions' => (isset($data['elements']['permissions']) ? $data['elements']['permissions'] : ''), - 'options' => (isset($data['elements']['options']) ? $data['elements']['options'] : ''), - 'preset' => (!empty($data['elements']['preset']) ? 1 : 0), + 'permissions' => isset($data['elements']['permissions']) ? $data['elements']['permissions'] : '', + 'options' => isset($data['elements']['options']) ? $data['elements']['options'] : '', + 'preset' => !empty($data['elements']['preset']) ? 1 : 0, 'presetMailNotificationType' => $presetMailNotificationType - ); + ]; } /** @@@ -126,14 -112,37 +113,37 @@@ FROM wcf".WCF_N."_".$this->tableName." WHERE objectTypeID = ? AND eventName = ?"; - $parameters = array( + $parameters = [ $data['objectTypeID'], $data['eventName'] - ); + ]; - return array( + return [ 'sql' => $sql, 'parameters' => $parameters - ); + ]; } + + /** + * Gets the id of given object type id. + * + * @param string $objectType + * @return integer + */ + protected function getObjectTypeID($objectType) { + // get object type id + $sql = "SELECT object_type.objectTypeID + FROM wcf".WCF_N."_object_type object_type + WHERE object_type.objectType = ? + AND object_type.definitionID IN ( + SELECT definitionID + FROM wcf".WCF_N."_object_type_definition + WHERE definitionName = 'com.woltlab.wcf.notification.objectType' + )"; + $statement = WCF::getDB()->prepareStatement($sql, 1); + $statement->execute([$objectType]); + $row = $statement->fetchArray(); + if (empty($row['objectTypeID'])) throw new SystemException("unknown notification object type '".$objectType."' given"); + return $row['objectTypeID']; + } }