Boofo, you would be a life saver. I've installed that hack but the members went ape#$($ because they didn't want anyone to know if they read the thread. Don't ask, I still don't know why.
Yesterday at 09:06 PM Boofo said this in Post #20 I redid this for my site so it only shows to Admins and it will show invisible users, too. I also put it at the bottom in it's own box. If anyone is interested I can attach the file, if filburt doesn't mind, that is.
The changes only would be better (I'm assuming it's only three lines of code, two of which are braces).
// make sure not to have redundancy in the view list, so get who's viewed it
// first (and do nothing for invisible users)
$thisthread = $DB_site->query_first("SELECT useridviews FROM thread
WHERE threadid = $threadid");
$useridviews = explode(" ", $thisthread['useridviews']);
if (!$bbuserinfo['invisible'])
{
if (!empty($thisthread['useridviews']))
{
if (!in_array($bbuserinfo['userid'], $useridviews))
{
$DB_site->query("
UPDATE thread
SET useridviews = CONCAT(useridviews, \" \", \"" .
$bbuserinfo['userid'] . "\")
WHERE threadid = $threadid");
}
}
else
{
$DB_site->query("UPDATE thread
SET useridviews = \"" . $bbuserinfo['userid'] . "\"
WHERE threadid = $threadid");
}
}
Change it to:
PHP Code:
// make sure not to have redundancy in the view list, so get who's viewed it
// first (and do nothing for invisible users)
$thisthread = $DB_site->query_first("SELECT useridviews FROM thread
WHERE threadid = $threadid");
$useridviews = explode(" ", $thisthread['useridviews']);
//if (!$bbuserinfo['invisible'])
//{
if (!empty($thisthread['useridviews']))
{
if (!in_array($bbuserinfo['userid'], $useridviews))
{
$DB_site->query("
UPDATE thread
SET useridviews = CONCAT(useridviews, \" \", \"" .
$bbuserinfo['userid'] . "\")
WHERE threadid = $threadid");
}
}
else
{
$DB_site->query("UPDATE thread
SET useridviews = \"" . $bbuserinfo['userid'] . "\"
WHERE threadid = $threadid");
}
//}
Find:
PHP Code:
$thread['viewers'] = implode(", ", $viewers);
}
Change it to:
PHP Code:
$thread['viewers'] = implode(", ", $viewers);
If ($bbuserinfo[usergroupid]==6 OR $bbuserinfo[usergroupid]==5) {
eval("\$totalviewers = \"".gettemplate('showthread_totalviewers')."\";");
}
}
Make a new template called "showthread_totalviewers" (and don't forget to include this in the templatesused line in the showthread.php)
Here's the only other problem that I'm expirencing. For whatever reason, it seems to not log the usernames, other than the ones that are able to view the list (in this case usergroups 5 and 6), unless I add additional usergroups, then it comes up working fine. here is the code that i have.
PHP Code:
if ($bbuserinfo[usergroupid]==6 OR $bbuserinfo[usergroupid]==5
OR $bbuserinfo[usergroupid]==8 OR $bbuserinfo[usergroupid]==7 OR $bbuserinfo[usergroupid]==4
OR $bbuserinfo[usergroupid]==13 OR $bbuserinfo[usergroupid]==16 OR $bbuserinfo[usergroupid]==14
OR $bbuserinfo[usergroupid]==18 OR $bbuserinfo[usergroupid]==12 OR $bbuserinfo[usergroupid]==17
OR $bbuserinfo[usergroupid]==15 OR $bbuserinfo[usergroupid]==2 OR $bbuserinfo[usergroupid]==9
OR $bbuserinfo[usergroupid]==3) {
// make sure not to have redundancy in the view list, so get who's viewed it
// first (and do nothing for invisible users)
$thisthread = $DB_site->query_first("SELECT useridviews FROM thread
WHERE threadid = $threadid");
$useridviews = explode(" ", $thisthread['useridviews']);
//if (!$bbuserinfo['invisible'])
//{
if (!empty($thisthread['useridviews']))
{
if (!in_array($bbuserinfo['userid'], $useridviews))
{
$DB_site->query("
UPDATE thread
SET useridviews = CONCAT(useridviews, \" \", \"" .
$bbuserinfo['userid'] . "\")
WHERE threadid = $threadid");
}
}
else
{
$DB_site->query("UPDATE thread
SET useridviews = \"" . $bbuserinfo['userid'] . "\"
WHERE threadid = $threadid");
}
//}
// now...who's viewed this thread? (will include $bbuserinfo if he's not invis)
if (empty($thisthread['useridviews']))
{
$thread['viewers'] = "nobody";
}
else
{
$result = $DB_site->query("SELECT userid, username FROM user
WHERE userid IN (" . implode(", ", $useridviews) . ")");
$viewers = array();
while ($user = $DB_site->fetch_array($result))
{
array_push($viewers, "<a target=\"_blank\" href=\"member.php?s=" .
$session['sessionhash'] . "&action=getinfo&userid=" .
$user['userid'] . "\">" . htmlspecialchars($user['username']) .
"</a>");
}
$thread['viewers'] = implode(", ", $viewers);
eval("\$totalviewers = \"".gettemplate('showthread_totalviewers')."\";");
}
}
how would i go about to only have these show up for admins, while having it log every user, w/o having to add all those additonal usergroups? thanks again filburt1 and boofo!
MetroSports82, sorry about that. Thanks for catching it. If you'll redo the code I posted above, it should now work fine. I had the bbuserinfo[usergroupid] in the wrong place. I edited my post above to put it right before it evals the template. I tested it and it seems to fix your problem. All usergroups will be tallied now and only the usergroups you want to see the listing will be able to see it.
hehe, nevermind boofo! just saw your edit on your original post where ya adding the usergroups line, right above the evals template line, and it works just fine now! thanks again m8.
PHP Code:
// make sure not to have redundancy in the view list, so get who's viewed it
// first (and do nothing for invisible users)
$thisthread = $DB_site->query_first("SELECT useridviews FROM thread
WHERE threadid = $threadid");
$useridviews = explode(" ", $thisthread['useridviews']);
//if (!$bbuserinfo['invisible'])
//{
if (!empty($thisthread['useridviews']))
{
if (!in_array($bbuserinfo['userid'], $useridviews))
{
$DB_site->query("
UPDATE thread
SET useridviews = CONCAT(useridviews, \" \", \"" .
$bbuserinfo['userid'] . "\")
WHERE threadid = $threadid");
}
}
else
{
$DB_site->query("UPDATE thread
SET useridviews = \"" . $bbuserinfo['userid'] . "\"
WHERE threadid = $threadid");
}
//}
// now...who's viewed this thread? (will include $bbuserinfo if he's not invis)
if (empty($thisthread['useridviews']))
{
$thread['viewers'] = "nobody";
}
else
{
$result = $DB_site->query("SELECT userid, username FROM user
WHERE userid IN (" . implode(", ", $useridviews) . ")");
$viewers = array();
while ($user = $DB_site->fetch_array($result))
{
array_push($viewers, "<a target=\"_blank\" href=\"member.php?s=" .
$session['sessionhash'] . "&action=getinfo&userid=" .
$user['userid'] . "\">" . htmlspecialchars($user['username']) .
"</a>");
}
$thread['viewers'] = implode(", ", $viewers);
if ($bbuserinfo[usergroupid]==6) {
eval("\$totalviewers = \"".gettemplate('showthread_totalviewers')."\";");
}
}