PDA

View Full Version : Javascript issues on a wiki


ZW Neo
02-01-2010, 06:55 AM
Hello. I'm not entirely sure what forum this would fit in, so I figured I'd stick it here.
I hail from Zelda Wiki, and we have a problem with one of our scripts. It's supposed to restrict the addition of the user rights management button to administrators only, but it causes everything below it to be administrator-restricted. We can't figure out why this is, and I've been trying to debug this thing all day.

The full script is here.

// --------------------------------------------------------
// user rights
// adds a link in the tool box while on user pages to a user's rights management page.
// --------------------------------------------------------
addOnloadHook(function () {
if (!rights_isAdmin)
return; //Restrict this feature to admins.
if (wgNamespaceNumber != "2" && wgNamespaceNumber != "3")
return; // restrict to User and User talk

var title = wgTitle;

addPortletLink('gumax-special-tools', '/Special:Userrights/'+title,
'User rights', 't-userrights', 'User rights for "'+title+'"');

});


And near the top of the page is this, which sets the value of the admin, user, etc.

// --------------------------------------------------------
// Rights
// Sets a variable "rights" which will return "false" if the
// currently logged in user is a bureaucrat, administrator, or autoconfirmed user. It will return true otherwise.
// it also defines variables which may be used elsewhere in scripts.
// --------------------------------------------------------

var rights_isAdmin = (wgUserGroups.toString().indexOf('sysop') != -1);
var rights_isAuto = (wgUserGroups.toString().indexOf('autoconfirmed') != -1);
var rights_isCrat = (wgUserGroups.toString().indexOf('bureaucrat') != -1);
var rights = true;
if (rights_isCrat || rights_isAdmin || rights_isAuto)
{rights=false}
//


I would greatly appreciate any help!

Dormilich
02-01-2010, 02:51 PM
do you have a link? the code alone doesn’t tell me much.

ZW Neo
02-01-2010, 08:27 PM
Sure.

http://zeldawiki.org/User:Neo/adming.js