vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 2.x Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=4)
-   -   Improved PM Popup JavaScript (https://vborg.vbsupport.ru/showthread.php?t=34356)

TWTCommish 01-21-2002 10:00 PM

What's it do?
Simple: it checks to see how many new PMs a user has. If they've only got one (which is usually the case...I don't think many people get tons of new PMs), the popup JavaScript alert displayed to them will let them know who sent them the message, what it's title is, and, rather than take them to the Inbox, it'll take them directly to the message.

If there's more than one, it'll display a more vague message, letting them know just how many new messages they have, and redirecting them to their Inbox (which is where the current popup directs you). Anyway, here's the hack:


Open global.php. Around line 266 you should see the following:

Code:

$newpmmsg=1;
RIGHT below it, place this (REPLACE your current code for this hack with the code below, if you happen to be one of the few people who actually intalled this originally from the Beta Hacks forum. :))

Code:

  $latest_pm = $DB_site->query("SELECT p.privatemessageid AS pm_popup_id, p.title AS pm_popup_title, u.username AS pm_popup_username FROM privatemessage p, user u WHERE messageread = 0 AND p.userid = $bbuserinfo[userid] AND p.fromuserid = u.userid ORDER BY dateline DESC");
  $hack_pm_total  = $DB_site->num_rows($latest_pm);
 
    if ($hack_pm_total > 1) {
      eval("\$pm_popup_text = \"".gettemplate('pm_popup_multiple')."\";");
      eval("\$pm_popup_url  = \"".gettemplate('pm_popup_url_multiple')."\";");
    } else {
      extract($DB_site->fetch_array($latest_pm));
      eval("\$pm_popup_text = \"".gettemplate('pm_popup')."\";");
      eval("\$pm_popup_url  = \"".gettemplate('pm_popup_url')."\";");
    }

Now, create the four new templates. I've attached a file to this post containing the names of the four templates, and the text I've used to populate them -- which will probably be the same text and such you'll want to use. Don't be intimidated...they're all very small. :)

After that, edit your head_newpm template to make use of the new variables. Here's my use of it (highly suggested):

Code:

<script language="JavaScript">
<!--
function confirm_newpm() {
        input_box = confirm("$pm_popup_text");
        if (input_box == true) { // Output when OK is clicked
                second_box = confirm("Open in new window?\n\n(Press cancel to open your $inboxname in the current window.)");
                if (second_box == true) {
                        window.open('$pm_popup_url','pmnew','width=600,height=500,menubar=yes,scrollbars=yes,toolbar=yes,location=yes,directories=yes,resizable=yes,top=50,left=50');
                } else {
                        window.location = "$pm_popup_url";
                }
        } else {
        // Output when Cancel is clicked
        }
}
-->
</script>

Enjoy.

TWTCommish 01-22-2002 12:52 PM

Here's an image of what the single-PM popup looks like:
https://vborg.vbsupport.ru/attachmen...414&fullpage=1

Scott MacVicar 01-22-2002 02:11 PM

you could have moved the thread from the beta forum to the full releases forum you know :P cause you have permission to do that.

anyway i've installed something like this, but it shows you how many unread messages you have and the last time and username

TWTCommish 01-22-2002 02:16 PM

Actually, I contacted FireFly via PM and asked him how I should go about this, and he advised me to create a new thread and close the old one; so I did. :) I also sent an update to the old users informing them of the new thread.

Quote:

anyway i've installed something like this, but it shows you how many unread messages you have and the last time and username
I'm afraid I don't understand. :confused: My hack does the same thing, doesn't it? If you have more than one, it tells you how many you have waiting and takes you to the Inbox. If you have only one, it gives you the title, the sender's username, and takes you right to the message itself. Perhaps you're thinking of the functionality of this hack when I released it in the Beta forum, rather than it's functionality now.

Ninth Dimension 01-22-2002 06:57 PM

This is a cool hack, i've just installed it, thank you.

One question, and as always, I could be wrong, but should this line not be removed from the file?
PHP Code:

  eval("\$headnewpm = \"".gettemplate('head_newpm')."\";"); 

Thanx

TWTCommish 01-22-2002 07:22 PM

From what file -- global.php? No! That's the part that processes the finished template and makes it available globally. :) Absolutely essential.

Ninth Dimension 01-22-2002 07:28 PM

ah ok, my bad :)

TWTCommish 01-22-2002 07:29 PM

No problem: thanks for installing it. I'm glad you like it. :) I get a real kick out of anyone who finds this stuff useful.

squawell 01-23-2002 10:13 AM

a good hack!!but it seems can't work for me!!i think maybe i do something wrong??see the below code what i change to
PHP Code:

 $newpmmsg=1
    
$latest_pm $DB_site->query("SELECT p.privatemessageid AS pm_popup_id, p.title AS pm_popup_title, u.username AS pm_popup_username FROM privatemessage p, user u WHERE messageread = 0 AND touserid = $bbuserinfo[userid] AND p.fromuserid = u.userid ORDER BY dateline DESC");
    
$hack_pm_total  $DB_site->num_rows($latest_pm);
  
    if (
$hack_pm_total 1) {
      eval(
"\$pm_popup_text = \"".gettemplate('pm_popup_multiple')."\";");
      eval(
"\$pm_popup_url  = \"".gettemplate('pm_popup_url_multiple')."\";");
    } else {
      
extract($DB_site->fetch_array($latest_pm));
      eval(
"\$pm_popup_text = \"".gettemplate('pm_popup')."\";");
      eval(
"\$pm_popup_url  = \"".gettemplate('pm_popup_url')."\";");
    }

    eval(
"\$headnewpm = \"".gettemplate('head_newpm')."\";");
  } 

am i do something wrong??

TWTCommish 01-23-2002 12:09 PM

Hmmm -- did you install the templates, too?

TheComputerGuy 01-23-2002 12:51 PM

I installed it, its just what the dr. ordered!!

I want to know whats it about prior to reading it!

TWTCommish 01-23-2002 12:59 PM

Glad you like it. Thanks very much. :) People saying they like it, and using it, is very rewarding!

squawell 01-23-2002 02:02 PM

Quote:

Originally posted by TWTCommish
Hmmm -- did you install the templates, too?
i'm sure i have created those templates~~

Lionel 01-23-2002 02:20 PM

but the pm are coming in normally like before...

Lionel 01-23-2002 02:23 PM

maybe my mistake. I just discovered a mistake in template name. By accident I had cut the full line.

Lionel 01-23-2002 11:15 PM

I can't get this hack to work. I am going to try by removing _txt in intructions

eval("\$pm_popup_text = \"".gettemplate('pm_popup_multiple')."

TWTCommish 01-23-2002 11:18 PM

Removing what? I've got no idea what you're talking about. :)

Lionel 01-23-2002 11:24 PM

shouldn't that:

eval("\$pm_popup_text = \"".gettemplate('pm_popup_multiple')."

be:

eval("\$pm_popup_multiple = \"".gettemplate('pm_popup_multiple')."

TWTCommish 01-23-2002 11:27 PM

No. That won't work. :) The value of $pm_popup_text is what goes in the head_pm template. The value is either from the one template, or the other. There are two variables that need to be filled before the head_pm template is called...the var names, therefore, are identical in the if() half, and the else half.

Maybe I can help: what's gone wrong? Have you gone over the steps again to make sure you did them all correctly?

Lionel 01-23-2002 11:30 PM

well this a fairly simple hack... I placed in global as instructed and cipy and pasted the four templates. double and triple check templates and did cut and paste for global.

TWTCommish 01-23-2002 11:35 PM

Can you post that block of code you have (the code around it, too) in global.php? If you don't want to, that's okay...just wanna help. :) You're right, it is a simple hack, by most hack standards.

TWTCommish 01-23-2002 11:39 PM

Quote:

Originally posted by squawell
i'm sure i have created those templates~~
Any progress? I'd be glad to help if I can. Are you sure you've tried it with any new PMs? Sometimes the vBulletin PM popups don't popup, for no apparent reason. You might want to try it more than once.

Lionel 01-23-2002 11:40 PM

$newpmmsg=0;
$headnewpm='';
if ($checknewpm and $bbuserinfo['userid']!=0 and $bbuserinfo['pmpopup']==2) {
if ($noshutdownfunc) {
$DB_site->query("UPDATE user SET pmpopup=1 WHERE userid=$bbuserinfo[userid]");
} else {
$shutdownqueries[]="UPDATE LOW_PRIORITY user SET pmpopup=1 WHERE userid=$bbuserinfo[userid]";
}
$newpmmsg=1;

$latest_pm = $DB_site->query("SELECT p.privatemessageid AS pm_popup_id, p.title AS pm_popup_title, u.username AS pm_popup_username FROM privatemessage p, user u WHERE messageread = 0 AND touserid = $bbuserinfo[userid] AND p.fromuserid = u.userid ORDER BY dateline DESC");
$hack_pm_total = $DB_site->num_rows($latest_pm);

if ($hack_pm_total > 1) {
eval("\$pm_popup_text = \"".gettemplate('pm_popup_multiple')."\";");
eval("\$pm_popup_url = \"".gettemplate('pm_popup_url_multiple')."\";") ;
} else {
extract($DB_site->fetch_array($latest_pm));
eval("\$pm_popup_text = \"".gettemplate('pm_popup')."\";");
eval("\$pm_popup_url = \"".gettemplate('pm_popup_url')."\";");
}

eval("\$headnewpm = \"".gettemplate('head_newpm')."\";");
}

TWTCommish 01-23-2002 11:43 PM

You should use the code tags next time -- the lack of formatting really hurts the legibility. :)

Anyway, the code looks good. Are you positive the templates are right? Do you get any JS errors? What I did to debug this the first time around was, if it didn't show up, I'd check the HTML on the page to see if the JS was actually there or not. If it's not, that means it hasn't detected a new PM at all. You might need to try it more than once to make sure it's not just a fluke, as it is now and then with vB's JS popup, it seems.

Lionel 01-23-2002 11:46 PM

