Go Back   vb.org Archive > Community Discussions > Modification Requests/Questions (Unpaid)
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 04-10-2005, 07:40 PM
Shy Shy is offline
 
Join Date: Apr 2005
Posts: 16
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Preventing thread authors from increasing the view count of their own threads

I searched but couldn't find anything related here or on vbulletin.com forums.
I've decided to post here instead of possibly wasting time and be told this would require hacking and getting pointed here.

Preventing the thread view count from getting increased by the thread's starter is very useful, and I'd say fundamental to any forum. I was able to find simple mods for several other forum solutions, but not for vBulletin.
If anyone knows how to achieve this, I'd appreciate directions.
Thank you.
Reply With Quote
  #2  
Old 04-10-2005, 08:10 PM
tnguy3n's Avatar
tnguy3n tnguy3n is offline
 
Join Date: May 2003
Location: U of I, Iowa
Posts: 846
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I didn't test it out, but you can try to replace

Code:
	$DB_site->shutdown_query("
		UPDATE " . TABLE_PREFIX . "thread
		SET views = views + 1
		WHERE threadid = " . intval($threadinfo['threadid'])
	);
WITH:
Code:
	$DB_site->shutdown_query("
		UPDATE " . TABLE_PREFIX . "thread
		SET views = views + 1
		WHERE threadid = " . intval($threadinfo['threadid'])
		AND postuserid <> $bbuserinfo[userid]
	);
Reply With Quote
  #3  
Old 04-10-2005, 08:23 PM
Paul M's Avatar
Paul M Paul M is offline
 
Join Date: Sep 2004
Location: Nottingham, UK
Posts: 23,748
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It might help if you said which file this was in
Reply With Quote
  #4  
Old 04-10-2005, 08:26 PM
Shy Shy is offline
 
Join Date: Apr 2005
Posts: 16
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you tnguy3n! This addition to showthread.php seems to work fine.

edit: nope, jump 2 posts
Reply With Quote
  #5  
Old 04-10-2005, 08:33 PM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Maybe better to try to avoid the query to be run (would save a query again) by surrounding it with an if tgesting for authorid. Something like:
PHP Code:
if ($threadinfo['postuserid'] != $bbuserinfo['userid'])
{
run query

Reply With Quote
  #6  
Old 04-10-2005, 08:35 PM
Shy Shy is offline
 
Join Date: Apr 2005
Posts: 16
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

sorry, i was wrong. in fact, it's not working properly, view count is not increased by anyone.
(i enabled instant view updating in cp)

edited: post=view*
Reply With Quote
  #7  
Old 04-10-2005, 08:59 PM
007's Avatar
007 007 is offline
 
Join Date: Jan 2003
Location: United States
Posts: 872
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I released a hack for this for VB2. Feel free to look at that for reference.
Reply With Quote
  #8  
Old 04-11-2005, 01:06 PM
Shy Shy is offline
 
Join Date: Apr 2005
Posts: 16
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Since I have little knowledge of PHP and how the forum's script works (plus I do need guest views to count), I hope someone could create this type of solution for vBulletin 3.
I'm surprised that it's not a widely requested feature. It's quite popular with other forums.
Reply With Quote
  #9  
Old 04-11-2005, 01:30 PM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Shy
Since I have little knowledge of PHP and how the forum's script works (plus I do need guest views to count), I hope someone could create this type of solution for vBulletin 3.
I'm surprised that it's not a widely requested feature. It's quite popular with other forums.
Well it really should work. Try the following edit to your showthread.php:

Find:
PHP Code:
if ($vboptions['threadviewslive'])
{
 
// doing it as they happen
 
$DB_site->shutdown_query("
  UPDATE " 
TABLE_PREFIX "thread
  SET views = views + 1
  WHERE threadid = " 
intval($threadinfo['threadid'])
 );
}
else
{
 
// or doing it once an hour
 
$DB_site->shutdown_query("
  INSERT INTO " 
TABLE_PREFIX "threadviews (threadid)
  VALUES (" 
intval($threadinfo['threadid']) . ')'
 
);

And replace by:
PHP Code:
// Ignore views by thread starter
if ($threadinfo[postuserid] != $bbuserinfo[userid])
{
 if (
$vboptions['threadviewslive'])
 {
  
// doing it as they happen
  
$DB_site->shutdown_query("
   UPDATE " 
TABLE_PREFIX "thread
   SET views = views + 1
   WHERE threadid = " 
intval($threadinfo['threadid'])
  );
 }
 else
 {
  
// or doing it once an hour
  
$DB_site->shutdown_query("
   INSERT INTO " 
TABLE_PREFIX "threadviews (threadid)
   VALUES (" 
intval($threadinfo['threadid']) . ')'
  
);
 }
}
// End: Ignore views by thread starter 
Reply With Quote
  #10  
Old 04-11-2005, 02:37 PM
Shy Shy is offline
 
Join Date: Apr 2005
Posts: 16
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

MarcoH64: Yes, this (really) works properly. Thanks!

However, queries jumped from 8 to 13.
Can someone modify it to be more query friendly?
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 12:10 AM.


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.09863 seconds
  • Memory Usage 2,263KB
  • Queries Executed 13 (?)
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
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_code
  • (3)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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_postinfo_query
  • fetch_postinfo
  • 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
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete