-
Notifications
You must be signed in to change notification settings - Fork 0
/
e_event.php
84 lines (60 loc) · 2.26 KB
/
e_event.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
/*
* e107 website system
*
* Copyright (C) 2008-2013 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
* XXX HIGHLY EXPERIMENTAL AND SUBJECT TO CHANGE WITHOUT NOTICE.
*/
if (!defined('e107_INIT')) { exit; }
class lscache_event // plugin-folder + '_event'
{
/**
* Configure functions/methods to run when specific e107 events are triggered.
* For a list of events, please visit: http://e107.org/developer-manual/classes-and-methods#events
* Developers can trigger their own events using: e107::getEvent()->trigger('plugin_event',$array);
* Where 'plugin' is the folder of their plugin and 'event' is a unique name of the event.
* $array is data which is sent to the triggered function. eg. myfunction($array) in the example below.
*
* @return array
*/
function config()
{
$event = array();
$event[] = array(
'name' => "admin_ui_updated", // when this is triggered... (see http://e107.org/developer-manual/classes-and-methods#events)
'function' => "clearCache",
);
$event[] = array(
'name' => "admin_ui_created", // when this is triggered... (see http://e107.org/developer-manual/classes-and-methods#events)
'function' => "clearCache",
);
$event[] = array(
'name' => "admin_ui_delete", // when this is triggered... (see http://e107.org/developer-manual/classes-and-methods#events)
'function' => "clearCache",
);
$event[] = array(
'name' => "cache_clear_all", // when this is triggered... (see http://e107.org/developer-manual/classes-and-methods#events)
'function' => "clearCache",
);
$event[] = array(
'name' => "admin_after_clear_cache", // when this is triggered... (see http://e107.org/developer-manual/classes-and-methods#events)
'function' => "clearCache",
);
return $event;
}
function clearCache($data=null)
{
if(!empty($data['plugin']))
{
header('X-LiteSpeed-Purge: public,tag='.$data['plugin'].';private,tag='.$data['plugin']);
e107::getMessage()->addInfo('Clearing LiteSpeed public/private cache with tag:<b>'.$data['plugin'].'</b>');
}
else
{
header('X-LiteSpeed-Purge: public,*;private,*');
e107::getMessage()->addInfo('Clearing all LiteSpeed public/private cache');
}
}
} //end class