1
Twilo
Private Messaging
  • 2005/11/19 8:24

  • Twilo

  • Just popping in

  • Posts: 24

  • Since: 2003/4/24


When a person sends a private message, a popup block will automaticly show up to the receiver screen. Could we do this?

2
OldFriend
Re: Private Messaging
  • 2005/11/19 10:53

  • OldFriend

  • Just popping in

  • Posts: 99

  • Since: 2005/10/28


I looked into this and couldn't find a way to do it.

So I added a block to another module that I am developing. I have intended to produce a module containing the block for distribution but haven't gotten around to it yet.

It needs to be changed to cater for multi-language support, but I haven't gotten around to it yet either.

I also want to add to it to notify when a "Notification" from the notify system is there.

The code is quite simple. I have only used it for XOOPS 2.2.2 so I don't know if it will work in other versions.

<?php
// 
// ------------------------------------------------------------------------- //
//               E-Xoops: Content Management for the Masses                  //
//                       < http://www.xoops.com > & ... nbsp;   //
// ------------------------------------------------------------------------- //
// ------------------------------------------------------------------------- //

function Check_PM()
{
    global 
$xoopsDB,$xoopsUser;
    if (
is_object($xoopsUser)) {
        
$uid $xoopsUser->getVar('uid');
        
$uname $xoopsUser->getVar('uname');
        
$sql "SELECT COUNT(*) FROM $db->prefix('priv_msgs`) WHERE `to_userid` = $uid AND `read_msg` = 0";
        
$result $xoopsDB->query($sql);
        list(
$count_PMs) = $xoopsDB->fetchRow($result);
        switch (
$count_PMs):
        case 
0:
            Return 
false;
        case 
1:
            
$block['message'] = "<a href=".XOOPS_URL."/modules/pm/>".$uname." you have ".$count_PMs." unread message.</a>";
            break;
        default:
            
$block['message'] = "<a href=".XOOPS_URL."/modules/pm/>".$uname." you have ".$count_PMs." unread messages.</a>";
        endswitch;
        Return 
$block;
    } else {
        Return 
false;
    }
}

?>

3
shank
Re: Private Messaging
  • 2005/12/12 1:59

  • shank

  • Not too shy to talk

  • Posts: 144

  • Since: 2004/8/17


You can use javascript in your theme to do this.

Let me do it again and i'll post back how.

The pop up will show next time the logo is loaded while they are logged in.

Check back later.
s l s h a n k l e @ b e l l s o u t h . n e t

4
shank
Re: Private Messaging
  • 2005/12/12 2:16

  • shank

  • Not too shy to talk

  • Posts: 144

  • Since: 2004/8/17


Replace the < body > tag in your theme with
<{if $xoops_isuser}><{insert name="pms"}>
<{if 
$msgcount 0}>
<
body onLoad="javascript: alert('Check Your Inbox!')"><{/if}><{else}><body><{/if}><{else}><body><{/if}>


And save the following as insert.pms.php in your class/smarty/plugins folder
<?
function 
smarty_insert_pms()
{
GLOBAL 
$xoopsUser;
$pm_handler =& xoops_gethandler('privmessage');
$uid $xoopsUser->getVar('uid');
$criteria = new CriteriaCompo(new Criteria('read_msg'0));
$criteria->add(new Criteria('to_userid'$uid));
$msgcount $pm_handler->getCount($criteria);
$GLOBALS['xoopsTpl']->assign('msgcount'$msgcount);
}
?>
s l s h a n k l e @ b e l l s o u t h . n e t

5
dannymac
Re: Private Messaging
  • 2005/12/13 15:43

  • dannymac

  • Just popping in

  • Posts: 8

  • Since: 2005/11/22


Hi there, can you elaborate a little on what you mean by "replace the < body > tag". I've tried a few different things but it always seems to destroy my template..

6
shank
Re: Private Messaging
  • 2005/12/13 19:09

  • shank

  • Not too shy to talk

  • Posts: 144

  • Since: 2004/8/17


In your theme.html file

change
<body>


