Completed
Push — master ( 9eda57...e722ec )
by Patrick
04:38
created

ProfilesLeadPage::__construct()   B

Complexity

Conditions 4
Paths 6

Size

Total Lines 47
Code Lines 34

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 34
nc 6
nop 1
dl 0
loc 47
rs 8.6845
c 0
b 0
f 0
1
<?php
2
require_once('class.ProfilesPage.php');
3
require_once('class.FlipSession.php');
4
class ProfilesLeadPage extends \Http\FlipAdminPage
5
{
6
    private $is_lead;
7
8
    public function __construct($title)
9
    {
10
        parent::__construct($title);
11
        if($this->user == false)
12
        {
13
            $this->is_lead = false;
14
        }
15
        else
16
        {
17
            $this->is_lead = $this->user->isInGroupNamed('Leads');
0 ignored issues
show
Bug introduced by
The property user does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
18
            if(!$this->is_lead)
19
            {
20
                $this->is_lead = $this->user->isInGroupNamed('CC');
21
            }
22
        }
23
        if($this->is_lead)
24
        {
25
            $this->is_admin = $this->is_lead;
26
        }
27
        $this->add_leads_css();
28
        $this->addWellKnownJS(JS_DATATABLE, false);
0 ignored issues
show
Unused Code introduced by
The call to ProfilesLeadPage::addWellKnownJS() has too many arguments starting with false.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
29
        $this->addWellKnownJS(JQUERY_VALIDATE);
30
        $this->addWellKnownJS(JS_METISMENU);
31
        $this->addJS('../_admin/js/admin.js');
32
        $this->addWellKnownJS(JS_LOGIN);
33
34
        $dirMenu = array(
35
                'All' => 'directory.php',
36
                'AAR' => 'directory.php?filter=aar',
37
                'AFs' => 'directory.php?filter=af',
38
                'CC'  => 'directory.php?filter=cc',
39
                '360/24/7 Department' => 'directory.php?filter=360',
40
                'Art' => 'directory.php?filter=Art',
41
                'City Planning' => 'directory.php?filter=CityPlanning',
42
                'Communications' => 'directory.php?filter=Comm',
43
                'Genesis' => 'directory.php?filter=Genesis',
44
                'Safety' => 'directory.php?filter=Safety',
45
                'Site-Ops' => 'directory.php?filter=site-ops',
46
                'Site Prep' => 'directory.php?filter=siteprep',
47
                'Site Sign-Off' => 'directory.php?filter=sign-off',
48
                'Volunteer Coordinator' => 'directory.php?filter=vc'
49
                );
50
51
        $this->content['header']['sidebar'] = array();
0 ignored issues
show
Bug introduced by
The property content does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
52
        $this->content['header']['sidebar']['Dashboard'] = array('icon' => 'fa-dashboard', 'url' => 'index.php');
53
        $this->content['header']['sidebar']['Directory'] = array('icon' => 'fa-th-list', 'menu' => $dirMenu);
54
    }
55
56
    protected function add_leads_css()
57
    {
58
        $this->addWellKnownCSS(CSS_DATATABLE);
59
        $this->addCSS('../css/profiles.css');
60
        $this->addCSS('css/lead.css');
61
    }
62
63
    public function isAdmin()
64
    {
65
        return $this->is_lead;
66
    }
67
}
68
/* vim: set tabstop=4 shiftwidth=4 expandtab: */
69