PDA

View Full Version : Show Thread Enhancements - Who viewed this thread?


Gary King
06 Feb 2004, 04:27
There is an enhanced version of this mod found here (http://www.vbulletin.org/forum/showthread.php?t=68876).

Who viewed this thread?
Version: 1.0
vB-version: 3.0.0 Release Candidate 3
Developer: Gary W
Install difficulty: Extremely Easy
File edits: 1
Template edits: 1

Description of the Hack:
This hack shows who has viewed any thread. View the screenshot to see how it looks.

If you don't want to have invisible users in the list, then remove $showinvisible = 1;

View the screenshot to see the hack in action :D

Instructions

FILES
------
showthread.php

TEMPLATES
-------------
SHOWTHREAD

RUN QUERY: ALTER TABLE thread ADD whoviewed TEXT NOT NULL;

ADD PHRASE:
already_viewed_this_thread / Already viewed this thread:


OPEN FILE showthread.php AND FIND


// ******************************************************************************** *
//set thread last view
set_bbarray_cookie('thread_lastview', $threadid, TIMENOW);


ABOVE ADD


$showinvisible = 1;

// Get who has already viewed this thread
$currentthread = $DB_site->query_first("SELECT whoviewed FROM ".TABLE_PREFIX."thread WHERE threadid = $threadid");
$vieweduserids = explode(" ", $currentthread['whoviewed']);

$userinfo = fetch_userinfo($bbuserinfo['userid']);

if (!$userinfo['invisible'] OR $showinvisible)
{
if (!empty($currentthread['whoviewed']))
{
if (!in_array($bbuserinfo['userid'], $vieweduserids))
{
$DB_site->query("UPDATE ".TABLE_PREFIX."thread SET whoviewed = CONCAT(whoviewed, \" \", \"" .$bbuserinfo['userid'] . "\") WHERE threadid = $threadid");
}
}
else
{
$DB_site->query("UPDATE ".TABLE_PREFIX."thread SET whoviewed = \"" . $bbuserinfo['userid'] . "\" WHERE threadid = $threadid");
}
}

// Who has viewed this thread?
if (empty($currentthread['whoviewed']))
{
$thread['viewers'] = '('.strtolower($vbphrase['none']).')';
}
else
{
$result = $DB_site->query("SELECT userid, username FROM ".TABLE_PREFIX."user WHERE userid IN (" . implode(", ", $vieweduserids) . ")");
$viewers = array();
while ($user = $DB_site->fetch_array($result))
{
array_push($viewers, "<a target=\"_blank\" href=\"member.php?".$session['sessionurl'] . "u=".$user['userid'] . "\">" . htmlspecialchars($user['username']) . "</a>");
}
$thread['viewers'] = implode(", ", $viewers);
}



OPEN SHOWTHREAD TEMPLATE AND FIND

$poll

ABOVE ADD

<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center"><tbody>
<tr>
<td class="thead">
<a style="float:$stylevar[right]" href="#top" onClick="return toggle_collapse('forumhome_todayactiveusers')"><img id="collapseimg_forumhome_todayactiveusers" src="$stylevar[imgdir_button]/collapse_thead$vbcollapse[collapseimg_forumhome_todayactiveusers].gif" alt="" border="0" /></a>
$vbphrase[already_viewed_this_thread]
</td>
</tr>
</tbody>
<tbody id="collapseobj_forumhome_todayactiveusers" style="$vbcollapse[collapseobj_forumhome_todayactiveusers]">
<tr>
<td class="alt1"><div class="smallfont">
$thread[viewers]
</div></td>
</tr>
</tbody>
</table>
<br />

INSTALLATION COMPLETE! :)

Omega Prime
06 Feb 2004, 14:32
oooh! Thanks for making this hack so fast :D !

Xenon
06 Feb 2004, 15:10
you should rename that php file into .txt ;)

mashour.net
06 Feb 2004, 15:20
Thanks :rolleyes:

sabret00the
06 Feb 2004, 17:18
not bad, not bad at all, would be great as a store action :)

Gary King
06 Feb 2004, 21:22
you should rename that php file into .txt ;)
I did it real quick and my default file format is PHP :p
Fixing now :)