no errors. It pops up normal like before. But does not tell me the details

TWTCommish 01-23-2002 11:51 PM

Oh! I'm so very, very stupid. I forget the template change. Go back to the first post...I'll edit it as soon as I post this to include the last change needed.

Lionel 01-23-2002 11:57 PM

I put the new part in head_pm. Should I remove old? cause I just got one with no details.

TWTCommish 01-23-2002 11:59 PM

Yes, you're replacing your entire head_newpm template. That should do the trick.

Lionel 01-24-2002 12:03 AM

ok, I just did and awaiting for nex pm... i'll let you know... thanks..

TWTCommish 01-24-2002 12:06 AM

Well, if you want to know sooner, you can just send one to yourself. :) How do you think I tested it? I sure as heck didn't wait for someone to send me one each time. :D Anyway, I hope you like it.

Lionel 01-24-2002 12:13 AM

on the forum index page but I have to wait for one to test it on site index page, cause when I log in it takes me straight into forum index. Usually they popup when I get on site.

Lionel 01-24-2002 12:13 AM

thanks for help

Ninth Dimension 01-24-2002 12:35 AM

Ah good, an update, i'll be sure to change that :)

Ninth Dimension 01-24-2002 12:45 AM

Hi, eeerrrmmm, i'm not getting any pop-ups, come to think of it, I did not get any before either, any ideas?

Ninth Dimension 01-24-2002 12:48 AM

I've just checked, and the script is being called into the page when I get a new message, but it's not doing anything, here is the script:
Code:

<!-- BEGIN TEMPLATE: head_newpm -->
<script language="JavaScript">
<!--
function confirm_newpm() {
        input_box = confirm("<!-- BEGIN TEMPLATE: pm_popup -->
You have a new private message from ofDan entitled \"Re: test.\"\nClick OK to view it, or cancel to hide this prompt.
<!-- END TEMPLATE: pm_popup -->");
        if (input_box == true) { // Output when OK is clicked
                second_box = confirm("Open in new window?\n\n(Press cancel to open your Inbox in the current window.)");
                if (second_box == true) {
                        window.open('<!-- BEGIN TEMPLATE: pm_popup_url -->
private.php?action=show&privatemessageid=674
<!-- END TEMPLATE: pm_popup_url -->','pmnew','width=600,height=500,menubar=yes,scrollbars=yes,toolbar=yes,location=yes,directories=yes,resizable=yes,top=50,left=50');
                } else {
                        window.location = "<!-- BEGIN TEMPLATE: pm_popup_url -->
private.php?action=show&privatemessageid=674
<!-- END TEMPLATE: pm_popup_url -->";
                }
        } else {
        // Output when Cancel is clicked
        }
}
-->
</script>

<!-- END TEMPLATE: head_newpm -->


Ninth Dimension 01-24-2002 12:51 AM

I just saw a problem, I had my template tags turned on, which I believed might have been the cause of the problem, so I tuned them off, and it's still not working
Code:

<script language="JavaScript">
<!--
function confirm_newpm() {
        input_box = confirm("You have a new private message from ofDan entitled \"Re: test.\"\nClick OK to view it, or cancel to hide this prompt.");
        if (input_box == true) { // Output when OK is clicked
                second_box = confirm("Open in new window?\n\n(Press cancel to open your Inbox in the current window.)");
                if (second_box == true) {
                        window.open('private.php?action=show&privatemessageid=676','pmnew','width=600,height=500,menubar=yes,scrollbars=yes,toolbar=yes,location=yes,directories=yes,resizable=yes,top=50,left=50');
                } else {
                        window.location = "private.php?action=show&privatemessageid=676";
                }
        } else {
        // Output when Cancel is clicked
        }
}
-->
</script>


squawell 01-24-2002 01:12 AM

Quote:

Originally posted by TWTCommish

Any progress? I'd be glad to help if I can. Are you sure you've tried it with any new PMs? Sometimes the vBulletin PM popups don't popup, for no apparent reason. You might want to try it more than once.

it have the popup window but still the old one!! :dead:

now i change the head_pm template like ur first post say

but no popup window??any idea??

Lionel 01-24-2002 01:16 AM

go back to the first post for the fix (new template)

Lionel 01-24-2002 01:19 AM

If I get more than one PM, the popup says you have an email from (blank) entitled (blank) but that is not the problem... It gets confused an open me a page that says the message cannot be found... maybe we should redirect to PM box?

TWTCommish 01-24-2002 01:30 AM

Are you sure? You have more than one new PM, and yet it only acts as if there's one? Keep in mind that if you have 2 new PMs and get a popup, and then send yourself another, the popup will only "see" one. That's the way the system works.

Daniel: that looks like it should work. Does your <body> tag on that same page at the same time have an onload="" attribute calling the confirm_newpm() function?

squawell: as Lionel said, please replace your head_newpm template with the one now listed in the first post of this thread. :)


All times are GMT. The time now is 04:44 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01235 seconds
  • Memory Usage 1,839KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (5)bbcode_code_printable
  • (2)bbcode_php_printable
  • (4)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete