.Tim
12-03-2005, 10:00 PM
This is a port of this:
https://vborg.vbsupport.ru/showthread.php?t=59890
Not much was changed from the original, other than a few minor code changes. Don't know if it was done in the best way but it works. :D I don't know of a way this could be done without file edits. If anyone has any ideas, they're more than welcome. And I also plan on making this optional for users, so they can decide if they want this or the normal popup.
-------------------
Open root/global.php
-------------------
------------
Find:
------------
// new private message script
'pm_popup_script',
-------------
Replace with:
-------------
// new private message script
'pm_new_globals',
------------
Find:
------------
// ################################################## ###########################
// get new private message popup
$shownewpm = false;
if ($vbulletin->userinfo['pmpopup'] == 2 AND $vbulletin->options['checknewpm'] AND $vbulletin->userinfo['userid'] AND !defined('NOPMPOPUP'))
{
$userdm =& datamanager_init('User', $vbulletin, ERRTYPE_SILENT);
$userdm->set_existing($vbulletin->userinfo);
$userdm->set('pmpopup', 1);
$userdm->save(true, 'pmpopup'); // 'pmpopup' tells db_update to issue a shutdownquery of the same name
unset($userdm);
if (THIS_SCRIPT != 'private' AND THIS_SCRIPT != 'login')
{
$newpm = $db->query_first("
SELECT pm.pmid, title, fromusername
FROM " . TABLE_PREFIX . "pmtext AS pmtext
LEFT JOIN " . TABLE_PREFIX . "pm AS pm USING(pmtextid)
WHERE pm.userid = " . $vbulletin->userinfo['userid'] . "
ORDER BY dateline DESC
LIMIT 1
");
$newpm['username'] = addslashes_js(unhtmlspecialchars($newpm['fromusername'], true), '"');
$newpm['title'] = addslashes_js(unhtmlspecialchars($newpm['title'], true), '"');
$shownewpm = true;
}
}
-------------
Replace with:
-------------
// get new private message alert - hack
$newpmmsg = 0;
$shownewpm = false;
if ($vbulletin->userinfo['pmpopup'] == 2 AND $vbulletin->options['checknewpm'] AND $vbulletin->userinfo['userid'] AND $vbulletin->userinfo['pmpopup'] == 2)
{
$userdm =& datamanager_init('User', $vbulletin, ERRTYPE_SILENT);
$userdm->set_existing($vbulletin->userinfo);
$userdm->set('pmpopup', 1);
$userdm->save(true, 'pmpopup'); // 'pmpopup' tells db_update to issue a shutdownquery of the same name
unset($userdm);
if (THIS_SCRIPT != 'private')
{
$newpmmsg = 1;
$newpm = $db->query_first("
SELECT pm.pmid, title, fromusername, fromuserid
FROM " . TABLE_PREFIX . "pmtext AS pmtext
LEFT JOIN " . TABLE_PREFIX . "pm AS pm USING(pmtextid)
WHERE pm.userid = ". $vbulletin->userinfo['userid'] ."
ORDER BY dateline DESC
LIMIT 1
");
require_once('./includes/functions_user.php');
$pm_avaurl = fetch_avatar_url($newpm['fromuserid']);
if (empty($pm_avaurl))
{
$showpm_ava = false;
}
else
{
$showpm_ava = true;
}
// end hack - new pm notifacation
$newpm['username'] = unhtmlspecialchars($newpm['fromusername'], true);
$newpm['userid'] = unhtmlspecialchars($newpm['fromuserid'], true);
$newpm['title'] = unhtmlspecialchars($newpm['title'], true);
$shownewpm = true;
}
}
-----------
Find:
-----------
if ($shownewpm)
{
if ($vbulletin->userinfo['pmunread'] == 1)
{
$pmpopupurl = 'private.php?' . $vbulletin->session->vars['sessionurl_js'] . "do=showpm&pmid=$newpm[pmid]";
}
else
{
if (!empty($vbulletin->session->vars['sessionurl_js']))
{
$pmpopupurl = 'private.php?' . $vbulletin->session->vars['sessionurl_js'];
}
else
{
$pmpopupurl = 'private.php';
}
}
eval('$footer .= "' . fetch_template('pm_popup_script') . '";');
}
-------------
Replace with:
-------------
if ($shownewpm)
{
eval('$newpm = "' . fetch_template('pm_new_globals') . '";');
}
else
{
$newpm = '';
}
/* - end file edits, now for the templates!:
---------------------
Open template: navbar
---------------------
At the very end of the template add:
<br />
$newpm
--------------------------------
Add new template: pm_new_globals
--------------------------------
Populate it with:
<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<tr><if condition="$newpm">
<td class="alt1" width="100%">
<div class="smallfont"><img src="./image.php?u=$newpm[userid]" alt="$newpm[username]'s avatar" border="0" /></div>
</td> </if>
<td class="alt2" valign="top" nowrap="nowrap">
<div class="smallfont">$bbuserinfo[username] you have a new private message from $newpm[username], subject: '$newpm[title]'<br /><a
href="private.php?$session[sessionurl]" TARGET="_blank">Click here to enter your private message area</a></div>
</td>
</tr>
</table>
https://vborg.vbsupport.ru/showthread.php?t=59890
Not much was changed from the original, other than a few minor code changes. Don't know if it was done in the best way but it works. :D I don't know of a way this could be done without file edits. If anyone has any ideas, they're more than welcome. And I also plan on making this optional for users, so they can decide if they want this or the normal popup.
-------------------
Open root/global.php
-------------------
------------
Find:
------------
// new private message script
'pm_popup_script',
-------------
Replace with:
-------------
// new private message script
'pm_new_globals',
------------
Find:
------------
// ################################################## ###########################
// get new private message popup
$shownewpm = false;
if ($vbulletin->userinfo['pmpopup'] == 2 AND $vbulletin->options['checknewpm'] AND $vbulletin->userinfo['userid'] AND !defined('NOPMPOPUP'))
{
$userdm =& datamanager_init('User', $vbulletin, ERRTYPE_SILENT);
$userdm->set_existing($vbulletin->userinfo);
$userdm->set('pmpopup', 1);
$userdm->save(true, 'pmpopup'); // 'pmpopup' tells db_update to issue a shutdownquery of the same name
unset($userdm);
if (THIS_SCRIPT != 'private' AND THIS_SCRIPT != 'login')
{
$newpm = $db->query_first("
SELECT pm.pmid, title, fromusername
FROM " . TABLE_PREFIX . "pmtext AS pmtext
LEFT JOIN " . TABLE_PREFIX . "pm AS pm USING(pmtextid)
WHERE pm.userid = " . $vbulletin->userinfo['userid'] . "
ORDER BY dateline DESC
LIMIT 1
");
$newpm['username'] = addslashes_js(unhtmlspecialchars($newpm['fromusername'], true), '"');
$newpm['title'] = addslashes_js(unhtmlspecialchars($newpm['title'], true), '"');
$shownewpm = true;
}
}
-------------
Replace with:
-------------
// get new private message alert - hack
$newpmmsg = 0;
$shownewpm = false;
if ($vbulletin->userinfo['pmpopup'] == 2 AND $vbulletin->options['checknewpm'] AND $vbulletin->userinfo['userid'] AND $vbulletin->userinfo['pmpopup'] == 2)
{
$userdm =& datamanager_init('User', $vbulletin, ERRTYPE_SILENT);
$userdm->set_existing($vbulletin->userinfo);
$userdm->set('pmpopup', 1);
$userdm->save(true, 'pmpopup'); // 'pmpopup' tells db_update to issue a shutdownquery of the same name
unset($userdm);
if (THIS_SCRIPT != 'private')
{
$newpmmsg = 1;
$newpm = $db->query_first("
SELECT pm.pmid, title, fromusername, fromuserid
FROM " . TABLE_PREFIX . "pmtext AS pmtext
LEFT JOIN " . TABLE_PREFIX . "pm AS pm USING(pmtextid)
WHERE pm.userid = ". $vbulletin->userinfo['userid'] ."
ORDER BY dateline DESC
LIMIT 1
");
require_once('./includes/functions_user.php');
$pm_avaurl = fetch_avatar_url($newpm['fromuserid']);
if (empty($pm_avaurl))
{
$showpm_ava = false;
}
else
{
$showpm_ava = true;
}
// end hack - new pm notifacation
$newpm['username'] = unhtmlspecialchars($newpm['fromusername'], true);
$newpm['userid'] = unhtmlspecialchars($newpm['fromuserid'], true);
$newpm['title'] = unhtmlspecialchars($newpm['title'], true);
$shownewpm = true;
}
}
-----------
Find:
-----------
if ($shownewpm)
{
if ($vbulletin->userinfo['pmunread'] == 1)
{
$pmpopupurl = 'private.php?' . $vbulletin->session->vars['sessionurl_js'] . "do=showpm&pmid=$newpm[pmid]";
}
else
{
if (!empty($vbulletin->session->vars['sessionurl_js']))
{
$pmpopupurl = 'private.php?' . $vbulletin->session->vars['sessionurl_js'];
}
else
{
$pmpopupurl = 'private.php';
}
}
eval('$footer .= "' . fetch_template('pm_popup_script') . '";');
}
-------------
Replace with:
-------------
if ($shownewpm)
{
eval('$newpm = "' . fetch_template('pm_new_globals') . '";');
}
else
{
$newpm = '';
}
/* - end file edits, now for the templates!:
---------------------
Open template: navbar
---------------------
At the very end of the template add:
<br />
$newpm
--------------------------------
Add new template: pm_new_globals
--------------------------------
Populate it with:
<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<tr><if condition="$newpm">
<td class="alt1" width="100%">
<div class="smallfont"><img src="./image.php?u=$newpm[userid]" alt="$newpm[username]'s avatar" border="0" /></div>
</td> </if>
<td class="alt2" valign="top" nowrap="nowrap">
<div class="smallfont">$bbuserinfo[username] you have a new private message from $newpm[username], subject: '$newpm[title]'<br /><a
href="private.php?$session[sessionurl]" TARGET="_blank">Click here to enter your private message area</a></div>
</td>
</tr>
</table>