Go Back   vb.org Archive > vBulletin Modifications > vBulletin 4.x Modifications > vBulletin 4.x Add-ons
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Mark Threads Unread (vB4) Details »»
Mark Threads Unread (vB4)
Version: 1.1, by nerbert nerbert is offline
Developer Last Online: Aug 2017 Show Printable Version Email this Page

Category: Show Thread Enhancements - Version: 4.2.0 Rating:
Released: 10-02-2013 Last Update: 10-06-2013 Installs: 18
Uses Plugins
Re-useable Code Translations  
No support by the author.

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

Download Now

File Type: xml product-mark_unread (1).xml (4.5 KB, 72 views)

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.
2 благодарности(ей) от:
ozzy47, tbworld

Comments
  #22  
Old 10-06-2013, 11:28 PM
nerbert nerbert is offline
 
Join Date: May 2008
Posts: 784
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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:

Code:
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,timeout: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:

Code:
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);
		}
	}
}
Reply With Quote
  #23  
Old 10-07-2013, 12:31 PM
djbaxter djbaxter is offline
 
Join Date: Aug 2006
Location: Ottawa, Canada
Posts: 2,601
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by nerbert View Post
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:

Code:
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,timeout: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:

Code:
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.
Reply With Quote
  #24  
Old 10-07-2013, 01:28 PM
nerbert nerbert is offline
 
Join Date: May 2008
Posts: 784
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
Благодарность от:
djbaxter
  #25  
Old 10-08-2013, 01:11 AM
tbworld tbworld is offline
 
Join Date: Oct 2008
Posts: 2,126
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Really nice @Nerbert!
Reply With Quote
  #26  
Old 10-12-2013, 08:19 AM
DF031 DF031 is offline
 
Join Date: Nov 2012
Posts: 152
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It seems there are no instructions on how to insdtall this mod. Or am I missing something ?
Reply With Quote
  #27  
Old 10-12-2013, 09:53 AM
ozzy47's Avatar
ozzy47 ozzy47 is offline
 
Join Date: Jul 2009
Location: USA
Posts: 10,929
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Sure there is, this is in the first post:

Installation: Import the product file in Product Manager
Reply With Quote
  #28  
Old 10-12-2013, 09:55 AM
nerbert nerbert is offline
 
Join Date: May 2008
Posts: 784
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Just upload the product xml file in the Import Product page and it's ready to go.
Reply With Quote
  #29  
Old 04-14-2014, 06:43 PM
edgeless edgeless is offline
 
Join Date: Mar 2013
Posts: 115
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #30  
Old 04-14-2014, 07:27 PM
tbworld tbworld is offline
 
Join Date: Oct 2008
Posts: 2,126
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #31  
Old 04-14-2014, 08:17 PM
edgeless edgeless is offline
 
Join Date: Mar 2013
Posts: 115
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for the reply.

Quote:
Originally Posted by tbworld View Post
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:

Quote:
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?
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:28 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.08843 seconds
  • Memory Usage 2,344KB
  • Queries Executed 26 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (4)bbcode_code
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)pagenav_pagelink
  • (11)post_thanks_box
  • (3)post_thanks_box_bit
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (2)post_thanks_postbit
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (1)postbit_attachment
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_attachment
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete