How to fetch external data thru a bridge ? How to fetch external data thru a bridge ?
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

How to fetch external data thru a bridge ?

Started by flux, April 19, 2006, 04:57:36 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

flux

Hi,

i've been testing a cpg 1.4.4 bridging with Invision Power Board 1.3.1 using the following bridge already posted on this forum :
http://forum.coppermine-gallery.net/index.php?topic=24712.0

everything works fine, as expected at least, but i'd like to tweak the bridge a little in order to improve my cpg integration.

Although it won't cover all my integration requirements, i guess i could sumup my problem with the simple following question :

how can i make that cpg/invision1.3 bridge to fetch additional data from my Invision board so i can use that data when building my cpg integration skin/theme ?

For example i would need to get the "avatar" data field from invision "ibf_members" table so i can use it in my custom cpg skin..
Is there a way to do that simply using the bridge functions/arrays or will i have to hack into cpg core routines to fetch that avatar data.

so far the only relevant place where i could handle field names/lists would be the "field" array, like the following one from that bridge :

// Table field names
$this->field = array(
'username' => 'name', // name of 'username' field in users table
'user_id' => 'id', // name of 'id' field in users table
'password' => 'password', // name of 'password' field in users table
'email' => 'email', // name of 'email' field in users table
'regdate' => 'joined', // name of 'registered' field in users table
'location' => 'location', // name of 'location' field in users table
'website' => 'website', // name of 'website' field in users table
'usertbl_group_id' => 'mgroup', // name of 'group id' field in users table
'grouptbl_group_id' => 'g_id', // name of 'group id' field in groups table
'grouptbl_group_name' => 'g_title' // name of 'group name' field in groups table
);


i haven't figured out where that array is used and how/if those data fields are available within cpg code.. so i dont really know if adding my avatar field there would make any sense..

I just want to make something as clean as possible, considering that avatar data has to be dynamic as members can change it whenever they want..
If cpg uses a global $CURRENT_USER array i could substitute some cpg "user_profileX" field with my invision "avatar" one and then use it throughout cpg scripts..

any idea would be appreciated
thx

.flux

Nibbler

You should be able to collect the avatar during your cookie or session extraction procedure where you are already accessing the user table, store it in the bridge object, override authenticate() or load_user_data() to contain a call to the parent's method followed by code to add the avatar data you collected earlier into the $USER_DATA array. It will then be available everywhere and you have only changed the bridge file. To keep it clean, you can add the avater field name into the field array and then use that in your code instead of hardcoding it.

flux

okay thx for the guidelines

i've made the necessary modifications to fetch the avatar field from within session_extraction(), then add it to the global $BRIDGE array and then add some extended code to the authenticate() function in the bridge file, like this :

function authenticate()
    {
global $BRIDGE, $USER_DATA;
parent::authenticate();

$USER_DATA['avatar'] = $BRIDGE['avatar'];
}


i can get the "avatar" key from $USER_DATA but i was wondering if the $BRIDGE array is also available everywhere, then i could just leave "avatar" there right ? or was it just to make it event cleaner and group user data together in $USER_DATA ?

as for the "field" array, built in the bridge constructor, from which object can it be accessed from, in cpg code ? I'm not sure i followed what was done with it exactly..

thx for the help !

.flux

Nibbler

The field array is a property of the bridge object, so can be accessed via $cpg_udb->fields from anywhere in the code. That allows you to make generic queries that will work for all bridges, such as selecting the name of the last registered user.

I meant for you to add the avatar setting as an object property like that, not in the $BRIDGE array. Although it probably does no harm.

flux

okay, well i'll leave it like that for the moment.

unfortunately i didn't quite understand the request my fellow users were asking me about those avatars..

In fact they don't want to see their own avatar when they browse the galleries but they want to see, pictures/comments owners avatars so they can identify in the blink of an eye who did what..
That actually makes sense but as i would like to keep the avatar data dynamic for the same reason i described before, i will have to fetch the avatar data at runtime from the forum database..

I guess i'll have to hack into cpg code in order to modify those requests..

I'm not even sure how php mysql driver handles requests with "left joins" across multiple databases.. i'll probably have to make the same database user have access to both databases..

i'll keep all the forum database info into the bridge arrays so it can be customized there, and i'll try to get my hack to work when bridging is desabled so it doesn't change cpg's behaviour in standalone mode..

.flux