Firefox PHP

Picture in Profile (beta)

Posted by pat 
pat
Picture in Profile (beta)
May 23, 2004 12:13PM
Hi,

This Code-Hack allows users to choose a picture that is shown in their profile. User has to upload picture to his/her "My Files" section and then is able to select it for display in his/her profile in by choosing it in "Edit My Profile"

Let's do the hacking:
First of all go to admin "Users/Groups"->"Custom Profiles" and add the Field Name "my_pic".

Then these files need to be modified:


1. phorum5\include\controlcenter\user.php
& phorum5\profile.php

2. phorum5\include\controlcenter\lang\your-langfile.php

3. phorum5\templates\your-template\cc_usersettings.tpl

4. phorum5\templates\your-template\cc_start.tpl
& phorum5\templates\your-template\profile.tpl



@1. add:

// generate users-file-list for pic in profile...
$files = phorum_db_get_user_file_list($PHORUM["user"]["user_id"]);
foreach($files as $key => $file) {
$files[$key]["url"]=phorum_get_url(PHORUM_FILE_URL, "file=$key");
}
//...and put it into array
$PHORUM["DATA"]["FILES"] = $files;



@2. add:

"MyPic" => "My Picture",
"NoPic" => "-No Picture-",



@3. add:
<tr>
<td nowrap="nowrap">{LANG->MyPic}:&nbsp;</td>
<td><select name="my_pic">
{LOOP FILES}
<option value="{FILES->url}">{FILES->filename}</option>
{/LOOP FILES}
<option value="">{LANG->NoPic}</option>
</select>
</td>
</tr>


@4. add:
{if PROFILE->my_pic}
<tr><td align="right" colspan="2"><img src="{PROFILE->my_pic}" alt="{LANG->MyPic}"></td></tr>
<tr><td align="right" colspan="2"><i>{LANG->MyPic}</i></td></tr>
{/if}


Only thing missing AFAIK is the check if the choosen File is really a pic as it could be a pdf, txt or whatever filetype you allow your users to upload. If anyone could add that check-routine (or any other improvement (security?)) I would be very greatful.

Thanx to Thomas for being a helpfull navigator in the code-jungle.

pat



Edited 1 time(s). Last edit at 05/27/2004 02:50PM by pat.
Re: Picture in Profile (beta)
May 23, 2004 10:38PM
What about a 80 x 80 picture that would automatically show next to a person's username in a post? Is that possible?
pat
Re: Picture in Profile (beta)
May 24, 2004 02:52PM
Hi poc,

sure is possible, but requires a bit more coding to be done.

The challange is to check uploaded files if they are pics and have the right size. If not ask user to get it right or - if you have GD-Lib installed on your server - you could even do the resizing via script.

But is that still Phorum? "Speed and Power" remember? A read page with lots of pictures is not fast anymore and is it less powerfull without them? Don't think so.

Sure enough for the roleplay stuff you guys are doing it could be a nice thing to have. Maybe Tridus has something like that in the pipline as he is doing roleplays, too (I think?).

pat

Re: Picture in Profile (beta)
May 25, 2004 10:16AM
I did something similar to this. Here's how it goes:

1) Add a custom profile field: "avatar_url" in the admin.

2) In read.tpl, add "<img src="{MESSAGES->user->avatar_url}">" wherever it makes sense for your template.

3) Users can either paste off-site URL's in their profile avatar_url, or they can upload files and copy/paste the URL's from there.

You can See an example here: [jumpspot.net]

Oh, I forgot but you can also add something like:

{IF PROFILE->avatar_url}
<tr>
    <td nowrap="nowrap" colspan="2"><img src="{PROFILE->avatar_url}"></td>
</tr>
{/IF}

to profile.tpl if you want it to show up there as well.

[jumpspot.net]

Jumpman



Edited 2 time(s). Last edit at 05/25/2004 10:31AM by Jumpman.
Re: Picture in Profile (beta)
May 26, 2004 03:22PM
I'm lost. Jumpman, please help!

How do you get the "Avatar URL:" Upload panel in
'Edit My Profile'?

[jumpspot.net]
Re: Picture in Profile (beta)
May 26, 2004 03:51PM
Mandingo, You have to edit the template

Brian - Cowboy Ninja Coder - Personal Blog - Twitter
Re: Picture in Profile (beta)
May 26, 2004 04:31PM
O.k. I worked it out, thanks!
DMa
Re: Picture in Profile (beta)
May 26, 2004 09:14PM
Hello, Brianlmoon

Help me please edit template. I'm newbie

How do you get the "Avatar URL:" Upload panel in
'Edit My Profile'?

:-(((

Please
Re: Picture in Profile (beta)
May 27, 2004 03:43AM
O.K - how about this - If someone hasn't uploaded an Avatar, there's a box with a red X in it. I want it to display nothing in the box if the person hasn't got an avatar, just their username etc...but no picture.

I think it needs something along the lines of -

{IF avatar_url false} etc....


in read.tpl


But that's as far I've got & then I'm lost...any ideas? :-)
Re: Picture in Profile (beta)
May 27, 2004 04:08AM
O.K. I got it!
Sorry, only registered users may post in this forum.

Click here to login