forum.coppermine-gallery.net

Support => cpg1.4.x Support => Older/other versions => cpg1.4 modpack by Stramm => Topic started by: obitsu on September 07, 2007, 06:49:27 am

Title: Getting Member Avatars to be Displayed in index.php ?
Post by: obitsu on September 07, 2007, 06:49:27 am
Hello!

I recently started using Coppermine and am really liking it. I installed the modpack to enable use of avatars, and so far, I've gotten them working on the comments, profile page, etc., but I was also wanting to have it shown on the front page (index.php) after the registered user logs in, so they see their name and their avatar.

How do I do this code-wise? ???

I'm a novice when it comes to PHP scripting, especially anything beyond simple theme modifications. My theme is based off of the "hardwired" coppermine theme if that helps any.

Thanks for any tips!
Title: Re: Getting Member Avatars to be Displayed in index.php ?
Post by: Stramm on September 17, 2007, 10:03:55 pm
Same has been asked here
http://forum.coppermine-gallery.net/index.php?topic=46865.0

Probably I'll post a code sample when I have some time again
Title: Re: Getting Member Avatars to be Displayed in index.php ?
Post by: Farnsi on September 18, 2007, 12:07:49 am
that would be awesome! It is a really cool idea.
I searched a little bit for the things you said in the other thread but i am too "php-dumb" for that.  ::)
perhaps i'll have another try tomorrow, when i'm not that tired..
Title: Re: Getting Member Avatars to be Displayed in index.php ?
Post by: flowmo on September 18, 2007, 06:01:16 am
I'm currently working on this myself and will have something in a week.. my sites new design is totally dependent upon this feature so if I can't figure out a solution, I will pay someone to do this within a week, so check back for a solution..

I am bridge with phpbb and thats where my avatars come from, so my current ideas are:

-Re-write stramms call for the avatar as done for comments (though the code is rather confusing to me, and I'm not sure how it would be rewritten for using the logged users id as opposed to the comment author, as it pulls avatar by comment author and not user id)
-Query phpbb tables for avatar URL
-Use phpbb fetch all to get avatar - CPU killing method...

If I don't come up with something within the next 2 days I'll pay someone on DP to re-write stramms code for the avatar and post it here.. unless someone here wants to do it for compensation (sorry if that is not allowed)  :P
Title: Re: Getting Member Avatars to be Displayed in index.php ?
Post by: Stramm on September 18, 2007, 06:39:39 pm
paste following code into the theme.php you're using right before the final ?>

Code: [Select]
function loginForm($logged=1) {

global $CONFIG, $lang_loginform, $REFERER;

//if (!$CONFIG['enable_loginform']) return $loginFormHtml = "";

if (!USER_ID && $CONFIG['enable_loginform']) {
  $loginFormHtml = <<<EOT
<ins>
    <form action="login.php?referer=$REFERER" method="post" name="loginbox" style="margin:0; padding:0;">
        <table cellpadding="0" cellspacing="3" border="0">
        <tr>
            <td><input type="text" class="textinput" name="username" size="10" /></td>
            <td><input type="password" class="textinput" name="password" size="10" /></td>
            <td><input name="submitted" type="submit" value="Login" />
            <input name="remember_me" type="hidden" class="checkbox" value="1" checked="checked" /></td>
        </tr>
        <tr>
        <td class="smallfont">$lang_loginform[user]</td>
        <td class="smallfont">$lang_loginform[pass]</td>
        <td></td>
</tr>
        </table>
        </form>
</ins>
EOT;
}

if (USER_ID) {

if ($CONFIG['enable_avatar']) {
if (AVATAR_URL !="") $avatar_url = "<a href='profile.php?op=edit_profile'><img src='".AVATAR_PATH.AVATAR_URL."' class=\"image\"></a>";
else $avatar_url="&nbsp;";
    $edit_profile_form_param[] = array('textplain', $avatar_url, $lang_register_php['manage_avatar']);

if (isset($_GET['uid'])) {
$user_data = $cpg_udb->get_user_infos($_GET['uid']);
$avatar_url = $user_data['avatar_url'];
if ($avatar_url !="") $avatar_url = "<img src='".AVATAR_PATH.$avatar_url."' class=\"image\">";
}
$loginFormHtml = "<span style=\"float: right\">".$avatar_url."</span>";
} else $loginFormHtml = NULL;

$loginFormHtml .= "<div align=\"right\" class=\"smallfont\">".$lang_loginform['welcome']." <strong>".(USER_NAME)."&nbsp;</strong><br />";


if ($CONFIG['display_pms_status']){
$result = cpg_db_query("SELECT count(*) FROM  {$CONFIG['TABLE_PMS']} WHERE owner=".(USER_ID));
list($tot_all_messages) = @mysql_fetch_array($result);
mysql_free_result($result);
$result = cpg_db_query("SELECT count(*) FROM  {$CONFIG['TABLE_PMS']} WHERE owner=".(USER_ID)." AND showed='0'");
list($tot_new_messages) = @mysql_fetch_array($result);
mysql_free_result($result);

if ($CONFIG['pms_enabled']) {
$loginFormHtml .= "<a href='pms.php'>".$lang_loginform['pms']."</a> ".$tot_new_messages.$lang_loginform['unread_total'].$tot_all_messages."&nbsp;</div>";
}
}

if ($CONFIG['display_buddy_status']){
// get some buddy data
$result = cpg_db_query("SELECT count(*) FROM  {$CONFIG['TABLE_BUDDY']} WHERE user_id=".(USER_ID));
list($tot_all_buddies) = @mysql_fetch_array($result);
mysql_free_result($result);
$result = cpg_db_query("SELECT count(*) FROM  {$CONFIG['TABLE_BUDDY_REQ']} WHERE buddy_to=".(USER_ID));
list($tot_new_buddies) = @mysql_fetch_array($result);
mysql_free_result($result);

if ($CONFIG['enable_buddy']){
$loginFormHtml .= "<div align=\"right\" class=\"smallfont\"><a href='buddy_manage.php'>".$lang_loginform['friends'].":</a> ".$tot_new_buddies." ".$lang_loginform['request'].", ".$lang_loginform['active']." ".$tot_all_buddies."&nbsp;</div>";
}
}

}
  return $loginFormHtml;
}
Title: Re: Getting Member Avatars to be Displayed in index.php ?
Post by: flowmo on September 18, 2007, 09:10:37 pm
stramm send me a paypal id you just saved me a lot of time
Title: Re: Getting Member Avatars to be Displayed in index.php ?
Post by: Joachim Müller on September 19, 2007, 08:31:27 am
We need your help (http://forum.coppermine-gallery.net/index.php?topic=14227.0) *wink*
Title: Re: Getting Member Avatars to be Displayed in index.php ?
Post by: flowmo on September 21, 2007, 06:50:39 am
We need your help (http://forum.coppermine-gallery.net/index.php?topic=14227.0) *wink*

Man trust me, I'd be the first to donate to you guys if you took donations..

And I would definitely sponsor a cache mod ;-).. though it looks impossible..

From now on though, I'll keep track of modifications I make to coppermine and post them here

Sorry to hijack
Title: Re: Getting Member Avatars to be Displayed in index.php ?
Post by: lobosden on September 27, 2007, 11:04:54 pm
O.K. I did this and all was good until you clicked on someones name to see their profile and it gave a error trying to send it to theme.php

???
Title: Re: Getting Member Avatars to be Displayed in index.php ?
Post by: Stramm on September 27, 2007, 11:12:44 pm
post a link and describe what you did
Title: Re: Getting Member Avatars to be Displayed in index.php ?
Post by: lobosden on September 27, 2007, 11:16:09 pm
well I took it down but I will put it up again real quick...lol

www.bodyarttalk.com
Title: Re: Getting Member Avatars to be Displayed in index.php ?
Post by: lobosden on September 27, 2007, 11:17:04 pm
I posted the below code before the final ?> SO THE AVATAR will show.
Title: Re: Getting Member Avatars to be Displayed in index.php ?
Post by: lobosden on September 27, 2007, 11:20:44 pm
Yea its back up now.... I see my avatar next to the messages.

But if I click on someones name to see thier profile It errors out.
Title: Re: Getting Member Avatars to be Displayed in index.php ?
Post by: Stramm on September 27, 2007, 11:23:10 pm
hmm.. a testuser account would be helpful ;)
Title: Re: Getting Member Avatars to be Displayed in index.php ?
Post by: lobosden on September 27, 2007, 11:27:57 pm
sorry I had one and deleted it had to remake it

test
test123
Title: Re: Getting Member Avatars to be Displayed in index.php ?
Post by: Stramm on September 27, 2007, 11:41:16 pm
your problem is that the profile doesn't display anymore when this avatar feature is in the theme.php?

hmmm, seems to be some incompatibility in either theme.php, template.html or even mods in profile.php ... can't tell you 100% cause I do not know your changes

at least I can tell you that profile.php shows either some frameset code or some javascript that's not part of coppermine

have you tried to add the code to the classic theme.php and try that?
Title: Re: Getting Member Avatars to be Displayed in index.php ?
Post by: lobosden on September 27, 2007, 11:44:25 pm
Yea, it works there, just the roll over is too confusing, people in my industry aren't very computer literate lol.

So I use this one and it's "KEWL" you know and user friendly. I will just take it out, all it does is post your ava at the top.

Is there away to maybe put users avatars that are online in the anycontent?
Title: Re: Getting Member Avatars to be Displayed in index.php ?
Post by: Stramm on September 27, 2007, 11:49:32 pm
possible, there's already a similar thread open that asks for that... maybe I have time to bring up a quick hack soon

Title: Re: Getting Member Avatars to be Displayed in index.php ?
Post by: lobosden on September 27, 2007, 11:54:31 pm
I'm sure I will be needing that paypal button from you before I am threw lol.
 ;)
Title: Re: Getting Member Avatars to be Displayed in index.php ?
Post by: Stramm on September 28, 2007, 01:00:31 pm
http://forum.coppermine-gallery.net/index.php?topic=46865.msg225401#msg225401
Title: Re: Getting Member Avatars to be Displayed in index.php ?
Post by: dumbo on March 20, 2008, 10:09:04 am
paste following code into the theme.php you're using right before the final ?>

Code: [Select]
function loginForm($logged=1) {

global $CONFIG, $lang_loginform, $REFERER;

//if (!$CONFIG['enable_loginform']) return $loginFormHtml = "";

if (!USER_ID && $CONFIG['enable_loginform']) {
  $loginFormHtml = <<<EOT
<ins>
    <form action="login.php?referer=$REFERER" method="post" name="loginbox" style="margin:0; padding:0;">
        <table cellpadding="0" cellspacing="3" border="0">
        <tr>
            <td><input type="text" class="textinput" name="username" size="10" /></td>
            <td><input type="password" class="textinput" name="password" size="10" /></td>
            <td><input name="submitted" type="submit" value="Login" />
            <input name="remember_me" type="hidden" class="checkbox" value="1" checked="checked" /></td>
        </tr>
        <tr>
        <td class="smallfont">$lang_loginform[user]</td>
        <td class="smallfont">$lang_loginform[pass]</td>
        <td></td>
</tr>
        </table>
        </form>
</ins>
EOT;
}

if (USER_ID) {

if ($CONFIG['enable_avatar']) {
if (AVATAR_URL !="") $avatar_url = "<a href='profile.php?op=edit_profile'><img src='".AVATAR_PATH.AVATAR_URL."' class=\"image\"></a>";
else $avatar_url="&nbsp;";
    $edit_profile_form_param[] = array('textplain', $avatar_url, $lang_register_php['manage_avatar']);

if (isset($_GET['uid'])) {
$user_data = $cpg_udb->get_user_infos($_GET['uid']);
$avatar_url = $user_data['avatar_url'];
if ($avatar_url !="") $avatar_url = "<img src='".AVATAR_PATH.$avatar_url."' class=\"image\">";
}
$loginFormHtml = "<span style=\"float: right\">".$avatar_url."</span>";
} else $loginFormHtml = NULL;

$loginFormHtml .= "<div align=\"right\" class=\"smallfont\">".$lang_loginform['welcome']." <strong>".(USER_NAME)."&nbsp;</strong><br />";


if ($CONFIG['display_pms_status']){
$result = cpg_db_query("SELECT count(*) FROM  {$CONFIG['TABLE_PMS']} WHERE owner=".(USER_ID));
list($tot_all_messages) = @mysql_fetch_array($result);
mysql_free_result($result);
$result = cpg_db_query("SELECT count(*) FROM  {$CONFIG['TABLE_PMS']} WHERE owner=".(USER_ID)." AND showed='0'");
list($tot_new_messages) = @mysql_fetch_array($result);
mysql_free_result($result);

if ($CONFIG['pms_enabled']) {
$loginFormHtml .= "<a href='pms.php'>".$lang_loginform['pms']."</a> ".$tot_new_messages.$lang_loginform['unread_total'].$tot_all_messages."&nbsp;</div>";
}
}

if ($CONFIG['display_buddy_status']){
// get some buddy data
$result = cpg_db_query("SELECT count(*) FROM  {$CONFIG['TABLE_BUDDY']} WHERE user_id=".(USER_ID));
list($tot_all_buddies) = @mysql_fetch_array($result);
mysql_free_result($result);
$result = cpg_db_query("SELECT count(*) FROM  {$CONFIG['TABLE_BUDDY_REQ']} WHERE buddy_to=".(USER_ID));
list($tot_new_buddies) = @mysql_fetch_array($result);
mysql_free_result($result);

if ($CONFIG['enable_buddy']){
$loginFormHtml .= "<div align=\"right\" class=\"smallfont\"><a href='buddy_manage.php'>".$lang_loginform['friends'].":</a> ".$tot_new_buddies." ".$lang_loginform['request'].", ".$lang_loginform['active']." ".$tot_all_buddies."&nbsp;</div>";
}
}

}
  return $loginFormHtml;
}

