phpbb Private Message Notifycation on coppermine theme phpbb Private Message Notifycation on coppermine theme
 

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

phpbb Private Message Notifycation on coppermine theme

Started by pszone, December 15, 2006, 01:26:18 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

pszone

Hi, I have a coppermine photo gallery and phpbb forum bridged. I make custom header for my theme - subsilver. In phpbb there are private messages report "you have 1 unread message" or "you dont have any new messages", so i need this line to be in my coppermine header, when the user is logged in. It is easy to get a link for gallery main page (privatemessages), but the notification is needed as well.

For other external pages I use this code to show this info:

if ( ($userdata['session_logged_in']) && (empty($gen_simple_header)) )
{
if ( $userdata['user_new_privmsg'] )
{
$l_message_new = ( $userdata['user_new_privmsg'] == 1 ) ? $lang['New_pm'] : $lang['New_pms'];
$l_privmsgs_text = sprintf($l_message_new, $userdata['user_new_privmsg']);

if ( $userdata['user_last_privmsg'] > $userdata['user_lastvisit'] )
{
$sql = "UPDATE " . USERS_TABLE . "
SET user_last_privmsg = " . $userdata['user_lastvisit'] . "
WHERE user_id = " . $userdata['user_id'];
if ( !$db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Could not update private message new/read time for user', '', __LINE__, __FILE__, $sql);
}

$s_privmsg_new = 1;
$icon_pm = $images['pm_new_msg'];
}
else
{
$s_privmsg_new = 0;
$icon_pm = $images['pm_new_msg'];
}
}
else
{
$l_privmsgs_text = $lang['No_new_pm'];

$s_privmsg_new = 0;
$icon_pm = $images['pm_no_new_msg'];
}

if ( $userdata['user_unread_privmsg'] )
{
$l_message_unread = ( $userdata['user_unread_privmsg'] == 1 ) ? $lang['Unread_pm'] : $lang['Unread_pms'];
$l_privmsgs_text_unread = sprintf($l_message_unread, $userdata['user_unread_privmsg']);
}
else
{
$l_privmsgs_text_unread = $lang['No_unread_pm'];
}
}
else
{
$icon_pm = $images['pm_no_new_msg'];
$l_privmsgs_text = $lang['Login_check_pm'];
$l_privmsgs_text_unread = '';
$s_privmsg_new = 0;
}


And this:

$template->assign_vars(array(
'L_PRIVATEMSGS' => $lang['Private_Messages'],
'PRIVATE_MESSAGE_INFO' => $l_privmsgs_text,
'PRIVATE_MESSAGE_INFO_UNREAD' => $l_privmsgs_text_unread,
'U_PRIVATEMSGS' => append_sid('privmsg.'.$phpEx.'?folder=inbox'),
)
);


What I need to edit and in which files. Thanks in advance!

Joachim Müller

You can't just insert some phpBB code snippets into Coppermine, as none of the vars that your phpBB code uses is being populated in coppermine. We don't know phpBB, so we can't advice. I know my way around in SMF a bit, so if your question would have been how to accomplish this with Coppermine and SMF bridged, I would have suggested using SMF's SSI.php. As you certainly won't migrate from phpBB to SMF just to accomplish what you're up to, I suggest looking this up on the phpBB resources - you need a code snippet that can work outside of phpBB that will fetch the needed data from phpBB and display it on the "external page". In your case, the external page could be inside your coppermine theme, or using anycontent.php, or using the custom_header/footer feature, or using an iframe. Anyway, you will need to come up with a code snippet that can do what you're up to on an external page first (external as in "a non-phpbb file").
Bottom line: search the phpBB suppor boards if they have something similar to SMF's SSI.php.

pszone

I know how to make that code work outside phpbb, but in coppermine conflict with database of the gallery system. I try everythink with custom header and anycontent file. I am now with iframe, but I don't want to use this method anymore. I was thinking to insert this code (the code from first post above) to phpbb bridge file and edited to check for Private Messages, but I am not sure that, this is possible. GauGau if you have time, show me how can do this in SMF, and will try to convert for phpbb.

Joachim Müller

SMF has pre-defined functions to accomplish this. If phpBB doesn't have those functions available, you can't port the code. Do as I suggested: create a file that works standalone. Post the full code and a working link to it.

pszone

Ok, here, what i use to show the PM to external pages.

In beginning of my page add this code:

<?php
define
('IN_PHPBB'true);
$phpbb_root_path '../forums/';
include(
$phpbb_root_path 'extension.inc');
include(
$phpbb_root_path 'common.'.$phpEx);
//
// Start session management
//
$userdata session_pagestart($user_ipPAGE_INDEX);
init_userprefs($userdata);
//
// End session management
//
?>


I add this above Head Tags:

<?php
if ( ($userdata['session_logged_in']) && (empty($gen_simple_header)) )
{
if ( $userdata['user_new_privmsg'] )
{
$l_message_new = ( $userdata['user_new_privmsg'] == ) ? $lang['New_pm'] : $lang['New_pms'];
$l_privmsgs_text sprintf($l_message_new$userdata['user_new_privmsg']);

if ( $userdata['user_last_privmsg'] > $userdata['user_lastvisit'] )
{
$sql "UPDATE " USERS_TABLE "
SET user_last_privmsg = " 
$userdata['user_lastvisit'] . "
WHERE user_id = " 
$userdata['user_id'];
if ( !$db->sql_query($sql) )
{
message_die(GENERAL_ERROR'Could not update private message new/read time for user'''__LINE____FILE__$sql);
}

$s_privmsg_new 1;
$icon_pm $images['pm_new_msg'];
}
else
{
$s_privmsg_new 0;
$icon_pm $images['pm_new_msg'];
}
}
else
{
$l_privmsgs_text $lang['No_new_pm'];

$s_privmsg_new 0;
$icon_pm $images['pm_no_new_msg'];
}

if ( $userdata['user_unread_privmsg'] )
{
$l_message_unread = ( $userdata['user_unread_privmsg'] == ) ? $lang['Unread_pm'] : $lang['Unread_pms'];
$l_privmsgs_text_unread sprintf($l_message_unread$userdata['user_unread_privmsg']);
}
else
{
$l_privmsgs_text_unread $lang['No_unread_pm'];
}
}
else
{
$icon_pm $images['pm_no_new_msg'];
$l_privmsgs_text $lang['Login_check_pm'];
$l_privmsgs_text_unread '';
$s_privmsg_new 0;
}
?>


Then I just add the link with message report somewhere in my header

<a href="<http://mysite.com/forums/privmsg.php?folder=inbox"><?php echo $l_privmsgs_text ?></a>

In the momment I can't show demo, because I make it this at home.