merk
09-08-2001, 10:00 PM
Description: Basically, this allows the moderator of a certain forum to add/take
access to users via access masks, however it only allows it if
the forum they moderate has that option enabled. It also
lists what users have access to a specified forum.
Please NOTE! If you dont use the Moderator Control Panel
(forum/mod/) Then this hack probably wont work, sorry!
Install:
Step1: First off, you will need phpMyAdmin, or something similar to add a column to the 'forum' database. I suggest you read > http://vbulletin.com/forum/showthread.php?s=&threadid=18558 for instructions on how to install it.
Once you get that installed, go to the forum table, and scroll down till you see 'Add new field :', put 1 in the box, choose 'At the end of the table' and click Go.
Call the field, 'allowmodaccess', its type, 'smallint' and size, '6'(all without quotes of course), then also choose default, and make it 0(zero)
Step2: Now comes the modding of forum.php in the AdminCP.
Find at approximatly Line 120
doformfooter("Save Forum");
}
// ###################### Start insert #######################
Replace With
//ADDED CODE
maketableheader("Moderator Accessmask Options");
makeyesnocode("Allow moderators of this forum to give/take access via the ModCP","modaccessmasks",0);
//UNADDED CODE
doformfooter("Save Forum");
}
// ###################### Start insert #######################
Then, Find at Approx 124ish
$DB_site->query("INSERT INTO forum
(forumid,styleid,title,description,active,displayo rder,parentid,
parentlist,allowposting,cancontainthreads,daysprun e,newpostemail,newthreademail,
moderatenew,allowhtml,allowbbcode,allowimages,allo wsmilies,allowicons,
styleoverride,allowratings,countposts,moderateatta ch,allowmodaccess)
VALUES
(NULL,'$styleset','".addslashes($title)."','".addslashes($description)."','$isactive','$displayorder','$parentid',
'','$allowposting','$cancontainthreads','$daysprun e','".addslashes($newpostemail)."','".addslashes($newthreademail)."',
'$moderatenew','$aallowhtmlcode','$aallowbbcode',' $aallowimgcode','$aallowsmilies','$aallowicons',
'$styleoverride','$allowratings','$countposts','$m oderateattach')");
Replace With
$DB_site->query("INSERT INTO forum
(forumid,styleid,title,description,active,displayo rder,parentid,
parentlist,allowposting,cancontainthreads,daysprun e,newpostemail,newthreademail,
moderatenew,allowhtml,allowbbcode,allowimages,allo wsmilies,allowicons,
styleoverride,allowratings,countposts,moderateatta ch,allowmodaccess)
VALUES
(NULL,'$styleset','".addslashes($title)."','".addslashes($description)."','$isactive','$displayorder','$parentid',
'','$allowposting','$cancontainthreads','$daysprun e','".addslashes($newpostemail)."','".addslashes($newthreademail)."',
'$moderatenew','$aallowhtmlcode','$aallowbbcode',' $aallowimgcode','$aallowsmilies','$aallowicons',
'$styleoverride','$allowratings','$countposts','$m oderateattach','$modaccessmasks')");
Then Find at Approx line 230
doformfooter("Save Changes");
}
// ###################### Start update #######################
Replace With
//ADDED CODE
maketableheader("Moderator Accessmask Options");
makeyesnocode("Allow moderators of this forum to give/take access via the ModCP","modaccessmasks",$forum[allowmodaccess]);
//UNADDED CODE
doformfooter("Save Changes");
}
// ###################### Start update #######################
Then Find at approx line 250
$DB_site->query("UPDATE forum
SET
styleid='$styleset', title='".addslashes($title)."', description='".addslashes($description)."',
active='$isactive', displayorder='$displayorder', parentid='$parentid', parentlist=$parentlist,
allowposting='$allowposting', cancontainthreads='$cancontainthreads', daysprune='$daysprune',
newpostemail='".addslashes($newpostemail)."', newthreademail='".addslashes($newthreademail)."',
moderatenew='$moderatenew', allowhtml='$aallowhtmlcode', allowbbcode='$aallowbbcode',
allowimages='$aallowimgcode', allowsmilies='$aallowsmilies', allowicons='$aallowicons',
styleoverride='$styleoverride', allowratings='$allowratings', countposts='$countposts',
moderateattach='$moderateattach'
WHERE forumid='$forumid'");
And replace with
$DB_site->query("UPDATE forum
SET
styleid='$styleset', title='".addslashes($title)."', description='".addslashes($description)."',
active='$isactive', displayorder='$displayorder', parentid='$parentid', parentlist=$parentlist,
allowposting='$allowposting', cancontainthreads='$cancontainthreads', daysprune='$daysprune',
newpostemail='".addslashes($newpostemail)."', newthreademail='".addslashes($newthreademail)."',
moderatenew='$moderatenew', allowhtml='$aallowhtmlcode', allowbbcode='$aallowbbcode',
allowimages='$aallowimgcode', allowsmilies='$aallowsmilies', allowicons='$aallowicons',
styleoverride='$styleoverride', allowratings='$allowratings', countposts='$countposts',
moderateattach='$moderateattach', allowmodaccess='$modaccessmasks'
WHERE forumid='$forumid'");
Step3: Now we need to modify index.php in the /mod/ folder.
Find at approx line 124
<!--<tr><td>
<table width="100%" border="0" cellspacing="0" cellpadding="2">
<tr bgcolor="#3F3849"><td><font color="#BCB6CD">
<b>Styles</b>
</font></td></tr></table>
<a href="style.php?s=<?php echo $session[sessionhash]; ?>&action=modify"> Edit </a>
</td></tr>-->
Replace With
<tr><td>
<table width="100%" border="0" cellspacing="0" cellpadding="2">
<?php maketableheader("User Access Masks"); ?>
</table>
<a href="modaccessmasks.php?s=<?php echo $session[sessionhash]; ?>&action=select"> Add | Edit | List </a>
</td></tr>
Step4: Making modaccessmasks.php...
Okay, this bit wont be easy :|
Basically, make this file as below, however, there are a few bits your going to have to grab from user.php in the admin directory.(which i will explain down furthur)
<?php
error_reporting(7);
require("./global.php");
cpheader();
if (isset($action)==0) {
$action="select";
}
//////////#########***********Here>><<>><< You need to add code i specifiy down furthur.
// ###################### Start Select Window Thing #####################
if ($action=="select"){
doformheader("modaccessmasks","editaccess");
makehiddencode("action","editaccess");
maketableheader("Access Granting For Forums","",0);
echo "<br>\n";
makeinputcode("User Name(exact)","user_name");
doformfooter("Edit User");
echo "<br>\n";
doformheader("modaccessmasks","editaccess");
makehiddencode("action","listusers");
maketableheader("List Users Access per Forum","",0);
echo "<br>\n";
makeinputcode("Forum ID","forumid");
doformfooter("List Forums");
}
// ################## Start List of Access per forum ##########
if ($action=="listusers") {
$query = "SELECT * FROM access ORDER BY userid";
$passthruquery=$DB_site->query($query);
while ($newsarray=$DB_site->fetch_array($passthruquery)) {
$query2 = "SELECT * FROM user WHERE userid=$newsarray[userid] LIMIT 1";
$query3 = "SELECT * FROM forum WHERE forumid=$newsarray[forumid] LIMIT 1";
$passthruquery2=$DB_site->query($query2);
$newsarray2=$DB_site->fetch_array($passthruquery2);
$passthruquery3=$DB_site->query($query3);
$newsarray3=$DB_site->fetch_array($passthruquery3);
if($newsarray[accessmask] == 1 AND $newsarray[forumid] == $forumid ) {
echo "$newsarray2[username] has access to $newsarray3[title]($newsarray[forumid])\n<br>";
}
}
}
cpfooter();
?>
Open up user.php And look around line 358 for
// ###################### Start Edit Access #######################
if ($action=="editaccess") {
And copy from there down to >> to approx line 425
echo "<p>User access updated successfully</p>";
$action="modify";
}
Put all that copy stuff into the above file, in the section thingo i specified.
Now you need to mod that code.
Step5: >>
Find
if ($action=="editaccess") {
Add immediatly below it
if(!isset($userid)) {
$username=$DB_site->query_first("SELECT userid FROM user WHERE username='$user_name'");
$userid=$username[userid];
}
Then Find
doformheader("user","updateaccess");
makehiddencode("userid","$userid");
Replace With
doformheader("modaccessmasks","updateaccess");
makehiddencode("userid","$userid");
I would recomend editing the below block of code, changing to description for your moderators.
echo "<tr class='firstalt'><td c.....
Now, find
maketableheader("Forum List");
$forumlist=$DB_site->query("SELECT * FROM forum");
Replace It with
maketableheader("Forum List");
///modified code
if($bbuserinfo[usergroupid]==5 OR $bbuserinfo[usergroupid]==6) {
$forumlist=$DB_site->query("SELECT * FROM forum WHERE forum.allowmodaccess=1 ORDER BY forum.title");
}
else {
$forumlist=$DB_site->query("SELECT moderator.userid,forum.title FROM moderator,forum WHERE moderator.forumid=forum.forumid AND moderator.userid=$bbuserinfo[userid] AND forum.allowmodaccess=1 ORDER BY forum.title");
}
//end modify
And Finally,
Find
echo "<p>User access updated successfully</p>";
$action="modify";
And Replace with
echo "<p>User access updated successfully</p>";
$action="select";
Phew, you should be done. Now go into your AdminCP, and modify all the forums you wish your users to be able to change/add accessmasks to and at the bottom, choose 'yes' for allow mods to change access masks.
To access it, go to http://yourforum.url/forumpath/mod/ login, and hit the Add | Edit | View button on the menu.
Thats all Folks!
PS Phew for the 12345 char limit ;)
access to users via access masks, however it only allows it if
the forum they moderate has that option enabled. It also
lists what users have access to a specified forum.
Please NOTE! If you dont use the Moderator Control Panel
(forum/mod/) Then this hack probably wont work, sorry!
Install:
Step1: First off, you will need phpMyAdmin, or something similar to add a column to the 'forum' database. I suggest you read > http://vbulletin.com/forum/showthread.php?s=&threadid=18558 for instructions on how to install it.
Once you get that installed, go to the forum table, and scroll down till you see 'Add new field :', put 1 in the box, choose 'At the end of the table' and click Go.
Call the field, 'allowmodaccess', its type, 'smallint' and size, '6'(all without quotes of course), then also choose default, and make it 0(zero)
Step2: Now comes the modding of forum.php in the AdminCP.
Find at approximatly Line 120
doformfooter("Save Forum");
}
// ###################### Start insert #######################
Replace With
//ADDED CODE
maketableheader("Moderator Accessmask Options");
makeyesnocode("Allow moderators of this forum to give/take access via the ModCP","modaccessmasks",0);
//UNADDED CODE
doformfooter("Save Forum");
}
// ###################### Start insert #######################
Then, Find at Approx 124ish
$DB_site->query("INSERT INTO forum
(forumid,styleid,title,description,active,displayo rder,parentid,
parentlist,allowposting,cancontainthreads,daysprun e,newpostemail,newthreademail,
moderatenew,allowhtml,allowbbcode,allowimages,allo wsmilies,allowicons,
styleoverride,allowratings,countposts,moderateatta ch,allowmodaccess)
VALUES
(NULL,'$styleset','".addslashes($title)."','".addslashes($description)."','$isactive','$displayorder','$parentid',
'','$allowposting','$cancontainthreads','$daysprun e','".addslashes($newpostemail)."','".addslashes($newthreademail)."',
'$moderatenew','$aallowhtmlcode','$aallowbbcode',' $aallowimgcode','$aallowsmilies','$aallowicons',
'$styleoverride','$allowratings','$countposts','$m oderateattach')");
Replace With
$DB_site->query("INSERT INTO forum
(forumid,styleid,title,description,active,displayo rder,parentid,
parentlist,allowposting,cancontainthreads,daysprun e,newpostemail,newthreademail,
moderatenew,allowhtml,allowbbcode,allowimages,allo wsmilies,allowicons,
styleoverride,allowratings,countposts,moderateatta ch,allowmodaccess)
VALUES
(NULL,'$styleset','".addslashes($title)."','".addslashes($description)."','$isactive','$displayorder','$parentid',
'','$allowposting','$cancontainthreads','$daysprun e','".addslashes($newpostemail)."','".addslashes($newthreademail)."',
'$moderatenew','$aallowhtmlcode','$aallowbbcode',' $aallowimgcode','$aallowsmilies','$aallowicons',
'$styleoverride','$allowratings','$countposts','$m oderateattach','$modaccessmasks')");
Then Find at Approx line 230
doformfooter("Save Changes");
}
// ###################### Start update #######################
Replace With
//ADDED CODE
maketableheader("Moderator Accessmask Options");
makeyesnocode("Allow moderators of this forum to give/take access via the ModCP","modaccessmasks",$forum[allowmodaccess]);
//UNADDED CODE
doformfooter("Save Changes");
}
// ###################### Start update #######################
Then Find at approx line 250
$DB_site->query("UPDATE forum
SET
styleid='$styleset', title='".addslashes($title)."', description='".addslashes($description)."',
active='$isactive', displayorder='$displayorder', parentid='$parentid', parentlist=$parentlist,
allowposting='$allowposting', cancontainthreads='$cancontainthreads', daysprune='$daysprune',
newpostemail='".addslashes($newpostemail)."', newthreademail='".addslashes($newthreademail)."',
moderatenew='$moderatenew', allowhtml='$aallowhtmlcode', allowbbcode='$aallowbbcode',
allowimages='$aallowimgcode', allowsmilies='$aallowsmilies', allowicons='$aallowicons',
styleoverride='$styleoverride', allowratings='$allowratings', countposts='$countposts',
moderateattach='$moderateattach'
WHERE forumid='$forumid'");
And replace with
$DB_site->query("UPDATE forum
SET
styleid='$styleset', title='".addslashes($title)."', description='".addslashes($description)."',
active='$isactive', displayorder='$displayorder', parentid='$parentid', parentlist=$parentlist,
allowposting='$allowposting', cancontainthreads='$cancontainthreads', daysprune='$daysprune',
newpostemail='".addslashes($newpostemail)."', newthreademail='".addslashes($newthreademail)."',
moderatenew='$moderatenew', allowhtml='$aallowhtmlcode', allowbbcode='$aallowbbcode',
allowimages='$aallowimgcode', allowsmilies='$aallowsmilies', allowicons='$aallowicons',
styleoverride='$styleoverride', allowratings='$allowratings', countposts='$countposts',
moderateattach='$moderateattach', allowmodaccess='$modaccessmasks'
WHERE forumid='$forumid'");
Step3: Now we need to modify index.php in the /mod/ folder.
Find at approx line 124
<!--<tr><td>
<table width="100%" border="0" cellspacing="0" cellpadding="2">
<tr bgcolor="#3F3849"><td><font color="#BCB6CD">
<b>Styles</b>
</font></td></tr></table>
<a href="style.php?s=<?php echo $session[sessionhash]; ?>&action=modify"> Edit </a>
</td></tr>-->
Replace With
<tr><td>
<table width="100%" border="0" cellspacing="0" cellpadding="2">
<?php maketableheader("User Access Masks"); ?>
</table>
<a href="modaccessmasks.php?s=<?php echo $session[sessionhash]; ?>&action=select"> Add | Edit | List </a>
</td></tr>
Step4: Making modaccessmasks.php...
Okay, this bit wont be easy :|
Basically, make this file as below, however, there are a few bits your going to have to grab from user.php in the admin directory.(which i will explain down furthur)
<?php
error_reporting(7);
require("./global.php");
cpheader();
if (isset($action)==0) {
$action="select";
}
//////////#########***********Here>><<>><< You need to add code i specifiy down furthur.
// ###################### Start Select Window Thing #####################
if ($action=="select"){
doformheader("modaccessmasks","editaccess");
makehiddencode("action","editaccess");
maketableheader("Access Granting For Forums","",0);
echo "<br>\n";
makeinputcode("User Name(exact)","user_name");
doformfooter("Edit User");
echo "<br>\n";
doformheader("modaccessmasks","editaccess");
makehiddencode("action","listusers");
maketableheader("List Users Access per Forum","",0);
echo "<br>\n";
makeinputcode("Forum ID","forumid");
doformfooter("List Forums");
}
// ################## Start List of Access per forum ##########
if ($action=="listusers") {
$query = "SELECT * FROM access ORDER BY userid";
$passthruquery=$DB_site->query($query);
while ($newsarray=$DB_site->fetch_array($passthruquery)) {
$query2 = "SELECT * FROM user WHERE userid=$newsarray[userid] LIMIT 1";
$query3 = "SELECT * FROM forum WHERE forumid=$newsarray[forumid] LIMIT 1";
$passthruquery2=$DB_site->query($query2);
$newsarray2=$DB_site->fetch_array($passthruquery2);
$passthruquery3=$DB_site->query($query3);
$newsarray3=$DB_site->fetch_array($passthruquery3);
if($newsarray[accessmask] == 1 AND $newsarray[forumid] == $forumid ) {
echo "$newsarray2[username] has access to $newsarray3[title]($newsarray[forumid])\n<br>";
}
}
}
cpfooter();
?>
Open up user.php And look around line 358 for
// ###################### Start Edit Access #######################
if ($action=="editaccess") {
And copy from there down to >> to approx line 425
echo "<p>User access updated successfully</p>";
$action="modify";
}
Put all that copy stuff into the above file, in the section thingo i specified.
Now you need to mod that code.
Step5: >>
Find
if ($action=="editaccess") {
Add immediatly below it
if(!isset($userid)) {
$username=$DB_site->query_first("SELECT userid FROM user WHERE username='$user_name'");
$userid=$username[userid];
}
Then Find
doformheader("user","updateaccess");
makehiddencode("userid","$userid");
Replace With
doformheader("modaccessmasks","updateaccess");
makehiddencode("userid","$userid");
I would recomend editing the below block of code, changing to description for your moderators.
echo "<tr class='firstalt'><td c.....
Now, find
maketableheader("Forum List");
$forumlist=$DB_site->query("SELECT * FROM forum");
Replace It with
maketableheader("Forum List");
///modified code
if($bbuserinfo[usergroupid]==5 OR $bbuserinfo[usergroupid]==6) {
$forumlist=$DB_site->query("SELECT * FROM forum WHERE forum.allowmodaccess=1 ORDER BY forum.title");
}
else {
$forumlist=$DB_site->query("SELECT moderator.userid,forum.title FROM moderator,forum WHERE moderator.forumid=forum.forumid AND moderator.userid=$bbuserinfo[userid] AND forum.allowmodaccess=1 ORDER BY forum.title");
}
//end modify
And Finally,
Find
echo "<p>User access updated successfully</p>";
$action="modify";
And Replace with
echo "<p>User access updated successfully</p>";
$action="select";
Phew, you should be done. Now go into your AdminCP, and modify all the forums you wish your users to be able to change/add accessmasks to and at the bottom, choose 'yes' for allow mods to change access masks.
To access it, go to http://yourforum.url/forumpath/mod/ login, and hit the Add | Edit | View button on the menu.
Thats all Folks!
PS Phew for the 12345 char limit ;)