vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   If statement depending if user is thread starter (https://vborg.vbsupport.ru/showthread.php?t=254306)

patt1293 11-27-2010 05:56 AM

If statement depending if user is thread starter
 
What i am attempting to do is make it so i can change a bit of text depnding if the user in question was the original poster of the thread.

I am doing this in cyb advanced forum statistics i have edited it and want it to change if the post in latest posts was created by the user it should say {username} posted in {forumname} but if they are not the thread creator it should read {username} replied in {forumname}

I've gotten everything except the text change i was thinking an if statement should be used but for the life of me i cant figure out how to do it. Can anyone advise how to get this working?

kh99 11-27-2010 09:34 AM

I'm not sure I'm following - are any of the users you mention the logged in user (the user viewing the stats), or do you just want to compare the thread creator with the user who made the latest post in that thread?

patt1293 11-28-2010 02:47 AM

yes they are all logged in users, i just want it to check and if they are the thread creator it will say the posted in that forum otherwise it would say they replied in that forum

kh99 11-28-2010 06:13 AM

I'm sorry I guess I didn't ask that right. In your first post, the first sentence refers to "the user in question" - which user is that exactly? Is it the "current" user who is viewing the stats, or the user who wrote the "latest post"? And is that the same as "the user" in the second sentence?

Sorry, maybe I'm being stupid or something.

patt1293 11-28-2010 06:43 PM

It would be the user that wrote the latest post. all im trying to do is change "replied in" to "posted in" if that user is post number 1 in that preticular thread. hope thats worded better.

kh99 11-29-2010 12:48 AM

OK, well hopefully I get it now. I think the problem is that when the plugin reads the latest post info from the db it doesn't get enough info to do what you want. But if you're willing to edit the plugin you can add it pretty easily. The plugin is "Cyb - Advanced Forum Statistics - FH", and you want to find this section (pretty near the top)

Code:

$get_stats_newposts = $vbulletin->db->query_read("
        SELECT thread.threadid, thread.title, thread.lastpost,
                            thread.lastpostid, thread.forumid, thread.lastposter,
                            thread.dateline, thread.views, thread.replycount, thread.visible,
                            thread.open, thread.prefixid, user.username, user.userid,
                            user.usergroupid, user.displaygroupid
        FROM " . TABLE_PREFIX . "thread AS thread
        LEFT JOIN " . TABLE_PREFIX . "user AS user ON (user.username = thread.lastposter)


then add ", thread.postuserid" to the end of the list of fields, so it looks like this (you have to scroll right to see what I added):
Code:

$get_stats_newposts = $vbulletin->db->query_read("
        SELECT thread.threadid, thread.title, thread.lastpost,
                            thread.lastpostid, thread.forumid, thread.lastposter,
                            thread.dateline, thread.views, thread.replycount, thread.visible,
                            thread.open, thread.prefixid, user.username, user.userid,
                            user.usergroupid, user.displaygroupid, thread.postuserid       
                FROM " . TABLE_PREFIX . "thread AS thread
        LEFT JOIN " . TABLE_PREFIX . "user AS user ON (user.username = thread.lastposter)


Then, I assume you're editing the template cyb_topstats_newposts, you should be able to use this condition:
Code:

<if condition="$get_new_posts[postuserid] == $get_new_posts[userid]">
// user started thread
<else />
// user didn't start thread
</if>


patt1293 11-29-2010 03:01 AM

Thank you, that worked like a charm it was actually in "Cyb - Advanced Forum Statistics - MN" but i bow down to you.


All times are GMT. The time now is 03:55 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01029 seconds
  • Memory Usage 1,727KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete