Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 01-25-2013, 08:51 AM
bzcomputers's Avatar
bzcomputers bzcomputers is offline
 
Join Date: Apr 2012
Location: TX
Posts: 503
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Custom page showing profile pic, need "wildcard" reference for pic changes

I currently have a custom page showing user profile pics.

The code below is currently calling up the images without issue from the file system.

PHP Code:
$url sprintf('customprofilepics/profilepic%d_1.gif'$registration['Registration']['user_id']); 
The issue I'm going to have is, as soon as someone updates their profile pic it will no longer show because it is hardcoded currently to "1". I need to replace the "1" with a wildcard so that it will find an image no matter how many times it's updated.

I'm just not experienced enough with php to know how to place a wildcard in that statement.

Any help would be appreciated, thanks.
Reply With Quote
  #2  
Old 01-25-2013, 12:24 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I think you want profilepicrevision from the user info. So something like:
Code:
$url = sprintf('customprofilepics/profilepic%d_%d.gif', $registration['Registration']['user_id'], $userinfo['profilepicrevision']);

but I don't know if there's any $userinfo available so I'd be surprised if that worked as is.
Reply With Quote
  #3  
Old 01-25-2013, 07:29 PM
bzcomputers's Avatar
bzcomputers bzcomputers is offline
 
Join Date: Apr 2012
Location: TX
Posts: 503
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I got this to pick up the correct revision #:

PHP Code:
$url sprintf('customprofilepics/profilepic%d_%d.gif'$registration['Registration']['user_id'], $vbulletin->userinfo['profilepicrevision']); 
..but then it uses the correct revision for the first user for all the remaining users on the page. So if the first user returned is on revision 3 and the rest are still on 1 it uses 3 for all.
Reply With Quote
  #4  
Old 01-25-2013, 08:22 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yeah, $vbulletin->userinfo will always be you (or whoever's logged in). You need to get the profilepicrevision for each user in that $registration array. You could just do a query of the user table for each user, but if there's already a query being done to get that other info you might be able to add on to that (or maybe you've already got it in memory somewhere).
Reply With Quote
  #5  
Old 01-25-2013, 08:39 PM
bzcomputers's Avatar
bzcomputers bzcomputers is offline
 
Join Date: Apr 2012
Location: TX
Posts: 503
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Here is the query above it:

PHP Code:
<td>
                                <?php
                                    
if ($GLOBALS['vbulletin']->db->query_first(sprintf('SELECT dateline FROM %1$scustomprofilepic WHERE userid = %2$d'TABLE_PREFIXRollCalls::$vB_User_Id)) != null && $registration['Registration']['profile_picture'] && $registration['Registration']['user_id']) {
                                        
$url sprintf('customprofilepics/profilepic%d_1.gif'$registration['Registration']['user_id']);
                                    } else {
                                        
$url 'images/misc/unknown.gif';
                                    }

                                    echo 
$this->Html->image("{$GLOBALS['vbulletin']->options['bburl']}/{$url}");
                                
?>
                            </td>
Reply With Quote
  #6  
Old 01-25-2013, 09:19 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Maybe try this change (replaces the similar block of code from what you posted above):

Code:
if (($ppic = $GLOBALS['vbulletin']->db->query_first(sprintf('SELECT dateline, profilepicrevision FROM %1$scustomprofilepic AS customprofilepic LEFT JOIN %1$suser USING(userid) WHERE customprofilepic.userid = %2$d', TABLE_PREFIX, RollCalls::$vB_User_Id))) != null && $registration['Registration']['profile_picture'] && $registration['Registration']['user_id']) {
    $url = sprintf('customprofilepics/profilepic%d_%d.gif', $registration['Registration']['user_id'], $ppic['profilepicrevision']);
} else {
    $url = 'images/misc/unknown.gif';
}
Reply With Quote
  #7  
Old 01-25-2013, 11:27 PM
bzcomputers's Avatar
bzcomputers bzcomputers is offline
 
Join Date: Apr 2012
Location: TX
Posts: 503
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks, but that didn't do it, still trying...
Reply With Quote
  #8  
Old 01-25-2013, 11:31 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What did happen? Did you get an error, or can you see what filename it was trying to load?
Reply With Quote
  #9  
Old 01-26-2013, 05:29 AM
bzcomputers's Avatar
bzcomputers bzcomputers is offline
 
Join Date: Apr 2012
Location: TX
Posts: 503
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It was returning a "0" for all pic revisions.

Examples:
/customprofilepics/profilepic1_0.gif
/customprofilepics/profilepic48_0.gif
Reply With Quote
  #10  
Old 01-26-2013, 01:27 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Oh right - I had a close paren in the wrong place. I fixed the above code so I think it should work now.
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 01:36 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.04305 seconds
  • Memory Usage 2,268KB
  • Queries Executed 11 (?)
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)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
  • (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_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