to
<{if $xoops_isuser}><{insert name="pms"}>
<{if 
$msgcount 0}>
<
body onLoad="java script: alert('Check Your Inbox!')"><{else}><body><{/if}><{else}><body><{/if}>
s l s h a n k l e @ b e l l s o u t h . n e t

7
dannymac
Re: Private Messaging
  • 2005/12/13 19:25

  • dannymac

  • Just popping in

  • Posts: 8

  • Since: 2005/11/22


Hrm, well I've tried that and it doesn't seem to do anything. No popup... It's not destroying my page anymore though :).

Any thaughts?.. could a different part of theme.html be interfearing?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<{$xoops_langcode}>" lang="<{$xoops_langcode}>">
<
head>
<
meta http-equiv="content-type" content="text/html; charset=<{$xoops_charset}>" />
<
meta http-equiv="content-language" content="<{$xoops_langcode}>" />
<
meta name="robots" content="<{$xoops_meta_robots}>" />
<
meta name="keywords" content="<{$xoops_meta_keywords}>" />
<
meta name="description" content="<{$xoops_meta_description}>" />
<
meta name="rating" content="<{$xoops_meta_rating}>" />
<
meta name="author" content="<{$xoops_meta_author}>" />
<
meta name="copyright" content="<{$xoops_meta_copyright}>" />
<
meta name="generator" content="XOOPS" />
<
title><{$xoops_sitename}> - <{$xoops_pagetitle}></title>
<
link href="<{$xoops_url}>/favicon.ico" rel="SHORTCUT ICON" />
<
link rel="stylesheet" type="text/css" media="all" href="<{$xoops_url}>/xoops.css" />
<
link rel="stylesheet" type="text/css" media="all" href="<{$xoops_themecss}>" />
<{
$xoops_module_header}>
<
script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</
script>
<
script type="text/javascript">
_uacct "#######";
urchinTracker();
</
script>

<
script type="text/javascript">
<!--
<{
$xoops_js}>
//-->
</script>
</
head>
<{if 
$xoops_isuser}><{insert name="pms"}>
<{if 
$msgcount 0}>
<
body onLoad="java script: alert('Check Your Inbox!')"><{else}><body><{/if}><{else}><body><{/if}>
<
table cellspacing="0" cellpadding="0" class="bg">
<
tr><td>
<
table cellspacing="0" cellpadding="0" class="bg1">
<
tr><td class="header">
<
img src="<{$xoops_url}>/themes/<{$xoops_theme}>/images/logo.png" alt="logo" /></a>
</
td>
</
tr>
<
tr><td colspan="2" class="topnav">

<!-- 
navibar set -->
<
a href="<{$xoops_url}>/">Home</a>
&
nbsp;&nbsp;
<
a href="<{$xoops_url}>/modules/news/">News</a>
&
nbsp;&nbsp;
<
a href="<{$xoops_url}>/modules/newbb/">Forum</a>
&
nbsp;&nbsp;
<
a href="<{$xoops_url}>/user.php">Profile</a>
&
nbsp;&nbsp;
<
a href="<{$xoops_url}>/search.php">Search</a>
&
nbsp;&nbsp;
<
a href="<{$xoops_url}>/register.php">Register</a>

</
td></tr></table>
</
td></tr>
<
tr><td>
<
table cellspacing="2" cellpadding="2"><tr><td width="20%">

<!-- 
Start left blocks loop -->

<{foreach 
item=block from=$xoops_lblocks}>
<
table class="outline"><tr><td>
<
table cellspacing="0" cellpadding="2">
<
tr><td class="blockTitle2">&nbsp;<{$block.title}></td></tr>
<
tr><td class="blockContent"><{$block.content}></td></tr></table>
</
td></tr></table><br />
<{/foreach}>

<!-- 
End left blocks loop -->

</
td>
<
td style="padding: 0px 5px 0px;">

<!-- 
Display center blocks if any -->

<{if 
$xoops_showcblock == 1}>
<
table cellspacing="0">
<
tr><td width="100%" colspan="2">

<!-- 
Start center-center blocks loop -->

<{foreach 
item=block from=$xoops_ccblocks}>
<
table class="outline"><tr><td>
<
table cellspacing="1" cellpadding="5">
<
tr><td class="blockTitle">&nbsp;<{$block.title}></td></tr>
<
tr><td class="blockContent"><{$block.content}></td></tr></table>
</
td></tr></table><br />
<{/foreach}>

<!-- 
End center-center blocks loop -->

</
td></tr>
<
tr><td width="50%">

<!-- 
Start center-left blocks loop -->

<{foreach 
item=block from=$xoops_clblocks}>
<
table class="outline"><tr><td>
<
table cellspacing="1" cellpadding="5">
<
tr> <td class="blockTitle">&nbsp;<{$block.title}></td></tr>
<
tr><td class="blockContent"><{$block.content}></td></tr></table>
</
td></tr></table><br />
<{/foreach}>

<!-- 
End center-left blocks loop -->

</
td><td width="50%">

<!-- 
Start center-right blocks loop -->

<{foreach 
item=block from=$xoops_crblocks}>
<
table class="outline"><tr><td>
<
table cellspacing="1" cellpadding="5">
<
tr> <td class="blockTitle">&nbsp;<{$block.title}></td></tr>
<
tr><td class="blockContent"><{$block.content}></td></tr></table>
</
td></tr></table><br />
<{/foreach}>

<!-- 
End center-right blocks loop -->

</
td></tr></table>
<{/if}>

<!-- 
End display center blocks -->

<
div id="content"><{$xoops_contents}></div></td>
<{if 
$xoops_showrblock == 1}>
<
td width=20align=center>

<!-- 
Start right blocks loop -->

<{foreach 
item=block from=$xoops_rblocks}>
<
table class="outline"><tr><td>
<
table cellspacing="0" cellpadding="2">
<
tr><td class="blockTitle2">&nbsp;<{$block.title}></td></tr>
<
tr><td class="blockContent"><{$block.content}></td></tr></table>
</
td></tr></table>
<
br /><{/foreach}>


<!-- 
End right blocks loop -->

<{/if}></
td></tr></table>
</
td></tr>
<
tr><td height="30" valign="middle"2 align="center">
<
p style="text-align: cener; padding-top: 5px;"><{$xoops_banner}></p>
<
div style="text-align: center; padding-top: 2px; font-size: 10px"><{$xoops_footer}></div>
<
div>:: FI Black phpBB2 style by <a href="http://www.forumimages.com/" target="_blank">Daz</a> :: XOOPS2 theme by <

href
="http://peekaboo.s8.xrea.com/" target="_blank">PetitOOps</a> ::</div><br />
</
td></tr></table>
</
body>
</
html>

8
shank
Re: Private Messaging
  • 2005/12/15 2:34

  • shank

  • Not too shy to talk

  • Posts: 144

  • Since: 2004/8/17


My bad. Remove the space between java and script. I posted it correctly, but for some reason it gets a space put in it. Same code but instead of java script it should have javascript

The bad part about this code is that the aleret will show everytime they refresh the page, or go to a new page, including inbox, till the check the mail.

I'll try to figure out a better way to do this.
s l s h a n k l e @ b e l l s o u t h . n e t

9
dannymac
Re: Private Messaging
  • 2005/12/18 0:37

  • dannymac

  • Just popping in

  • Posts: 8

  • Since: 2005/11/22


Oh cool :) thanks for clearing that up, this is a handy little addition.

10
shank
Re: Private Messaging
  • 2005/12/22 0:31

  • shank

  • Not too shy to talk

  • Posts: 144

  • Since: 2004/8/17


Ok. I think I got this going good, and need some people to try it.

This seems to work on XOOPS version 2.0.13.2

I have not tried it with version 2.2.3, but if someone wants to try it out and let me know if it works great.

Download the ZIP file here!

This is for English language only as far as right now.
I have never tried to make anything multi language, but if this thing works I might do it.

Let me know,
Steve
s l s h a n k l e @ b e l l s o u t h . n e t

Login

Who's Online

53 user(s) are online (27 user(s) are browsing Support Forums)


Members: 0


Guests: 53


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Aug 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits