From 0f7229cac63d304598fd69bb4b089127ec846f0c Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Thu, 18 Aug 2016 18:31:34 +0200 Subject: [PATCH] Fix WCF.User.ObjectWatch.Subscribe for different object types --- wcfsetup/install/files/js/WCF.User.js | 12 +++++++++--- .../object/watch/UserObjectWatchAction.class.php | 2 ++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/wcfsetup/install/files/js/WCF.User.js b/wcfsetup/install/files/js/WCF.User.js index c87c440558..77763c89da 100644 --- a/wcfsetup/install/files/js/WCF.User.js +++ b/wcfsetup/install/files/js/WCF.User.js @@ -2586,8 +2586,14 @@ WCF.User.ObjectWatch.Subscribe = Class.extend({ $(this._buttonSelector).each($.proxy(function(index, button) { var $button = $(button); $button.addClass('pointer'); + var $objectType = $button.data('objectType'); var $objectID = $button.data('objectID'); - this._buttons[$objectID] = $button.click($.proxy(this._click, this)); + + if (this._buttons[$objectType] === undefined) { + this._buttons[$objectType] = {}; + } + + this._buttons[$objectType][$objectID] = $button.click($.proxy(this._click, this)); }, this)); WCF.System.Event.addListener('com.woltlab.wcf.objectWatch', 'update', $.proxy(this._updateSubscriptionStatus, this)); @@ -2634,7 +2640,7 @@ WCF.User.ObjectWatch.Subscribe = Class.extend({ } // bind event listener - this._dialog.find('.formSubmit > .jsButtonSave').data('objectID', data.returnValues.objectID).click($.proxy(this._save, this)); + this._dialog.find('.formSubmit > .jsButtonSave').data('objectID', data.returnValues.objectID).data('objectType', data.returnValues.objectType).click($.proxy(this._save, this)); var $enableNotification = this._dialog.find('input[name=enableNotification]').disable(); // toggle subscription @@ -2678,7 +2684,7 @@ WCF.User.ObjectWatch.Subscribe = Class.extend({ * @param object event */ _save: function(event) { - var $button = this._buttons[$(event.currentTarget).data('objectID')]; + var $button = this._buttons[$(event.currentTarget).data('objectType')][$(event.currentTarget).data('objectID')]; var $subscribe = this._dialog.find('input[name=subscribe]:checked').val(); var $enableNotification = (this._dialog.find('input[name=enableNotification]').is(':checked')) ? 1 : 0; diff --git a/wcfsetup/install/files/lib/data/user/object/watch/UserObjectWatchAction.class.php b/wcfsetup/install/files/lib/data/user/object/watch/UserObjectWatchAction.class.php index bec706d6c4..49b2dee199 100644 --- a/wcfsetup/install/files/lib/data/user/object/watch/UserObjectWatchAction.class.php +++ b/wcfsetup/install/files/lib/data/user/object/watch/UserObjectWatchAction.class.php @@ -64,6 +64,7 @@ class UserObjectWatchAction extends AbstractDatabaseObjectAction { return [ 'objectID' => $this->parameters['objectID'], + 'objectType' => $this->parameters['objectType'], 'template' => WCF::getTPL()->fetch('manageSubscription') ]; } @@ -115,6 +116,7 @@ class UserObjectWatchAction extends AbstractDatabaseObjectAction { return [ 'objectID' => $this->parameters['objectID'], + 'objectType' => $this->parameters['objectType'], 'subscribe' => $this->parameters['subscribe'] ]; } -- 2.20.1