Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Branch: master
Tyler Smith
202 lines (185 sloc) 10.15 kB
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="modx.prosilver.en.xsl"?>
<!--For security purposes, please check: http://www.phpbb.com/mods/ for the latest version of this MOD. Although MODs are checked before being allowed in the MODs Database there is no guarantee that there are no security problems within the MOD. No support will be given for MODs not found within the MODs Database which can be found at http://www.phpbb.com/mods/-->
<mod xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.phpbb.com/mods/xml/modx-1.2.0.xsd">
<header>
<license>http://opensource.org/licenses/gpl-license.php GNU General Public License v2</license>
<title lang="en">Send PM on Friend</title>
<description lang="en">Sends a PM to tell people that someone has added them as a friend </description>
<author-group>
<author>
<realname>Tyler Smith</realname>
<email>blazes816@yahoo.com</email>
<username>blazes816</username>
<homepage>http://tylersmith.me</homepage>
<contributions />
</author>
</author-group>
<author-notes lang="en">send_friend_pm function written by Kevin Martin (DualFusion) yusuka_madik@yahoo.com </author-notes>
<author-group/>
<mod-version>0.3.0</mod-version>
<installation>
<level>easy</level>
<time>300</time>
<target-version>3.0.2</target-version>
</installation>
<history>
<entry>
<date>2009-10-08</date>
<rev-version>0.4.0</rev-version>
<changelog lang="en">
<change>Fix error where PM has link to add friend, even if the other user is already a friend</change>
</changelog>
</entry>
<entry>
<date>2009-10-09</date>
<rev-version>0.4.1</rev-version>
<changelog lang="en">
<change>Added DB extraction support.</change>
</changelog>
</entry> </history>
</header>
<action-group>
<open src="includes/functions_privmsgs.php">
<edit>
<find>?></find>
<action type="before-add">
<![CDATA[
function send_friend_pm($user_id, $friendusername, $friend_user_id, $link = true, $send_id = 2) {
global $config, $user, $db, $phpbb_root_path, $phpEx;
include_once($phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx);
$sql = 'SELECT username, user_regdate, user_email
FROM ' . USERS_TABLE . '
WHERE user_id = ' . $user_id;
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
$username = $row['username'];
$user_ip = $user->ip;
$user_regdate = $user->format_date($row['user_regdate']);
$user_email = $row['user_email'];
// Backup the $user->data array, as we have to modify it
$backup_user = array(
'data' => $user->data,
'ip' => $user->ip,
);
$sql = 'SELECT username, user_colour
FROM ' . USERS_TABLE . '
WHERE user_id = ' . (int) $send_id;
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
$user->data = array_merge($user->data, array(
'user_id' => (int) $send_id,
'is_registered' => 0,
'username' => $row['username'],
'user_colour' => $row['user_colour'],
));
$user->ip = '0.0.0.0';
$sql = 'SELECT user_avatar, user_avatar_type, user_avatar_width, user_avatar_height
FROM ' . USERS_TABLE . '
WHERE user_id = ' . (int) $friend_user_id;
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
// Parse the text with the bbcode parser and write into $text
$subject = sprintf($user->lang['FRIEND_PM_SUBJECT'], $friendusername);
if($link) {
$template = $user->lang['FRIEND_PM_MESSAGE'];
}
else {
$template = $user->lang['FRIEND_PM_MESSAGE_NO_LINK'];
}
$message = sprintf($template, $friend_user_id, $friendusername,
($user->optionget('viewavatars')) ? get_user_avatar($row['user_avatar'], $row['user_avatar_type'], $row['user_avatar_width'], $row['user_avatar_height']) : '');
$text = utf8_normalize_nfc($message);
$uid = $bitfield = $options = ''; // will be modified by generate_text_for_storage
$allow_bbcode = $allow_smilies = true;
$allow_urls = false;
generate_text_for_storage($text, $uid, $bitfield, $options, $allow_bbcode, $allow_urls, $allow_smilies);
$text = generate_text_for_display($text, $uid, $bitfield, $options);
$user->add_lang('ucp');
// Switch array keys, with values in welcome pm.
$pm_vars = array(
'{USERNAME}' => $username,
'{USER_IP}' => $user_ip,
'{USER_REGDATE}' => $user_regdate,
'{USER_EMAIL}' => $user_email,
'{SITE_NAME}' => $config['sitename'],
'{SITE_DESC}' => $config['site_desc'],
);
$text = str_replace(array_keys($pm_vars), array_values($pm_vars), $text);
$pm_data = array(
'address_list' => array('u' => array($user_id => 'to')),
'from_user_id' => $user->data['user_id'],
'from_user_ip' => $user->data['user_ip'],
'from_username' => $user->data['username'],
'enable_sig' => false,
'enable_bbcode' => true,
'enable_smilies' => true,
'enable_urls' => false,
'icon_id' => 0,
'bbcode_bitfield' => $bitfield,
'bbcode_uid' => $uid,
'message' => $text,
);
submit_pm('post', $subject, $pm_data, false);
// Restore the $user->data array
$user->data = $backup_user['data'];
$user->ip = $backup_user['ip'];
unset($backup_user);
}
]]>
</action>
</edit>
</open>
<open src="language/en/ucp.php">
<edit>
<find><![CDATA[ 'PM_ACTION' => array(]]>
</find>
<action type="before-add"><![CDATA[
'FRIEND_PM_SUBJECT' => '%s wants to be friends!',
'FRIEND_PM_MESSAGE' => '%3$s<br /><a href="memberlist.php?mode=viewprofile&u=%1$d">%2$s</a> has added you as his or her friend. <a href="ucp.php?i=zebra&add=%2$s">Add %2$s to your friends?</a>',
'FRIEND_PM_MESSAGE_NO_LINK' => '%3$s<br /><a href="memberlist.php?mode=viewprofile&u=%1$d">%2$s</a> has added you as his or her friend.',]]>
</action>
</edit>
</open>
<open src="includes/ucp/ucp_zebra.php">
<edit>
<find>class ucp_zebra</find>
<action type="before-add">include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
include($phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx);
</action>
</edit>
<edit>
<find><![CDATA[
if ($row['user_id'] != ANONYMOUS && $row['user_type'] != USER_IGNORE)
{
$user_id_ary[] = $row['user_id'];
}
]]>
</find>
<action type="before-add">$friend_to_be_id = $row['user_id'];</action>
</edit>
<edit>
<find> meta_refresh(3, $this->u_action);</find>
<action type="before-add"><![CDATA[
if($mode == 'friends' && $data['add'][0] != '') {
$sql = "SELECT * FROM ".ZEBRA_TABLE." WHERE user_id = {$friend_to_be_id} AND zebra_id = {$user->data['user_id']}";
$db->sql_query($sql);
$friend_already = $db->sql_affectedrows();
if($friend_already < 1) {
$link = true;
}
else {
$link = false;
}
send_friend_pm($friend_to_be_id, $user->data['username'], $user->data['user_id'], $link);
$db->sql_freeresult($result);
}
]]>
</action>
</edit>
</open>
</action-group>
</mod>
Jump to Line
Something went wrong with that request. Please try again.