MediaWiki:Gadget-UserRightsManager.js: Difference between revisions
From Test Wiki
MediaWiki:Gadget-UserRightsManager.js (view source)
Revision as of 14:07, 27 February 2024
, 27 Februaryno edit summary
(clean out code for updating markadmins.json since it's no longer necessary due to gadget changes) |
No edit summary Tags: Mobile edit Mobile web edit |
||
(15 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
// <nowiki> | // <nowiki> | ||
// Adapted from [[mhtest:MediaWiki:Gadget-userRightsManagerTW.js]], itself adapted from [[w:User:MusikAnimal/userRightsManager.js]] | // Adapted from [[mhtest:MediaWiki:Gadget-userRightsManagerTW.js]], itself adapted from [[w:User:MusikAnimal/userRightsManager.js]], this code is therefore licensed under CC-BY-SA 4.0 | ||
(function() { | (function() { | ||
if (mw.config.get('wgPageName') != 'Test_Wiki: | if (mw.config.get('wgPageName') != 'Test_Wiki:Request_for_permissions' && !mw.config.get('wgPageName').includes('URMTW-TESTPAGE-RFP')) { | ||
return; | return; | ||
} | } | ||
Line 9: | Line 9: | ||
'sysop': 'Administrator', | 'sysop': 'Administrator', | ||
'bureaucrat': 'Bureaucrat', | 'bureaucrat': 'Bureaucrat', | ||
'interface-admin': 'Interface | 'interface-admin': 'Interface administrator', | ||
'non-stewardsuppress': 'Suppressor', | |||
} | } | ||
var cannedResponses = { | var cannedResponses = { | ||
'sysop': '{{ | 'sysop': '{{administrator granted}} ~~~~', | ||
'bureaucrat': '{{ | 'bureaucrat': '{{bureaucrat granted}} ~~~~', | ||
'interface-admin': '{{done}}. ~~~~' | 'interface-admin': '{{interface administrator granted}} ~~~~', | ||
'non-stewardsuppress': '{{done}}. ~~~~' | |||
}; | }; | ||
Line 69: | Line 71: | ||
this.groupsInterfaceAdminInput = new OO.ui.CheckboxInputWidget({ | this.groupsInterfaceAdminInput = new OO.ui.CheckboxInputWidget({ | ||
selected: permissionText.includes('interface') && mw.config.get('wgUserGroups').includes('steward'), | selected: permissionText.includes('interface') && mw.config.get('wgUserGroups').includes('steward'), | ||
disabled: !mw.config.get('wgUserGroups').includes('steward') | |||
}); | |||
this.groupsNonStewardSuppressInput = new OO.ui.CheckboxInputWidget({ | |||
selected: permissionText.includes('suppress') && mw.config.get('wgUserGroups').includes('steward'), | |||
disabled: !mw.config.get('wgUserGroups').includes('steward') | disabled: !mw.config.get('wgUserGroups').includes('steward') | ||
}); | }); | ||
Line 86: | Line 92: | ||
new OO.ui.FieldLayout(this.groupsBureaucratInput, {label: 'Bureaucrat', align: 'inline'}), | new OO.ui.FieldLayout(this.groupsBureaucratInput, {label: 'Bureaucrat', align: 'inline'}), | ||
new OO.ui.FieldLayout(this.groupsInterfaceAdminInput, {label: 'Interface administrator', align: 'inline'}), | new OO.ui.FieldLayout(this.groupsInterfaceAdminInput, {label: 'Interface administrator', align: 'inline'}), | ||
new OO.ui.FieldLayout(this.groupsNonStewardSuppressInput, {label: 'Suppressor', align: 'inline'}), | |||
] | ] | ||
}) | }) | ||
Line 125: | Line 132: | ||
if(this.groupsBureaucratInput.isSelected()) perms.push('bureaucrat'); | if(this.groupsBureaucratInput.isSelected()) perms.push('bureaucrat'); | ||
if(this.groupsInterfaceAdminInput.isSelected()) perms.push('interface-admin'); | if(this.groupsInterfaceAdminInput.isSelected()) perms.push('interface-admin'); | ||
if(this.groupsNonStewardSuppressInput.isSelected()) perms.push('non-stewardsuppress'); | |||
var self = this, promiseCount = | var self = this, promiseCount = 2; | ||
self.actions.setAbilities( { submit: false } ); | self.actions.setAbilities( { submit: false } ); | ||
Line 208: | Line 216: | ||
user: userName.replace(/ /g, '_'), | user: userName.replace(/ /g, '_'), | ||
add: perms.join('|'), | add: perms.join('|'), | ||
reason: '+' + perms.join(', +') + '; ' + permaLink + ' at [[TW: | reason: '+' + perms.join(', +') + '; ' + permaLink + ' at [[TW:RfP]]', | ||
expiry: 'infinity', | expiry: 'infinity', | ||
tags: ' | tags: 'userRightsManager' | ||
}); | }); | ||
} | } | ||
Line 230: | Line 238: | ||
'section': sectionId, | 'section': sectionId, | ||
'text': newContent, | 'text': newContent, | ||
'tags': ' | 'tags': 'userRightsManager', | ||
summary: '/* User:' + userName + ' */ done' | summary: '/* User:' + userName + ' */ done' | ||
}) | }) |