Completed
Push — master ( caf2b3...e6bed0 )
by Robbie
25s
created

LogEntry::canDelete()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
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';
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
Unused Code introduced by
The property $table_name is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
21
22
    /**
23
     * {@inheritDoc}
24
     */
25
    private static $db = [
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
Unused Code introduced by
The property $db is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
26
        'Entry'    => 'Text',
27
        'Level'    => 'Varchar'
28
    ];
29
30
    /**
31
     * {@inheritDoc}
32
     */
33
    private static $summary_fields = [
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
Unused Code introduced by
The property $summary_fields is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
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