Bridging e107 v0.7.5 and CPG v1.4.8 Bridging e107 v0.7.5 and CPG v1.4.8
 

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

Main Menu

Bridging e107 v0.7.5 and CPG v1.4.8

Started by Saiorse, June 16, 2006, 07:23:22 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Saiorse

Dear People,

First of all, there is a lot that I want, though there is a lot I don't know.

So, I've seen some Bridges, I think I know how it works, though I don't know how to do it.

It's like I'm missing variables, processes and more. And most of all, I'm not experienced enough to do it at the moment.

I don't want to be lazy, so, would someone be so kind for me to help me getting started.

Perhaps a list with the variables used in CPG which has to be ported. So i can find out where they are stored in e107.

And make a start with the porting.

Or perhaps an example of the process of the bridging with the cookies and stuff.

I hope someone could help me guiding the way,



Grtz Martijn Kerver

Joachim Müller

There is not guide available (yet) for creating bridge files, sorry. I suggest taking a look at the existing bridge files and then modifying/creating one that fits. We'd appreciate to see your custom bridge file contrib if you should succeed. Sorry that I can't give you more pointers.

bybinhabr

e107coders.org always have old packages of CPG to e107  :-\
We need the "formula" to change files and make the bridge by our hands!

We are from Brazil (www.e107brasilnet) and I think CPG is the best one to integration with e107 sites!

I have this file in "bridge" directory:
<?php
// ------------------------------------------------------------------------- //
//  Coppermine Photo Gallery                                                 //
// ------------------------------------------------------------------------- //
//  Copyright (C) 2002,2003  Grégory DEMAR <gdemar@wanadoo.fr>               //
//  http://www.chezgreg.net/coppermine/                                      //
// ------------------------------------------------------------------------- //
//  Based on PHPhotoalbum by Henning Støverud <henning@stoverud.com>         //
//  http://www.stoverud.com/PHPhotoalbum/                                    //
// ------------------------------------------------------------------------- //
//  This program is free software; you can redistribute it and/or modify     //
//  it under the terms of the GNU General Public License as published by     //
//  the Free Software Foundation; either version 2 of the License, or        //
//  (at your option) any later version.                                      //
// ------------------------------------------------------------------------- //
//
//  e107 Integration for Coppermine
//
// ------------------------------------------------------------------------- //

// ------------------------------------------------------------------------- //
//  Modify the values below according to your e107 installation
// ------------------------------------------------------------------------- //


define('E107_ADMIN_GROUP'1);
define('E107_MEMBERS_GROUP'2);
define('E107_GUEST_GROUP'3);
define('E107_BANNED_GROUP'4);

// Retrieve the name of a user
function udb_get_user_name($uid) {
$sql2 = new db;
if(USER===TRUE){
if(!empty($uid)){
if($sql2 -> db_Select("user","user_name","user_id='{$uid}'")){
$row $sql2 -> db_Fetch();
return $row['user_name'];
} else {
return "Unknown";
}
} else {
return USERNAME;
}
} else {
return "";
}
}

// Authenticate a user using cookies
function udb_authenticate() {
global 
$HTTP_COOKIE_VARS$USER_DATA$UDB_DB_LINK_ID$UDB_DB_NAME_PREFIX$CONFIG;
global 
$HTTP_SERVER_VARS$HTTP_X_FORWARDED_FOR$HTTP_PROXY_USER$REMOTE_ADDR$USER;

$USER['lang']=strtolower(e_LANGUAGE);

// For error checking
$CONFIG['TABLE_USERS'] = '**ERROR**';

// Permissions for a default group
$default_group = array(
        
'group_id' => E107_GUEST_GROUP,
        
'group_name' => 'Unknown',
        
'has_admin_access' => 0,
        
'can_send_ecards' => 0,
        
'can_rate_pictures' => 0,
        
'can_post_comments' => 0,
        
'can_upload_pictures' => 0,
        
'can_create_albums' => 0,
        
'pub_upl_need_approval' => 1,
        
'priv_upl_need_approval' => 1,
);

// get first 50 chars
$HTTP_USER_AGENT=substr($HTTP_SERVER_VARS['HTTP_USER_AGENT'],0,50);
$REMOTE_ADDR=substr($HTTP_SERVER_VARS['REMOTE_ADDR'],0,50);

if(
USER===TRUE){
        
define('USER_ID'USERID);
        
define('USER_NAME'USERNAME);
        
$USER_DATA['user_name']=USERNAME;
        if(
ADMINPERMS=="0" || check_class("COPPERMINE_ADMIN")){
                
$USER_DATA['mgroup']=E107_ADMIN_GROUP;
        } else {
                
$sql "SELECT * ".
                           
"FROM {$CONFIG['TABLE_USERGROUPS']} ORDER BY group_name";
                
$result db_query($sql);
                if(
mysql_num_rows($result)){
                        while((
$row mysql_fetch_array($result)) && empty($USER_DATA['mgroup'])){
                                
extract($row);
                                if(
check_class(strtoupper($group_name))){
                                        
$USER_DATA['mgroup']=$group_id;
                                }
                        }
                }
                if(empty(
$USER_DATA['mgroup'])){
                        
$USER_DATA['mgroup']=E107_MEMBERS_GROUP;
                }
        }

        
// Retrieve group information
        
$sql "SELECT * ".
                   
"FROM {$CONFIG['TABLE_USERGROUPS']} ".
                   
"WHERE group_id = '{$USER_DATA['mgroup']}'";
        
$result db_query($sql);
        if (
mysql_num_rows($result)){
                
$USER_DATA2 mysql_fetch_array($result);
        } else {
                
$USER_DATA2 $default_group;
        }

        
$USER_DATA array_merge($USER_DATA$USER_DATA2);

           
define('USER_GROUP'$USER_DATA['group_name']);
           
define('USER_GROUP_SET''('.$USER_DATA['group_id'].')');
           
define('USER_IS_ADMIN', ($USER_DATA['mgroup'] == E107_ADMIN_GROUP));
           
define('USER_CAN_SEND_ECARDS', (int)$USER_DATA['can_send_ecards']);
           
define('USER_CAN_RATE_PICTURES', (int)$USER_DATA['can_rate_pictures']);
           
define('USER_CAN_POST_COMMENTS', (int)$USER_DATA['can_post_comments']);
           
define('USER_CAN_UPLOAD_PICTURES', (int)$USER_DATA['can_upload_pictures']);
           
define('USER_CAN_CREATE_ALBUMS', (int)$USER_DATA['can_create_albums']);
           
mysql_free_result($result);
        } else {
                
$result db_query("SELECT * FROM {$CONFIG['TABLE_USERGROUPS']} WHERE group_id = ".E107_GUEST_GROUP);
                if (!
mysql_num_rows($result)) {
                        
$USER_DATA $default_group;
                } else {
                        
$USER_DATA mysql_fetch_array($result);
                }
           
define('USER_ID'0);
           
define('USER_NAME''Anonymous');
                
define('USER_GROUP_SET''('.E107_GUEST_GROUP.')');
           
define('USER_IS_ADMIN'0);
           
define('USER_CAN_SEND_ECARDS', (int)$USER_DATA['can_send_ecards']);
           
define('USER_CAN_RATE_PICTURES', (int)$USER_DATA['can_rate_pictures']);
           
define('USER_CAN_POST_COMMENTS', (int)$USER_DATA['can_post_comments']);
           
define('USER_CAN_UPLOAD_PICTURES', (int)$USER_DATA['can_upload_pictures']);
           
define('USER_CAN_CREATE_ALBUMS'0);
                
mysql_free_result($result);
        }
}

function 
udb_edit_users(){
        
$target e_ADMIN.'users.php';
        
udb_redirect($target);
}

function 
udb_get_user_infos($uid){
        
$target e_HTTP."user.php?id.".$uid;
        
udb_redirect($target);
}

function 
udb_synchronize_groups(){
        global 
$CONFIG,$mySQLprefix;
        
$result db_query("SELECT userclass_id, userclass_name FROM ".$mySQLprefix."userclass_classes WHERE 1");
        while (
$row mysql_fetch_array($result)){
                
$e107_groups[$row['userclass_id']+4] = $row['userclass_name'];
        }
        
mysql_free_result($result);

        
$result=db_query("SELECT group_id, group_name FROM {$CONFIG['TABLE_USERGROUPS']} WHERE 1");
        while (
$row mysql_fetch_array($result)){
                
$cpg_groups[$row['group_id']] = $row['group_name'];
        }
        
mysql_free_result($result);

        
// Scan Coppermine groups that need to be deleted
        
foreach($cpg_groups as $c_group_id => $c_group_name){
                if ((!isset(
$e107_groups[$c_group_id]) && $c_group_id 4)) {
                           
db_query("DELETE FROM {$CONFIG['TABLE_USERGROUPS']} WHERE group_id = '".$c_group_id."' LIMIT 1");
                        unset(
$cpg_groups[$c_group_id]);
                }
        }

        
// Scan e107 groups that need to be created inside Coppermine table
        
if(count($e107_groups)){
                foreach(
$e107_groups as $i_group_id => $i_group_name){
                        if ((!isset(
$cpg_groups[$i_group_id]))) {
                                if(
$i_group_name != "COPPERMINE_ADMIN"){
                                        
db_query("INSERT INTO {$CONFIG['TABLE_USERGROUPS']} (group_id, group_name) VALUES ('$i_group_id', '".addslashes($i_group_name)."')");
                                        
$cpg_groups[$i_group_id] = $i_group_name;
                                }
                        }
                }

        
// Update Group names
                
foreach($e107_groups as $i_group_id => $i_group_name){
                        if (
$cpg_groups[$i_group_id] != $i_group_name) {
                                
db_query("UPDATE {$CONFIG['TABLE_USERGROUPS']} SET group_name = '".addslashes($i_group_name)."' WHERE group_id = '$i_group_id' LIMIT 1");
                        }
                }
        }
}

