Post by Ross on Dec 18, 2005 16:51:38 GMT -8
This is another code which I'm pretty sure is still a little buggy but I haven't been able to find anything majorly wrong with it. What it is a system where posts must be 'approved' by a moderator. A moderator is anyone who has the ability to modify the post.
Uses of this code may include putting members on probation or for database submissions. This code can go in either the an individual board footer or the global footer depending on what it is being used for. But note, if you do put it on just an individual board footer, it will also need to go into the main footer.
Just follow all the instructions when editing the code. Any problems then post in the Code Support board
<script type="text/javascript">
<!--
/*
pending threads with moderator approval - v0.5
coded by ross
support.proboards.com
please do not redistribute without permission
*/
// Icon Used to Identify threads awaiting approval
var icon = 'www.proboards.com/v4images/exclamation.gif';
// Types of Thread. ie. Application, Submission or just Thread
var name = 'Submission';
// Message shown after posting a new thread.
var message = '<font size=2>Before users may view this thread, it must first be approved by a member of staff.</font>';
// The mode determines what the code is being used for. Use '1' to effect all new threads by all members except staff and the 'exception' members. Use '2' to put certain members on 'probation' where only their posts need approval
var mode = 1;
// Special users. Either ones that the code doesn't effect (mode 1) or the members on probation (mode 2)
var exceptions = '(username1|username2|username3)';
// No need to edit blow this line
var mod = false;
var a = document.getElementsByTagName('a');
for(i=0; i<a.length; i++) {
if(a.item(i).href.match(/(action=(admin|lockthread|stickythread)|&moderationmode)/))
mod = true;
else if(a.item(i).href.match(/action=modifypost/) && a.item(i).parentNode.parentNode.previousSibling.firstChild.firstChild.innerHTML.match(/^\[p\]:/)) {
a.item(i).href += '&accept';
a.item(i).innerHTML = '[Accept '+name+']';
a.item(i+1).style.display = (a.item(i+1).href.match(/doConfirm/))? 'none' : 'block';
a.item(i-1).style.display = (a.item(i-1).href.match(/quote=/))? 'none' : 'block';
} else if(a.item(i).innerHTML.match(/\[p\]:/) && a.item(i).href.match(/ion=(display|goto)/)){
if(mod && location.href.match(/board=\w+$/)) {
a.item(i).innerHTML = a.item(i).innerHTML.replace(/\[p\]:/, 'Pending Approval: ')
a.item(i).parentNode.parentNode.parentNode.previousSibling.firstChild.firstChild.src = icon;
} else if(!mod) {
if(location.href.match(/board=\w|d+$/)) {
a.item(i).parentNode.parentNode.parentNode.parentNode.style.display = 'none';
}
else if(location.href.match(/\.com\/?(index.cgi)?\??(action=home|#\w+)?$/) && !mod)
a.item(i).parentNode.innerHTML = a.item(i).parentNode.innerHTML.split(/by/i)[0];
else if(location.href.match(/ion=((user)?recent|search2)/))
a.item(i).parentNode.parentNode.parentNode.parentNode.parentNode.style.display = 'none';
else if(location.href.match(/ion=viewprofile/))
a.item(i).parentNode.parentNode.style.display = 'none';
}
}
}
if((pb_username.match(exceptions) && mode == 1) || (!pb_username.match(exceptions) && mode == 2))
mod = true;
if(document.postForm && !document.postForm.to && !document.postForm.subject.value.match(/Re:/i)) {
var pForm = document.postForm;
if(location.href.match(/&accept/)) {
pForm.subject.value = pForm.subject.value.replace(/\[p\]:/gi,'');
pForm.parentNode.rows[0].style.display = 'none';
var newCell = pForm.parentNode.insertRow(0).insertCell(0);
pForm.parentNode.className = 'bordercolor';
pForm.parentNode.cellSpacing = '1';
newCell.innerHTML = '<div style="text-align: center; margin: auto; padding: 10px;"><input type="button" value="Accept '+name+'" onclick="pForm.submit(true);"></div>';
newCell.className = 'windowbg2';
} else if(!pForm.to && !mod) {
pForm.subject.maxLength = 46;
pForm.onsubmit = function() {
if(pForm.nextaction.value == 'post') {
pForm.subject.value = '
Uses of this code may include putting members on probation or for database submissions. This code can go in either the an individual board footer or the global footer depending on what it is being used for. But note, if you do put it on just an individual board footer, it will also need to go into the main footer.
Just follow all the instructions when editing the code. Any problems then post in the Code Support board
<script type="text/javascript">
<!--
/*
pending threads with moderator approval - v0.5
coded by ross
support.proboards.com
please do not redistribute without permission
*/
// Icon Used to Identify threads awaiting approval
var icon = 'www.proboards.com/v4images/exclamation.gif';
// Types of Thread. ie. Application, Submission or just Thread
var name = 'Submission';
// Message shown after posting a new thread.
var message = '<font size=2>Before users may view this thread, it must first be approved by a member of staff.</font>';
// The mode determines what the code is being used for. Use '1' to effect all new threads by all members except staff and the 'exception' members. Use '2' to put certain members on 'probation' where only their posts need approval
var mode = 1;
// Special users. Either ones that the code doesn't effect (mode 1) or the members on probation (mode 2)
var exceptions = '(username1|username2|username3)';
// No need to edit blow this line
var mod = false;
var a = document.getElementsByTagName('a');
for(i=0; i<a.length; i++) {
if(a.item(i).href.match(/(action=(admin|lockthread|stickythread)|&moderationmode)/))
mod = true;
else if(a.item(i).href.match(/action=modifypost/) && a.item(i).parentNode.parentNode.previousSibling.firstChild.firstChild.innerHTML.match(/^\[p\]:/)) {
a.item(i).href += '&accept';
a.item(i).innerHTML = '[Accept '+name+']';
a.item(i+1).style.display = (a.item(i+1).href.match(/doConfirm/))? 'none' : 'block';
a.item(i-1).style.display = (a.item(i-1).href.match(/quote=/))? 'none' : 'block';
} else if(a.item(i).innerHTML.match(/\[p\]:/) && a.item(i).href.match(/ion=(display|goto)/)){
if(mod && location.href.match(/board=\w+$/)) {
a.item(i).innerHTML = a.item(i).innerHTML.replace(/\[p\]:/, 'Pending Approval: ')
a.item(i).parentNode.parentNode.parentNode.previousSibling.firstChild.firstChild.src = icon;
} else if(!mod) {
if(location.href.match(/board=\w|d+$/)) {
a.item(i).parentNode.parentNode.parentNode.parentNode.style.display = 'none';
}
else if(location.href.match(/\.com\/?(index.cgi)?\??(action=home|#\w+)?$/) && !mod)
a.item(i).parentNode.innerHTML = a.item(i).parentNode.innerHTML.split(/by/i)[0];
else if(location.href.match(/ion=((user)?recent|search2)/))
a.item(i).parentNode.parentNode.parentNode.parentNode.parentNode.style.display = 'none';
else if(location.href.match(/ion=viewprofile/))
a.item(i).parentNode.parentNode.style.display = 'none';
}
}
}
if((pb_username.match(exceptions) && mode == 1) || (!pb_username.match(exceptions) && mode == 2))
mod = true;
if(document.postForm && !document.postForm.to && !document.postForm.subject.value.match(/Re:/i)) {
var pForm = document.postForm;
if(location.href.match(/&accept/)) {
pForm.subject.value = pForm.subject.value.replace(/\[p\]:/gi,'');
pForm.parentNode.rows[0].style.display = 'none';
var newCell = pForm.parentNode.insertRow(0).insertCell(0);
pForm.parentNode.className = 'bordercolor';
pForm.parentNode.cellSpacing = '1';
newCell.innerHTML = '<div style="text-align: center; margin: auto; padding: 10px;"><input type="button" value="Accept '+name+'" onclick="pForm.submit(true);"></div>';
newCell.className = 'windowbg2';
} else if(!pForm.to && !mod) {
pForm.subject.maxLength = 46;
pForm.onsubmit = function() {
if(pForm.nextaction.value == 'post') {
pForm.subject.value = '
:'+pForm.subject.value;
}
}
}
}
if(document.title.match(/ - :\w+/) && !mod) {
var table = document.getElementsByTagName('table')
message = '<table width=100% class=bordercolor cellspacing=1 cellpadding=4><tr><td class=titlebg><font size=2>An Error Has Occured</font></td></tr><tr><td class=windowbg>' +message+ '<br /><br /></td></tr></table>';
for(i=4; i<table.length; i++) {
if(table.item(i).width == '92%' && table.item(i).className == '' && table.item(i).innerHTML.match(/\[p\]:/)) {
table.item(i).rows[0].cells[0].innerHTML = table.item(i).rows[0].cells[0].innerHTML.split(/<table/i)[0] + message;
break;
}
}
}
//-->
</script>