Commit 0a9400b2 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Delete friend notifications when requester is deleted (bug #872641)



Friend request notifications from deleted users stay in the inbox,
and contain a url to the deleted user's profile.  We should just
delete these notifications, because they're no longer useful.

Change-Id: I224197238e3d5ca2f90bd28514a07f6d5d6b9852
Signed-off-by: default avatarRichard Mansfield <richard.mansfield@catalyst.net.nz>
parent 0043cc83
...@@ -84,6 +84,13 @@ class PluginNotificationInternal extends PluginNotification { ...@@ -84,6 +84,13 @@ class PluginNotificationInternal extends PluginNotification {
public static function deleteuser($event, $user) { public static function deleteuser($event, $user) {
delete_records('notification_internal_activity', 'usr', $user['id']); delete_records('notification_internal_activity', 'usr', $user['id']);
// Delete system messages from this user where the url points to their
// missing profile. They're mostly friend requests, which are now useless.
delete_records_select(
'notification_internal_activity',
'"from" = ? AND type = (SELECT id FROM {activity_type} WHERE name = ?) AND url = ?',
array($user['id'], 'maharamessage', get_config('wwwroot') . 'user/view.php?id=' . $user['id'])
);
} }
/** /**
......
...@@ -98,6 +98,7 @@ function requestfriendship_submit(Pieform $form, $values) { ...@@ -98,6 +98,7 @@ function requestfriendship_submit(Pieform $form, $values) {
$n = new StdClass; $n = new StdClass;
$n->url = get_config('wwwroot') . 'user/view.php?id=' . $loggedinid; $n->url = get_config('wwwroot') . 'user/view.php?id=' . $loggedinid;
$n->users = array($user->id); $n->users = array($user->id);
$n->fromuser = $loggedinid;
$lang = get_user_language($user->id); $lang = get_user_language($user->id);
$displayname = display_name($USER, $user); $displayname = display_name($USER, $user);
$n->strings->urltext = (object) array('key' => 'Requests'); $n->strings->urltext = (object) array('key' => 'Requests');
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment