Commit ea65a307 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Fix bug in 'delete all notifications' for notifications with replies (bug #664521)


Signed-off-by: default avatarRichard Mansfield <richard.mansfield@catalyst.net.nz>
parent 6287624f
......@@ -178,8 +178,23 @@ $deleteall = pieform(array(
function delete_all_notifications_submit() {
global $USER, $SESSION;
db_begin();
$count = count_records('notification_internal_activity', 'usr', $USER->get('id'));
// Remove parent pointers to messages we're about to delete
// Use temp table in subselect for Mysql compat.
execute_sql("
UPDATE {notification_internal_activity}
SET parent = NULL
WHERE parent IN (
SELECT id
FROM (
SELECT id FROM {notification_internal_activity} WHERE usr = ?
) AS temp
)",
array($USER->get('id'))
);
delete_records('notification_internal_activity', 'usr', $USER->get('id'));
db_commit();
$SESSION->add_ok_msg(get_string('deletednotifications', 'activity', $count));
redirect(get_config('wwwroot') . 'account/activity/index.php');
}
......
Markdown is supported
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