Sponsored Content
Top Forums Web Development Tapatalk Modification for vB3 - Issue with Avatar Icons Post 302884173 by Neo on Saturday 18th of January 2014 05:51:23 AM
Old 01-18-2014
Tapatalk Modification for vB3 - Issue with Avatar Icons

This post will be soon moved to the "Web Application" forum so our Tapatalk developer friends can follow an unresolved issue with regard to how the Tapatalk app fetches can caches avatar icons.

We start this process by creating a hook in the vB 3.8 tapatalk file get_online_users.php

PHP Code:
($hook vBulletinHook::fetch_hook('neo_tapatalk_online_bits')) ? eval($hook) : false
in the location within the file here:

PHP Code:
$from 'browser';

if(isset(
$loggedin['useragent']))
      {
            
$userAgent $loggedin['useragent'];
             
             if(
strpos($userAgent,'Android') !== false || strpos($userAgent,'iPhone') !== false ||  strpos($userAgent,'BlackBerry') !== false)
             
$from 'mobile';
             if(
strpos($userAgent,'Tapatalk') !== false)
                    
$from 'tapatalk';
              if(
strpos($userAgent,'BYO') !== false)
                    
$from 'byo';            
      }


$username mobiquo_encode($loggedin['musername']) ? mobiquo_encode($loggedin['musername']) : mobiquo_encode($loggedin['username']);

(
$hook vBulletinHook::fetch_hook('neo_tapatalk_online_bits')) ? eval($hook) : false
and the hook code simply takes the $from variable and adds a small bit of text to the $display_text that is displayed in the TT "People" page:

