User:Joepayne/stripRights.js: Difference between revisions

From Test Wiki
Content deleted Content added
Joepayne (talk | contribs)
m Joepayne moved page User:Joepayne/stripAdmin.js to User:Joepayne/stripRights.js without leaving a redirect: Script relocate
m Removed protection from "User:Joepayne/stripRights.js": Unnecessary
 
(11 intermediate revisions by one other user not shown)
Line 15: Line 15:
).done( function ( data ) {
).done( function ( data ) {
try {
try {
if(data.query.users[0].groups.indexOf(!'sysop') >= 0) {/* Do nothing */}
if(data.query.users[0].groups.indexOf('!sysop') >= 0) {/* Do nothing */}
else {
else {
var link = mw.util.addPortletLink(
var link = mw.util.addPortletLink(
Line 22: Line 22:
'Strip rights',
'Strip rights',
'pt-striprightslink',
'pt-striprightslink',
'Remove standard rights from this user'
'Remove standard rights from this user for inactivity'
);
);
$(link).click(function() {
$(link).click(function() {
checkAndPromote(username);
checkAndDemote(username);
});
});
}
}
Line 39: Line 39:
}
}


function checkAndPromote(username) {
function checkAndDemote(username) {
$.getJSON(
$.getJSON(
//Get user's group membership again
//Get user's group membership again
Line 52: Line 52:
).done( function ( data ) {
).done( function ( data ) {
try {
try {
if(data.query.users[0].groups.indexOf(!'sysop') >= 0) {/* Do nothing */}
if(data.query.users[0].groups.indexOf('!sysop') >= 0) {/* Do nothing */}
else {
else {
check = confirm("Do you want to remove " + username + "'s rights on this wiki?");
check = confirm("Do you want to remove " + username + "'s bureaucrat and admin rights on this wiki for inactivity?");
if (check) {
if (check) {
stripRights(username);
stripRights(username);
alertUser(username);
demotionAlert(username);
alert(username + " has had all rights removed");
alert(username + " has had their bureaucrat and admin removed for inactivity");
}
}
}
}
Line 112: Line 112:
}
}


function alertUser(username) {
function demotionAlert(username) {
//If page already exists
//If page already exists
$.ajax( {
$.ajax( {
Line 122: Line 122:
action: 'edit',
action: 'edit',
title: 'User talk:' + username,
title: 'User talk:' + username,
summary: 'Notification',
summary: 'Notification of rights removal',
nocreate: 1,
nocreate: 1,
appendtext: 'Your rights have been revoked for inactivity.',
appendtext: '\n\n{{subst:' + 'Rights removed}}',
token: mw.user.tokens.get( 'csrfToken' )
token: mw.user.tokens.get( 'csrfToken' )
}
}
Line 143: Line 143:
action: 'edit',
action: 'edit',
title: 'User talk:' + username,
title: 'User talk:' + username,
summary: 'Notification',
summary: 'Notification of rights removal',
createonly: 1,
createonly: 1,
text: 'Your rights have been revoked for inactivity.',
text: '\n\n{{subst:' + 'Rights removed}}',
token: mw.user.tokens.get( 'csrfToken' )
token: mw.user.tokens.get( 'csrfToken' )
}
}