[Req] PM Read Notification

Looking for a MOD? Have a MOD request? Post here for help. (Note: This forum is community supported; phpBB does not have official MOD authors)
Scam Warning
Tim81
Registered User
Posts: 20
Joined: Tue Aug 31, 2010 12:55 pm
Location: The Netherlands

[Req] PM Read Notification

Post by Tim81 » Wed Oct 20, 2010 9:53 am

What I'm looking for is a Read Notification mod for Private Messages.

- A user can send a PM to another user and check the checkbox to receive a notification when it has been read, so that is not on by default as it is needed for some games we play on our board, based on time.
- The user that has sent the PM receives the "replied" message with the exact date/time (servertime) when it has been opened.

A second or different option could be, that user that has sent the message can see the read notification in their sentbox (in the details of the sent message), when the message is really been opened.

User avatar
jsoni
Registered User
Posts: 355
Joined: Mon Aug 02, 2010 3:55 pm
Location: Mauritius
Contact:

Re: [Req] PM Read Notification

Post by jsoni » Wed Oct 20, 2010 11:16 am

It is there as per my knowledge.
But in different way,

When you send a PM to anyone you will see your PM will be into your Outbox till next person has read it. :)
So I think Read notification doesn't required anymore when this feature works fine. :)
Don't you think so?
PM me for phpbb modification
Not phpbb or php master but can help you to gain my knowledge.
On your own risk :)
For graphics and animation PM me.
Forum:http://www.pixelandgrain.in/

Tim81
Registered User
Posts: 20
Joined: Tue Aug 31, 2010 12:55 pm
Location: The Netherlands

Re: [Req] PM Read Notification

Post by Tim81 » Wed Oct 20, 2010 8:24 pm

see your PM will be into your Outbox till next person has read it
No, it will leave the Outbox as soon as someone opens the PM-inbox, while not actually opening the message. Also when going to the forum-index, it will indicate you have no new messages, while you still have an UNREAD message.

My request is that the sender gets to know the exact time someone opens the message (and thus really read it) to be able to have a timed response to it.

lugsciath
Registered User
Posts: 316
Joined: Tue Oct 02, 2007 11:12 am

Re: [Req] PM Read Notification

Post by lugsciath » Wed Oct 20, 2010 10:46 pm

Hi,

there is a existing mod (or snippet) for pm notifications, it shows "read" in status on the ucp pm panel, in if the sended pm is read. I dont know if it is a snippet or a dev/abd mod, did you have consult the search function ? ;)

User avatar
jsoni
Registered User
Posts: 355
Joined: Mon Aug 02, 2010 3:55 pm
Location: Mauritius
Contact:

Re: [Req] PM Read Notification

Post by jsoni » Thu Oct 21, 2010 5:49 am

No, it will leave the Outbox as soon as someone opens the PM-inbox, while not actually opening the message. Also when going to the forum-index, it will indicate you have no new messages, while you still have an UNREAD message.

My request is that the sender gets to know the exact time someone opens the message (and thus really read it) to be able to have a timed response to it.
Oh I didn't know that :P Thanks for the info.. I also want that MOD now :D
PM me for phpbb modification
Not phpbb or php master but can help you to gain my knowledge.
On your own risk :)
For graphics and animation PM me.
Forum:http://www.pixelandgrain.in/

Tim81
Registered User
Posts: 20
Joined: Tue Aug 31, 2010 12:55 pm
Location: The Netherlands

Re: [Req] PM Read Notification

Post by Tim81 » Thu Oct 21, 2010 11:18 am

lugsciath wrote:did you have consult the search function ? ;)
I have found this one earlier:
http://www.phpbb.com/community/viewtopi ... &t=1042025

Download is dead, so not really helpfull :cry:

Tim81
Registered User
Posts: 20
Joined: Tue Aug 31, 2010 12:55 pm
Location: The Netherlands

Re: [Req] PM Read Notification

Post by Tim81 » Fri Oct 22, 2010 1:40 pm

I've done some manual additions to files as well some database updates to make it working the way I wanted it. Now to share this with you, I'll post here exactly what is needed to add, perhaps someone could create it into a 'mod' to install it simple.

