forum.coppermine-gallery.net

Support => cpg1.4.x Support => Older/other versions => cpg1.4 modpack by Stramm => Topic started by: blackRock on April 19, 2007, 06:53:33 pm

Title: patch: CPG and SMF avatars...
Post by: blackRock on April 19, 2007, 06:53:33 pm
With CPG 1.4.10 (with modpack) and SMF 1.1.2 bridged, only the avatars that are in the avatars folder of the forum are displayed in CPG's comments page.
The avatars that the users have uploaded are not.

I tried to solved it and I made a solution. When the users uploads a file for avatar, two things happen:
1. The 'avatar' column in 'smf_members' table is empty
2. A row is added in 'smf_attachments' with the id_member of the user recorded in the column 'id_member'. Only when the file is for the user's avatar there is a value greater than zero in this column!

The goal is to get this id_attach and use the link: ../forum/index.php?action=dlattach;type=avatar;id=id_attach as image source in the $avatar_url variable of the theme.inc.php file.

Here is the code I used:

Code: [Select]
if ($row['avatar_url'] == "") {
  $sql = "SELECT id_attach FROM smf_attachments WHERE id_member=".$row['author_id'];
  $attach_row = mysql_fetch_array(cpg_db_query($sql));
  $avatar_url= " <img src='../forum/index.php?action=dlattach;type=avatar;id=".$attach_row['id_attach']."' class='image' style='float: left; margin-right: 5px;' alt='' />";
}

I added this code after the closing tag of: if($cpg_udb->can_join()){
The code starts with:
Code: [Select]
if($cpg_udb->can_join()){
  if ($CONFIG['enable_avatar']){

Make sure that you put the correct path for the forum's index.php in the img tag.
I would consider the solution better if I could make the sql parametric in order not to have the table 'smf_attachment' fixed with the smf_ prefix. Let someone help please!

I hope this help you.
Title: Re: CPG and SMF avatars...
Post by: Stramm on April 19, 2007, 07:01:30 pm
thanks for that addition
Title: Full solution for CPG and SMF avatars...
Post by: blackRock on April 24, 2007, 05:43:15 pm
There are four cases for avatar in the SMF:

Open the file themes.inc.php in the include folder and find line 2429. Replace the code shown here:
Code: [Select]
//check joins
if($cpg_udb->can_join()){
if ($CONFIG['enable_avatar']){
        ($row['avatar_url'] != "") ? $avatar_url= "<img src='".AVATAR_PATH.$row["avatar_url"]."' class='image' style='float: left; margin-right: 5px;' alt='' />" : $avatar_url = '';
}
else $avatar_url="";
} else { // only used when tables can't be joined... then we need to query for the avatar URL -> function get_avatar
if ($CONFIG['enable_avatar']){
$result2 = $cpg_udb->get_avatar($row['author_id']);
$avatar_url= preg_replace('/\/\//','/',AVATAR_PATH.$result2["avatar_url"]);
        ($result2['avatar_url'] != "") ? $avatar_url= "<img src='".$avatar_url."' class='image' style='float: left; margin-right: 5px;' alt='' />" : $avatar_url = '';
}
else $avatar_url="";
}

with this code:
Code: [Select]
//check joins
if($cpg_udb->can_join()){
if ($CONFIG['enable_avatar']){
if ($row['avatar_url'] != "") {
// See if the avatar is a url
if (stristr($row['avatar_url'], 'http://')) {
$avatar_url= "<img src='".$row["avatar_url"]."' class='image' style='float: left; margin-right: 5px;' alt='' />";
}
else {
// it is in the avatars folder
$avatar_url= "<img src='".AVATAR_PATH.$row["avatar_url"]."' class='image' style='float: left; margin-right: 5px;' alt='' />";
} // end if - stristr($row['avatar_url'], 'http://')
} // end if - $row['avatar_url'] != ""
}
else {
$avatar_url=""; // no avatar info in the smf_members table
} // end if - $CONFIG['enable_avatar'
}
else { // only used when tables can't be joined... then we need to query for the avatar URL -> function get_avatar
if ($CONFIG['enable_avatar']){
$result2 = $cpg_udb->get_avatar($row['author_id']);
if ($result2['avatar_url'] != "") {
// See if the avatar is a url
if (stristr($row['avatar_url'], 'http://')) {
$avatar_url= "<img src='".$result2["avatar_url"]."' class='image' style='float: left; margin-right: 5px;' alt='' />";
}
else {
// it is in the avatars folder
$avatar_url= preg_replace('/\/\//','/',AVATAR_PATH.$result2["avatar_url"]);
$avatar_url= "<img src='".$avatar_url."' class='image' style='float: left; margin-right: 5px;' alt='' />";
} // end if - stristr($row['avatar_url'], 'http://')
}
else {
$avatar_url = "";
} // end if - $result2['avatar_url'] != ""
} // end if - $CONFIG['enable_avatar'
else $avatar_url="";
} // end if - $cpg_udb->can_join()

// If the $avatar_url is still empty, maybe the user has upload one
if ($row['avatar_url'] == "") {
$sql = "SELECT id_attach FROM smf_attachments WHERE id_member=".$row['author_id'];
$attach_row = mysql_fetch_array(cpg_db_query($sql));
if ($attach_row['id_attach'] != "") {
$avatar_url= $id_attach." <img src='../forum/index.php?action=dlattach;type=avatar;id=".$attach_row['id_attach']."' class='image' style='float: left; margin-right: 5px;' alt='' />";
}
else $avatar_url = "";
}

This code will show avatar (if there is one) for all the cases I've metioned before.
Title: Re: patch: CPG and SMF avatars...
Post by: Riox on October 03, 2007, 02:06:51 pm
Thanks for your efforts. Unfortunately I already use SMF 1.1.4 and CPG 1.4.13 modpack v2

As soon as there are comments for a picture I get a "Critical error - There was an error while processing a database query".
It doesn’t matter if the users have an avatar or not so I guess they made some changes to the DB structure. Sadly I don’t have access to the SQL-error-logs :/
Title: Re: patch: CPG and SMF avatars...
Post by: caiboy on October 18, 2007, 08:37:44 am
I would consider the solution better if I could make the sql parametric in order not to have the table 'smf_attachment' fixed with the smf_ prefix. Let someone help please!
wow geld (http://www.wowgold-de.com)|wow gold (http://www.wowgold-de.com)|world of warcraft geld (http://www.wowgold-de.com/world-of-warcraft-de-gold-7.html)|wow geld kauf (http://www.wowgold-de.com/world-of-warcraft-fr-gold-8.html)|wow geld kaufen (http://www.wowgold-de.com/world-of-warcraft-uk-gold-9.html)|billig wow gold (http://www.wowgold-de.com/world-of-warcraft-es-gold-10.html)
Title: Re: patch: CPG and SMF avatars...
Post by: Joachim Müller on October 18, 2007, 09:16:32 am
Stop the board spam - nobody asked for multiple links to your page >:(