Completed
Pull Request — master (#2076)
by Ilia
17:01 queued 08:55
created

start.php ➔ delete_old_notif_init()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
elgg_register_event_handler('init', 'system', 'delete_old_notif_init');
4
5
/*
6
 * Plugin Init
7
 */
8
9
function delete_old_notif_init() {
10
	elgg_register_library('elgg:old_notification:functions', elgg_get_plugins_path() . 'delete_old_notif/lib/functions.php');
11
	elgg_register_plugin_hook_handler('cron', 'weekly', 'delete_weekly_cron_handler', 100);
12
	elgg_register_event_handler('pagesetup', 'system', 'delete_old_notif_pagesetup');
13
}
14
15
function delete_weekly_cron_handler($hook, $entity_type, $return_value, $params) {
16
	echo "<p>Starting up the cron job for the delete old notification (delete_old_notif plugin)</p>";
17
	elgg_load_library('elgg:old_notification:functions');
18
19
	$cutoff_timestamp = time() - ( elgg_get_plugin_setting('delete_old_notif_cutoff', 'delete_old_notif', 90) * 24 * 60 * 60 );
20
	$err = initialize_list( $cutoff_timestamp );
21
	
22
	if (!$err)
23
		delete_notifications();
24
}