Previous Thread
Next Thread
Print Thread
Rate Thread
Joined: Jan 2001
Posts: 32
User
User
Offline
Joined: Jan 2001
Posts: 32
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


Sponsored Links

Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
isaac
isaac
California
Posts: 1,157
Joined: July 2001
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20221218)