The testcase I used is an empty, 3.0.7-PL1 installation without any other mods installed.

file: includes/functions_privmsgs.php

Find: $sql_ary = array();

Code: Select all

		$sql_ary = array();
		foreach ($recipients as $user_id => $type)
		{
			$sql_ary[] = array(
				'msg_id'		=> (int) $data['msg_id'],
				'user_id'		=> (int) $user_id,
				'author_id'		=> (int) $data['from_user_id'],
				'folder_id'		=> PRIVMSGS_NO_BOX,
				'pm_notify_read' => (int) $data['notify_read'],
				'pm_new'		=> 1,
				'pm_unread'		=> 1,
				'pm_forwarded'	=> ($mode == 'forward') ? 1 : 0
			);
		}
The line: 'pm_notify_read' => (int) $data['notify_read'],
is added here.


file: language/en/acp/permissions_phpbb.php (for English)

find: // User Permissions

Code: Select all

// User Permissions
$lang = array_merge($lang, array(
	'acl_u_viewprofile'	=> array('lang' => 'Can view profiles, memberlist and online list', 'cat' => 'profile'),
	'acl_u_chgname'		=> array('lang' => 'Can change username', 'cat' => 'profile'),
	'acl_u_chgpasswd'	=> array('lang' => 'Can change password', 'cat' => 'profile'),
	'acl_u_chgemail'	=> array('lang' => 'Can change e-mail address', 'cat' => 'profile'),
	'acl_u_chgavatar'	=> array('lang' => 'Can change avatar', 'cat' => 'profile'),
	'acl_u_chggrp'		=> array('lang' => 'Can change default usergroup', 'cat' => 'profile'),

	'acl_u_attach'		=> array('lang' => 'Can attach files', 'cat' => 'post'),
	'acl_u_download'	=> array('lang' => 'Can download files', 'cat' => 'post'),
	'acl_u_savedrafts'	=> array('lang' => 'Can save drafts', 'cat' => 'post'),
	'acl_u_chgcensors'	=> array('lang' => 'Can disable word censors', 'cat' => 'post'),
	'acl_u_sig'			=> array('lang' => 'Can use signature', 'cat' => 'post'),

	'acl_u_sendpm'		=> array('lang' => 'Can send private messages', 'cat' => 'pm'),
	'acl_u_masspm'		=> array('lang' => 'Can send messages to multiple users', 'cat' => 'pm'),
	'acl_u_masspm_group'=> array('lang' => 'Can send messages to groups', 'cat' => 'pm'),
	'acl_u_readpm'		=> array('lang' => 'Can read private messages', 'cat' => 'pm'),
	'acl_u_pm_edit'		=> array('lang' => 'Can edit own private messages', 'cat' => 'pm'),
	'acl_u_pm_delete'	=> array('lang' => 'Can remove private messages from own folder', 'cat' => 'pm'),
	'acl_u_pm_forward'	=> array('lang' => 'Can forward private messages', 'cat' => 'pm'),
	'acl_u_pm_emailpm'	=> array('lang' => 'Can e-mail private messages', 'cat' => 'pm'),
	'acl_u_pm_printpm'	=> array('lang' => 'Can print private messages', 'cat' => 'pm'),
	'acl_u_pm_attach'	=> array('lang' => 'Can attach files in private messages', 'cat' => 'pm'),
	'acl_u_pm_download'	=> array('lang' => 'Can download files in private messages', 'cat' => 'pm'),
	'acl_u_pm_bbcode'	=> array('lang' => 'Can use BBCode in private messages', 'cat' => 'pm'),
	'acl_u_pm_smilies'	=> array('lang' => 'Can use smilies in private messages', 'cat' => 'pm'),
	'acl_u_pm_img'		=> array('lang' => 'Can use [img] BBCode tag in private messages', 'cat' => 'pm'),
	'acl_u_pm_flash'	=> array('lang' => 'Can use [flash] BBCode tag in private messages', 'cat' => 'pm'),
	'acl_u_pm_readnotify'	=> array('lang' => 'Can use the PM Read notification', 'cat' => 'pm'),
	
	'acl_u_sendemail'	=> array('lang' => 'Can send e-mails', 'cat' => 'misc'),
	'acl_u_sendim'		=> array('lang' => 'Can send instant messages', 'cat' => 'misc'),
	'acl_u_ignoreflood'	=> array('lang' => 'Can ignore flood limit', 'cat' => 'misc'),
	'acl_u_hideonline'	=> array('lang' => 'Can hide online status', 'cat' => 'misc'),
	'acl_u_viewonline'	=> array('lang' => 'Can view hidden online users', 'cat' => 'misc'),
	'acl_u_search'		=> array('lang' => 'Can search board', 'cat' => 'misc'),
));
Add:

'acl_u_pm_readnotify' => array('lang' => 'Can use the PM Read notification', 'cat' => 'pm'),

After acl_u_pm_flash (see above)

file: language/en/ucp.php (for English)

Just above

));
?>

Add:

'PM_READ_NOTIFY_SUBJECT' => 'Read: %s',
'PM_READ_NOTIFY_TEXT' => 'Your PM is read at %s ',
'PM_NOTIFY_READ' => 'Enable read notification for this PM'

Code:

Code: Select all

	'NO_LEADER'		=> 'No group leaderships',
	'NO_MEMBER'		=> 'No group memberships',
	'NO_PENDING'	=> 'No pending memberships',
	'NO_NONMEMBER'	=> 'No non-member groups',
	// PM notification MOD
	'PM_READ_NOTIFY_SUBJECT'	=> 'Read: %s',
	'PM_READ_NOTIFY_TEXT'		=> 'Your PM is read at %s ',
	'PM_NOTIFY_READ'			=> 'Enable read notification for this PM'
));

?>
file: posting_editor.html (template)

I have used the prosilver template for the testcase, but I'm sure others should work as well.

Find: <!-- IF S_SMILIES_ALLOWED -->

Just above it, add:

<!-- IF S_PRIVMSGS and S_PM_ALLOW_NOTIFY -->
<div><label for="notify_read"><input type="checkbox" name="notify_read" id="notify_read" /> {L_PM_NOTIFY_READ}</label></div>
<!-- ENDIF -->

Code:

Code: Select all

		<fieldset class="fields1">
			<!-- IF S_BBCODE_ALLOWED -->
				<div><label for="disable_bbcode"><input type="checkbox" name="disable_bbcode" id="disable_bbcode"{S_BBCODE_CHECKED} /> {L_DISABLE_BBCODE}</label></div>
			<!-- ENDIF -->
			<!-- IF S_PRIVMSGS and S_PM_ALLOW_NOTIFY -->
				<div><label for="notify_read"><input type="checkbox" name="notify_read" id="notify_read" /> {L_PM_NOTIFY_READ}</label></div>
			<!-- ENDIF -->
			<!-- IF S_SMILIES_ALLOWED -->
				<div><label for="disable_smilies"><input type="checkbox" name="disable_smilies" id="disable_smilies"{S_SMILIES_CHECKED} /> {L_DISABLE_SMILIES}</label></div>
			<!-- ENDIF -->
file: includes/ucp/ucp_pm_compose.php

Find:

$enable_bbcode = (!$bbcode_status || isset($_POST['disable_bbcode'])) ? false : true;
$enable_smilies = (!$smilies_status || isset($_POST['disable_smilies'])) ? false : true;

Just after the $enable_smilies line, add:

$notify_read = (($auth->acl_get('u_pm_readnotify')) && isset($_POST['notify_read'])) ? true : false;

Code:

Code: Select all

		if (($submit || $preview) && !check_form_key('ucp_pm_compose'))
		{
			$error[] = $user->lang['FORM_INVALID'];
		}
		$subject = utf8_normalize_nfc(request_var('subject', '', true));
		$message_parser->message = utf8_normalize_nfc(request_var('message', '', true));

		$icon_id			= request_var('icon', 0);

		$enable_bbcode 		= (!$bbcode_status || isset($_POST['disable_bbcode'])) ? false : true;
		$enable_smilies		= (!$smilies_status || isset($_POST['disable_smilies'])) ? false : true;
		$notify_read		= (($auth->acl_get('u_pm_readnotify')) && isset($_POST['notify_read'])) ? true : false;
		$enable_urls 		= (isset($_POST['disable_magic_url'])) ? 0 : 1;
		$enable_sig			= (!$config['allow_sig'] ||!$config['allow_sig_pm']) ? false : ((isset($_POST['attach_sig'])) ? true : false);
Then find: // Store message, sync counters

Add the following line, after “'enable_urls' => (bool) $enable_urls,

'notify_read' => (bool) $notify_read,

Code:

Code: Select all

		// Store message, sync counters
		if (!sizeof($error) && $submit)
		{
			$pm_data = array(
				'msg_id'				=> (int) $msg_id,
				'from_user_id'			=> $user->data['user_id'],
				'from_user_ip'			=> $user->ip,
				'from_username'			=> $user->data['username'],
				'reply_from_root_level'	=> (isset($post['root_level'])) ? (int) $post['root_level'] : 0,
				'reply_from_msg_id'		=> (int) $msg_id,
				'icon_id'				=> (int) $icon_id,
				'enable_sig'			=> (bool) $enable_sig,
				'enable_bbcode'			=> (bool) $enable_bbcode,
				'enable_smilies'		=> (bool) $enable_smilies,
				'enable_urls'			=> (bool) $enable_urls,
				'notify_read'			=> (bool) $notify_read,
				'bbcode_bitfield'		=> $message_parser->bbcode_bitfield,
				'bbcode_uid'			=> $message_parser->bbcode_uid,
				'message'				=> $message_parser->message,
				'attachment_data'		=> $message_parser->attachment_data,
				'filename_data'			=> $message_parser->filename_data,
				'address_list'			=> $address_list
			);
Then find: S_FORM_ENCTYPE

Add: 'S_PM_ALLOW_NOTIFY' => ($auth->acl_get('u_pm_readnotify')) ? true : false,
after the line you found.

Code:

Code: Select all

		'S_SAVE_ALLOWED'		=> ($auth->acl_get('u_savedrafts') && $action != 'edit') ? true : false,
		'S_HAS_DRAFTS'			=> ($auth->acl_get('u_savedrafts') && $drafts),
		'S_FORM_ENCTYPE'		=> $form_enctype,
		'S_PM_ALLOW_NOTIFY'		=> ($auth->acl_get('u_pm_readnotify')) ? true : false,

		'S_BBCODE_IMG'			=> $img_status,
		'S_BBCODE_FLASH'		=> $flash_status,
		'S_BBCODE_QUOTE'		=> true,
file: includes/ucp/ucp_pm_viewmessage.php

Find: // Message history

After

{
$template->assign_var('S_DISPLAY_HISTORY', true);
}

Add:

}

$msg_id = intval($message_row['msg_id']);
$user_id = intval($user->data['user_id']);
$sql = 'SELECT pm_notify_read FROM ' . PRIVMSGS_TO_TABLE . " WHERE user_id = {$user_id} AND msg_id = {$msg_id}";
$result = $db->sql_query($sql);
$notify_row = $db->sql_fetchrow($result);

if ($notify_row['pm_notify_read'] && $user->data['user_id'] != $message_row['author_id']) {
$subject = utf8_normalize_nfc(sprintf($user->lang['PM_READ_NOTIFY_SUBJECT'], $message_row['message_subject']));
$text = utf8_normalize_nfc(sprintf($user->lang['PM_READ_NOTIFY_TEXT'], date('d-m-Y G:i:s')));

// variables to hold the parameters for submit_pm
$poll = $uid = $bitfield = $options = '';
generate_text_for_storage($subject, $uid, $bitfield, $options, false, false, false);
generate_text_for_storage($text, $uid, $bitfield, $options, true, true, true);

$data = array(
'address_list' => array ('u' => array($message_row['author_id'] => 'to')),
'from_user_id' => $user->data['user_id'],
'from_username' => $user->data['username'],
'icon_id' => 0,
'from_user_ip' => $user->data['user_ip'],

'enable_bbcode' => true,
'enable_smilies' => true,
'enable_urls' => true,
'enable_sig' => true,

'message' => $text,
'bbcode_bitfield' => $bitfield,
'bbcode_uid' => $uid,
);

submit_pm('post', $subject, $data, false);

$sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . " SET pm_notify_read = 0 WHERE msg_id = {$msg_id} AND user_id = {$user_id}";
$db->sql_query($sql);


Code:

Code: Select all

	{
		// Message History
		if (message_history($msg_id, $user->data['user_id'], $message_row, $folder))
		{
			$template->assign_var('S_DISPLAY_HISTORY', true);
		}
		}

	$msg_id		= intval($message_row['msg_id']);
	$user_id	= intval($user->data['user_id']);
	$sql = 'SELECT pm_notify_read FROM ' . PRIVMSGS_TO_TABLE . " WHERE user_id = {$user_id} AND msg_id = {$msg_id}";
	$result = $db->sql_query($sql);
	$notify_row = $db->sql_fetchrow($result);

	if ($notify_row['pm_notify_read'] && $user->data['user_id'] != $message_row['author_id']) {
		$subject	= utf8_normalize_nfc(sprintf($user->lang['PM_READ_NOTIFY_SUBJECT'], $message_row['message_subject']));
		$text		= utf8_normalize_nfc(sprintf($user->lang['PM_READ_NOTIFY_TEXT'], date('d-m-Y G:i:s')));

		// variables to hold the parameters for submit_pm
		$poll = $uid = $bitfield = $options = '';
		generate_text_for_storage($subject, $uid, $bitfield, $options, false, false, false);
		generate_text_for_storage($text, $uid, $bitfield, $options, true, true, true);

		$data = array(
			'address_list'		=> array ('u' => array($message_row['author_id'] => 'to')),
			'from_user_id'		=> $user->data['user_id'],
			'from_username'		=> $user->data['username'],
			'icon_id'			=> 0,
			'from_user_ip'		=> $user->data['user_ip'],

			'enable_bbcode'		=> true,
			'enable_smilies'	=> true,
			'enable_urls'		=> true,
			'enable_sig'		=> true,

			'message'			=> $text,
			'bbcode_bitfield'	=> $bitfield,
			'bbcode_uid'		=> $uid,
		);

		submit_pm('post', $subject, $data, false);

		$sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . " SET pm_notify_read = 0 WHERE msg_id = {$msg_id} AND user_id = {$user_id}";
		$db->sql_query($sql);
	}
	
}

/**
* Get user information (only for message display)
*/

Database changes:

Add the field ‘pm_notify_read’ to the privmsgs_to table:

‘pm_notify_read’ tinyint(1) NOT NULL DEFAULT ‘0’


Note: when having a clean install, the permission value 118 is the next one free. You may want to check if it is in use and use a different (higher) value.

When adding it manually, in phpmyadmin:

auth_option_id 118
auth_option u_pm_read_notify
is_global 1
is_local 0
founder_only 0





Edit: I found that the following SQL-command adds u_pm_read_notify with a free number:

INSERT INTO `phpbb_acl_options` (
`auth_option_id` ,
`auth_option` ,
`is_global` ,
`is_local` ,
`founder_only`
)
VALUES (
NULL , 'u_pm_readnotify', '1', '0', '0'
);
Last edited by Tim81 on Sat Oct 23, 2010 9:57 pm, edited 4 times in total.

Tim81
Registered User
Posts: 20
Joined: Tue Aug 31, 2010 12:55 pm
Location: The Netherlands

Re: [Req] PM Read Notification

Post by Tim81 » Fri Oct 22, 2010 2:04 pm

Screens with example:

Image
User will need to have permission to use the function (by default you don't have it)

Image
When composing a message, you now have the option to enable Read notification (default is unchecked).

Image
When the recipient opens the message, you will receive this "read" message, with the exact date and time.

User avatar
jsoni
Registered User
Posts: 355
Joined: Mon Aug 02, 2010 3:55 pm
Location: Mauritius
Contact:

Re: [Req] PM Read Notification

Post by jsoni » Fri Oct 22, 2010 2:50 pm

Hey dude you are just rocking.. and thanks to notify me with PM:)

Here for me everything is fine to Modify but but but.. as I am new to all these, I dont know how to edit Mysql database and because of that I am just afraid to do that as it may effect my running forums. So can you please know me how to do that step by step in mysql or any detail tutorial please.

I really appreciate your effort and help truly by heart.
PM me for phpbb modification
Not phpbb or php master but can help you to gain my knowledge.
On your own risk :)
For graphics and animation PM me.
Forum:http://www.pixelandgrain.in/

Tim81
Registered User
Posts: 20
Joined: Tue Aug 31, 2010 12:55 pm
Location: The Netherlands

Re: [Req] PM Read Notification

Post by Tim81 » Fri Oct 22, 2010 3:52 pm

First you will need to download PHPMyAdmin, if you haven't done so already.

Then go to the login page and login:

Image

After you login, you can select the database.
When you have selected one, you can see the table list like:

Image

Use the fourth action (Insert) on the acl_options table like below:
Image

Then you can add the needed values in the fields:
Image
And press Go to add the field to the table.

Note: As already said earlier, the value of 118 may already exist if you are using modifications, you can find that out using the browse function on this table. The auth_option_id must be unique.


Now to add a new field to the privmsgs_to table:

Select the table and show the structure:
Image

Below the list you have the following:
Image
Use the options as indicated and press Go.

Now you have the following screen:
Image
Use the values and options as displayed and press Save to add the field to the table.

User avatar
katib
Registered User
Posts: 562
Joined: Thu Jun 26, 2008 12:27 pm

Re: [Req] PM Read Notification

Post by katib » Fri Oct 22, 2010 7:57 pm

seems very intersting
Will give it a try
Thanks a lot

User avatar
jsoni
Registered User
Posts: 355
Joined: Mon Aug 02, 2010 3:55 pm
Location: Mauritius
Contact:

Re: [Req] PM Read Notification

Post by jsoni » Sat Oct 23, 2010 4:59 am

Wow dude,

You have put lots of effort to teach me. Thanks you so much. I will try and get back to you..Thanks again.
PM me for phpbb modification
Not phpbb or php master but can help you to gain my knowledge.
On your own risk :)
For graphics and animation PM me.
Forum:http://www.pixelandgrain.in/

User avatar
Boardtalk.net
Registered User
Posts: 1209
Joined: Fri Jun 05, 2009 8:12 pm
Location: Ireland
Name: Colette
Contact:

Re: [Req] PM Read Notification

Post by Boardtalk.net » Sat Oct 23, 2010 10:43 am

This is excellent work Tim and thanks for sharing it. When I get a little free time I would like to try it out.

User avatar
jsoni
Registered User
Posts: 355
Joined: Mon Aug 02, 2010 3:55 pm
Location: Mauritius
Contact:

Re: [Req] PM Read Notification

Post by jsoni » Sat Oct 23, 2010 6:13 pm

Hello Tim81,

I am having some trouble to get this work :(

Actually first let me know you that my auth_option_id is 161 as I have used so many MODs :P so is that the cause? if it is what should I do?
Even I am not getting any option into the 'User permissions' as you shown in your print screen :P

Do I need to change the number what you show '118' to '161' in any php file or template?

please let me know.
PM me for phpbb modification
Not phpbb or php master but can help you to gain my knowledge.
On your own risk :)
For graphics and animation PM me.
Forum:http://www.pixelandgrain.in/

User avatar
jsoni
Registered User
Posts: 355
Joined: Mon Aug 02, 2010 3:55 pm
Location: Mauritius
Contact:

Re: [Req] PM Read Notification

Post by jsoni » Sat Oct 23, 2010 6:23 pm

Here I am embedding images.

Image
Image
PM me for phpbb modification
Not phpbb or php master but can help you to gain my knowledge.
On your own risk :)
For graphics and animation PM me.
Forum:http://www.pixelandgrain.in/

Locked

Return to “[3.0.x] MOD Requests”