Version: , by Admin (Coder)
Developer Last Online: Nov 2024
Version: 2.2.x
Rating:
Released: 09-16-2001
Last Update: Never
Installs: 78
No support by the author.
This was requested by David Copeland.
He wanted to be able to list all users that have or don't have access to a certain forum.
This is very very easy to install, you just need to add one block of code and a link!
Install:
In user.php (admin folder), add this code:
PHP Code:
echo "<li><a href=\"user.php?s=$session[sessionhash]&action=findaccess\">List by access masks</a></li>\n";
right after
PHP Code:
echo "<li><a href=\"user.php?s=$session[sessionhash]&action=find\">List all users</a></li>\n";
Still in user.php, add this code:
PHP Code:
// ###################### Start Find by Access #######################
if ($action=="dofindaccess") {
if ($checkaccess!="1" and $checkaccess!="0") {
$action = "findaccess";
} else {
$lists = $DB_site->query("SELECT * FROM access");
$inquery = "";
while ($list = $DB_site->fetch_array($lists)) {
if ($list[forumid]==$forumfrom and $list[accessmask]==$checkaccess) {
if ($inquery) {
$inquery .= ",";
}
$inquery .= "$list[userid]";
}
}
if ($inquery=="") {
echo "No users found.";
$action = "findaccess";
} else {
$users = $DB_site->query("SELECT userid,username,usergroupid,password,email,FROM_UNIXTIME(joindate) AS joindate,FROM_UNIXTIME(lastvisit) AS lastvisit,posts FROM user WHERE userid IN ($inquery)");
echo "<p>Click username to view forum profile.</p>";
doformheader("","");
// ###################### Start List by Access #######################
if ($action=="findaccess") {
doformheader("user","dofindaccess");
maketableheader("List Users by Access Masks","",0);
echo "<tr class='firstalt'><td colspan=2><p>Here you can list all users that match the settings you set below.</p></td></tr>\n";
maketableheader("Forum Select");
makeforumchoosercode("Forum you'd like to order by:",forumfrom);
makeyesnocode("Does the user has access to that forum?",checkaccess,"2");
echo "</p></td></tr>\n";
doformfooter("List users");
}
right before
PHP Code:
cpfooter();
?>
The end.
See, I told you it's easy!
Now you have a link for this under Users => Find => List by access masks (under List all users).
By the way, I know that one part of the code there could be combined with the other search part, but this is just as good.
Sue me.
Feedback please.
Show Your Support
This modification may not be copied, reproduced or published elsewhere without author's permission.
Thanks a lot, even for such a fast answer!
Anyway...
I can't manage to use 'UNION' on two simple select ... Even returning the 'userid' alone....
ERRATA CORRIGE: ooops. The UNION [ALL] SQL command requires +4.x version of MySQL...
I think the hack should merge itself the different result sets within php code and not sql-query...
Thanks this hack works great! And it makes it MUCH more convenient when trying to find out who all has access to certain forums.
As previously stated, it seems that it doesn't list users that have access to certain forums because they are allowed entry because of the user group they are in. Unless it is actually selected in the persons access masks, it doesn't list them as having access to that forum.
Originally posted by FireFly I'll see what I can come up with Jawelin, but I can't promise anything.
I know what you said, but just for reminder... :supwink:
Meanwhile I tried myself but can't manage to merge different result sets within php code, as my server has mySQL 3.2x and not +4...
Anyway is very hard to findout an algorithm to select and make explicit permissions with inherited ones...
:noid:
Ok....i am VERY sorry to be such a brat...but I have a BIG request here......
Any way I could talk you into adding a link in this hack that would reset a user's "custom status'" to usergroup defaults for ALL forums?? I have over 300 at present...and doing it by hand if a mod gets demoted gets REALLY old.
Just a tip:
what about
1) choose a forum from a combo-list (best ordered the same way in jump-combo is, not alphabetically), fixing a parameter, this way.
2) seek all the user table checking :
PHP Code:
$permissions=getpermissions($forum[forumid],$userid);
if ($permissions['canview'] == 1/0 ) {
// add this user to the enabled/disabled list
}
The complexity should be linear than the usercount, and this way the search should keep the inheritance, the access table, the usergroup permission, etc.