1
Jack404
XOOPS2: Private Messages Question
  • 2003/8/20 20:37

  • Jack404

  • Just popping in

  • Posts: 56

  • Since: 2003/5/16


I'm currently working on a "Report This Post" template hack for the X2 NewBB module, and my goal is for a private message to be sent to the webmaster (or, more ideally, the moderator of the forum, but I can't think of how I'd do this) regarding the post that was reported.

My problem is that I cannot figure out how to insert text into the Subject and Message parts of the Private Message by using a link.

For instance, as a test, I wanted the Private Message window to open to be sent to the Webmaster (always uid 1, or it is in my case) with the subject "Report" and the message body saying "testing123". This is the link I am using:

http://www.mysite.url/pmlite.php?send2=1&to_userid=1&subject=report&message=testing123

However, I open the window using the link and nothing is in the subject or message boxes. What am I doing wrong? Do I need to hack the pmlite.php file in order for this to work, or just tweak the URL I'm using?

Any help would be IMMENSELY appreciated!

2
ackbarr
Re: XOOPS2: Private Messages Question

you will need to hack pmlite.php for this to work. You'll need to retrieve the supplied text from the $HTTP_GET_VARS array and modify the HTML code to output the supplied variables.

3
Jack404
Re: XOOPS2: Private Messages Question
  • 2003/8/20 21:44

  • Jack404

  • Just popping in

  • Posts: 56

  • Since: 2003/5/16


Contents of pmlite.php:

$xoopsOption['pagetype'] = "pmsg";

include 
"mainfile.php";
$reply = !empty($HTTP_GET_VARS['reply']) ? 0;
$send = !empty($HTTP_GET_VARS['send']) ? 0;
$send2 = !empty($HTTP_GET_VARS['send2']) ? 0;
$to_userid = !empty($HTTP_GET_VARS['to_userid']) ? intval($HTTP_GET_VARS['to_userid']) : 0;
//added
$msg_text = !empty($HTTP_GET_VARS['msg_text']) ? intval($HTTP_GET_VARS['msg_text']) : 0;
//end added
$msg_id = !empty($HTTP_GET_VARS['msg_id']) ? intval($HTTP_GET_VARS['msg_id']) : 0;
if ( empty(
$HTTP_GET_VARS['refresh'] ) && isset($HTTP_POST_VARS['op']) && $HTTP_POST_VARS['op'] != "submit" ) {
        
$jump "pmlite.php?refresh=".time()."";
        if ( 
$send == ) {
                
$jump .= "&send=".$send."";
        } elseif ( 
$send2 == ) {
                
$jump .= "&send2=".$send2."&to_userid=".$to_userid."";
        } elseif ( 
$reply == ) {
                
$jump .= "&reply=".$reply."&msg_id=".$msg_id."";
        } else {
        }
        echo 
".$jump."' />";
        exit();
}
xoops_header();
if (
$xoopsUser) {
        
$myts =& MyTextSanitizer::getInstance();
        if (isset(
$HTTP_POST_VARS['op']) && $HTTP_POST_VARS['op'] == "submit") {
                
$res $xoopsDB->query("SELECT COUNT(*) FROM ".$xoopsDB->prefix("users")." WHERE uid=".intval($HTTP_POST_VARS['to_userid'])."");
                list(
$count) = $xoopsDB->fetchRow($res);
                if (
$count != 1) {
                        echo 
"

"._PM_USERNOEXIST."";
                        echo 
_PM_PLZTRYAGAIN."

";
                            echo 
"[ "._PM_GOBACK." ]
"
;
                } else {
                        
$pm_handler =& xoops_gethandler('privmessage');
                        
$pm =& $pm_handler->create();
                        
$pm->setVar("subject"$HTTP_POST_VARS['subject']);
                        
$pm->setVar("msg_text"$HTTP_POST_VARS['message']);
                        
$pm->setVar("to_userid"$HTTP_POST_VARS['to_userid']);
                        
$pm->setVar("from_userid"$xoopsUser->getVar("uid"));
                        if (!
$pm_handler->insert($pm)) {
                                echo 
$pm->getHtmlErrors();
                                echo 
""._PM_GOBACK."";
                        } else {
                                echo 
"

"._PM_MESSAGEPOSTED."

javascript:window.opener.location='".XOOPS_URL."/viewpmsg.php';window.close();">"._PM_CLICKHERE."javascript:window.close();">"._PM_ORCLOSEWINDOW."
";
                        }
                }
        } elseif (
$reply == || $send == || $send2 == 1) {
                include 
XOOPS_ROOT_PATH."/include/xoopscodes.php";
                if (
$reply == 1) {
                        
$pm_handler =& xoops_gethandler('privmessage');
                        
$pm =& $pm_handler->get($msg_id);
                        if (
$pm->getVar("to_userid") == $xoopsUser->getVar('uid')) {
                                
$pm_uname XoopsUser::getUnameFromId($pm->getVar("from_userid"));
                
$message  "[quote]n";
                                
$message .= sprintf(_PM_USERWROTE,$pm_uname);
                                
$message .= "n".$pm->getVar("msg_text""E")."n[/quote]";
                        } else {
                                unset(
$pm);
                                
$reply $send2 0;
                        }
                }
                echo 
"n";
                echo 
""._PM_TO."";
                if ( 
$reply == ) {
                        echo 
".$pm->getVar("from_userid")."' />".$pm_uname."";
                } elseif ( 
$send2 == ) {
                        
$to_username XoopsUser::getUnameFromId($to_userid);
                        echo 
".$to_userid."' />".$to_username."";
                } else {
                        echo 
"";
                        
$result $xoopsDB->query("SELECT uid, uname FROM ".$xoopsDB->prefix("users")." WHERE level > 0 ORDER BY uname");
            while ( list(
$ftouid$ftouname) = $xoopsDB->fetchRow($result) ) {
                                echo 
".$ftouid."'>".$myts->makeTboxData4Show($ftouname)."";
                        }
            echo 
"";
        }
        echo 
"";
        echo 
""._PM_SUBJECTC."";
                if ( 
$reply == ) {
                        
$subject $pm->getVar('subject''E');
                        if (!
preg_match("/^Re:/i",$subject)) {
                                
$subject 'Re: '.$subject;
                        }
                        echo 
".$subject."' size='30' maxlength='100' />";
                } else {
                        echo 
".$subject."' size='30' maxlength='100' />";
                }
                echo 
"";
        echo 
""._PM_MESSAGEC."";
                echo 
"";
                
xoopsCodeTarea("message",37,8);
                
xoopsSmilies("message");
                echo 
"";
                echo 
"";
        echo 
" 
                
                ._PM_SUBMIT."' /> 
                ._PM_CLEAR."' />
                 ._PM_CANCELSEND."' onclick='javascript:window.close();' />
                n"
;
                   echo 
"n";
        }
} else {
        echo 
_PM_SORRY.".XOOPS_URL."/register.php'>"._PM_REGISTERNOW.".";
}

xoops_footer();


What would I need to add? I'm not too great at hacking, and I think this could be a nice addition to the newBB module, so anyone who could help would benefit the multitudes

4
Catzwolf
Re: XOOPS2: Private Messages Question
  • 2003/8/21 1:08

  • Catzwolf

  • Home away from home

  • Posts: 1392

  • Since: 2007/9/30


You could try using this code in your own, this will use the PM system directly without having to hack any other files:

$pm_handler = & xoops_gethandler( 'privmessage' );
$pm = & $pm_handler -> create();
$pm -> setVar( "subject", $HTTP_POST_VARS['subject'] );
$pm -> setVar( "msg_text", $HTTP_POST_VARS['message'] );
$pm -> setVar( "to_userid", $HTTP_POST_VARS['to_userid'] );
$pm -> setVar( "from_userid", $xoopsUser -> getVar( "uid" ) );

Hope this helps

5
mvandam
Re: XOOPS2: Private Messages Question
  • 2003/8/21 2:17

  • mvandam

  • Quite a regular

  • Posts: 253

  • Since: 2003/2/7 2


catzwolf's suggestions would be the simplest.

A slightly more complicated approach, but one would give the option of sending EMAIL in addition or as alternative to PM, is to use the 'xoopsmultimailer'. If interested, check out kernel/notification.php for code to set up the mailer to send messages.

6
Jack404
Re: XOOPS2: Private Messages Question
  • 2003/8/21 2:19

  • Jack404

  • Just popping in

  • Posts: 56

  • Since: 2003/5/16


I'm a bit confused, but thanks for all the help!

I saw that bit of code, and that's what got me to use what I did in the URL. I saw that it was looking for "message" in the URL, so I added that, but that didn't let the message show up in the message box.

Could it be that the message is there, but just not being added to the textbox and made visible?

7
Jack404
Re: XOOPS2: Private Messages Question
  • 2003/8/21 3:00

  • Jack404

  • Just popping in

  • Posts: 56

  • Since: 2003/5/16


Got it!

I added these lines after line 34 of pmlite.php:

// Begin Hack
$message = $HTTP_GET_VARS['message'];
$subject = $HTTP_GET_VARS['subject'];
// End Hack

Now it works!

8
mvandam
Re: XOOPS2: Private Messages Question
  • 2003/8/21 5:51

  • mvandam

  • Quite a regular

  • Posts: 253

  • Since: 2003/2/7 2


OK, I'm sorry I didn't read carefully enough what you intended to do before I posted. You want everything to happen in that link (i.e. not go to some other page first). You solution should work, though I think it is a little insecure because it will be very easy for your visitors to figure out the URL and start spamming you (if you have a small trusted userbase this may not be a problem).

I would suggest instead, wrapping a tiny HTML form around the link, and make the link a *button* instead. This way the message will be set as a POST var. Then your change isn't needed, and security is improved.

9
gruessle
Re: XOOPS2: Private Messages Question
  • 2003/10/15 22:04

  • gruessle

  • Friend of XOOPS

  • Posts: 348

  • Since: 2003/9/20


Quote:


by Catzwolf on 2003/8/20 17:08:20

You could try using this code in your own, this will use the PM system directly without having to hack any other files:

$pm_handler = & xoops_gethandler( 'privmessage' );
$pm = & $pm_handler -> create();
$pm -> setVar( "subject", $HTTP_POST_VARS['subject'] );
$pm -> setVar( "msg_text", $HTTP_POST_VARS['message'] );
$pm -> setVar( "to_userid", $HTTP_POST_VARS['to_userid'] );
$pm -> setVar( "from_userid", $xoopsUser -> getVar( "uid" ) );




I am trying to do something similar.
I am trying to provide a link when someone would like to request additional futures like Webmail account or Photo Album account. I would place that link on each page where something new can be requested. The subject should change to (the page they are on) and description 'Please activate my (the page they are on) account' to make the request easy.

Now I don't see any difference between the code in pmlite.php and the code you have given.

Thank you for your help

How do I change

Login

Who's Online

111 user(s) are online (64 user(s) are browsing Support Forums)


Members: 0


Guests: 111


more...

Donat-O-Meter

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

Latest GitHub Commits