PHP Code:
 if($from == 'tapatalk'
       { 
             if(empty(
$userinfo['avatarurl'])) 
                    
$userinfo['avatarurl'] = 'customavatars/avatar46598_1.gif';  // testing this line
                    
$display_text $display_text mobiquo_encode(' ...  (using Tapatalk)'); 
        } 
else if(
$vbulletin->userinfo['styleid'] == '137'
        { 
                  
$display_text $display_text mobiquo_encode(' ... (using Mobile Skin)'); 
        } 
else if(
$from == 'mobile'
        { 
                  
$display_text $display_text mobiquo_encode(' ... (using Mobile No Skin)'); 
        } 
Image

This code works as expected, and in the screen shot above; we can see two online TT users.

(Note: There is also one "special system bot" user we created that is used to display system information to mods, but I will not describe that code in this post; it is discussed in this post).

Because this works so easily, I then decided to add icons for all users who do not have icons already (because they did not upload a custom avatar). We will do this for the. I created many different hooks and experimented in many different places (because there is an issue with the icons, as they are fetched and cached in the TT app)

Currently, I am using the vB 3 file: functions_user.php

and the hook is:

PHP Code:
// final case: didn't get an avatar, so use the fake one
if (empty($userinfo['avatarurl']) AND $returnfakeavatar)  // we never use this fake one, only the hook code below
     
{
                
$userinfo['avatarurl'] = $stylevar['imgdir_misc'] . '/unknown.gif';
      }

(
$hook vBulletinHook::fetch_hook('neo_vbulletin_fetch_avatar_from_userinfo')) ? eval($hook) : false
and the hook code we are testing is quite simple:

PHP Code:
if($userinfo['avatarurl'] == ''

$agent $location;   // for testing purposes
   
if($userinfo['usergroupid'] == '10')   
     
$userinfo['avatarurl'] = 'customavatars/avatar302016126_2.gif';   
else if(
$userinfo['usergroupid'] == '5')   
     
$userinfo['avatarurl'] =  'customavatars/avatar302016126_2.gif';   
else if(
$userinfo['usergroupid'] == '13')   
    
$userinfo['avatarurl'] = 'customavatars/avatar34166_2.gif';   
else if(
$userinfo['usergroupid'] == '11')   
    
$userinfo['avatarurl'] = 'customavatars/avatar44786_2.gif';   
else if(
$userinfo['usergroupid'] == '3')   
    
$userinfo['avatarurl'] = 'customavatars/avatar302052812_2.gif'
else   
   {   
     if(
$agent == 'tapatalk')   
        {   
         
$userinfo['avatarurl'] = 'customavatars/avatar46598_1.gif';   
        }   
     else if(
$agent == 'browser')   
        {   
         
$userinfo['avatarurl'] = 'customavatars/avatar302087525_1.gif';   
        }   
       else if(
$agent == 'mobile')   
        {   
         
$userinfo['avatarurl'] = 'customavatars/avatar302051592_2.gif';   
        }   
       else  
        {   
         
$userinfo['avatarurl'] = 'customavatars/avatar302087525_1.gif';   
        }   

    }   

// our simple logging code for debugging
if(1)  
{  
     
$log '/var/log/apache2/neo_fetch_avatar_from_userinfo';  
     
//$stuff = print_r($userinfo,TRUE);  
     
error_log(date(DATE_RFC822).' '.$userinfo['usergroupid'].'  '$_SERVER['REMOTE_ADDR']. 
'  '$userinfo['username'] .' URL  '.$userinfo['avatarurl'] .' From: '.$agent."\n"3$log);

OBTW, I also modify the function (used above) to send it the required $location parameter:

PHP Code:
function fetch_avatar_from_userinfo(&$userinfo$thumb false$returnfakeavatar true,$location''


This code basically says, fetch the avatar from the userinfo with an addition location parameter, and if there is no user avatar, replace with our custom avatar, one for various user groups, and if the user is not a member of any of those groups, show a default "UX" avatar, but if their location is "Using Tapatalk" then show a different TT icon.

Unfortunately, this does not work. You can see in the image above, two users are online via TT and the status message is correct, but the icon is not correct. We see the default "UX" icon and not the "TT" icon.

Also, FYI:

Code:
fetch_avatar_from_userinfo()

is called from the TT include file common.php

which is located in our modified function (with our optional agent param):

Code:
function mobiquo_get_user_icon($userid,$agent = '')

which contains this code:


PHP Code:
$icon_url "";
if(
$vbulletin->options['avatarenabled']){
     
fetch_avatar_from_userinfo($userinfo,true,false,$agent);

     if(
$userinfo[avatarurl]){
            
$icon_url get_icon_real_url($userinfo['avatarurl']);
     } else {
           
$icon_url '';   // this should never happen because we add default icons in the  fetch_avatar_from_userinfo() function
     
}

I have tried placing the hooks in various locations, clearing the cache, restarting the app on the mobile phone, even restarting the phone. The logging info always shows that the icons are set correct by the code; but they do not display correctly.

So, I have concluded this is a pre-fetching or caching bug in the TT app that causes the avatar icons not to display properly. In this same screenshot, the icons are wrong for the two logged in TT users:

Image
 

7 More Discussions You Might Find Interesting

1. Post Here to Contact Site Administrators and Moderators

avatar

where can i upload an image for avatar (3 Replies)
Discussion started by: royal
3 Replies

2. News, Links, Events and Announcements

Similar Threads - a new vB3 feature for UNIX.COM

Note the new feature on UNIX.COM, many thread at the bottom of the page have a new feature: Similiar Threads Here is an example on one of Perderabo's posts: https://www.unix.com/showthread.php?t=16337 Kudos to the vB folks for this built-in feature!! Neo (0 Replies)
Discussion started by: Neo
0 Replies

3. Post Here to Contact Site Administrators and Moderators

Avatar problem

Hi, I wanted to change my avatar, but I get the message You may not upload animated images. How come that this user has one? https://www.unix.com/members/3394.html https://www.unix.com/avatars/perderabo.gif All users are equal, but some are more equal than other? Thanks. (0 Replies)
Discussion started by: Ebbi
0 Replies

4. What is on Your Mind?

How to get an avatar to work?

I have uploaded a small image, 64x64 and about 5k in size, that was about a week ago, I still do not see my image when I post, or maybe I just can't see it and others can? It helps me scroll through threads and find my own posts easier, but on this forum it either doesn't show up for me or is just... (1 Reply)
Discussion started by: raidzero
1 Replies

5. What is on Your Mind?

Member Reviews of the Movie: Avatar

Please comment and vote only if you saw the movie. What did you think? (13 Replies)
Discussion started by: Neo
13 Replies

6. Web Development

Tapatalk Modification for vB3 - Adding User for System Information

Referring back to this thread: Tapatalk Modification for vB3 - Issue with Avatar Icons I mentioned that we had some "system bot" code: In this post, I describe that code and how easy it is to create a "system bot" user for Tapatalk (TT): Basically, its quite easy. We add a hook to... (0 Replies)
Discussion started by: Neo
0 Replies

7. Web Development

Tapatalk - More Frustrations with Icons, Versions and User Agent String

My frustration with Tapatalk continues. After reinstalling TT for the forums, I'm trying to tweet it so we can get a lot of benefit for forum members. TT has both a free version and a "Pro" version (which we pay for). I paid for the "Pro" version, and the first thing I noticed was that the app... (3 Replies)
Discussion started by: Neo
3 Replies
All times are GMT -4. The time now is 07:19 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy