Databasebackup_ModelAdmin::canView()   A
last analyzed

Complexity

Conditions 5
Paths 6

Size

Total Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 17
rs 9.3888
c 0
b 0
f 0
cc 5
nc 6
nop 1
1
<?php
2
3
4
5
class Databasebackup_ModelAdmin extends ModelAdmin
6
{
7
    private static $managed_models = array('DatabasebackupLog');
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...
8
9
    private static $url_segment = 'databasebackuplog';
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...
10
11
    private static $menu_title = 'Database Backup';
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...
12
13
    private static $allowed_actions = array(
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...
14
        "test"
15
    );
16
17
    /**
18
     * @param Member $member
0 ignored issues
show
Documentation introduced by
Should the type for parameter $member not be Member|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
19
     * @return boolean
20
     */
21
    public function canView($member = null)
22
    {
23
        if (!$member && $member !== false) {
24
            $member = Member::currentUser();
25
        }
26
27
        // cms menus only for logged-in members
28
        if (!$member) {
29
            return false;
30
        }
31
32
        // Check for "CMS admin" permission
33
        if (Permission::checkMember($member, "ADMIN")) {
0 ignored issues
show
Unused Code introduced by
This if statement, and the following return statement can be replaced with return (bool) \Permissio...mber($member, 'ADMIN');.
Loading history...
34
            return true;
35
        }
36
        return false;
37
    }
38
39
40
    /**
41
     *
42
     * allows for custom CMSActions
43
     */
44
    public function getEditForm($id = null, $fields = null)
45
    {
46
        $form = parent::getEditForm($id = null, $fields = null);
47
        $listfield = $form->Fields()->fieldByName("DatabasebackupLog");
48
        $model = Injector::inst()->get("DatabasebackupLog");
0 ignored issues
show
Unused Code introduced by
$model is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
49
        $listfield->getConfig()->getComponentByType('GridFieldDetailForm')
50
            ->setItemRequestClass('DatabasebackupLogDetailForm_ItemRequest');
51
        //->setFormActions($model->getCMSActions());
52
        return $form;
53
    }
54
}
55