News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

ssi function for popup PM

Started by aw06, October 08, 2009, 05:38:08 PM

Previous topic - Next topic

aw06

I need the ssi function to display the pop to a user when they have new PM .. basically exactly like how it is within SMF itself
:: ShopinJA.com Powered by SMF 1.1.19 | Ig-Oh Theme by Koni | 70 Rock Solid Error Free Mods | Many Custom Edits & Tweaks ::
- Host Unlimited Websites - Free Website Builder & Templates - Unlimited Disk Space & Bandwidth

Arantor

It's not really practical to make this an SSI function since it doesn't work on regular HTML.

Normal SSI functions output body HTML, this would have to be <head> HTML.

That said, put the include of SSI as your first line, then inside the <head> tag (where <title> is):

<?php
echo '<script type="text/javascript">var msg = ' . ($context['user']['unread_messages'] > 'true' 'false') . ';
if(msg) {
  alert("You have new messages!");
}
</script>'
;
?>


Not as clean as the proper SMF one but it should work (NB not tested)

aw06

#2
ok, im using the pm informer mod  :-[

i just tried your code .. it pops up saying you have a message .. on click it does not go to the message ... and the popup comes everytime the page is refreshed.. if you you have no messages..

I replaced your code with the code from the pm informer mod ... it now goes to the message when clicked and it pop up looks just like it is in smf

<?php echo '<script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
      if (confirm("'
.$txt[318].': '.$context['pm_informer']['sender'].' \\n'.$txt[319].': '.$context['pm_informer']['subject'].' \\n  \\n' $txt['show_personal_messages'] . '" ))
         window.location = "' 
$scripturl '?action=pm" ;
   // ]]></script>'
;
?>


basically they same thing happens .. it is popped up on every refresh .. and also it does not catch the subject and pm title...

you can click here to see http://shopinja.com/forum/home.php .. it also displays an error when their is infact a pm

Notice: Undefined index: pm_informer and the error is on forum/Sources/Subs.php on line 3190 ...
:: ShopinJA.com Powered by SMF 1.1.19 | Ig-Oh Theme by Koni | 70 Rock Solid Error Free Mods | Many Custom Edits & Tweaks ::
- Host Unlimited Websites - Free Website Builder & Templates - Unlimited Disk Space & Bandwidth

aw06

all i need to do really if get rid of the error on the page .. i dont really need to pm popup ... i was hoping that using it would fix the error
:: ShopinJA.com Powered by SMF 1.1.19 | Ig-Oh Theme by Koni | 70 Rock Solid Error Free Mods | Many Custom Edits & Tweaks ::
- Host Unlimited Websites - Free Website Builder & Templates - Unlimited Disk Space & Bandwidth

Arantor

I know nothing of the PM Informer mod. You could ask about changes to that in the mod's own thread.

All my code does is advise there are new PMs, nothing more.


EDIT: The reason it doesn't work is because pm_informer doesn't exist outside of SMF, meaning it REALLY won't work in SSI setups.

What, *exactly* do you want from this?

aw06

oK .. using your code .. what happens is that even after you click ok .. when you refresh the pop up returnes .. can you put the lines in your code so that the user can click and it will open the pm ?
:: ShopinJA.com Powered by SMF 1.1.19 | Ig-Oh Theme by Koni | 70 Rock Solid Error Free Mods | Many Custom Edits & Tweaks ::
- Host Unlimited Websites - Free Website Builder & Templates - Unlimited Disk Space & Bandwidth

Arantor

Try:
<?php
echo '<script type="text/javascript">var msg = ' . ($context['user']['unread_messages'] > 'true' 'false') . ';
if(msg) {
  if(confirm("You have ' 
$context['user']['unread_messages'] . ' new message(s)!")) {
    window.location = "' 
$scripturl '?action=pm";
  }
}
</script>'
;
?>

aw06

ok that .. works .. but still getting this error message displayed on the page

Notice: Undefined index: pm_informer in /home/xxxxxx/xxxxxxx/xxxx/Sources/Subs.php on line 3190


Seems i may have to uninstall this mod :(
:: ShopinJA.com Powered by SMF 1.1.19 | Ig-Oh Theme by Koni | 70 Rock Solid Error Free Mods | Many Custom Edits & Tweaks ::
- Host Unlimited Websites - Free Website Builder & Templates - Unlimited Disk Space & Bandwidth

Arantor

Yes, that's nothing to do with my code.

aw06

can i not bypass the pm informer ?? or call it into the page somehow ? .. or add some code to hide errors from mod that dont output ssi ?
:: ShopinJA.com Powered by SMF 1.1.19 | Ig-Oh Theme by Koni | 70 Rock Solid Error Free Mods | Many Custom Edits & Tweaks ::
- Host Unlimited Websites - Free Website Builder & Templates - Unlimited Disk Space & Bandwidth

Arantor

No, since it's in Subs.php and is obviously broken in some way.

aw06

ok , i know i should get support from the mod topic ... but can you quickly look at the codes .. perhaps you can quickly advise on a fix for it to output ssi..

./Sources/Load.php
//Pm Warning...
function loadPmWarning()
{
global $scripturl, $db_prefix, $ID_MEMBER, $context, $user_info, $func;

//Gimme the newest pm, if we have.
if(!empty($user_info['unread_messages'])) {
$request = db_query("
SELECT
pm.ID_PM, pm.ID_MEMBER_FROM, pm.fromName, pm.msgtime, pm.subject, pm.body
FROM {$db_prefix}personal_messages AS pm
LEFT JOIN {$db_prefix}pm_recipients AS pmr ON (pmr.ID_PM = pm.ID_PM)
WHERE pmr.is_read = 0 AND pmr.ID_MEMBER = $ID_MEMBER
ORDER BY pm.msgtime DESC
LIMIT 1", __FILE__, __LINE__);
$context['pm_informer'] = array();
while ($row = mysql_fetch_assoc($request))
{
//You can't be so looongggg. He he. :)
if ($func['strlen']($row['body']) > 250)
$row['body'] = $func['substr']($row['body'], 0, 250) . '<a href="' . $scripturl . '?action=pm#msg' . $row['ID_PM'] . '">...</a>';

// Build the array.
$context['pm_informer'] = array(
'from' => $row['ID_MEMBER_FROM'],
'sender' => $row['fromName'],
'msgtime' => timeformat($row['msgtime'], false),
'subject' => $row['subject'],
'body' => parse_bbc($row['body']),
);
}
mysql_free_result($request);
}
}



./Sources/Subs.php
if (confirm("'.$txt[318].': '.$context['pm_informer']['sender'].' \\n'.$txt[319].': '.$context['pm_informer']['subject'].' \\n  \\n' . $txt['show_personal_messages'] . '" ))

./index.php
// Is there new pms? PM Informer...
loadPmWarning();


Or perhaps you can tell me how to hardcode what the mod does into smf  :-[
:: ShopinJA.com Powered by SMF 1.1.19 | Ig-Oh Theme by Koni | 70 Rock Solid Error Free Mods | Many Custom Edits & Tweaks ::
- Host Unlimited Websites - Free Website Builder & Templates - Unlimited Disk Space & Bandwidth

Arantor

Add loadPmWarning() to SSI.php after Subs.php has been loaded; early on in SSI.php there is a set of require instructions, to Load.php and others. Add it after that.

aw06

Sorry, but i dont quite follow .... what exatly should i do ?

// Load the important includes.
require_once($sourcedir . '/QueryString.php');
require_once($sourcedir . '/Subs.php');
require_once($sourcedir . '/Errors.php');
require_once($sourcedir . '/Load.php');
require_once($sourcedir . '/Security.php');
:: ShopinJA.com Powered by SMF 1.1.19 | Ig-Oh Theme by Koni | 70 Rock Solid Error Free Mods | Many Custom Edits & Tweaks ::
- Host Unlimited Websites - Free Website Builder & Templates - Unlimited Disk Space & Bandwidth

Arantor

After those lines, add:
loadPmWarning();

aw06

 :-[ still getting the error message
:: ShopinJA.com Powered by SMF 1.1.19 | Ig-Oh Theme by Koni | 70 Rock Solid Error Free Mods | Many Custom Edits & Tweaks ::
- Host Unlimited Websites - Free Website Builder & Templates - Unlimited Disk Space & Bandwidth

Arantor


aw06

error log is clean .. it does not show up in the error logs ... it displays at the top of the page for all to see ...

Notice: Undefined index: pm_informer in /home/xxxxxx/xxxxxxx/xxxx/Sources/Subs.php on line 3190

It goes away on refresh
:: ShopinJA.com Powered by SMF 1.1.19 | Ig-Oh Theme by Koni | 70 Rock Solid Error Free Mods | Many Custom Edits & Tweaks ::
- Host Unlimited Websites - Free Website Builder & Templates - Unlimited Disk Space & Bandwidth

Arantor

So, what's line 3190 of your Subs.php, and the 10 or so lines immediately above it?

aw06

This is on line 3190
if (confirm("'.$txt[318].': '.$context['pm_informer']['sender'].' \\n'.$txt[319].': '.$context['pm_informer']['subject'].' \\n  \\n' . $txt['show_personal_messages'] . '" ))


More Code above
$context['in_maintenance'] = !empty($maintenance);
$context['current_time'] = timeformat(time(), false);
$context['current_action'] = isset($_GET['action']) ? $_GET['action'] : '';
$context['show_quick_login'] = !empty($modSettings['enableVBStyleLogin']) && $user_info['is_guest'];

if (empty($settings['theme_version']))
$context['show_vBlogin'] = $context['show_quick_login'];

// This is here because old index templates might still use it.
$context['show_news'] = !empty($settings['enable_news']);

// This is done to make it easier to add to all themes...
if ($context['user']['popup_messages'] && !empty($options['popup_messages']) && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'pm'))
{
$context['html_headers'] .= '
<script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
if (confirm("'.$txt[318].': '.$context['pm_informer']['sender'].' \\n'.$txt[319].': '.$context['pm_informer']['subject'].' \\n  \\n' . $txt['show_personal_messages'] . '" ))
window.location = "' . $scripturl . '?action=pm" ;
// ]]></script>';
}
:: ShopinJA.com Powered by SMF 1.1.19 | Ig-Oh Theme by Koni | 70 Rock Solid Error Free Mods | Many Custom Edits & Tweaks ::
- Host Unlimited Websites - Free Website Builder & Templates - Unlimited Disk Space & Bandwidth

Advertisement: