1
tdickson
Personal Messaging Block?
  • 2005/9/26 19:32

  • tdickson

  • Just popping in

  • Posts: 26

  • Since: 2005/9/26


I would like to add the personal messaging block to my main page so that it shows new messages when the guest logs in. (rather than having to click on a link to the PM module)

I tried using custom block and inserting the viewpmsg.php source code, selected content type of php and submitted... but nothing showed up.
Is there anyway to do this? I think it would be a nice feature that many could use.

2
tdickson
Re: Personal Messaging Block?
  • 2005/9/30 16:31

  • tdickson

  • Just popping in

  • Posts: 26

  • Since: 2005/9/26


anyone?

3
JamesSAEP
Re: Personal Messaging Block?
  • 2005/9/30 17:23

  • JamesSAEP

  • Just can't stay away

  • Posts: 732

  • Since: 2005/2/28


I asked a simular question a while back. Here is the response:

global $xoopsUser;
if (is_object($xoopsUser)) {
$pm_handler =& xoops_gethandler('privmessage');
$criteria = new CriteriaCompo(new Criteria('read_msg', 0));
$criteria->add(new Criteria('to_userid', $xoopsUser->getVar('uid')));
$msgs = $pm_handler->getCount($criteria);
}
$xoops_url = XOOPS_URL;
if ($msgs > 0) {
echo "
You have new messages (".$msgs.")
";
}


How does this work? Here's a brief explanation.

First you need to determine if there's new private messages for the logged user. This won't work for anonymous users, since all the code is wrapped in an if statement that precludes it.

One line instantiates the private message handler. Then we create a mixed criteria that includes the actual user id and as far as I can see, the existence of non-read messages.

Then we assign to a variable the result of counting the non-read messages sent to the user. If this variable is larger than zero, that is, if there are non-read private messages addressed to the user, then we echo to the screen the table containing the count and the link to the private message page.

A couple of extra notes:

1) Don't include the opening and closing tags for PHP. They are already included.

2. Don't try to use Smarty variables. All blocks are rendered through a template that already exists, so you can only use general variables, as in the example above.

I hope this works.

4
tdickson
Re: Personal Messaging Block?
  • 2005/10/1 8:42

  • tdickson

  • Just popping in

  • Posts: 26

  • Since: 2005/9/26


You absolutely rock!
I was looking at this one for hours and couldn't figure it out. My boss just kept saying... get it done, it's a feature we need. And yeah, I was sweating so I really appreciate it! Hat's off to you!
I wish there was a way to integrate this into the build. I'm sure it's a feature everyone would want.

5
zippylad
Re: Personal Messaging Block?
  • 2005/10/17 1:11

  • zippylad

  • Just popping in

  • Posts: 14

  • Since: 2005/10/16


This was an excellent script!! Saved me hours of time... Only problem is I wanted the box to actually say "no new messages" when there aren't any...so I modified the script. Here is what it looks like after I mangled it:

global $xoopsUser;
if (is_object($xoopsUser)) {
$pm_handler =& xoops_gethandler('privmessage');
$criteria = new CriteriaCompo(new Criteria('read_msg', 0));
$criteria->add(new Criteria('to_userid', $xoopsUser->getVar('uid')));
$msgs = $pm_handler->getCount($criteria);
}
$xoops_url = XOOPS_URL;
if ($msgs > 0) {
echo "
You have new messages (".$msgs.")
";
}
else {
echo "
You have no new messages
";
}

6
moflus
Re: Personal Messaging Block?
  • 2005/11/10 23:29

  • moflus

  • Just popping in

  • Posts: 24

  • Since: 2004/12/25


In XOOPS version 2.2.3 the link
<class='highlight' href='$xoops_url/viewpmsg.php'>
redirects to Quote:
$xoops_url/modules/pm/
so you can change the link in the script to...
<class='highlight' href='$xoops_url/modules/pm/'>

Login

Who's Online

279 user(s) are online (191 user(s) are browsing Support Forums)


Members: 0


Guests: 279


more...

Donat-O-Meter

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

Latest GitHub Commits