|
Post by Wormopolis on Apr 16, 2012 19:28:30 GMT -8
Browsers Tested: IE and FF Placement: main footer
this code will let you set up a ranking system for your mods who have the ability to modify profiles. If you want certain mods to not be able to edit other mods, just put their name into a higher rank. you can establish however many ranks you need. any mod not listed in the ranks will only be able to modify his own profile and regular users.
<script type="text/javascript"> <!-- // prevent modify profile by rank // v 1.2 // request by OJ - code by Wormo // keep header intact
var rankHierarchy=new Array(); rankHierarchy[1]=['admin','user2']; rankHierarchy[2]=['user3','user4']; rankHierarchy[3]=['test','user6']; rankHierarchy[4]=['user6','ranktest'];
// admin always has power regardless of rank.
function returnRank(uname) { var saveRank=rankHierarchy.length+1; for (funcMyRank in rankHierarchy) { for (rc=0; rc<rankHierarchy[funcMyRank].length; rc++) { if (uname==rankHierarchy[funcMyRank][rc]) return parseInt(funcMyRank); } } return saveRank; }
if (pb_action=='viewprofile' && pb_username!='admin') { var saveMyRank=returnRank(pb_username); for (lnks=document.getElementsByTagName('a'), ll=0; ll<lnks.length; ll++) { if (lnks[ll].href.match(/action=modifyprofile&user=(.*?)($|&)/)) { var linkVictim=RegExp.$1; var victimRank=returnRank(linkVictim); if (saveMyRank >= victimRank && pb_username!=linkVictim) lnks[ll].style.display='none'; } } } if (pb_action=='modifyprofile' && pb_username!='admin') { var getLoc=location.href.match(/user=(.*?)($|&)/); var uname=(getLoc ? getLoc[1] : pb_username); var myRank=returnRank(pb_username), victimRank=returnRank(uname); if (myRank>=victimRank && pb_username!=uname) { document.modifyForm.parentNode.innerHTML="Sorry, you are not allowed to modify this member's profile."; } } //--> </script>
|
|