different themes based on user profile (when bridged) different themes based on user profile (when bridged)
 

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

different themes based on user profile (when bridged)

Started by gummiman, December 12, 2004, 02:25:02 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

gummiman

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]

Joachim Müller

Quote from: gummiman on December 12, 2004, 02:25:02 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

gummiman

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:
// 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:
define('PHPBB_THEME_TABLE', 'themes');

find:
// 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:
//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:
// 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:
// 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.

kmonie


kegobeer

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

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?
L8r,
PopTheTop

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

PopTheTop

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

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

gummiman

Quote from: PopTheTop 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?

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.