// Edit user profile
function udb_edit_profile($uid)
{
        
$target e_HTTP.'usersettings.php';
        
udb_redirect($target);
}

// Redirect
function udb_redirect($target)
{
        
header('Location: '.$target);
        exit;
}

// Query used to list users
function udb_list_users_query(&$user_count) {
        global 
$CONFIG$FORBIDDEN_SET;

        
$sql =  "SELECT (category - ".FIRST_USER_CAT.") as user_id,".
                        
"                '???' as user_name,".
                        
"                COUNT(DISTINCT a.aid) as alb_count,".
                        
"                COUNT(DISTINCT pid) as pic_count,".
                        
"                MAX(pid) as thumb_pid ".
                        
"FROM {$CONFIG['TABLE_ALBUMS']} AS a ".
                        
"INNER JOIN {$CONFIG['TABLE_PICTURES']} AS p ON p.aid = a.aid ".
                        
"WHERE approved = 'YES' AND category > ".FIRST_USER_CAT." ".
                        
"$FORBIDDEN_SET ".
                        
"GROUP BY category ".
                        
"ORDER BY category ";
        
$result db_query($sql);

        
$user_count mysql_num_rows($result);
        return 
$result;
}

// Retrieve the album list used in gallery admin mode
function udb_get_admin_album_list()
{
        global 
$CONFIG$UDB_DB_NAME_PREFIX$UDB_DB_LINK_ID$FORBIDDEN_SET;
                
$sql "SELECT aid, IF(category > ".FIRST_USER_CAT.", CONCAT('* ', title), CONCAT(' ', title)) AS title ".
                           
"FROM {$CONFIG['TABLE_ALBUMS']} ".
                           
"ORDER BY title";
                return 
$sql;
}

function 
udb_list_users_retrieve_data($result$lower_limit$count) {

        global 
$CONFIG$mySQLprefix;

        
mysql_data_seek($result$lower_limit);

        
$rowset = array();
        
$i=0;
        
$user_id_set='';

        while ((
$row mysql_fetch_array($result)) && ($i++ < $count)){
                
$user_id_set .= $row['user_id'].',';
                
$rowset[] = $row;
        }
        
mysql_free_result($result);


        
$user_id_set '('.substr($user_id_set0, -1).')';
        
$sql "SELECT user_id as user_id, user_name as user_name ".
                   
"FROM ".$mySQLprefix."user ".
                   
"WHERE user_id IN $user_id_set";

        
$result db_query($sql);
        while (
$row mysql_fetch_array($result)){
                
$name[$row['user_id']] = $row['user_name'];
        }
        for(
$i=0$i<count($rowset); $i++){
                
$rowset[$i]['user_name'] = empty($name[$rowset[$i]['user_id']]) ? '???' $name[$rowset[$i]['user_id']];
        }

        return 
$rowset;

}

?>


I know we must make a lot of changes in CPG to work with e107... just this only file didn't work, isn't? Or will work?

I don't know php... sorry!

Can anyone help here?

Thanks!

Barbara Tostes
from Brazil - e107brasil.net community
we love CPG! + e107!

Joachim Müller

The bridging mechanisms have changed from cpg1.3.x to cpg1.4.x, that's why you can't use a bridge file made for cpg1.3.x with a cpg1.4.x install. As we (the coppermine devs) don't know e107, a member of the e107 community will have to come up with a bridge file for cpg1.4.x. Bottom line: you're on your own with this - ask support on the e107 support boards. The coppermine devs will not look into this.