Post by Wormopolis on Mar 23, 2009 17:08:05 GMT -8
Browser Tested: IE and FF
placement: global footer
Puts a "flag" button above each post for mods/admins that have modifypost access. flags the post to be unreadable by anyone without staff access, and creates a PM to the admins that a post has been flagged for review. creates a link in the PM to the offensive post.
Preview:
What a user with an admin button would see:
there are "flag" and "unflag" buttons at the top right of the posts.
What user "test" would see:
Mods with ability to modify posts, but do not have admin buttons would see the flag button, but posts would look like what user "test" would see.
UPDATE 4/15/09: updated to work with view recent replies
UPDATES TO THIS CODE FOUND ON wormocodes.proboards.com
placement: global footer
Puts a "flag" button above each post for mods/admins that have modifypost access. flags the post to be unreadable by anyone without staff access, and creates a PM to the admins that a post has been flagged for review. creates a link in the PM to the offensive post.
<script type="text/javascript">
<!--
// Post Flagging v1.5
// by Wormopolis - wormocodes.proboards.com
// keep header intact - do not repost
// -------- USER VARIABLES
var flagBtnImg="http://i197./aa250/WORMOPOLIS/flagbtn.gif";
var unflagBtnImg="http://i197./aa250/WORMOPOLIS/unflagbtn.gif";
var hideModifyBtn = true; // set true if you want to hide the modify btn if not flagged
var hideDeleteBtn = true; // set true if you want to hide the delete btn if not flagged
var hideModifyBtnUser = true; //set true to keep users from modifying flagged posts
var reportTo = "admin, wormopolis"; // list of ppl to report flagged post to
var reportSub = "THIS POST HAS BEEN FLAGGED";
var reportBody = "Please review this post for violations:";
// -------- END USER VARIABLES
// No need to edit below unless for support
staffCheck=false;
for (igs=document.images, g=0; g<igs.length; g++) {
if (igs[g].parentNode.nodeName=="A" && igs[g].parentNode.href.match(/index.cgi\?action=admin/i)) {
staffCheck=true;
break;
}
}
// modify post with flag
if (location.href.match(/&flaggum=(\d+?)/)) {
pagenum=RegExp.$1;
document.postForm.parentNode.style.display="none";
document.postForm.parentNode.nextSibling.nextSibling.nextSibling.style.display="none";
document.postForm.message.value="[§flag§]\n"+document.postForm.message.value;
postthread=location.href.split('?')[1].split('&flaggum')[0].replace(/&post=/,(pagenum>0 ? '&page='+pagenum : '' )+'#');
postthread=postthread.replace(/=/g,'*');
document.cookie="flagpost="+postthread;
document.postForm.submit();
}
// clear flag
if (location.href.match(/&unflaggum=(\d+?)/)) {
document.postForm.parentNode.style.display="none";
document.postForm.parentNode.nextSibling.nextSibling.nextSibling.style.display="none";
document.postForm.message.value=document.postForm.message.value.replace(/\[§flag§\]/,'');
document.postForm.submit();
}
// setup PM to admins
function stripThings(text) {
return escape(text).replace(/\s/g,'%20');
}
if (location.href.match(/display/) && document.cookie.match(/flagpost=(.*?)($|;)/) ) {
postthread=RegExp.$1;
postthread=postthread.replace(/\*/g,'=').replace(/modifypost/,'display');
nwtm=new Date();
document.cookie="flagpost=; expires="+nwtm;
urltemp=location.href.split('?')[0];
reportBody+=escape("\n\n")+urltemp+'?'+stripThings(postthread);
window.location = "/index.cgi?action=pmsend&to="+stripThings(reportTo)+"&subject="+stripThings(reportSub)+"&message="+reportBody;
}
// check for flags
for (tds=document.getElementsByTagName('td'), i=0; i<tds.length; i++) {
if (tds[i].colSpan==3 && tds[i].vAlign=="top" && tds[i].firstChild && tds[i].firstChild.nodeName.match(/hr/i) && tds[i].firstChild.className.match(/hr/i)) {
msg=tds[i].getElementsByTagName('font')[0];
btnbar=tds[i].parentNode.previousSibling;
auth=tds[i].parentNode.parentNode.parentNode.parentNode.previousSibling;
auth=(auth.childNodes[(document.all?2:3)].nodeName.match(/^b$/i) ? auth.childNodes[(document.all ? 2 : 3)].firstChild.href.split('user=')[1] : auth.childNodes[2].nodeValue );
if (msg.innerHTML.match(/\[§flag§\]/)) {
nwmsg=(staffCheck ? msg.innerHTML.replace(/\[§flag§\]/g,'') : "");
msg.innerHTML="<div align='center' style='background-color:FF0000'><font size=4 color='FFFFFF'>THIS POST HAS BEEN FLAGGED FOR THE ADMINS</font></div><br><br>"+nwmsg;
tds[i].parentNode.nextSibling.style.display="none";
if (btnbar.innerHTML.match(/quote=/)) {
btnbar.cells[2].getElementsByTagName('a')[0].style.display="none";
}
for(modbtns=btnbar.cells[2].firstChild.getElementsByTagName('a'), aa=0;aa<modbtns.length; aa++) {
if (modbtns[aa].href.match(/modifypost/)) {
if (hideModifyBtnUser && auth==pb_username) modbtns[aa].style.display="none";
flagbtn=document.createElement('a');
flagbtn.href=modbtns[aa].href+"&unflaggum=1";
flagimg=flagbtn.appendChild(document.createElement('img'));
flagimg.src=unflagBtnImg;
flagimg.border=0;
if (staffCheck) btnbar.cells[2].firstChild.appendChild(flagbtn);
break;
}
}
} else {
if (btnbar.innerHTML.match(/modifypost/)) {
flagbtn=document.createElement('a');
for(modbtns=btnbar.cells[2].firstChild.getElementsByTagName('a'), aa=0;aa<modbtns.length; aa++) {
if (modbtns[aa].href.match(/modifypost/)) {
if (hideModifyBtn && auth!=pb_username) modbtns[aa].style.display="none";
pagekeep=tds[i].parentNode.nextSibling.firstChild.firstChild;
pagekeep=pagekeep.getElementsByTagName('td')[1].getElementsByTagName('a')[0];
pagekeep=(pagekeep.href.match(/page=/) ? pagekeep.href.split('page=')[1].split('#')[0] : 0);
flagbtn.href=modbtns[aa].href+"&flaggum="+pagekeep;
}
if (modbtns[aa].href.match(/deletepost/)) {
if (hideDeleteBtn && auth!=pb_username) modbtns[aa].style.display="none";
}
}
flagimg=flagbtn.appendChild(document.createElement('img'));
flagimg.src=flagBtnImg;
flagimg.border=0;
if (auth!=pb_username) btnbar.cells[2].firstChild.appendChild(flagbtn);
}
}
} else {
if (tds[i].width=="100%" && tds[i].className.match(/windowbg/i) && tds[i].firstChild && tds[i].firstChild.nodeName.match(/font/i) && tds[i].firstChild.innerHTML.match(/\[§flag§\]/) && !tds[i].firstChild.innerHTML.match(/<textarea/i)) {
msg=tds[i].firstChild;
nwmsg=(staffCheck ? msg.innerHTML.replace(/\[§flag§\]/,'') : "");
msg.innerHTML="<div align='center' style='background-color:FF0000'><font size=4 color='FFFFFF'>THIS POST HAS BEEN FLAGGED FOR THE ADMINS</font></div><br><br>"+nwmsg;
}
}
}
// -->
</script>
Preview:
What a user with an admin button would see:
there are "flag" and "unflag" buttons at the top right of the posts.
What user "test" would see:
Mods with ability to modify posts, but do not have admin buttons would see the flag button, but posts would look like what user "test" would see.
UPDATE 4/15/09: updated to work with view recent replies
UPDATES TO THIS CODE FOUND ON wormocodes.proboards.com