Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #11  
Old 08-27-2010, 07:06 PM
DataHero DataHero is offline
 
Join Date: Jun 2009
Location: NL
Posts: 140
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Alright, I looked at showgroups.php once more and tried to figure out what the vital parts of the query would be. I came up with this:
Code:
$showgroups = $db->query_read("
SELECT
	user.*, userfield.*, usertextfield.*,
		" . iif($vbulletin->options['avatarenabled'], 'avatar.avatarpath, NOT ISNULL(customavatar.userid) AS hascustomavatar, customavatar.dateline AS avatardateline,customavatar.width AS avwidth,customavatar.height AS avheight,') . "
		postparsed.pagetext_html, postparsed.hasimages,
		$hook_showgroups_complete
	LEFT JOIN " . TABLE_PREFIX . "usertextfield AS usertextfield ON(usertextfield.userid = user.userid)
		" . iif($vbulletin->options['avatarenabled'], "LEFT JOIN " . TABLE_PREFIX . "avatar AS avatar ON(avatar.avatarid = user.avatarid) LEFT JOIN " . TABLE_PREFIX . "customavatar AS customavatar ON(customavatar.userid = user.userid)") . "
");
I've added that to the plug-in text-area thing, set the hook to showgroups_complete and also added this in the field:
HTML Code:
if ($this->post['avatarid'])
	{
		$this->post['avatarurl'] = $this->post['avatarpath'];
	}
else
	{
		if ($this->post['hascustomavatar'] AND $this->registry->options['avatarenabled'])
		{
			if ($this->registry->options['usefileavatar'])
			{
				$this->post['avatarurl'] = $this->registry->options['avatarurl'] . '/avatar' . $this->post['userid'] . '_' . $this->post['avatarrevision'] . '.gif';
			}
			else
			{
				$this->post['avatarurl'] = 'image.php?' . $this->registry->session->vars['sessionurl'] . 'u=' . $this->post['userid'] . '&dateline=' . $this->post['avatardateline'];
			}
			if ($this->post['avwidth'] AND $this->post['avheight'])
			{
				$this->post['avwidth'] = 'width="' . $this->post['avwidth'] . '"';
				$this->post['avheight'] = 'height="' . $this->post['avheight'] . '"';
			}
			else
			{
				$this->post['avwidth'] = '';
				$this->post['avheight'] = '';
			}
		}
		else
		{
			$this->post['avatarurl'] = '';
		}
	}

	if ( // no avatar defined for this user
			empty($this->post['avatarurl'])
			OR // visitor doesn't want to see avatars
			($this->registry->userinfo['userid'] > 0 AND !$this->registry->userinfo['showavatars'])
			OR // user has a custom avatar but no permission to display it
			(!$this->post['avatarid'] AND !($this->cache['perms'][$this->post['userid']]['genericpermissions'] & $this->registry->bf_ugp_genericpermissions['canuseavatar']) AND !$this->post['adminavatar']) //
		)
	{
		$show['avatar'] = false;
	}
	else
	{
		$show['avatar'] = true;
	}
Is this any better or close to what I should do?
Reply With Quote
  #12  
Old 08-27-2010, 08:17 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yes, that is much closer. I haven't actually read the code line for line, but it looks more like what I am used to seeing when an avatar is included.
Reply With Quote
  #13  
Old 08-28-2010, 12:37 AM
DataHero DataHero is offline
 
Join Date: Jun 2009
Location: NL
Posts: 140
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Seems I keep getting an SQL error, but I don't know where it's coming from.

This is the query_read (or something, I'm a novice with SQL; used this query part from showthread.php (changed $posts to $show['avatar'])):

Code:
$show['avatar'] = $db->query_read(" 
        SELECT 
            user.*, userfield.*, usertextfield.*, 
            " . iif($vbulletin->options['avatarenabled'], 'avatar.avatarpath, NOT ISNULL(customavatar.userid) AS hascustomavatar, customavatar.dateline AS avatardateline,customavatar.width AS avwidth,customavatar.height AS avheight,') . " 
            $hook_query_fields 
        LEFT JOIN " . TABLE_PREFIX . "user AS user ON(user.userid = post.userid) 
        LEFT JOIN " . TABLE_PREFIX . "userfield AS userfield ON(userfield.userid = user.userid) 
        LEFT JOIN " . TABLE_PREFIX . "usertextfield AS usertextfield ON(usertextfield.userid = user.userid) 
            " . iif($vbulletin->options['avatarenabled'], "LEFT JOIN " . TABLE_PREFIX . "avatar AS avatar ON(avatar.avatarid = user.avatarid) LEFT JOIN " . TABLE_PREFIX . "customavatar AS customavatar ON(customavatar.userid = user.userid)") . " 
            $hook_query_joins 
");
Reply With Quote
  #14  
Old 08-28-2010, 02:00 AM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

A query is not just the query_read part. You then just get left with pointers and have to get that data out of there by doing something like a fetch_array. *Then* you end up with variables you can do something with (you can see that in the showthread.php page).
Reply With Quote
  #15  
Old 08-29-2010, 05:27 AM
DataHero DataHero is offline
 
Join Date: Jun 2009
Location: NL
Posts: 140
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Okay, I see the part where it's being fetched (if I am right), which starts at:
PHP Code:
while ($post $db->fetch_array($posts)) { etc 
And then I have the bit where $posts is defined. So basically, I'll have to adjust the query of $posts accordingly (and rename the defined variable), and then make a similar while for the newly defined variable?

Also, after having this done, should I pretty much edit the showgroups.php page to include the defined $show['avatar'] from the class_postbit.php?

And as a last thing: should the case be that I have to adjust the query accordingly, what would be the best way to know which table (or whatever it is?) should be selected/called/queried?
Reply With Quote
  #16  
Old 08-29-2010, 02:05 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If you already have a query in the showgroups page that then goes through a while loop like we are talking about, most likely, you just want to combine the two queries into one query and do everything at once. Is that what you are doing right now?
Reply With Quote
  #17  
Old 08-29-2010, 08:12 PM
DataHero DataHero is offline
 
Join Date: Jun 2009
Location: NL
Posts: 140
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm not quite certain whether or not I understood it correctly. Is showgroups.php supposed to have a query related to that already (seeing how you have referred to 'two queries into one')?

And no, I haven't edited the showgroups.php itself yet. I wanted to be certain how I should go on about this before messing up everything.

My idea (my last post) was to basically copy the $show['avatar'] bit and put it in showgroups.php as well, so it's defined (which I could then use as a variable in the showgroups template). The same goes for the query from class_postbit.php. Or am I understanding this completely wrong?
Reply With Quote
  #18  
Old 08-29-2010, 10:30 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I assumed from your first post that you were going to be showing the avatars for the users in the groups on the showgroups page. If so, there is already a query to grab the users in each group, so you would then want to add the extra stuff to select to that query, I would think.
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 11:46 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.04530 seconds
  • Memory Usage 2,259KB
  • Queries Executed 12 (?)
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
  • (1)bbcode_html
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (8)post_thanks_box
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (8)post_thanks_postbit_info
  • (8)postbit
  • (8)postbit_onlinestatus
  • (8)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
  • 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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete