[Function] insert_pm()

This forum is now closed as part of retiring phpBB2.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

This forum is now closed due to phpBB2.0 being retired.
wGEric
Former Team Member
Posts: 8805
Joined: Sun Oct 13, 2002 3:01 am
Location: Friday
Name: Eric Faerber
Contact:

[Function] insert_pm()

Post by wGEric » Mon Feb 23, 2004 1:46 am

This function creates a Private Message for a user. It updates the users new PM notification, sends an email (if user has checked this option).

I took the phpBB code that did this and turned it into a function and edited it a little.

You can find it here
http://mods.best-dev.com/files/insert_pm.txt
Last edited by wGEric on Thu Feb 26, 2004 11:05 pm, edited 1 time in total.
Eric

DanielT
Former Team Member
Posts: 3324
Joined: Tue Aug 27, 2002 10:55 am
Contact:

Post by DanielT » Mon Feb 23, 2004 8:19 am

thank you very much, it's something we have needed for a long time.

User avatar
morpheus2matrix
Former Team Member
Posts: 9171
Joined: Wed Apr 10, 2002 7:31 pm
Location: France
Contact:

Post by morpheus2matrix » Mon Feb 23, 2004 9:15 am

That's great : thank you :)
Former phpBB MOD-Team Member -

Forgive my bad English :(

No support by PM/Email - Thanks - You can thanks me here :) - Pay me for installing MOD's :lol:

User avatar
A_Jelly_Doughnut
Former Team Member
Posts: 34457
Joined: Sat Jan 18, 2003 1:26 am
Location: Where the Rivers Run
Contact:

Post by A_Jelly_Doughnut » Mon Feb 23, 2004 10:36 pm

I take it my IRC bugging had some effect ^_^

I'll hopefully implement this tonight and test it for a few days to be sure nothing is b0rked :D
A Donut's Blog
"Bach's Prelude (Cello Suite No. 1) is driving Indiana country roads in Autumn" - Ann Kish

StoneViper
Registered User
Posts: 15
Joined: Sat Sep 06, 2003 1:58 am
Contact:

Post by StoneViper » Wed Feb 25, 2004 3:45 pm

cool!

can you make a page in the admin section for mass pm's like the one that does mass emails?

wGEric
Former Team Member
Posts: 8805
Joined: Sun Oct 13, 2002 3:01 am
Location: Friday
Name: Eric Faerber
Contact:

Post by wGEric » Wed Feb 25, 2004 10:06 pm

StoneViper wrote: cool!

can you make a page in the admin section for mass pm's like the one that does mass emails?


That would be a MOD. This is just a function that authors can use in their MODs.
Eric

User avatar
morpheus2matrix
Former Team Member
Posts: 9171
Joined: Wed Apr 10, 2002 7:31 pm
Location: France
Contact:

Post by morpheus2matrix » Wed Feb 25, 2004 10:49 pm

StoneViper wrote: cool!

can you make a page in the admin section for mass pm's like the one that does mass emails?


Check this : http://mods.db9.dk/viewforum.php?f=38
Former phpBB MOD-Team Member -

Forgive my bad English :(

No support by PM/Email - Thanks - You can thanks me here :) - Pay me for installing MOD's :lol:

StoneViper
Registered User
Posts: 15
Joined: Sat Sep 06, 2003 1:58 am
Contact:

Post by StoneViper » Thu Feb 26, 2004 1:26 am

hot. thanks :)

DemonBob
Registered User
Posts: 226
Joined: Thu Jan 15, 2004 7:04 pm
Location: Louisiana, United States
Contact:

Post by DemonBob » Sat Feb 28, 2004 11:36 pm

Hi, this is really nice code, intergrated it into my mod very nicely

Dr DLP
Registered User
Posts: 527
Joined: Sat Mar 29, 2003 5:34 pm
Location: France
Contact:

Post by Dr DLP » Wed Apr 14, 2004 5:31 pm

The email notification doesn't work with previous versions ( 2.0.4 is still used ) , because of the from() function .
I use that :

Code: Select all

		if ( $to_userdata['user_notify_pm'] && !empty($to_userdata['user_email']) && $to_userdata['user_active'] )
		{
			// have the mail sender infos
			$script_name = preg_replace('/^\/?(.*?)\/?$/', "\\1", trim($board_config['script_path']));
			$script_name = ( $script_name != '' ) ? $script_name . '/privmsg.'.$phpEx : 'privmsg.'.$phpEx;
			$server_name = trim($board_config['server_name']);
			$server_protocol = ( $board_config['cookie_secure'] ) ? 'https://' : 'http://';
			$server_port = ( $board_config['server_port'] <> 80 ) ? ':' . trim($board_config['server_port']) . '/' : '/';

			include_once($phpbb_root_path . './includes/emailer.'.$phpEx);
			$emailer = new emailer($board_config['smtp_delivery']);
        
			if  ( $board_config['version'] == '.0.5' || $board_config['version'] == '.0.6' || $board_config['version'] == '.0.7' || $board_config['version'] == '.0.8')
			{   
				$emailer->from($board_config['board_email']);
				$emailer->replyto($board_config['board_email']);
				$emailer->use_template('privmsg_notify', $to_userdata['user_lang']);
			}
			else
			{
				$email_headers = 'From: ' . $board_config['board_email'] . "\nReturn-Path: " . $board_config['board_email'] . "\n";
				$emailer->use_template('privmsg_notify', $to_userdata['user_lang']);
				$emailer->extra_headers($email_headers);
			}
			$emailer->email_address($to_userdata['user_email']);
			$emailer->set_subject($lang['Notification_subject']);

			$emailer->assign_vars(array(
				'USERNAME' => $to_username,
				'SITENAME' => $board_config['sitename'],
				'EMAIL_SIG' => (!empty($board_config['board_email_sig'])) ? str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']) : '',
				'U_INBOX' => $server_protocol . $server_name . $server_port . $script_name . '?folder=inbox')
			 );

			$emailer->send();
			$emailer->reset();
		}
You can also add the Advanced private message ( made by Ptirhiik ) compliance with adding :

Code: Select all

	if ( defined('PRIVMSGA_TABLE'))
	{
		include_once($phpbb_root_path . 'includes/functions_messages.'.$phpEx);
		send_pm( 0 , '' , $to_id , $privmsg_subject, $privmsg_message, '' );
	}
	else
	{
		the main code
                }
Before :

Code: Select all

   //
   // See if recipient is at their inbox limit
   //
Last thing , I add some issues with the uses of lang keys , I have added addslashes for the subject and the message .

And thanks , this is really of use :)

rayoder
Registered User
Posts: 5
Joined: Sun Apr 04, 2004 6:21 pm

Post by rayoder » Wed Jun 09, 2004 3:50 am

I love this function! It worked great until a few weeks ago, I upgraded to 2.0.8 (from 2.0.7) and installed the xtreme template mod. Could either of these have caused this function to stop working?? The problem appears to be from trying to query mysql tables. What's the best way to go about diagnosing this?

Thanks in advance for all your help!

rayoder
Registered User
Posts: 5
Joined: Sun Apr 04, 2004 6:21 pm

Post by rayoder » Thu Jun 10, 2004 12:45 am

What needs to be included for this to work?? Perhaps I need to include a file or a global that is no longer being included, and caused it to stop working...

rayoder
Registered User
Posts: 5
Joined: Sun Apr 04, 2004 6:21 pm

Post by rayoder » Thu Jun 10, 2004 11:12 pm

In case anyone else runs into this problem... I was able to fix the problem by inserting a mysql_connect(); line into the beginning of the function. Perhaps I needed it because I am using it from outside phpbb.

Paddic
Registered User
Posts: 198
Joined: Tue May 18, 2004 10:58 am

Post by Paddic » Sat Jun 12, 2004 9:49 am

I cannot download the file :( I've tried for several days, but always:
The requested URL /files/insert_pm.txt was not found on this server.

I might try to build a "light version" of multiple pm recipients functionality with this (all the multiple pm mods are unnecessarily complex for me), but that would require me getting my hands on this function...

wGEric
Former Team Member
Posts: 8805
Joined: Sun Oct 13, 2002 3:01 am
Location: Friday
Name: Eric Faerber
Contact:

Post by wGEric » Sat Jun 12, 2004 5:21 pm

Paddic wrote: I cannot download the file :( I've tried for several days, but always:
The requested URL /files/insert_pm.txt was not found on this server.


Sorry about that. I did some switching on that server and forgot about this file. You should be able to get it now.
Eric

Post Reply

Return to “[2.0.x] MOD Writers Discussion”