View Full Version : Show Thread Enhancements - Mark Threads Unread (vB4)
nerbert
10-02-2013, 10:00 PM
This product undoes thread read marking so the thread will show in New Posts in case you want to come back to it later. Open the Thread Tools menu and click the button at the bottom. Enable/disable is in General Settings.
Improved version now handles both database and cookie methods of marking threads read. The link now shows only for threads younger than the read marking limit.
Bug fixed The improved version had a bug, which I have fixed.
Installation: Import the product file in Product Manager
nerbert
10-03-2013, 03:18 AM
Reserved
ozzy47
10-03-2013, 09:01 AM
That's cool nerbert, glad you found a way to do it. :)
cellarius
10-03-2013, 10:41 AM
It should be mentioned that this only works for threads that are newer than the global new/unread cutoff. If your forum shows new threads to your users for seven days, only threads from the last seven days can be marked unread. Or did you find a way around that?
nerbert
10-03-2013, 11:24 AM
When thread is marked read the threadid, userid and read time are recorded in the data base. This product simply deletes that entry based on threadid and userid.
I haven't followed through all the code but I would assume a year old thread isn't shown in New Posts simply because search.php searches back only so far (the seven days you used for an example). So to show a thread older than seven days you would have to build a special table to store ancient threads marked unread and append that list to the New Posts search. It's doable I suppose but far more work than I want to get into.
cellarius
10-03-2013, 02:00 PM
When thread is marked read the threadid, userid and read time are recorded in the data base. This product simply deletes that entry based on threadid and userid.
That's what I derived from your code ;)
I haven't followed through all the code but I would assume a year old thread isn't shown in New Posts simply because search.php searches back only so far (the seven days you used for an example).
That's not how it works. Search.php has nothing to do with it. The markread table is pruned by a cron job. All threads that are older than the cutoff will be deleted from that table automatically. It would grow enourmously big if that would not be the case, since a value is stored for every thread for every user that reads it.
So to show a thread older than seven days you would have to build a special table to store ancient threads marked unread and append that list to the New Posts search. It's doable I suppose but far more work than I want to get into.
It's not only for the New Posts search. The unread markings are used all over the place (bolding in showthread, for example). And there are other tables (for read groups, for example).
Your addon does what is possible, and I'm sure many will find it very helpful. It's great you made it. I've looked into the system quite extensively for an addon of mine, and chances are you'll pretty soon hear requests to extend it. I had to explain the limits of the system quite a few times...
tbworld
10-03-2013, 08:04 PM
Thank you @Nerbert and @Cellarius, I looked at the code for unread markings and received a headache for the undertaking. I really appreciate your discussion on this subject.
cflyrun
10-04-2013, 04:51 PM
Even if it's only able to be marked unread for one day, that'll still do it. I have an online classroom and check the forums every day, sometimes I want to mark a thread unread to come back to in a day or so, not usually longer than that. Sweet, installing now, THANKS. Happy to donate a bit of $ as well...
DF031
10-04-2013, 05:15 PM
Hi all,
Where do I find my current "global new/unread cutoff." ?
tbworld
10-04-2013, 09:36 PM
Hi all,
Where do I find my current "global new/unread cutoff." ?
I am taking a stab at what you are asking. See if this helps:
ACP -> Options -> Settings-> General Settings --> Database Read Marking Limit
cellarius
10-05-2013, 06:20 AM
Yes, that's it. And it, of course, points to another limitation I forgot to mention: It only works with database read marking, not the other two options. (Which are pretty limited in itself). Whew, I really came to dislike that read marking system of vB...
DF031
10-05-2013, 04:07 PM
Thanks guys !
Our "Thread/Forum Read Marking Type" is set to "Database (automatic forum marking)" and "Database Read Marking Limit" to "180".
Would this mean (when the mod is installed) that when a thread has not had any replies for 181 days it can not be marked as unread ?
Are there any screen shots of this mod available ?
cellarius
10-05-2013, 04:42 PM
This is correct.
nerbert
10-05-2013, 05:27 PM
Yes, that's it. And it, of course, points to another limitation I forgot to mention: It only works with database read marking, not the other two options. (Which are pretty limited in itself). Whew, I really came to dislike that read marking system of vB...
Had a quick look at the cookie based option. It shouldn't be too hard to make that work (but you never know!). I'm busy with other matters right now, I can look into it later today.
DF031
10-05-2013, 08:11 PM
This is correct.
Thanks Cell !
Will the user still see the menu option or will it not be present when the 181day threshold has been reached ?
cellarius
10-05-2013, 08:39 PM
This would be for nerbert to answer, but as far as I read the code, yes, the option will still be present.
DF031
10-06-2013, 12:40 PM
This would be for nerbert to answer, but as far as I read the code, yes, the option will still be present.
In that case I think this great mod is not right for our forums. It will just be too confusing to our uswers.
Too bad :mad:
nerbert
10-06-2013, 01:41 PM
I'm working on having the link not show when the last thread is older than the cutoff time. It's almost ready, I just have to test it a little more. Also I have it working for the cookie option. Sorry I'm not getting at this, too many other things going on.
ozzy47
10-06-2013, 02:22 PM
I know the feeling nerbert, way to many things going on these days. :)
DF031
10-06-2013, 02:36 PM
I'm working on having the link not show when the last thread is older than the cutoff time. It's almost ready, I just have to test it a little more.
Great, looking forward to it :up:
nerbert
10-06-2013, 11:28 PM
I fixed the problem with cookie based thread marking and now the link shows only for threads younger than the marking cut off limit.
Here's a quick paste in update.
For the "Build Form and Link" Plugin:
if($vbulletin->options['enable_mark_unread'])
{
$template_hook['showthread_after_activeusers'] .= '
<form name="unmark">
<input type="hidden" name="do" value="unmark" />
<input type="hidden" name="threadid" value="' . $threadinfo['threadid'] . '" />
<input type="hidden" name="forumid" value="' . $foruminfo['forumid'] . '" />
<input type="hidden" name="userid" value="' . $vbulletin->userinfo['userid'] . '" />
<input type="hidden" name="s" value="' . $session['sessionhash'] . '" />
<input type="hidden" name="securitytoken" value="' . $vbulletin->userinfo['securitytoken'] . '" />
</form>
<script>
function vB_AJAX_Mark_Unread(form) {
this.form = form;
this.lastPost = ' . $threadinfo['lastpost'] . ';
this.cutOff = ' . (TIMENOW - ($vbulletin->options['markinglimit'] * 86400)) . ';
}
vB_AJAX_Mark_Unread.prototype.addLink = function() {
if(this.lastPost > this.cutOff) {
var unmark = document.createElement("li");
unmark.innerHTML = \'<a id="mark_unread" href="javascript:markUnread.unmark();">' . $vbphrase['mark_unread'] . '</a>\';
fetch_object("threadtools").getElementsByTagName("ul")[0].appendChild(unmark);
}
}
vB_AJAX_Mark_Unread.prototype.unmark = function() {
YAHOO.util.Connect.setForm(this.form);
YAHOO.util.Connect.asyncRequest("POST","showthread.php?do=unmark",{success:this.confirm,failure:this.confirm,timeou t:vB_Default_Timeout,scope:this});
}
vB_AJAX_Mark_Unread.prototype.confirm = function(doc) {
fetch_object("mark_unread").parentNode.innerHTML = \'<a style="background:rgb(200,50,20);color:white;">' . $vbphrase['marked_unread'] .'</a>\';
}
markUnread = new vB_AJAX_Mark_Unread(document.forms.unmark);
window.onload = function() {
markUnread.addLink();
}
</script>
';
}
For the "Delete Query" plugin:
if($vbulletin->options['enable_mark_unread'])
{
if($_REQUEST['do'] == 'unmark')
{
$vbulletin->input->clean_array_gpc('r', array(
'threadid' => TYPE_STR,
'forumid' => TYPE_STR,
'userid' => TYPE_STR
));
$threadid = intval($vbulletin->GPC['threadid']);
$forumid = intval($vbulletin->GPC['forumid']);
$userid = intval($vbulletin->GPC['userid']);
if ($vbulletin->options['threadmarking'])
{
$vbulletin->db->query_write("
DELETE FROM " . TABLE_PREFIX . "threadread
WHERE threadid = $threadid
AND userid = $userid;
");
$vbulletin->db->query_write("
DELETE FROM " . TABLE_PREFIX . "forumread
WHERE forumid = $forumid
AND userid = $userid;
");
die('done');
}
else
{
set_bbarray_cookie('thread_lastview', $threadid, 0);
}
}
}
djbaxter
10-07-2013, 12:31 PM
I fixed the problem with cookie based thread marking and now the link shows only for threads younger than the marking cut off limit.
Here's a quick paste in update.
For the "Build Form and Link" Plugin:
if($vbulletin->options['enable_mark_unread'])
{
$template_hook['showthread_after_activeusers'] .= '
<form name="unmark">
<input type="hidden" name="do" value="unmark" />
<input type="hidden" name="threadid" value="' . $threadinfo['threadid'] . '" />
<input type="hidden" name="forumid" value="' . $foruminfo['forumid'] . '" />
<input type="hidden" name="userid" value="' . $vbulletin->userinfo['userid'] . '" />
<input type="hidden" name="s" value="' . $session['sessionhash'] . '" />
<input type="hidden" name="securitytoken" value="' . $vbulletin->userinfo['securitytoken'] . '" />
</form>
<script>
function vB_AJAX_Mark_Unread(form) {
this.form = form;
this.lastPost = ' . $threadinfo['lastpost'] . ';
this.cutOff = ' . TIMENOW - ($vbulletin->options['markinglimit'] * 86400) . ';
}
vB_AJAX_Mark_Unread.prototype.addLink = function() {
if(this.lastPost > this.cutOff) {
var unmark = document.createElement("li");
unmark.innerHTML = \'<a id="mark_unread" href="javascript:markUnread.unmark();">' . $vbphrase['mark_unread'] . '</a>\';
fetch_object("threadtools").getElementsByTagName("ul")[0].appendChild(unmark);
}
}
vB_AJAX_Mark_Unread.prototype.unmark = function() {
YAHOO.util.Connect.setForm(this.form);
YAHOO.util.Connect.asyncRequest("POST","showthread.php?do=unmark",{success:this.confirm,failure:this.confirm,timeou t:vB_Default_Timeout,scope:this});
}
vB_AJAX_Mark_Unread.prototype.confirm = function(doc) {
fetch_object("mark_unread").parentNode.innerHTML = \'<a style="background:rgb(200,50,20);color:white;">' . $vbphrase['marked_unread'] .'</a>\';
}
markUnread = new vB_AJAX_Mark_Unread(document.forms.unmark);
window.onload = function() {
markUnread.addLink();
}
</script>
';
}
For the "Delete Query" plugin:
if($vbulletin->options['enable_mark_unread'])
{
if($_REQUEST['do'] == 'unmark')
{
$vbulletin->input->clean_array_gpc('r', array(
'threadid' => TYPE_STR,
'forumid' => TYPE_STR,
'userid' => TYPE_STR
));
$threadid = intval($vbulletin->GPC['threadid']);
$forumid = intval($vbulletin->GPC['forumid']);
$userid = intval($vbulletin->GPC['userid']);
if ($vbulletin->options['threadmarking'])
{
$vbulletin->db->query_write("
DELETE FROM " . TABLE_PREFIX . "threadread
WHERE threadid = $threadid
AND userid = $userid;
");
$vbulletin->db->query_write("
DELETE FROM " . TABLE_PREFIX . "forumread
WHERE forumid = $forumid
AND userid = $userid;
");
die('done');
}
else
{
set_bbarray_cookie('thread_lastview', $threadid, 0);
}
}
}
Not working correctly. It now fails to show the Mark Unread option in threads that are well within the timeframe (using database marking).
Fortunately, I didn't overwrite my saved copy of the previous version which was better, IMO.
nerbert
10-07-2013, 01:28 PM
Bug fixed. After I had tested it I tidied up the code and introduced a bug. The file is corrected and a the paste-in code in my earlier post is corrected. Sorry
tbworld
10-08-2013, 01:11 AM
Really nice @Nerbert! :)
DF031
10-12-2013, 08:19 AM
It seems there are no instructions on how to insdtall this mod. Or am I missing something ?
ozzy47
10-12-2013, 09:53 AM
Sure there is, this is in the first post:
Installation: Import the product file in Product Manager
nerbert
10-12-2013, 09:55 AM
Just upload the product xml file in the Import Product page and it's ready to go.
edgeless
04-14-2014, 06:43 PM
Will someone please take a guess on what I'm missing here or what's wrong? I've imported this mod and it installed correctly. It shows as being enabled by default in the AdminCP General Settings panel. However, when I go into a thread and click on the 'Mark Unread' menu item, it changes to a bright red highlight and the menu remains visible (i.e., it doesn't go away). The particular thread then does not appear to be marked as unread (no boldface subject text, etc). Am I missing something obvious? Thanks in advance.
tbworld
04-14-2014, 07:27 PM
Make sure you have read through the thread and you are using the database for thread marking. Check for JavaScript errors on the AJAX calls.
edgeless
04-14-2014, 08:17 PM
Thanks for the reply.
Make sure you have read through the thread and you are using the database for thread marking. Check for JavaScript errors on the AJAX calls.The threads I'm testing have been read and were recently created. I'm using the cookie thread marking option, BUT the description for this mod says:
Improved version now handles both database and cookie methods of marking threads read.Both the statement above and nerbert's dialog here lead me to believe that he coded this mod to work with the cookie thread marking option as well. So I'm confused about the behavior I'm noticing. Any ideas what's going on?
edgeless
04-14-2014, 09:45 PM
Okay, some further information here...
-There are no AJAX or other scripting errors shown in the error log relevant to my clicking the 'Mark Unread' menu item.
-Absence of intended function occurs on both of the browser's I'm using for testing: Firefox and Chrome.
-Absence of intended function occurs with either the cookie-based or the database-based thread marking option enabled.
And by the way, this is the first vB add-on I've installed that doesn't seem to work. I'd sure like to understand why it's not working because we have a real need for what it's supposed to do.
EDIT: I've just realized that when I enable 'database' thread marking, each thread listing vanishes from the list once it's been read - that didn't happen with cookie thread marking enabled. Once a thread vanishes from the list, clicking on 'Mark Unread' does indeed make the thread listing return to the list. But the listing that returns is not in boldface (as it should be to indicate that it in fact holds unread status). And the Thread Tools menu still doesn't cancel once 'Mark Unread' has been clicked upon. So are these bugs? Or are these behaviors isolated to me? It's hard to know since there aren't many comments for this add-on.
nerbert
04-14-2014, 10:39 PM
Will someone please take a guess on what I'm missing here or what's wrong? I've imported this mod and it installed correctly. It shows as being enabled by default in the AdminCP General Settings panel. However, when I go into a thread and click on the 'Mark Unread' menu item, it changes to a bright red highlight and the menu remains visible (i.e., it doesn't go away). The particular thread then does not appear to be marked as unread (no boldface subject text, etc). Am I missing something obvious? Thanks in advance.
As far as I know everything is working correctly. When you open one of the drop down menus you have to click outside the menu to close it. That's the way it is for any other link in the menu.
It's supposed to turn red shortly after you click it to indicate that the AJAX request has been processed.
I just tested it by right clicking a link on the forum display page and opening the thread on a new page, marking that thread unread and then refreshing the forum display page and the font for that thread link is bold again as it should be.
edgeless
04-14-2014, 10:49 PM
Thanks for the reply, nerbert.
Is it supposed to also make threads that have been marked as unread show in bold text within the subscribed threads list on the UserCP page?
edgeless
04-14-2014, 11:59 PM
No reply. Okay then. I felt that would be a fairly simple question to answer. Bolding the subject font for threads marked as unread within the subscribed threads list is precisely what I was hoping this mod would do - and, really, what I needed. But it's not doing that for me and no one has replied to indicate whether or not it's doing that for them. As such, it appears the answer may be that this mod simply won't do that.
It was worth a try.
cellarius
04-15-2014, 05:16 AM
No reply. Okay then.
Now really, so this nerbert guy who coded this for free does not offer 24 hours support and answers within the hour? Shame on him. :rolleyes:
edgeless
04-15-2014, 02:20 PM
cellarius: you are correct. I apologize for my impatience.
Rabso
01-05-2015, 08:47 AM
can we have this mod for VB5?
ozzy47
01-05-2015, 09:19 AM
The hook and plugin system this mod uses to do this is not available in vB5.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2024, vBulletin Solutions Inc.