I was determined to share whatever I learned in playing with PHP and W3T and I've seen a few people asking for a PHP version of something Eileen did in Perl to prevent anyone but mods and admins from starting a new thread. e.g I want to use it to have news boards where only reporters can post original news items but where all users can discuss the news items afterwards:
In config.inc.php add a config variable:
$config['modonlyboards'] = "comma,separated,list,of,boards,to,which,this,applies"
Then in postlist.php find the following (around line 380 in my copy) and hack into it as follows:
// ---------------------------------------------------------------------
// We need to check and see if they have write privileges for this forum
$gsize = sizeof($Grouparray);
for ($i=0; $i <$gsize; $i++) {
if (ereg("-$Grouparray[$i]-",$CanWrite) ) {
$makepost = "yes";
break;
}
}
// Jock: addition to test if this is a board where only mods can initiate
// a new thread.
if (strpos($config[modonlyboards],$Board)) {
$makepost = "no";
}
if ($user[U_Status] == "Administrator") {
$makepost = "yes";
}
if ($user[U_Status] == "Moderator") {
// Check if they moderate this board
$Username_q = addslashes($Username);
$query = "
SELECT Mod_Board
FROM w3t_Moderators
WHERE Mod_Username = '$Username_q'
AND Mod_Board = '$Board_q'
";
$sth = $dbh -> do_query($query);
$rows = $dbh -> fetch_array($sth);
$dbh -> finish_sth($sth);
if ($rows[0]) {
$makepost = "yes";
}
}
// Jock: end addition to test if this is a board where only mods can initiate
// a new thread.
if ($makepost == "yes") {
echo "<a href="$config[phpurl]/newpost.php?Cat=$Cat&Board=$Board&page=$page&view=$view&sb=$sb"><img $images[newpost] src="$config[images]/newpost.gif" alt="$lang[MAKE_A_NEW]" border=0></a>";
}
else {
echo "<img alt="*" src="$config[images]/greynewpost.gif" $images[newpost]>";
}
I hope I'm doing this right and people can follow all that. And I hope someone finds that useful.
To improve it I need to do something in newpost to jump out if for some reason someone manages to get into the post screen on one of these boards, and maybe create something in config to let users select which boards to make mod post only.
Jock