works fine Stram but when we click on the use names from the user list or the online status it shows error ...else things working fine , please tell me how to fix this , i tried the above mentioned codes exactly
Title: Re: Getting Member Avatars to be Displayed in index.php ?
Post by: dumbo on March 20, 2008, 10:34:04 am
also plaicing avatar image using place holder possible  :) , i am new to php
Title: Re: Getting Member Avatars to be Displayed in index.php ?
Post by: Stramm on March 21, 2008, 06:31:22 pm
possible... but then you have to do a lil bit more coding
Title: Re: Getting Member Avatars to be Displayed in index.php ?
Post by: dumbo on March 23, 2008, 07:56:28 am
Please do it staramm actually now i got to complete my Aero theme at any cost :)
Got to get that control on avatar's positioning ..would be great if its has a place holder. once this is done lil work on my skin also will be completed

I wish i Knew php  :'(

Working on a gif based theme for sick IE :) .
Title: Re: Getting Member Avatars to be Displayed in index.php ?
Post by: dumbo on March 23, 2008, 08:04:06 am
Stramm Hope u have read through the erron i am getting , its on reply 20...
Title: Re: Getting Member Avatars to be Displayed in index.php ?
Post by: seros on August 12, 2008, 05:23:32 am
I tried to apply this code in the theme.php (oranje theme) but actually the avatar s shown, BUT if I click on my profile i just get empty white pages.
So where can I find the login form which is already somewhere in some file? I think I need to make changes in there.
Thanks Stramm :)
Title: Re: Getting Member Avatars to be Displayed in index.php ?
Post by: seros on August 12, 2008, 02:09:23 pm
solved
Title: Re: Getting Member Avatars to be Displayed in index.php ?
Post by: Joachim Müller on August 12, 2008, 11:23:56 pm
Why don't you tell us how you solved your issue for the benfit of others with similar issues? That's the point of a support board.
Title: Re: Getting Member Avatars to be Displayed in index.php ?
Post by: seros on August 13, 2008, 07:54:51 am
Late at night I was just too tired, sorry. Hope this is the solution, for me it worked.

remove this part from the code:
Code: [Select]
if (isset($_GET['uid'])) {
$user_data = $cpg_udb->get_user_infos($_GET['uid']);
$avatar_url = $user_data['avatar_url'];
if ($avatar_url !="") $avatar_url = "<img src='".AVATAR_PATH.$avatar_url."' class=\"image\">";
}