Advanced search  

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]

Pages: [1]   Go Down

Author Topic: different themes based on user profile (when bridged)  (Read 12788 times)

0 Members and 1 Guest are viewing this topic.

gummiman

  • Contributor
  • Coppermine newbie
  • ***
  • Offline Offline
  • Posts: 3
different themes based on user profile (when bridged)
« on: December 12, 2004, 02:25:02 am »

Can coppermine be set to use the users bbs profile theme?

An example would be a site running phpbb and coppermine intergrated, the phpbb templates dir and the cpg themes dir have theme a, b, and c. The user selects theme b in their phpbb profile, can cpg pick that up? If not, would it be easy to alter cpg to do this??

[edit GauGau]
renamed thread from "Can coppermine be set to use the users bbs profile theme?" to "different themes based on user profile (when bridged)"
[/edit]
« Last Edit: January 01, 2005, 11:05:10 am by GauGau »
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Can coppermine be set to use the users bbs profile theme?
« Reply #1 on: December 12, 2004, 09:36:54 am »

The user selects theme b in their phpbb profile, can cpg pick that up? If not, would it be easy to alter cpg to do this??
Out-of-the-box: no and no. Coppermine doesn't care about the theme you're using with your bbs, it has a themeing/template engine of it's own. You have to create a theme in coppermine that resembles the theme of your bbs app if you want a close visual integration.
Making a coppermine theme selector/switch based on the logged in user would be possible as well (some php knowledge needed though); you would have to add a query into coppermine's code to look up what theme the particular user has set in his profile in the bbs app.

Joachim
Logged

gummiman

  • Contributor
  • Coppermine newbie
  • ***
  • Offline Offline
  • Posts: 3
Re: Can coppermine be set to use the users bbs profile theme?
« Reply #2 on: December 31, 2004, 07:00:38 pm »

I started looking into it and have it working the way I wanted it. Heres how I did it if anyone else is interested:

in /bridge/phpbb.inc.php find:
Code: [Select]
// Prefix and names for the database tables
define('PHPBB_TABLE_PREFIX', 'lrbb_'); // The prefix used for the DB tables
define('PHPBB_USER_TABLE', 'users'); // The members table
define('PHPBB_SESSION_TABLE', 'sessions'); // The session table
define('PHPBB_GROUP_TABLE', 'groups'); // The groups table
define('PHPBB_UGROUP_TABLE', 'user_group'); // The group/user table

after add:
Code: [Select]
define('PHPBB_THEME_TABLE', 'themes');
find:
Code: [Select]
// Retrieve the groups the user is a member of
        $sql = "SELECT (ug.group_id + 5) as group_id " . "FROM " . $UDB_DB_NAME_PREFIX . PHPBB_TABLE_PREFIX . PHPBB_UGROUP_TABLE . " as ug " . "LEFT JOIN " . $UDB_DB_NAME_PREFIX . PHPBB_TABLE_PREFIX . PHPBB_GROUP_TABLE . " as g ON ug.group_id = g.group_id " . "WHERE user_id = " . USER_ID . " AND user_pending = 0 AND group_single_user = 0";
        $result = db_query($sql, $UDB_DB_LINK_ID);
        while ($row = mysql_fetch_array($result)) {
                array_push($USER_DATA['groups'], $row['group_id']);
        }
        mysql_free_result($result);

        $user_group_set = '(' . implode(',', $USER_DATA['groups']) . ')';
        // Default group data
        $USER_DATA['group_quota'] = 1;
        $USER_DATA['can_rate_pictures'] = 0;
        $USER_DATA['can_send_ecards'] = 0;
        $USER_DATA['can_post_comments'] = 0;
        $USER_DATA['can_upload_pictures'] = 0;
        $USER_DATA['can_create_albums'] = 0;
        $USER_DATA['pub_upl_need_approval'] = 1;
        $USER_DATA['priv_upl_need_approval'] = 1;
        $USER_DATA['upload_form_config'] = 0;
        $USER_DATA['num_file_upload'] = 0;
        $USER_DATA['num_URI_upload'] = 0;
        $USER_DATA['custom_user_upload'] = 0;

        $USER_DATA = array_merge($USER_DATA, cpgGetUserData($USER_DATA['groups'][0], $USER_DATA['groups'], PHPBB_GUEST_GROUP));

        define('USER_GROUP', '');
        define('USER_GROUP_SET', $user_group_set);
        define('USER_IS_ADMIN', ($USER_DATA['user_level'] == 1));
        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']);
        define('USER_UPLOAD_FORM', (int)$USER_DATA['upload_form_config']);
        define('CUSTOMIZE_UPLOAD_FORM', (int)$USER_DATA['custom_user_upload']);
        define('NUM_FILE_BOXES', (int)$USER_DATA['num_file_upload']);
        define('NUM_URI_BOXES', (int)$USER_DATA['num_URI_upload']);
    } else {
        $USER_DATA = cpgGetUserData(PHPBB_GUEST_GROUP, array(), PHPBB_GUEST_GROUP);
        define('USER_ID', 0);
        define('USER_NAME', 'Anonymous');
        define('USER_GROUP_SET', '(' . PHPBB_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);
        define('USER_UPLOAD_FORM', (int)$USER_DATA['upload_form_config']);
        define('CUSTOMIZE_UPLOAD_FORM', (int)$USER_DATA['custom_user_upload']);
        define('NUM_FILE_BOXES', (int)$USER_DATA['num_file_upload']);
        define('NUM_URI_BOXES', (int)$USER_DATA['num_URI_upload']);
        mysql_free_result($result);
    }
}

after add:
Code: [Select]
//phpbb users theme
function udb_userstyle($uid)
{
global $UDB_DB_LINK_ID, $UDB_DB_NAME_PREFIX;

$sql = "SELECT template_name as theme" . " FROM " . $UDB_DB_NAME_PREFIX . PHPBB_TABLE_PREFIX . PHPBB_USER_TABLE . ", ". $UDB_DB_NAME_PREFIX . PHPBB_TABLE_PREFIX . PHPBB_THEME_TABLE . " " . "WHERE user_id='$uid' AND themes_id=user_style";
$result = db_query($sql, $UDB_DB_LINK_ID);

if (mysql_num_rows($result)) {
       $row = mysql_fetch_array($result);
       mysql_free_result($result);
       return $row['theme'];
} else {
return 'classic';
}
}

in /include/init.inc.php find:
Code: [Select]
// Load theme file
if (isset($USER['theme']) && !strstr($USER['theme'], '/') && is_dir('themes/' . $USER['theme'])) {
    $CONFIG['theme'] = strtr($USER['theme'], '$/\\:*?"\'<>|`', '____________');
} else {
    unset($USER['theme']);
}

replace with:
Code: [Select]
// Load theme file
if (defined('UDB_INTEGRATION') && isset($USER_DATA['user_id']) && empty($HTTP_GET_VARS['theme'])) {
    $CONFIG['theme'] = udb_userstyle((int)$USER_DATA['user_id']);
    unset($USER['theme']);
} else {

if (isset($USER['theme']) && !strstr($USER['theme'], '/') && is_dir('themes/' . $USER['theme'])) {
    $CONFIG['theme'] = strtr($USER['theme'], '$/\\:*?"\'<>|`', '____________');
} else {
    unset($USER['theme']);
}
}

So now when a user is logged in, cpg will use the same theme as phpbb. As long as the phpbb templates dirs and the cpg themes dirs have the same names (ex.. (phpbb2 dir)/templates/mytheme1 and (cpg dir)/themes/mytheme1), if the dir doesn't exsist, cpg defaults to classic.

Should work with other bb's, you'll just need to modify the right bridge file and modify the sql statement.
Logged

kmonie

  • Coppermine newbie
  • Offline Offline
  • Posts: 1
Need some help
« Reply #3 on: January 10, 2005, 03:07:51 am »

...
Logged

kegobeer

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 4637
  • Beer - it does a body good!
    • The Kazebeer Family Website
Re: different themes based on user profile (when bridged)
« Reply #4 on: January 10, 2005, 03:26:52 am »

What does ... mean?  Please don't post gibberish.
Logged
Do not send me a private message unless I ask for one.  Make your post public so everyone can benefit.

There are no stupid questions
But there are a LOT of inquisitive idiots

PopTheTop

  • Coppermine newbie
  • Offline Offline
  • Gender: Male
  • Posts: 18
    • Pop-the-top
Re: different themes based on user profile (when bridged)
« Reply #5 on: January 10, 2005, 04:10:18 am »

Hey gummiman,
I did the modifications as you stated to do above and when you visit or log into our photo gallery, it still uses the classic theme.

I also uploads a duplicate of the phpBB subSilver template folder into cpg/themes/ folder so it is locate at cpg/themes/subSilver

How do I get the phpBB theme to work?
Logged
L8r,
PopTheTop

It's a pop-up thing...
   You wouldn't understand!

PopTheTop

  • Coppermine newbie
  • Offline Offline
  • Gender: Male
  • Posts: 18
    • Pop-the-top
Re: different themes based on user profile (when bridged)
« Reply #6 on: January 11, 2005, 03:31:08 pm »

Also, no matter what theme you chose, it still reverts back to the clasic theme.
Logged
L8r,
PopTheTop

It's a pop-up thing...
   You wouldn't understand!

gummiman

  • Contributor
  • Coppermine newbie
  • ***
  • Offline Offline
  • Posts: 3
Re: different themes based on user profile (when bridged)
« Reply #7 on: January 12, 2005, 02:11:40 am »

Hey gummiman,
I did the modifications as you stated to do above and when you visit or log into our photo gallery, it still uses the classic theme.

I also uploads a duplicate of the phpBB subSilver template folder into cpg/themes/ folder so it is locate at cpg/themes/subSilver

How do I get the phpBB theme to work?

You need to create a theme for cpg that matches you phpBB theme. PhpBB uses tpl files (templates) for defining the look, but cpg uses the template.html and theme.php files for defining the look. The best thing to do would be to make a copy of the classic dir and rename it to the same name of the phpBB template dir (ex.. subSilver), then start modifying the theme.php, template.html and style.css files till you get the look your after.

If your uncomfortable will editing files you could try surfing the web for phpBB themes that match some of the themes in the downloads section, then install the themes in their respective places.
Logged
Pages: [1]   Go Up
 

Page created in 0.037 seconds with 24 queries.