Advanced search  

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Pages: [1]   Go Down

Author Topic: patch: CPG and SMF avatars...  (Read 5756 times)

0 Members and 1 Guest are viewing this topic.

blackRock

  • Translator
  • Coppermine novice
  • **
  • Offline Offline
  • Gender: Male
  • Posts: 20
    • DecoClub
patch: CPG and SMF avatars...
« 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.
« Last Edit: April 22, 2007, 11:04:01 am by Stramm »
Logged

Stramm

  • Moderator
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Male
  • Posts: 6006
    • Bettis Wollwelt
Re: CPG and SMF avatars...
« Reply #1 on: April 19, 2007, 07:01:30 pm »

thanks for that addition

blackRock

  • Translator
  • Coppermine novice
  • **
  • Offline Offline
  • Gender: Male
  • Posts: 20
    • DecoClub
Full solution for CPG and SMF avatars...
« Reply #2 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.
Logged

Riox

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Male
  • Posts: 55
Re: patch: CPG and SMF avatars...
« Reply #3 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 :/
Logged

caiboy

  • Coppermine newbie
  • Offline Offline
  • Posts: 1
    • wow gold
Re: patch: CPG and SMF avatars...
« Reply #4 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|wow gold|world of warcraft geld|wow geld kauf|wow geld kaufen|billig wow gold
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: patch: CPG and SMF avatars...
« Reply #5 on: October 18, 2007, 09:16:32 am »

Stop the board spam - nobody asked for multiple links to your page >:(
Logged
Pages: [1]   Go Up
 

Page created in 0.023 seconds with 19 queries.