Gary King
06 Feb 2004, 21:23
not bad, not bad at all, would be great as a store action :)
You mean for the Store hack?

sabret00the
06 Feb 2004, 22:26
yup theirs no vb3 version yet, but it would be awesome, to buy the power to see who's viewed threads :)

WAR
08 Feb 2004, 03:14
Is this Hack HTL compliant?

I noticed that the changes file was .htl but you didn't really indicate that it was anywhere else in this thread...

Gary King
08 Feb 2004, 03:56
Is this Hack HTL compliant?

I noticed that the changes file was .htl but you didn't really indicate that it was anywhere else in this thread...
There hopefully a bit more clear ;)

StarBuG
08 Feb 2004, 10:07
Hi

I have one question.
What about if a thread was viewed by let´s say 150 members do I see the whole list of 150 members above the thread then?

Wouldn´t it be better to have the who viewed as a link wich opens a popup list.

Greetings

Star

Gary King
08 Feb 2004, 15:05
Hi

I have one question.
What about if a thread was viewed by let´s say 150 members do I see the whole list of 150 members above the thread then?

Wouldn´t it be better to have the who viewed as a link wich opens a popup list.

Greetings

Star
Well technically that's how WOL works as well, so this is like that. If there are lots of people, then yes it will show the whole list, but it's not like every thread will be like that (hopefully) :D If there are lots of people who want this feature added then I could do that.

rms10
11 Feb 2004, 17:45
If there are lots of people who want this feature added then I could do that.

I would like this feature added :)

rms10
11 Feb 2004, 18:41
BTW trying to use the htl file to install the hack on RC4 and get the following error:

No Phrases file found in Hack data or file system!
No groupname specified.

running the verbose test it showed this info:

This step would import a new set of phrases for the Hack

It would create this new column on the language table:
phrasegroup_

It would take the new phrases from this file:
./htlfiles/whoviewed_phrases

Xenon
11 Feb 2004, 20:36
Well technically that's how WOL works as well, so this is like that. If there are lots of people, then yes it will show the whole list, but it's not like every thread will be like that (hopefully) :D If there are lots of people who want this feature added then I could do that.
may i suggest another method?

just put it into a collapsable table, that way it wouldn't fill up to much space if not wanted ;)

Gary King
11 Feb 2004, 21:42
may i suggest another method?

just put it into a collapsable table, that way it wouldn't fill up to much space if not wanted ;)
Yeah I know that was my alternative.

Gary King
11 Feb 2004, 22:26
Collapsable table added :)

Gary King
11 Feb 2004, 22:28
Fancy screenshot added as well :p

Xenon
11 Feb 2004, 22:54
*gg* nice screeny

Gary King
11 Feb 2004, 23:12
*gg* nice screeny
Thanks :D

Alas-Digitales
12 Feb 2004, 23:49
Is it possible to show this option also to super-moderatos? I have tried to insert it this way:

<if condition="$+++++ad and $bbuserinfo[usergroupid]==5 and $bbuserinfo[usergroupid]==6">

But it does no work. How can I do it?

Gary King
12 Feb 2004, 23:58
Is it possible to show this option also to super-moderatos? I have tried to insert it this way:

<if condition="$+++++ad and $bbuserinfo[usergroupid]==5 and $bbuserinfo[usergroupid]==6">

But it does no work. How can I do it?
Use 'or' instead of 'and'.

Alas-Digitales
13 Feb 2004, 00:06
Thanks!!!

Ocean
29 Mar 2004, 14:13
Hi, Gary!


Quick question - is this hack fully stable and compatible with vB 3.0 Gold? Or does it need to be updated?

Gary King
29 Mar 2004, 21:04
Hi, Gary!


Quick question - is this hack fully stable and compatible with vB 3.0 Gold? Or does it need to be updated?
Yes it should work with Gold.

Ocean
29 Mar 2004, 21:34
Great!

Thanks again!

Carter876
30 Mar 2004, 11:38
Hi Gery W, I like very much this hack but I have a questions:
Is there the possibility that onlyAdmins see this "Who viewed this thread" Panel (if Yes, How?)

Tnx and compliments for the nice hack :)

Regards

Ocean
30 Mar 2004, 14:07
Hi, Gary! I just installed this hack, but I'm having three issues with it:


1. Invisible Users don't show up at all. I would have thought that this would work like vB's Currently Active Users, or even like your Who Was Online Today - where Invisible Users appear to those who have the rights to see them (and they are suffixed with a " * " character. But in this case, they are just not there.

2. The Title Bar doesn't actually reach all the way to the right side. If you collapse it, then it displays properly. But while expanded, it falls a quarter inch short.

3. On your Who Was Online Today hack, when you click on a Username, it brings up the profile in the same window. But on this one, it opens a new window. Is this easily fixable?


Now the only question is - did I do something wrong? Or are these three issues actually bugs? :)

Gary King
31 Mar 2004, 01:11
Hi, Gary! I just installed this hack, but I'm having three issues with it:


1. Invisible Users don't show up at all. I would have thought that this would work like vB's Currently Active Users, or even like your Who Was Online Today - where Invisible Users appear to those who have the rights to see them (and they are suffixed with a " * " character. But in this case, they are just not there.

2. The Title Bar doesn't actually reach all the way to the right side. If you collapse it, then it displays properly. But while expanded, it falls a quarter inch short.

3. On your Who Was Online Today hack, when you click on a Username, it brings up the profile in the same window. But on this one, it opens a new window. Is this easily fixable?


Now the only question is - did I do something wrong? Or are these three issues actually bugs? :)
All 3 are fixed :) The invisible users part, it shows invisible users to all users to have less strain on the servers.

Ocean
31 Mar 2004, 01:28
All 3 are fixed :) The invisible users part, it shows invisible users to all users to have less strain on the servers.


Great! I'll give it a shot tomorrow and see how it goes.


Incidentally, I only plan on certain users being able to access this feature - so I wouldn't think it would be that great a strain on the Server, for me at least.

What would I need to change, if I wanted Invisible Users handled the same way it is on the Forum Home? (i.e. Only shown to those with access to see Invisible Users, suffixed with the "*" character, etc...)

:)

Carter876
31 Mar 2004, 08:48
Hi Gery W, I like very much this hack but I have a questions:
Is there the possibility that onlyAdmins see this "Who viewed this thread" Panel (if Yes, How?)

Tnx and compliments for the nice hack :)

Regards

Gery can you answer to my question, pls?

Tnx :)

Ocean
31 Mar 2004, 11:56
Gery can you answer to my question, pls?

Tnx :)

Carter876, take the entire block of code that you are supposed to enter into the Showthread Template and surround it like this:



<if condition="is_member_of($bbuserinfo,6)">

<!-- Inserted code goes here -->

</if>




By doing that, you are saying that that code will apply only if the User is a member of Group-ID 6 (which should be the default for Admins).

VitroX
31 Mar 2004, 14:21
This is a wonderfull hack, thanks for making.

I wonder if it is possible to show the members with color depending of the usergroup where they belongs, per example Admins in red, Mods in blue, etc.

Thanks again.

Carter876
31 Mar 2004, 22:40
Carter876, take the entire block of code that you are supposed to enter into the Showthread Template and surround it like this:



<if condition="is_member_of($bbuserinfo,6)">

<!-- Inserted code goes here -->

</if>




By doing that, you are saying that that code will apply only if the User is a member of Group-ID 6 (which should be the default for Admins).




Tnx for the help but this code don't work (i have a Parse error) :disappointed:

Someone can help me, pls?

Regards

Ocean
01 Apr 2004, 21:32
All 3 are fixed :) The invisible users part, it shows invisible users to all users to have less strain on the servers.

Hi, Gary! I finally got the chance to install the revised version. And although the problem with the Invisible Users and the Title Bar are fixed (thanks!), the third problem remains. Clicking on a Username still opens up the Profile in a new window, rather than the same one.


p.s. I'm still interested in knowing what I would need to change, if I wanted Invisible Users handled the same way it is on the Forum Home. (i.e. Only shown to those with access to see Invisible Users, suffixed with the "*" character, etc...) :) :) :)

Ocean
01 Apr 2004, 21:37
Tnx for the help but this code don't work (i have a Parse error) :disappointed:

Someone can help me, pls?

Regards

Carter876, the code does the job perfectly. I just tried it myself. Are you sure you implemented it correctly?

The code needs to be inserted into the ShowThread **Template** (NOT Showthread.php). If you put it into ShowThread.php, that would account for the Parse Error.

But in the Template, the complete code to be inserted (including the Admin-Only section) is as follows:





<if condition="is_member_of($bbuserinfo,6)">

<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center"><tbody>
<tr>
<td class="thead">
<a style="float:$stylevar[right]" href="#top" onClick="return toggle_collapse('forumhome_todayactiveusers')"><img id="collapseimg_forumhome_todayactiveusers" src="$stylevar[imgdir_button]/collapse_thead$vbcollapse[collapseimg_forumhome_todayactiveusers].gif" alt="" border="0" /></a>
$vbphrase[already_viewed_this_thread]
</td>
</tr>
</tbody>
<tbody id="collapseobj_forumhome_todayactiveusers" style="$vbcollapse[collapseobj_forumhome_todayactiveusers]">
<tr>
<td class="alt1"><div class="smallfont">
$thread[viewers]
</div></td>
</tr>
</tbody>
</table>
<br />

</if>




Also, remember that although I stated that Group-ID 6 should be the default for Admins - that doesn't mean that it's not possible for that to have changed on your system. It's worth double checking both that, as well as the syntax.

Gary King
01 Apr 2004, 22:37
Hi, Gary! I finally got the chance to install the revised version. And although the problem with the Invisible Users and the Title Bar are fixed (thanks!), the third problem remains. Clicking on a Username still opens up the Profile in a new window, rather than the same one.


p.s. I'm still interested in knowing what I would need to change, if I wanted Invisible Users handled the same way it is on the Forum Home. (i.e. Only shown to those with access to see Invisible Users, suffixed with the "*" character, etc...) :) :) :)
To open in same window, remove target="_blank"

Carter876
01 Apr 2004, 23:04
Carter876, the code does the job perfectly. I just tried it myself. Are you sure you implemented it correctly?

The code needs to be inserted into the ShowThread **Template** (NOT Showthread.php). If you put it into ShowThread.php, that would account for the Parse Error.


Ops you are right ;) , it now works perfectly :up: Tnx :D

I have another question (maybe a little bug) and a suggestion:

1.) If I close the collapsable table of "Who viewed this thread" I see my Collapsable table of "Number of Active Users" in Index that is Closed too, why!?
2.) Is there the possibility to signal how many times a user has seen that threads?

Tnx for the help! :)

Regards

Isotope
02 Apr 2004, 02:04
What needs to be changed in the code, if I want this bar to be Collapsed by default, rather than expanded?

pcalloway
04 Apr 2004, 01:07
My table heading is showing as blank rather then stating:

"Already viewed this thread:"

In the phrase manager I used "already_viewed_this_thread" as the Var name and "Already viewed this thread:" as the text. Did I goof something up?

VitroX
06 Apr 2004, 14:36
This is a wonderfull hack, thanks for making.

I wonder if it is possible to show the members with color depending of the usergroup where they belongs, per example Admins in red, Mods in blue, etc.

Thanks again.

This feature is not possible?

Njörd Eriksson
06 Apr 2004, 15:16
Great hack, Gary. Thank you. :)

Gary King
06 Apr 2004, 20:56
My table heading is showing as blank rather then stating:

"Already viewed this thread:"

In the phrase manager I used "already_viewed_this_thread" as the Var name and "Already viewed this thread:" as the text. Did I goof something up?
Did you modify the showthread template?

pcalloway
10 Apr 2004, 04:20
Did you modify the showthread template?

Yeah, right above $poll... sure did.

Gary King
10 Apr 2004, 16:47
Go to View Source and check to see if you can find: collapseobj_forumhome_todayactiveusers in it.

Ocean
15 Apr 2004, 17:33
Hi, Gary! Quick question...

For this hack, you say to put the code ABOVE this text:


// ******************************************************************************** *
//set thread last view


By doing this, we are inserting your PHP code at the end of the "Update Views Counter" Section. However, in vB 3.0.1 - this section is no longer in the same place.

In vB 3.0.1, directly above the "Set Thread Last View" section, is a comment listed: "END LINEAR / THREADED"


So, the question is:

Should we still be inserting the code above the "Set Thread Last View" section? Or should we be putting at the END of the "Update Views Counter" Section?
:)

Gary King
15 Apr 2004, 23:51
The lower the better, before the output of the postbit anyways.

So I say, put it lower if you can't put it exactly where it's supposed to be :)

Ocean
16 Apr 2004, 00:16
The lower the better, before the output of the postbit anyways.

So I say, put it lower if you can't put it exactly where it's supposed to be :)

Aha! So, in other words - your original instructions stand.

Thanks, Gary. :)

knetgummi
19 Apr 2004, 22:22
thats a reaaly good one
thank u very much
greetz
knetgummi

JagFan
19 Apr 2004, 23:05
I installed! Works great...thanks!!

weaver
25 Apr 2004, 00:27
2.) Is there the possibility to signal how many times a user has seen that threads?

I'm interested in this as well... or some way of telling when was the most recent time they viewed the thread.

welo
25 Apr 2004, 02:54
Installed. Nice little hack. Took me a minute to find the first <tbody> tag (at the end of the line), and I added

<div style="float:left">Who viewed this thread:</div>
..right before

<a style="float:$stylevar[right]" href="#top" etc>
...to clarify a bit. Might also be prudent in the SHOWTHREAD template to wrap the whole thing with a quick "if" statement to restrict viewing only to admins:

<if condition="in_array($bbuserinfo['usergroupid'], array(5, 6, 7))">
[SHOWTHREAD code goes here]
</if>

Thanks. This will come in handy.

Gary King
25 Apr 2004, 02:57
Well not everyone wants to only show this to staff :)

Also, you should use the following instead: <if condition="is_member_of($bbuserinfo, 5, 6, 7)">

welo
25 Apr 2004, 03:08
Got it. Any idea how to add how many guests have viewed the thread? That would be pretty cool too.

Ah, wait, that wouldn't work anyway. I suppose some math could be coded to subtract the number of names in the list from the number of thread views, but that would give a distorted measurement unless you install this hack on a fresh board. Was a passing thought.

Thanks again.

welo
25 Apr 2004, 04:15
Also, you should use the following instead: <if condition="is_member_of($bbuserinfo, 5, 6, 7)">
Sorry man, this code doesn't work. I was able to see it but no other usergroup could (probably because the rest of my staff are all in specially created usergroups, an dnot in the default list). My code works.

Gary King
25 Apr 2004, 15:36
Well just replace the ID no. with yours.

welo
25 Apr 2004, 17:24
That's what I did. In our case I had to use ($bbuserinfo, 6, 9, 10, 11, 17). In this case the only default usergroup is 6 (me). I could see it but nobody else on staff could (I didn't know this until someone mentioned it, so I logged in as then and confirmed). Once I switched it back to my code they could all see it fine.

Gary King
25 Apr 2004, 17:31
Then probably has to be an array.

is_member_of($bbuserinfo, array(5, 6, 7)) just try that :) The reason you should use this code instead of yours, because it checks additional groups as well.

welo
25 Apr 2004, 18:13
Sorry man. Using that code I can't even see it. Am also unclear what you mean by "...because it checks additional groups..." Checking them for what? All other groups are excluded.

Gary King
25 Apr 2004, 18:16
Check the membergroupids, not just usergroupid

welo
25 Apr 2004, 19:10
I apologize once again, because I have no idea what you just said.

Gary King
25 Apr 2004, 19:47
the is_member_of function also checks the additional usergroups for users, not just their primary usergroup

welo
25 Apr 2004, 20:19
Ah, I see what you mean. Kinda makes it too bad it doesn't work, huh? ;)

Gary King
25 Apr 2004, 20:30
It should.

Gary King
25 Apr 2004, 20:31
Check the function declaration to see that you are using it properly.

