Fix WCF.User.ObjectWatch.Subscribe for different object types
authorMatthias Schmidt <gravatronics@live.com>
Thu, 18 Aug 2016 16:31:34 +0000 (18:31 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Thu, 18 Aug 2016 16:31:37 +0000 (18:31 +0200)
wcfsetup/install/files/js/WCF.User.js
wcfsetup/install/files/lib/data/user/object/watch/UserObjectWatchAction.class.php

index c87c4405587fb6fa977da1e2d87c348216376c9d..77763c89da8bd16e6edde933277c7b4d5df66511 100644 (file)
@@ -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;
                
index bec706d6c497112241ed5fa2421d876113908132..49b2dee1991c229a75796411139eb98e7c9f7e50 100644 (file)
@@ -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']
                ];
        }