diff options
Diffstat (limited to 'phpBB/includes/functions_privmsgs.php')
| -rw-r--r-- | phpBB/includes/functions_privmsgs.php | 132 | 
1 files changed, 38 insertions, 94 deletions
diff --git a/phpBB/includes/functions_privmsgs.php b/phpBB/includes/functions_privmsgs.php index 9e055a319f..6c31c6d6c3 100644 --- a/phpBB/includes/functions_privmsgs.php +++ b/phpBB/includes/functions_privmsgs.php @@ -269,46 +269,46 @@ function check_rule(&$rules, &$rule_row, &$message_row, $user_id)  		case RULE_IS_LIKE:  			$result = preg_match("/" . preg_quote($rule_row['rule_string'], '/') . '/i', $check0);  		break; -		 +  		case RULE_IS_NOT_LIKE:  			$result = !preg_match("/" . preg_quote($rule_row['rule_string'], '/') . '/i', $check0);  		break; -		 +  		case RULE_IS:  			$result = ($check0 == $rule_row['rule_string']);  		break; -		 +  		case RULE_IS_NOT:  			$result = ($check0 != $rule_row['rule_string']);  		break; -		 +  		case RULE_BEGINS_WITH:  			$result = preg_match("/^" . preg_quote($rule_row['rule_string'], '/') . '/i', $check0);  		break; -		 +  		case RULE_ENDS_WITH:  			$result = preg_match("/" . preg_quote($rule_row['rule_string'], '/') . '$/i', $check0);  		break; -		 +  		case RULE_IS_FRIEND:  		case RULE_IS_FOE:  		case RULE_ANSWERED:  		case RULE_FORWARDED:  			$result = ($check0 == 1);  		break; -		 +  		case RULE_IS_USER:  			$result = ($check0 == $rule_row['rule_user_id']);  		break; -		 +  		case RULE_IS_GROUP:  			$result = in_array($rule_row['rule_group_id'], $check0);  		break; -		 +  		case RULE_TO_GROUP:  			$result = (in_array('g_' . $message_row[$check_ary['check2']], $check0) || in_array('g_' . $message_row[$check_ary['check2']], $message_row[$check_ary['check1']]));  		break; -		 +  		case RULE_TO_ME:  			$result = (in_array('u_' . $user_id, $check0) || in_array('u_' . $user_id, $message_row[$check_ary['check1']]));  		break; @@ -876,7 +876,10 @@ function update_unread_status($unread, $msg_id, $user_id, $folder_id)  		return;  	} -	global $db, $user; +	global $db, $user, $phpbb_notifications; + +	// Mark the PM as read +	$phpbb_notifications->mark_notifications_read('pm', $msg_id, $user_id);  	$sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . "  		SET pm_unread = 0 @@ -982,6 +985,7 @@ function handle_mark_actions($user_id, $mark_action)  function delete_pm($user_id, $msg_ids, $folder_id)  {  	global $db, $user, $phpbb_root_path, $phpEx; +	global $phpbb_notifications;  	$user_id	= (int) $user_id;  	$folder_id	= (int) $folder_id; @@ -1093,6 +1097,9 @@ function delete_pm($user_id, $msg_ids, $folder_id)  		$user->data['user_unread_privmsg'] -= $num_unread;  	} +	// Delete Notifications +	$phpbb_notifications->delete_notifications('pm', array_keys($delete_rows)); +  	// Now we have to check which messages we can delete completely  	$sql = 'SELECT msg_id  		FROM ' . PRIVMSGS_TO_TABLE . ' @@ -1137,6 +1144,7 @@ function delete_pm($user_id, $msg_ids, $folder_id)  function phpbb_delete_user_pms($user_id)  {  	global $db, $user, $phpbb_root_path, $phpEx; +	global $phpbb_notifications;  	$user_id = (int) $user_id; @@ -1253,6 +1261,9 @@ function phpbb_delete_user_pms($user_id)  				WHERE folder_id = ' . PRIVMSGS_NO_BOX . '  					AND ' . $db->sql_in_set('msg_id', $delivered_msg);  			$db->sql_query($sql); + +			// Delete Notifications +			$phpbb_notifications->delete_notifications('pm', $delivered_msg);  		}  		if (!empty($undelivered_msg)) @@ -1264,6 +1275,9 @@ function phpbb_delete_user_pms($user_id)  			$sql = 'DELETE FROM ' . PRIVMSGS_TABLE . '  				WHERE ' . $db->sql_in_set('msg_id', $undelivered_msg);  			$db->sql_query($sql); + +			// Delete Notifications +			$phpbb_notifications->delete_notifications('pm', $undelivered_msg);  		}  	} @@ -1306,6 +1320,9 @@ function phpbb_delete_user_pms($user_id)  			$sql = 'DELETE FROM ' . PRIVMSGS_TABLE . '  				WHERE ' . $db->sql_in_set('msg_id', $delete_ids);  			$db->sql_query($sql); + +			// Delete Notifications +			$phpbb_notifications->delete_notifications('pm', $delete_ids);  		}  	} @@ -1543,6 +1560,7 @@ function get_folder_status($folder_id, $folder)  function submit_pm($mode, $subject, &$data, $put_in_outbox = true)  {  	global $db, $auth, $config, $phpEx, $template, $user, $phpbb_root_path; +	global $phpbb_notifications;  	// We do not handle erasing pms here  	if ($mode == 'delete') @@ -1842,95 +1860,21 @@ function submit_pm($mode, $subject, &$data, $put_in_outbox = true)  	$db->sql_transaction('commit');  	// Send Notifications -	if ($mode != 'edit') -	{ -		pm_notification($mode, $data['from_username'], $recipients, $subject, $data['message'], $data['msg_id']); -	} - -	return $data['msg_id']; -} - -/** -* PM Notification -*/ -function pm_notification($mode, $author, $recipients, $subject, $message, $msg_id) -{ -	global $db, $user, $config, $phpbb_root_path, $phpEx, $auth; - -	$subject = censor_text($subject); - -	// Exclude guests, current user and banned users from notifications -	unset($recipients[ANONYMOUS], $recipients[$user->data['user_id']]); - -	if (!sizeof($recipients)) -	{ -		return; -	} - -	if (!function_exists('phpbb_get_banned_user_ids')) -	{ -		include($phpbb_root_path . 'includes/functions_user.' . $phpEx); -	} -	$banned_users = phpbb_get_banned_user_ids(array_keys($recipients)); -	$recipients = array_diff(array_keys($recipients), $banned_users); - -	if (!sizeof($recipients)) -	{ -		return; -	} - -	$sql = 'SELECT user_id, username, user_email, user_lang, user_notify_pm, user_notify_type, user_jabber -		FROM ' . USERS_TABLE . ' -		WHERE ' . $db->sql_in_set('user_id', $recipients); -	$result = $db->sql_query($sql); - -	$msg_list_ary = array(); -	while ($row = $db->sql_fetchrow($result)) -	{ -		if ($row['user_notify_pm'] == 1 && trim($row['user_email'])) -		{ -			$msg_list_ary[] = array( -				'method'	=> $row['user_notify_type'], -				'email'		=> $row['user_email'], -				'jabber'	=> $row['user_jabber'], -				'name'		=> $row['username'], -				'lang'		=> $row['user_lang'] -			); -		} -	} -	$db->sql_freeresult($result); +	$pm_data = array_merge($data, array( +		'message_subject'		=> $subject, +		'recipients'			=> $recipients, +	)); -	if (!sizeof($msg_list_ary)) +	if ($mode == 'edit')  	{ -		return; +		$phpbb_notifications->update_notifications('pm', $pm_data);  	} - -	include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); -	$messenger = new messenger(); - -	foreach ($msg_list_ary as $pos => $addr) +	else  	{ -		$messenger->template('privmsg_notify', $addr['lang']); - -		$messenger->to($addr['email'], $addr['name']); -		$messenger->im($addr['jabber'], $addr['name']); - -		$messenger->assign_vars(array( -			'SUBJECT'		=> htmlspecialchars_decode($subject), -			'AUTHOR_NAME'	=> htmlspecialchars_decode($author), -			'USERNAME'		=> htmlspecialchars_decode($addr['name']), - -			'U_INBOX'			=> generate_board_url() . "/ucp.$phpEx?i=pm&folder=inbox", -			'U_VIEW_MESSAGE'	=> generate_board_url() . "/ucp.$phpEx?i=pm&mode=view&p=$msg_id", -		)); - -		$messenger->send($addr['method']); +		$phpbb_notifications->add_notifications('pm', $pm_data);  	} -	unset($msg_list_ary); - -	$messenger->save_queue(); -	unset($messenger); +	return $data['msg_id'];  }  /**  | 
