1
xgarb
PM -> you got mail - done it - comments?
  • 2004/2/24 10:36

  • xgarb

  • Not too shy to talk

  • Posts: 154

  • Since: 2003/3/30


Hi,

Just starting to look at implementing a method of letting site members know when someone has sent them a PM via an autogenerated email. I'm looking at adding to this part of the pmlite code..

if ( empty($HTTP_GET_VARS['refresh'] ) && isset($HTTP_POST_VARS['op']) && $HTTP_POST_VARS['op'] != "submit" ) {


code from the register.php page like this...

$xoopsMailer =& getMailer();   etc...


Am I on the right track? I sort of know what I'm doing!

ta,

xgarb

2
Mithrandir
Re: PM -> you got mail - ideas please?

yes, if you want to force an email to be sent every time a member receives a PM, that would be on the right track.

However, I would love it more with a notification option, where the user could choose to be notified on PM receival - provided he/she is being notified by email (no point in sending a PM notification that a PM has been received + it may result in an indefinite loop etc.)

I agree that the process of actually sending the PM would probably be the best place to input the emailing/notifying code.

3
xgarb
Re: PM -> you got mail - done it - comments please.
  • 2004/3/7 13:02

  • xgarb

  • Not too shy to talk

  • Posts: 154

  • Since: 2003/3/30


OK, I've got it working. An email is now sent to whoever is PM'd to get them to come back to the site.

I created a mail template like this...

Hello {RNAME},

{
SNAMEhas sent you a PM.

Log in to {SITENAME} ({SITEURL}) to read the message.



--------------------------------------------------------------------------------

{
SITENAME} ({SITEURL})


added the following line below 'include "mainfile.php";' in pmlite.php

include "class/xoopsmailer.php";


and the following below ' echo "
"._PM_GOBACK."";
} else {'
(around line 70)

$xoopsMailer =& getMailer(); 
$xoopsMailer->useMail(); 
$xoopsMailer->setTemplateDir(XOOPS_ROOT_PATH.'/language/'.$xoopsConfig['language'].'/mail_template'); 
$xoopsMailer->setTemplate("yougotmail.tpl"); 
$toUserID $HTTP_POST_VARS['to_userid'];
$sql mysql_query("SELECT email,uname FROM ".$xoopsDB->prefix("users")." WHERE uid = $toUserID");
$toUserEmail mysql_result($sql0'email');
$toUserName mysql_result($sql0'uname');
$xoopsMailer->setToEmails($toUserEmail); 
$xoopsMailer->setFromEmail($xoopsConfig['adminmail']);
$xoopsMailer->setFromName($xoopsConfig['sitename']);
$subject 'You've got mail!!';
$xoopsMailer->setSubject($subject);
$sname = $xoopsUser->getVar("uname");
$xoopsMailer->assign("RNAME", $toUserName);
$xoopsMailer->assign("SNAME", $sname); 
$xoopsMailer->assign("SITENAME", $xoopsConfig['
sitename']); 
$xoopsMailer->assign("SITEURL", XOOPS_URL."/"); 
$xoopsMailer->send();


All seems to work great. Feel free to point out errors or pitfalls in my implementation

Thanks,

xgarb


4
Herko
Re: PM -> you got mail - done it - comments please.
  • 2004/3/7 17:57

  • Herko

  • XOOPS is my life!

  • Posts: 4238

  • Since: 2002/2/4 1


Great work Can you submit this at the XOOPS Core Development Patch Tracker at sourceforge.net? That way it'll get reviewed for inclusion in the next versions.

Herko

5
svaha
Re: PM -> you got mail - done it - comments please.
  • 2004/3/21 20:11

  • svaha

  • Just can't stay away

  • Posts: 896

  • Since: 2003/8/2 2


Made changes in PMlite and made templates for english and dutch language, but nothing happens when I send a pm (well, no mail is send)
Do I have to update something or somebody to get this to work?

6
Mithrandir
Re: PM -> you got mail - done it - comments please.

A few suggestions:
1) Use $_POST instead of $HTTP_POST_VARS - future PHP versions will only support the first, which has been in PHP since 4.1.0, which is also the required version for XOOPS according to the Requirements page

2)
$toUser = new XoopsUser($toUserID);
$toUserEmail $toUser->getVar('email');
$toUserName $toUser->getVar('uname');

instead of a manual query (which should use the $xoopsDB object anyway instead of directly using mysql_ functions) for Object Oriented approach and in order not to break it, if there are future changes to the user table

3) Use a language constant for $subject

4) Your solution will send an email on every PM sent - this may not be all that desirable. Some user-specific or at least site-wide toggle of this function should be in this before it is included in the core per standard

5) For easier reading, move the mailing to an individual function with a meaningful name, so it is more transparent, what is actually done - some sendPMNotificationEmail($to_userid) function or something (do find a better name )

7
svaha
Re: PM -> you got mail - done it - comments please.
  • 2004/3/22 11:03

  • svaha

  • Just can't stay away

  • Posts: 896

  • Since: 2003/8/2 2


Thanks Mithrandir,
I made changes 1 and 2 and it works.
I agree with you that users should have the choice to recieve/not recieve e-mails, so I will work on that and the other suggestions you made, I'll be back.

Quote:
It would seem that you have no useful skill or talent whatsoever, have you thought of going into teaching?

Man, you can read my mind, I'm just thinking of that one.

8
Mithrandir
Re: PM -> you got mail - done it - comments please.

Hehe.
Dunno if Terry Pratchett has made it to Aelse, but he's wonderful in his ironic comments

9
jfebus
Re: PM -> you got mail - done it - comments please.
  • 2005/1/3 23:40

  • jfebus

  • Just popping in

  • Posts: 97

  • Since: 2004/9/1 1


is this in the CORE?

Login

Who's Online

250 user(s) are online (169 user(s) are browsing Support Forums)


Members: 0


Guests: 250


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