welo
25 Apr 2004, 21:01
Ok, look - I've tried applying what you gave me exactly as you stated and it doesn't work. This is especially frustrating when I started out this whole thing by posting code that does work. Since it's clear you're feeding me suggestions you aren't bothering to test, I say we stop this conversation now. Give me something that you know works or quit wasting my time by increasing your post count with useless one-sentence replies.

I hate to sound harsh or frustrated, but damn. I'm only trying to help make your hack better. Peace, out.

Intex
22 May 2004, 09:44
Nice Hack Gary W. /me clicks install.

DCX
28 May 2004, 06:37
gettin this error when i try to view a thread.....

Database error in vBulletin 3.0.1:

Invalid SQL: SELECT whoviewed FROM thread WHERE threadid = 6505
mysql error: Unknown column 'whoviewed' in 'field list'

mysql error number: 1054

Date: Friday 28th of May 2004 05:35:42 AM
Script: xxx
Referer: xxx
Username: xxx
IP Address: xxx

mtha
28 May 2004, 10:02
if (!$userinfo['invisible'] OR $showinvisible)
{
if (!empty($currentthread['whoviewed']))
{
if (!in_array($bbuserinfo['userid'], $vieweduserids))
{
$DB_site->query("UPDATE ".TABLE_PREFIX."thread SET whoviewed = CONCAT(whoviewed, \" \", \"" .$bbuserinfo['userid'] . "\") WHERE threadid = $threadid");
}
}
else
{
$DB_site->query("UPDATE ".TABLE_PREFIX."thread SET whoviewed = \"" . $bbuserinfo['userid'] . "\" WHERE threadid = $threadid");
}
}

It seems like this code will record "guest id = 0" too.
Should it check if $bbuserinfo['userid'] exist?

Njörd Eriksson
29 May 2004, 19:32
Great! I'll give it a shot tomorrow and see how it goes.


Incidentally, I only plan on certain users being able to access this feature - so I wouldn't think it would be that great a strain on the Server, for me at least.

What would I need to change, if I wanted Invisible Users handled the same way it is on the Forum Home? (i.e. Only shown to those with access to see Invisible Users, suffixed with the "*" character, etc...)

:)
Gary,

What would I have to change if I would like that members with a certain user ID or members of a certain usergroup are NOT displayed on the "Who viewed this thread?" list, even if they have viewed a certain thread?

I don't want myself listed for others.

weaver
29 May 2004, 19:54
I'm interested in this as well... or some way of telling when was the most recent time they viewed the thread.
I'm still interested in this if anyone has figured out how to do it. I'd like to be able to pinpoint if a member has read a post after additional information was posted for them. Right now I can only determine if they read the post at all. Thanks. :)

Ocean
02 Jun 2004, 15:53
I have a really great idea for a way to improve this hack.


The basis is this - it's nice to be able to see who has viewed a particular Thread. But once that Thread gets going - it becomes next to useless if you need to ask "Okay, who has viewed this Thread since Post #13 was made?"


I would recommend, for Admins only, that the functionality be added so that they can see who last viewed a given thread since a particular date and time.


This can be done in a number of ways with varying levels of functionality:




Method 1


Underneath the current "Already viewed this thread" section, a second section would be added - "Viewed this Thread since..."

This section will be updated just like the first one. However, this section will have a Reset button. When an Admin clicks on the Reset button - it clears all users from that section. The section will list the new Date/Timestamp - and will start collecting User View information from that point on.

So that it will now show, for example, "Users who have viewed this Thread since 6/2/2004 10:31pm:"

Effectively, it works like your car's Trip Odometer.


This method would (I think) only require an additional field in the database for a second set of User View data. It would get updated just like the first one - it's just that there is a Reset button in each ShowThread page that allows Admins to clear this second set of data and set a new Date/Timestamp to be shown.

I would think that this first method should be very easy to implement. But Gary would have to chime in here to confirm. :)



Method 2


Add the ability for this hack to store Date/Timestamps for each user who views any given thread. It only needs to store the Last Viewed date/time.

Then, add a second section (similar to example 1) - however, this one has an Input Box that allows you to type a date (and possibly a time) in. Then, you can refresh the page and that second section will show all users who have Viewed that Thread since the date/time you entered.


