vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=251)
-   -   Custom page showing profile pic, need "wildcard" reference for pic changes (https://vborg.vbsupport.ru/showthread.php?t=294367)

bzcomputers 01-25-2013 07:51 AM

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.

kh99 01-25-2013 11:24 AM

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.

bzcomputers 01-25-2013 06:29 PM

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.

kh99 01-25-2013 07:22 PM

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).

bzcomputers 01-25-2013 07:39 PM

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>


kh99 01-25-2013 08:19 PM

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';
}


bzcomputers 01-25-2013 10:27 PM

Thanks, but that didn't do it, still trying...

kh99 01-25-2013 10:31 PM

What did happen? Did you get an error, or can you see what filename it was trying to load?

bzcomputers 01-26-2013 04:29 AM

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

Examples:
/customprofilepics/profilepic1_0.gif
/customprofilepics/profilepic48_0.gif

kh99 01-26-2013 12:27 PM

Oh right - I had a close paren in the wrong place. I fixed the above code so I think it should work now.


All times are GMT. The time now is 07:21 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.01945 seconds
  • Memory Usage 1,742KB
  • 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
  • (2)bbcode_code_printable
  • (3)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete