1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
// Base on cp_notification |
4
|
|
|
function initialize_list( $cutoff_timestamp ){ |
5
|
|
|
$dbprefix = elgg_get_config('dbprefix'); |
6
|
|
|
$message_subtype = get_subtype_id( 'object', 'messages'); |
7
|
|
|
$fromId = elgg_get_metastring_id('fromId'); |
8
|
|
|
|
9
|
|
|
# get user guid list of old notifications and insert them all into a temp table |
10
|
|
|
$query_table = "CREATE TABLE tmp_notify_delete_list ( `guid` bigint(20) unsigned NOT NULL, PRIMARY KEY (`guid`) )"; |
11
|
|
|
$query = "INSERT INTO tmp_notify_delete_list (guid) SELECT e.guid FROM {$dbprefix}entities e |
12
|
|
|
LEFT JOIN {$db_prefix}metadata msg_fromId on e.guid = msg_fromId.entity_guid |
|
|
|
|
13
|
|
|
LEFT JOIN {$db_prefix}metastrings msvfrom ON msg_fromId.value_id = msvfrom.id |
|
|
|
|
14
|
|
|
LEFT JOIN {$db_prefix}entities efrom ON msvfrom.string = efrom.guid |
|
|
|
|
15
|
|
|
WHERE e.subtype=$message_subtype AND e.time_created < {$cutoff_timestamp} |
16
|
|
|
AND msg_fromId.name_id='{$fromId}' AND efrom.type <> 'user'"; |
17
|
|
|
|
18
|
|
|
try{ |
19
|
|
|
$result_table = insert_data($query_table); |
20
|
|
|
$result = insert_data($query); |
21
|
|
|
} catch (Exception $e) {/* let mysql take care of duplicate insert attempts and trivialize leader election*/ return 1; } |
22
|
|
|
|
23
|
|
|
return 0; |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
|
27
|
|
|
|
28
|
|
|
function delete_notifications(){ |
29
|
|
|
$delete_entities = "DELETE FROM {$dbprefix}entities WHERE guid IN (SELECT guid FROM tmp_notify_delete_list)"; |
|
|
|
|
30
|
|
|
$delete_objects = "DELETE FROM {$dbprefix}objects_entity WHERE guid IN (SELECT guid FROM tmp_notify_delete_list)"; |
31
|
|
|
$delete_metadata = "DELETE FROM {$dbprefix}metadata WHERE entity_guid IN (SELECT guid FROM tmp_notify_delete_list)"; |
32
|
|
|
$cleanup_tmp = "DROP TABLE tmp_notify_delete_list"; |
33
|
|
|
|
34
|
|
|
|
35
|
|
|
delete_data($delete_entities); |
36
|
|
|
delete_data($delete_objects); |
37
|
|
|
delete_data($delete_metadata); |
38
|
|
|
delete_data($cleanup_tmp); |
39
|
|
|
} |
This check looks for variables that are accessed but have not been defined. It raises an issue if it finds another variable that has a similar name.
The variable may have been renamed without also renaming all references.