forum.coppermine-gallery.net

Support => cpg1.4.x Support => Older/other versions => cpg1.4 modpack by Stramm => Topic started by: giorgio79 on February 07, 2007, 05:22:22 pm

Title: modding "enable buddy view of private album"
Post by: giorgio79 on February 07, 2007, 05:22:22 pm
Hi Stramm,

Hope you are well.

I am currently integrating your modpack, mainly for the buddies feature. Even though, I decided that for buddy queries I will use my own social network db. (my 'buddy' db stores buddies separated by commas, and does not make a new row for each buddy)

The main feature I would like to use is enabling buddy view of the private album!

I have been analyzing the code, and I think I found where CPG pulls the array of buddies and checks it the current user is a member of the buddy array.
 here it is
functions.inc.php
   
line 747

Code: [Select]
if ($CONFIG['enable_buddy_private_view'] && USER_ID) {
[b]$buddies[/b] = cpg_db_query("SELECT a.aid FROM {$CONFIG['TABLE_ALBUMS']} as a INNER JOIN {$CONFIG['TABLE_BUDDY']} AS b on a.category=b.buddy_id + ". FIRST_USER_CAT ." WHERE b.user_id = ".USER_ID." AND a.visibility = '-1' AND buddy_ok = 'YES' OR category = ".(USER_ID + FIRST_USER_CAT));
while(list($allowed_list[]) = mysql_fetch_row($buddies));


Will the $buddies array contain a list of buddies separated by commas? Looking at the query it seems like it is pulling in some albums as well...
For my db I can pull the same array, it is just called $friends, and I could plug that in here...

Please let me know.

Thank you,

Gyuri
Title: Re: modding "enable buddy view of private album"
Post by: Stramm on February 07, 2007, 08:24:56 pm
The buddy feature is making use of CPGs private album feature and therefore integrating into that system. So it's pulling a list of forbidden albums (comma separated). Few lines below you'll see exactly what it does...

Code: [Select]
                $FORBIDDEN_SET = "p.aid NOT IN (".substr($set, 0, -1).') ';
                $ALBUM_SET .= 'AND aid NOT IN ('.substr($set, 0, -1).') ';

-> ~ p.aid NOT IN 2,3,19,174
Title: Re: modding "enable buddy view of private album"
Post by: giorgio79 on February 08, 2007, 12:31:16 am
Thanks Stramm!

And as I udnerstand it does so by selecting the albums (a.id) which belong to the buddies (a.category=b.buddy_id) of the current user (b.user_id), right? I am just trying to grasp the flow :)

SELECT a.aid FROM {$CONFIG['TABLE_ALBUMS']} as a INNER JOIN {$CONFIG['TABLE_BUDDY']} AS b on a.category=b.buddy_id + ". FIRST_USER_CAT ." WHERE b.user_id = ".USER_ID." AND a.visibility = '-1' AND buddy_ok = 'YES' OR category = ".(USER_ID + FIRST_USER_CAT))