Fix ACL buttons when editing media files successively
authorMatthias Schmidt <gravatronics@live.com>
Wed, 18 Nov 2020 16:32:21 +0000 (17:32 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Wed, 18 Nov 2020 16:32:21 +0000 (17:32 +0100)
Replaces 3a7740a3704339c79d08fd2f5094fa1a1973318b by backporting and using parts of 6ee58cd2865980cd7fa16a1f3ebc660131fc7fd6.

com.woltlab.wcf/templates/aclSimple.tpl
wcfsetup/install/files/acp/templates/aclSimple.tpl
wcfsetup/install/files/js/WoltLabSuite/Core/Media/Editor.js
wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Acl/Simple.js
wcfsetup/install/files/lib/data/media/MediaAction.class.php

index 7e556d8b09e7d1d51e5d1e020064ea508baa0c7e..8d4486ee3ef18ba4797fa2bc8d74bdd7bcca2bfc 100644 (file)
@@ -1,4 +1,5 @@
 {if !$__aclSimplePrefix|isset}{assign var='__aclSimplePrefix' value=''}{/if}
+{if !$__aclInputName|isset}{assign var='__aclInputName' value='aclValues'}{/if}
 
 <div class="section">
        <dl>
@@ -6,11 +7,11 @@
                <dd>
                        <ol class="flexibleButtonGroup">
                                <li>
-                                       <input type="radio" id="{@$__aclSimplePrefix}aclAllowAll" name="aclValues[allowAll]" value="1"{if $aclValues[allowAll]} checked{/if}>
+                                       <input type="radio" id="{@$__aclSimplePrefix}aclAllowAll" name="{@$__aclInputName}[allowAll]" value="1"{if $aclValues[allowAll]} checked{/if}>
                                        <label for="{@$__aclSimplePrefix}aclAllowAll" class="green"><span class="icon icon16 fa-check"></span> {lang}wcf.acp.option.type.boolean.yes{/lang}</label>
                                </li>
                                <li>
-                                       <input type="radio" id="{@$__aclSimplePrefix}aclAllowAll_no" name="aclValues[allowAll]" value="0"{if !$aclValues[allowAll]} checked{/if}>
+                                       <input type="radio" id="{@$__aclSimplePrefix}aclAllowAll_no" name="{@$__aclInputName}[allowAll]" value="0"{if !$aclValues[allowAll]} checked{/if}>
                                        <label for="{@$__aclSimplePrefix}aclAllowAll_no" class="red"><span class="icon icon16 fa-times"></span> {lang}wcf.acp.option.type.boolean.no{/lang}</label>
                                </li>
                        </ol>
@@ -36,7 +37,7 @@
                                                <span class="icon icon16 fa-users"></span>
                                                <span class="aclLabel">{$aclGroup}</span>
                                                <span class="icon icon16 fa-times pointer jsTooltip" title="{lang}wcf.global.button.delete{/lang}"></span>
-                                               <input type="hidden" name="aclValues[group][]" value="{@$aclGroup->groupID}">
+                                               <input type="hidden" name="{@$__aclInputName}[group][]" value="{@$aclGroup->groupID}">
                                        </li>
                                {/foreach}
                                {foreach from=$aclValues[user] item=aclUser}
@@ -44,7 +45,7 @@
                                                <span class="icon icon16 fa-user"></span>
                                                <span class="aclLabel">{$aclUser}</span>
                                                <span class="icon icon16 fa-times pointer jsTooltip" title="{lang}wcf.global.button.delete{/lang}"></span>
-                                               <input type="hidden" name="aclValues[user][]" value="{@$aclUser->userID}">
+                                               <input type="hidden" name="{@$__aclInputName}[user][]" value="{@$aclUser->userID}">
                                        </li>
                                {/foreach}
                        </ul>
@@ -54,6 +55,6 @@
 
 <script data-relocate="true">
        require(['WoltLabSuite/Core/Ui/Acl/Simple'], function(UiAclSimple) {
-               new UiAclSimple('{@$__aclSimplePrefix}');
+               new UiAclSimple('{@$__aclSimplePrefix}', '{@$__aclInputName}');
        });
 </script>
index 2df87fbadfd1abb0820dc19c05af4b9dd2421317..1c69e5d6ddeed53821dcb6110bade88a83ac03d5 100644 (file)
@@ -1,4 +1,5 @@
 {if !$__aclSimplePrefix|isset}{assign var='__aclSimplePrefix' value=''}{/if}
+{if !$__aclInputName|isset}{assign var='__aclInputName' value='aclValues'}{/if}
 
 <div class="section">
        <dl>
@@ -6,11 +7,11 @@
                <dd>
                        <ol class="flexibleButtonGroup">
                                <li>
-                                       <input type="radio" id="{@$__aclSimplePrefix}aclAllowAll" name="aclValues[allowAll]" value="1"{if $aclValues[allowAll]} checked{/if}>
+                                       <input type="radio" id="{@$__aclSimplePrefix}aclAllowAll" name="{@$__aclInputName}[allowAll]" value="1"{if $aclValues[allowAll]} checked{/if}>
                                        <label for="{@$__aclSimplePrefix}aclAllowAll" class="green"><span class="icon icon16 fa-check"></span> {lang}wcf.acp.option.type.boolean.yes{/lang}</label>
                                </li>
                                <li>
-                                       <input type="radio" id="{@$__aclSimplePrefix}aclAllowAll_no" name="aclValues[allowAll]" value="0"{if !$aclValues[allowAll]} checked{/if}>
+                                       <input type="radio" id="{@$__aclSimplePrefix}aclAllowAll_no" name="{@$__aclInputName}[allowAll]" value="0"{if !$aclValues[allowAll]} checked{/if}>
                                        <label for="{@$__aclSimplePrefix}aclAllowAll_no" class="red"><span class="icon icon16 fa-times"></span> {lang}wcf.acp.option.type.boolean.no{/lang}</label>
                                </li>
                        </ol>
@@ -36,7 +37,7 @@
                                                <span class="icon icon16 fa-users"></span>
                                                <span class="aclLabel">{$aclGroup}</span>
                                                <span class="icon icon16 fa-times pointer jsTooltip" title="{lang}wcf.global.button.delete{/lang}"></span>
-                                               <input type="hidden" name="aclValues[group][]" value="{@$aclGroup->groupID}">
+                                               <input type="hidden" name="{@$__aclInputName}[group][]" value="{@$aclGroup->groupID}">
                                        </li>
                                {/foreach}
                                {foreach from=$aclValues[user] item=aclUser}
@@ -44,7 +45,7 @@
                                                <span class="icon icon16 fa-user"></span>
                                                <span class="aclLabel">{$aclUser}</span>
                                                <span class="icon icon16 fa-times pointer jsTooltip" title="{lang}wcf.global.button.delete{/lang}"></span>
-                                               <input type="hidden" name="aclValues[user][]" value="{@$aclUser->userID}">
+                                               <input type="hidden" name="{@$__aclInputName}[user][]" value="{@$aclUser->userID}">
                                        </li>
                                {/foreach}
                        </ul>
@@ -54,6 +55,6 @@
 
 <script data-relocate="true">
        require(['WoltLabSuite/Core/Ui/Acl/Simple'], function(UiAclSimple) {
-               new UiAclSimple('{@$__aclSimplePrefix}');
+               new UiAclSimple('{@$__aclSimplePrefix}', '{@$__aclInputName}');
        });
 </script>
index a68e56715730e81a2db481ec424e33d785ce6964..b9d181da6f5ab5053ba786f09b80d517ca3f73b9 100644 (file)
@@ -196,12 +196,12 @@ define(
                                user: []
                        };
                        
-                       var aclGroups = elBySelAll('input[name="aclValues[group][]"]', content);
+                       var aclGroups = elBySelAll('input[name="mediaEditor_' + this._media.mediaID + 'aclValues[group][]"]', content);
                        for (var i = 0, length = aclGroups.length; i < length; i++) {
                                aclValues.group.push(~~aclGroups[i].value);
                        }
                        
-                       var aclUsers = elBySelAll('input[name="aclValues[user][]"]', content);
+                       var aclUsers = elBySelAll('input[name="mediaEditor_' + this._media.mediaID + 'aclValues[user][]"]', content);
                        for (var i = 0, length = aclUsers.length; i < length; i++) {
                                aclValues.user.push(~~aclUsers[i].value);
                        }
index 5875b5d93401f44ad71d9aef1891398f40057947..69f1997f99657a8de2b0533d98565c76765deaac 100644 (file)
@@ -12,10 +12,11 @@ define(['Language', 'StringUtil', 'Dom/ChangeListener', 'WoltLabSuite/Core/Ui/Us
                return Fake;
        }
        
-       function UiAclSimple(prefix) { this.init(prefix); }
+       function UiAclSimple(prefix, inputName) { this.init(prefix, inputName); }
        UiAclSimple.prototype = {
-               init: function(prefix) {
+               init: function(prefix, inputName) {
                        this._prefix = prefix || '';
+                       this._inputName = inputName || 'aclValues';
                        
                        this._build();
                },
@@ -57,7 +58,7 @@ define(['Language', 'StringUtil', 'Dom/ChangeListener', 'WoltLabSuite/Core/Ui/Us
                        var html = '<span class="icon icon16 fa-' + (type === 'group' ? 'users' : 'user') + '"></span>';
                        html += '<span class="aclLabel">' + StringUtil.escapeHTML(label) + '</span>';
                        html += '<span class="icon icon16 fa-times pointer jsTooltip" title="' + Language.get('wcf.global.button.delete') + '"></span>';
-                       html += '<input type="hidden" name="aclValues[' + type + '][]" value="' + elData(listItem, 'object-id') + '">';
+                       html += '<input type="hidden" name="' + this._inputName + '[' + type + '][]" value="' + elData(listItem, 'object-id') + '">';
                        
                        var item = elCreate('li');
                        item.innerHTML = html;
index 30d168eacd036f7de4632beef188fd6ff774c13c..9f57164c9355105910a98f35d9854489af92a8fc 100644 (file)
@@ -308,6 +308,7 @@ class MediaAction extends AbstractDatabaseObjectAction implements ISearchAction,
                        'mediaData' => $this->getI18nMediaData($mediaList)[$this->getSingleObject()->mediaID],
                        'template' => WCF::getTPL()->fetch('mediaEditor', 'wcf', [
                                '__aclSimplePrefix' => 'mediaEditor_' . $media->mediaID . '_',
+                               '__aclInputName' => 'mediaEditor_' . $media->mediaID . '_aclValues',
                                '__languageChooserPrefix' => 'mediaEditor_' . $media->mediaID . '_',
                                'aclValues' => SimpleAclHandler::getInstance()->getValues('com.woltlab.wcf.media', $media->mediaID),
                                'availableLanguages' => LanguageFactory::getInstance()->getLanguages(),