|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace SilverLeague\LogViewer\Model; |
|
4
|
|
|
|
|
5
|
|
|
use SilverStripe\ORM\DataObject; |
|
6
|
|
|
use SilverStripe\Security\Permission; |
|
7
|
|
|
use SilverStripe\Security\PermissionProvider; |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* A LogEntry is a set of data provided from Monolog via the DataObjectHandler |
|
11
|
|
|
* |
|
12
|
|
|
* @package silverstripe-logviewer |
|
13
|
|
|
* @author Robbie Averill <[email protected]> |
|
14
|
|
|
*/ |
|
15
|
|
|
class LogEntry extends DataObject implements PermissionProvider |
|
16
|
|
|
{ |
|
17
|
|
|
/** |
|
18
|
|
|
* {@inheritDoc} |
|
19
|
|
|
*/ |
|
20
|
|
|
private static $table_name = 'LogEntry'; |
|
|
|
|
|
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* {@inheritDoc} |
|
24
|
|
|
*/ |
|
25
|
|
|
private static $db = [ |
|
|
|
|
|
|
26
|
|
|
'Entry' => 'Text', |
|
27
|
|
|
'Level' => 'Varchar' |
|
28
|
|
|
]; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* {@inheritDoc} |
|
32
|
|
|
*/ |
|
33
|
|
|
private static $summary_fields = [ |
|
|
|
|
|
|
34
|
|
|
'Entry', |
|
35
|
|
|
'Created', |
|
36
|
|
|
'Level' |
|
37
|
|
|
]; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* Permissions |
|
41
|
|
|
*/ |
|
42
|
|
|
public function providePermissions() |
|
43
|
|
|
{ |
|
44
|
|
|
return array( |
|
45
|
|
|
'DELETE_ENTRY' => array( |
|
46
|
|
|
'name' => _t('LogEntry.PERMISSION_DELETE_DESCRIPTION', 'Delete log entries'), |
|
47
|
|
|
'category' => _t('Permissions.LOGENTRY_CATEGORY', 'Log entry permissions'), |
|
48
|
|
|
'help' => _t('LogEntry.PERMISSION_DELETE_HELP', 'Permission required to delete existing log entries.') |
|
49
|
|
|
), |
|
50
|
|
|
'VIEW_ENTRY' => array( |
|
51
|
|
|
'name' => _t('LogEntry.PERMISSION_VIEW_DESCRIPTION', 'View log entries'), |
|
52
|
|
|
'category' => _t('Permissions.LOGENTRY_CATEGORY', 'Log entry permissions'), |
|
53
|
|
|
'help' => _t('LogEntry.PERMISSION_VIEW_HELP', 'Permission required to view existing log entries.') |
|
54
|
|
|
), |
|
55
|
|
|
); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* {@inheritdoc} |
|
60
|
|
|
*/ |
|
61
|
|
|
public function canCreate($member = null, $context = []) |
|
62
|
|
|
{ |
|
63
|
|
|
return false; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* We should never edit log entries |
|
68
|
|
|
* |
|
69
|
|
|
* {@inheritDoc} |
|
70
|
|
|
*/ |
|
71
|
|
|
public function canEdit($member = null) |
|
72
|
|
|
{ |
|
73
|
|
|
return false; |
|
74
|
|
|
} |
|
75
|
|
|
/** |
|
76
|
|
|
* {@inheritdoc} |
|
77
|
|
|
*/ |
|
78
|
|
|
public function canDelete($member = null) |
|
79
|
|
|
{ |
|
80
|
|
|
return Permission::checkMember($member, array('DELETE_ENTRY', 'CMS_ACCESS_LogViewerAdmin')); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* {@inheritdoc} |
|
85
|
|
|
*/ |
|
86
|
|
|
public function canView($member = null) |
|
87
|
|
|
{ |
|
88
|
|
|
return Permission::checkMember($member, array('VIEW_ENTRY', 'CMS_ACCESS_LogViewerAdmin')); |
|
89
|
|
|
} |
|
90
|
|
|
} |
|
91
|
|
|
|