Post by SubDevo on Mar 6, 2010 9:15:49 GMT -8
Members Must Read Rules Before Posting by SubDevo
Tested in IE, FF, Opera, Safari and Chrome.
This code "forces" your members to at least look at your forum rules before posting the first time.
Once they do, they can post normally.
The code checks your cookie. If you have visited the "Rules" thread or you view a thread that you have already posted in, then a cookie is set to indicate that you have read the rules. In this case, the user can post normally.
If it isn't set, this code changes the URL for the Reply, Quote, New Topic (thread), New Poll buttons to your "Rules" thread URL. When a user clicks any of the above, they will get an alert box with a message asking them to read the forum rules. If they click cancel, they stay on the same page and nothing happens. If they click OK, they are taken to your rules thread.
In the Quick Reply area, the Post Reply and Preview (if it is there) buttons are disabled and your "message" appears in the message area. A "Read Rules" button is also added to the Quick Reply. Clicking on that brings you to the rules page. If a nice member, just happens to look at the rules without clicking any of the above, their cookie will still be set and they can post normally without ever seeing the alert box!
EXAMPLE
You also have the option to include users to ignore. These are staff or members that delete their cookies often and it becomes annoying to them to get the alert message.
Any staff with the power to modify profiles will never get the alert. Even if they are not listed in the "ignore" list.
If the user deletes their cookies, they will get the "Read Rules" message again...
Unless, of course, they are in the "ignore" list.
Enjoy!!!
SubDevo
Variables: Edit the Maroon portions.
var fStaff=/^(admin|staff1)$/i; // User names to ignore.
Any names entered here will NEVER see the "Read Rules" alert message.
Enter the user names (NOT display names) of the users that you wish the code to ignore.
Separate each name with a |. Do NOT put a | after the last name in the list.
var gRules="URL TO FORUM RULES THREAD"; // URL to Rules Thread
Enter the full URL to your rules thread WITHOUT the "&page=X" at the end.
The code automatically checks the page URL to see if "&page=X" is there or not.
The code will still set the user's cookie in either case.
var gNotice="Please Read Our Forum Rules Before Posting."; // Text for Notice
This is the message the user will see in the alert box and in the Quick Reply area before posting the first time.
If you are curious, the code that is used in the example pic above is this:
var gNotice="Hi "+pb_displayname+"!\nPlease Read IOD's Global Rules Before Posting.\nYou will not get this message again if you do.\n(Unless your cookies get deleted.)\nSo, come on! Give them a quick read! OK?"; // Text for Notice
Note the use of pb_displayname for the members name and \n for a line break in the message.
NOTE:
If you are using my Reply Button In Every Post code (or similar), or any quick reply modifying codes, make sure this code is below it.
Location: Global Footer
<script type="text/Javascript">
/* Members Must Read Rules Before Posting by SubDevo */
/* Global Footer - Please leave this header intact. Do not repost. */
/* interoceandesigns.com or lsdp.proboards.com */
var fStaff=/^(admin|staff1)$/i; // User names to ignore.
var gRules="URL TO FORUM RULES THREAD"; // URL to Rules Thread
var gNotice="Please Read Our Forum Rules Before Posting."; // Text for Notice
function gCook(){return document.cookie.indexOf("gRulesRead=true")!=-1?1:0;}
function cLinks(d){ if(gCook()){return;} var nF=0,x=-1,m,nM,a;
a=(d)?document.links:document.getElementsByTagName("input");
while(a[++x]){ m=a[x];
if(d&&/ion=(post|createpoll)&?/i.test(m.href)){m.href="javascript:rgLink()";}
else if(m.type=="submit"&&/Post Reply|Preview/.test(m.value)){nF=1;m.disabled=true;}
} nM=document.getElementsByName("message")[0];
if(!document.getElementById("b_Drules")&&nM&&nF){nM=nM.parentNode;
nM.innerHTML=nM.innerHTML.replace(/><\/textarea/i,">"+gNotice+"</textarea")+' <input type="button" value="Read Rules" onClick="parent.location='+"'"+gRules+"'"+'">';
}}
function rgLink(){if(rgRules(gNotice)){location.href=gRules;}}
function rgRules(i){ if(i){var b=confirm(i);}else{var b=true}
document.cookie="gRulesRead="+b+"; expires=Sat, 17 Jan 2050 12:12:12 UTC; path=/";
return (b)?true:false;
}
if(!fStaff.test(pb_username)){
if(new RegExp(gRules.split("?")[1]+"($|&page)").test(location.href)){rgRules(0);}
var g=gCook(),x=-1,n=document.links;
if(!g&&/^(display|search2)$/.test(pb_action)){
while(n[++x]){
if(n[x].href.indexOf("=modifypost")!=-1){rgRules(0);break;}
} cLinks(1); cLinks(0);
} g=gCook(); if(!g&&pb_action=="boardindex"){ cLinks(1);}
}
</script>
EDIT: 07/10/2010
MAJOR update. The code has been completely re-written.
Fixes:
Code now runs on the "Search Results" and "Recent" pages.
Code now looks for a "Modify" button in posts and since the user has posted, it assumes that they have read the rules and sets their cookie.
Since PB has placed another ad at the bottom of post pages, the message that is supposed to be put into the quick reply, only worked in IE. Fixed.
Added the ability to ignore certain users.
EDIT: 07/04/2011
Since PB added vigLink services, the "onclick" of links is intercepted. This prevented the alert to ask the member to read the rules. Code has been updated to get around this.
This only affected non ad-free forums (most of you out there lol).
Tested in IE, FF, Opera, Safari and Chrome.
This code "forces" your members to at least look at your forum rules before posting the first time.
Once they do, they can post normally.
The code checks your cookie. If you have visited the "Rules" thread or you view a thread that you have already posted in, then a cookie is set to indicate that you have read the rules. In this case, the user can post normally.
If it isn't set, this code changes the URL for the Reply, Quote, New Topic (thread), New Poll buttons to your "Rules" thread URL. When a user clicks any of the above, they will get an alert box with a message asking them to read the forum rules. If they click cancel, they stay on the same page and nothing happens. If they click OK, they are taken to your rules thread.
In the Quick Reply area, the Post Reply and Preview (if it is there) buttons are disabled and your "message" appears in the message area. A "Read Rules" button is also added to the Quick Reply. Clicking on that brings you to the rules page. If a nice member, just happens to look at the rules without clicking any of the above, their cookie will still be set and they can post normally without ever seeing the alert box!
EXAMPLE
You also have the option to include users to ignore. These are staff or members that delete their cookies often and it becomes annoying to them to get the alert message.
Any staff with the power to modify profiles will never get the alert. Even if they are not listed in the "ignore" list.
If the user deletes their cookies, they will get the "Read Rules" message again...
Unless, of course, they are in the "ignore" list.
Enjoy!!!
SubDevo
Variables: Edit the Maroon portions.
var fStaff=/^(admin|staff1)$/i; // User names to ignore.
Any names entered here will NEVER see the "Read Rules" alert message.
Enter the user names (NOT display names) of the users that you wish the code to ignore.
Separate each name with a |. Do NOT put a | after the last name in the list.
var gRules="URL TO FORUM RULES THREAD"; // URL to Rules Thread
Enter the full URL to your rules thread WITHOUT the "&page=X" at the end.
The code automatically checks the page URL to see if "&page=X" is there or not.
The code will still set the user's cookie in either case.
var gNotice="Please Read Our Forum Rules Before Posting."; // Text for Notice
This is the message the user will see in the alert box and in the Quick Reply area before posting the first time.
If you are curious, the code that is used in the example pic above is this:
var gNotice="Hi "+pb_displayname+"!\nPlease Read IOD's Global Rules Before Posting.\nYou will not get this message again if you do.\n(Unless your cookies get deleted.)\nSo, come on! Give them a quick read! OK?"; // Text for Notice
Note the use of pb_displayname for the members name and \n for a line break in the message.
NOTE:
If you are using my Reply Button In Every Post code (or similar), or any quick reply modifying codes, make sure this code is below it.
Location: Global Footer
<script type="text/Javascript">
/* Members Must Read Rules Before Posting by SubDevo */
/* Global Footer - Please leave this header intact. Do not repost. */
/* interoceandesigns.com or lsdp.proboards.com */
var fStaff=/^(admin|staff1)$/i; // User names to ignore.
var gRules="URL TO FORUM RULES THREAD"; // URL to Rules Thread
var gNotice="Please Read Our Forum Rules Before Posting."; // Text for Notice
function gCook(){return document.cookie.indexOf("gRulesRead=true")!=-1?1:0;}
function cLinks(d){ if(gCook()){return;} var nF=0,x=-1,m,nM,a;
a=(d)?document.links:document.getElementsByTagName("input");
while(a[++x]){ m=a[x];
if(d&&/ion=(post|createpoll)&?/i.test(m.href)){m.href="javascript:rgLink()";}
else if(m.type=="submit"&&/Post Reply|Preview/.test(m.value)){nF=1;m.disabled=true;}
} nM=document.getElementsByName("message")[0];
if(!document.getElementById("b_Drules")&&nM&&nF){nM=nM.parentNode;
nM.innerHTML=nM.innerHTML.replace(/><\/textarea/i,">"+gNotice+"</textarea")+' <input type="button" value="Read Rules" onClick="parent.location='+"'"+gRules+"'"+'">';
}}
function rgLink(){if(rgRules(gNotice)){location.href=gRules;}}
function rgRules(i){ if(i){var b=confirm(i);}else{var b=true}
document.cookie="gRulesRead="+b+"; expires=Sat, 17 Jan 2050 12:12:12 UTC; path=/";
return (b)?true:false;
}
if(!fStaff.test(pb_username)){
if(new RegExp(gRules.split("?")[1]+"($|&page)").test(location.href)){rgRules(0);}
var g=gCook(),x=-1,n=document.links;
if(!g&&/^(display|search2)$/.test(pb_action)){
while(n[++x]){
if(n[x].href.indexOf("=modifypost")!=-1){rgRules(0);break;}
} cLinks(1); cLinks(0);
} g=gCook(); if(!g&&pb_action=="boardindex"){ cLinks(1);}
}
</script>
EDIT: 07/10/2010
MAJOR update. The code has been completely re-written.
Fixes:
Code now runs on the "Search Results" and "Recent" pages.
Code now looks for a "Modify" button in posts and since the user has posted, it assumes that they have read the rules and sets their cookie.
Since PB has placed another ad at the bottom of post pages, the message that is supposed to be put into the quick reply, only worked in IE. Fixed.
Added the ability to ignore certain users.
EDIT: 07/04/2011
Since PB added vigLink services, the "onclick" of links is intercepted. This prevented the alert to ask the member to read the rules. Code has been updated to get around this.
This only affected non ad-free forums (most of you out there lol).