Post by Chris on Jan 31, 2007 4:18:20 GMT -8
By Request
There are two variables that need to be edited:
*This uses a feature from javascript 1.6 that IE6 doesn't support which is why it is prototyped. Not tested on IE7
<script type="text/javascript">
<!-- /* Staff Reserved Message Icons (Open Source)*/
//to add more items use pipe symbol for separator
//example: (exclamation|thumbs|question)
var staffIcons="(exclamation)";
//names of staff in limited power groups and boards they supervise
// template: ["username","board1","board2",....,"board106"]
var limitedPowerStaff=
[
//["eton","oldstuff","newstuff"],
//["hiddenamongyou","general"]
];
if (!Array.prototype.filter){
Array.prototype.filter = function(func){
var len = this.length;
var ret = [];
var thisp = arguments[1];
for (var i = 0; i < len; i++){
if (i in this){
var val = this[i];
if (func.call(this, val, i, thisp)) ret.push(val);
}
}
return ret;
};
}
function isAllowed(elem){
var j=1;
if(elem[0].match(new RegExp("^"+pb_username+"$","i"))){
while(elem[j]){
if(location.href.match(new RegExp("board="+elem[j],"i"))){return true;};
j++
}
}
return false;
}
function isStaff(){
if(limitedPowerStaff.filter(isAllowed,pb_username).length){return true;}
var td=document.getElementsByTagName('td');
for(var i=0;i<td.length;i++){
if(td[i].className=="menubg" && td[i].innerHTML.match(/alt=['"]?\[home\]["']?/i)){
if(td[i].innerHTML.match(/action=admin/)){return true;}else{return false;}
}
}
}
if(document.postForm && document.postForm.icon && !isStaff()){
var opts=document.postForm.icon.options;
var reservedIcons=new RegExp(staffIcons,"i");
for(var j=opts.length-1;j>-1;j--){
if(opts[j].text.match(reservedIcons)){opts[j]=null;}
}
}
//-->
</script>
There are two variables that need to be edited:
- staffIcons contains the names of the icons to be reserved. It can be a partial name such as thumbs which will reserve both Thumbs Up and Thumbs Down for example.
- limitedPowerStaff contains the names and corresponding boards of staff that do not have access to the admin panel. The first entry is the username and additional entries contains the name of the boards they moderate. Each staff member gets their own line. This way they can only use the reserved icons on the boards they have powers on.
*This uses a feature from javascript 1.6 that IE6 doesn't support which is why it is prototyped. Not tested on IE7