As a secondary benefit/implementation - since under this method, the date/time of Last Viewed will be stored for each user, it should be easy to make it so that by hovering your mouse over a username in the first section (the "Already viewed this thread" section), you can get a tooltip with the date and time that that user last viewed this thread.


The advantage of this method over Method #1, is that you can check for Last Viewed data retroactively.

The disadvantage, of course, is the complication of implementing this. And perhaps, a performance concern.




So, what do you guys think? Would this be useful to you? :)


Gary, do you like this idea? Is either Method practically doable?

Intex
02 Jun 2004, 15:57
I'd personnally find that very useful. I have a thread where I update the progress of certains items on the website. At the moment I have to delete the thread and re-create it, if I want to see who's viewed it again, since I last made any updates.

Option 1 is probably more work than option 2. The timestamp from my perspective would be the one to go for. It would be great if someone could implement this change.

Ocean
02 Jun 2004, 16:26
I'd personnally find that very useful. I have a thread where I update the progress of certains items on the website. At the moment I have to delete the thread and re-create it, if I want to see who's viewed it again, since I last made any updates.

Option 1 is probably more work than option 2. The timestamp from my perspective would be the one to go for. It would be great if someone could implement this change.

The original version of this hack only adds one Field ("whoviewed") to the "threads" table. It stores a list of UserIDs, and that's it.

Method 1 would only add another Field (i.e. "whoviewedsince" ), which would be handled in exactly the same manner.


If we go with Method 2, some way needs to be found to efficiently store a date/timestamp with each UserID for each thread. To my mind, that makes Method 2 more complicated to implement - although I agree that it would be the more useful option. :)

FWF
01 Jul 2004, 08:08
this should be updated for 3.0.1

FWF
05 Jul 2004, 05:06
no update i take it ?

Rocol
06 Jul 2004, 19:27
Will this hack be udated to work on vB3.0.3 please ... thanks in advance guys, keep up the excellent work ;)

Ocean
06 Jul 2004, 21:21
Will this hack be udated to work on vB3.0.3 please ... thanks in advance guys, keep up the excellent work ;)



I have this working on a 3.0.3 installation. Is there a reason why you think that it needs to be updated for 3.0.3?

mtha
06 Jul 2004, 22:36
I have this working on a 3.0.3 installation. Is there a reason why you think that it needs to be updated for 3.0.3?
:) because the hack said to work with version 3.0.0, and some people dont want to give it a shoot in other versions.

update would be adding a line, saying it works with ... some versions :D

Rocol
07 Jul 2004, 09:24
@ Ocean .. thanks for the reply, after reading that it worked for you, I checked again .. it was my bad application of the hack .. when copying I had missed off the last } .. all working fine now .. thanks ;)

Ocean
07 Jul 2004, 12:10
@ Ocean .. thanks for the reply, after reading that it worked for you, I checked again .. it was my bad application of the hack .. when copying I had missed off the last } .. all working fine now .. thanks ;)


:)

I'm glad everything's working well. :)

FWF
13 Jul 2004, 04:58
I was told this didnt work corectly for 3.0.1 ?

xmitchx
17 Jul 2004, 08:29
It works for all 3.0.x so far (tested). :)

gotvenm
20 Jul 2004, 01:27
i guess im just stoopid cause i cant get this mod to work without a parse error.

what exactly is mod'd in the showthread.php ?

I dont understand this statement in the instructions

OPEN FILE showthread.php AND FIND
// ******************************************************************************** *
//set thread last view
set_bbarray_cookie('thread_lastview', $threadid, TIMENOW);




ABOVE ADD
---------

<if condition="is_member_of($bbuserinfo,6)">

$showinvisible = 1;

// Get who has already viewed this thread
$currentthread = $DB_site->query_first("SELECT whoviewed FROM ".TABLE_PREFIX."thread WHERE threadid = $threadid");
$vieweduserids = explode(" ", $currentthread['whoviewed']);

$userinfo = fetch_userinfo($bbuserinfo['userid']);

if (!$userinfo['invisible'] OR $showinvisible)
{
if (!empty($currentthread['whoviewed']))
{
if (!in_array($bbuserinfo['userid'], $vieweduserids))
{
$DB_site->query("UPDATE ".TABLE_PREFIX."thread SET whoviewed = CONCAT(whoviewed, \" \", \"" .$bbuserinfo['userid'] . "\") WHERE threadid = $threadid");
}
}
else
{
$DB_site->query("UPDATE ".TABLE_PREFIX."thread SET whoviewed = \"" . $bbuserinfo['userid'] . "\" WHERE threadid = $threadid");
}
}

// Who has viewed this thread?
if (empty($currentthread['whoviewed']))
{
$thread['viewers'] = '('.strtolower($vbphrase['none']).')';
}
else
{
$result = $DB_site->query("SELECT userid, username FROM ".TABLE_PREFIX."user WHERE userid IN (" . implode(", ", $vieweduserids) . ")");
$viewers = array();
while ($user = $DB_site->fetch_array($result))
{
array_push($viewers, "<a target=\"_blank\" href=\"member.php?".$session['sessionurl'] . "u=".$user['userid'] . "\">" . htmlspecialchars($user['username']) . "</a>");
}
$thread['viewers'] = implode(", ", $viewers);
}
</if>


i put this in the showthread template above $poll


<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center"><tbody>
<tr>
<td class="thead">
<a style="float:$stylevar[right]" href="#top" onClick="return toggle_collapse('forumhome_todayactiveusers')"><img id="collapseimg_forumhome_todayactiveusers" src="$stylevar[imgdir_button]/collapse_thead$vbcollapse[collapseimg_forumhome_todayactiveusers].gif" alt="" border="0" /></a>
$vbphrase[already_viewed_this_thread]
</td>
</tr>
</tbody>
<tbody id="collapseobj_forumhome_todayactiveusers" style="$vbcollapse[collapseobj_forumhome_todayactiveusers]">
<tr>
<td class="alt1"><div class="smallfont">
$thread[viewers]
</div></td>
</tr>
</tbody>
</table>
<br />


thanks...

gotvenm
22 Jul 2004, 22:12
anyone using this mod ?

help ? please ?

flame
24 Aug 2004, 23:16
the reason your getting a parse error is because you have this (<if condition="is_member_of($bbuserinfo,6)">) in your .php file whereas it should be in your showthread template.

Also a small requesy ont knoe if its posible, but what aout changing the font colour for ppl wo have replied to thread theat way we can see quicly who has replied and who hasnt.

I had a look at whosposted, and the only way i can think of is to "compare" $posters against $viewers any matchs result in font change? is there such a function to compare to exlpoded lists?

Flame

Loki12
27 Aug 2004, 00:51
ADD PHRASE:
already_viewed_this_thread / Already viewed this thread:



Where does one add this phrase??? :ermm:

Ocean
30 Aug 2004, 21:41
Hi, everyone!


A while back, I posted some suggestions for improving this already excellent hack. As some time had passed, I decided to make some of those modifications myself and offer them as an enhanced version of this hack.

I have just released it earlier today. For anyone who's interested, Gary has put a link to it from the first post of this thread.


Or, here it is again: http://www.vbulletin.org/forum/showthread.php?t=68876


:)

Edric
13 Sep 2004, 12:42
I installed this about 12 hours ago on 3.0.1 but I do not get the list of Members that viewed threads (and Members did view threads for sure), the box is there for each thread but no Members are listed, any idea what am I doing wrong?

Bison
23 Dec 2004, 17:50
bump ...

Tipi
18 Jan 2005, 01:03
Installed!

Just wondering, but i got two lines with names on. The same names! It's just like i've installed the hack twice. Strange, but true. :nervous: Any idea why?

snake-boy
16 Apr 2005, 19:05
I just installed 3.0.7 and decided to switch from this hack to the enhanced version by Ocean. Sadly (just like this thread), support seems to have been abandoned.

It does work though..

-snake

lewisbeech
15 Aug 2005, 10:36
great hack! thanks a lot!

thunder_sti
11 Sep 2006, 10:52
Would this work on vbulletin v3.5.5????

Thanks