Firefox PHP

Module: User Avatar

Posted by Maurice Makaay 
Re: Module: User Avatar
November 14, 2008 05:05AM
What code should I user if I want to show the avatar in the header for an example? Is it possible? I've got it to work under my profile and when I am listing the thread with the following.

{IF PROFILE->mod_user_avatar}

{IF MESSAGES->mod_user_avatar}

What should I use if I always want to show the avatar in the header?
Re: Module: User Avatar
November 14, 2008 06:18AM
That was not an option in the User Avatar module, but I have done a quick change on the module code that should enable the use of {USER->mod_user_avatar} at any spot in the templates. I must admit that I didn't have time to test the changed code, so you are my lab rat now ;-)

Please download and install 3.0.4, go to the admin interface to reload the module information (accessing the admin.php front page should be enough for that) and try out if you can use {USER->mod_user_avatar}.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: Module: User Avatar
November 14, 2008 07:53AM
I get this error:

Fatal error: Cannot unset string offsets in /home/jblan/public_html/phorum/mods/user_avatar/user_avatar.php on line 119
Re: Module: User Avatar
November 14, 2008 08:10AM
That's what one gets from not testing the code :-)
I fixed the problem. The module should work fine now.
Redownload the now fixed 3.0.4 package.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: Module: User Avatar
November 14, 2008 08:14AM
even more :P

Fatal error: Cannot unset string offsets in /home/jblan/public_html/phorum/mods/user_avatar/cc_panel.php on line 203
Re: Module: User Avatar
November 14, 2008 08:35AM
The template data was overriding the avatar settings data for the user (same name in the data structure). Therefore, I changed the template variable names from {DATA->mod_user_avatar} to {DATA->user_avatar}. This way, you can now use {USER->user_avatar} without risking this template data from overriding the user settings. All existing variables that you had are still intact. I still fill those for backward compatibility.

Again, I repackaged the latest version. Dowload it, add {USER->user_avatar} to your template and see if it works. I quickly tested on my own system and this version did work for me.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: Module: User Avatar
November 14, 2008 09:37AM
That did the trick, thank you!

//New problem below =)

Where in the database can I find the active avatar id for the user that is logged in? I need to get the active avatar outside phorum.

I found a column "data" in ph_user_custom_fields wich contains:
P_SER:a:3:{s:10:"image_info";a:2:{i:3;a:2:{s:5:"width";i:150;s:6:"height";i:129;}i:4;a:2:{s:5:"width";i:16;s:6:"height";i:16;}}s:6:"avatar";i:4;s:22:"disable_avatar_display";b:0;}

The text marked with red is the avatars id in the ph_files table. How do i extract the number 4 from all this, I tried a little with the php function explode(); with no luck. Is there a function in phorum wich extract all this settings somehow?



Edited 1 time(s). Last edit at 11/14/2008 09:39AM by hamatzu.
Re: Module: User Avatar
November 14, 2008 09:54AM
That is a PHP serialized data, serialized using serialize()
To get the original data back, use the function unserialize()


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: Module: User Avatar
November 14, 2008 10:12AM
How do I use the functions, I don't really understan. Do you have a working example maybe?
Re: Module: User Avatar
November 14, 2008 10:19AM
Yes we have a working example.
It is called Phorum ;-)

You first need to load the field from the database. Let's say that you put that field in $data. Then you can do:

Language: PHP
$array = unserialize($data); $avatar_id = NULL; if (isset($array[';avatar';]) && $array[';avatar';] != -1) { $avatar_id = $array[';avatar';]; }

IIRC, the -1 value indicates "no avatar", so that one should not be used. I think the above code does about what you need.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Sorry, only registered users may post in this forum.

Click here to login