Completed
Pull Request — master (#22)
by Patrick
02:13
created

ProfilesLeadPage::add_header()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 74
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 14
nc 4
nop 0
dl 0
loc 74
rs 9.0335
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
require_once('class.ProfilesPage.php');
3
require_once('class.FlipSession.php');
4
class ProfilesLeadPage extends FlipAdminPage
5
{
6
    private $is_lead;
7
8
    function __construct($title)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
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');
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->add_links();
29
        $this->addWellKnownJS(JS_DATATABLE, false);
30
        $this->addWellKnownJS(JQUERY_VALIDATE);
31
        $this->addWellKnownJS(JS_METISMENU);
32
        $this->addJSByURI('../_admin/js/admin.js');
33
        $this->addWellKnownJS(JS_LOGIN);
34
    }
35
36
    function add_leads_css()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
37
    {
38
        $this->addWellKnownCSS(CSS_DATATABLE);
39
        $this->addCSSByURI('../css/profiles.css');
40
        $this->addCSSByURI('css/lead.css');
41
    }
42
43
    function add_links()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
44
    {
45
         $dirMenu = array(
46
             'All' => 'directory.php',
47
             'AAR' => 'directory.php?filter=aar',
48
             'AFs' => 'directory.php?filter=af',
49
             'CC'  => 'directory.php?filter=cc',
50
             '360/24/7 Department' => 'directory.php?filter=360',
51
             'Art' => 'directory.php?filter=Art',
52
             'City Planning' => 'directory.php?filter=CityPlanning',
53
             'Communications' => 'directory.php?filter=Comm',
54
             'Genesis' => 'directory.php?filter=Genesis',
55
             'Safety' => 'directory.php?filter=Safety',
56
             'Site-Ops' => 'directory.php?filter=site-ops',
57
             'Site Prep' => 'directory.php?filter=siteprep',
58
             'Site Sign-Off' => 'directory.php?filter=sign-off',
59
             'Volunteer Coordinator' => 'directory.php?filter=vc'
60
         );
61
         $this->addLink('<span class="fa fa-dashboard"></span> Dashboard', 'index.php');
62
         $this->addLink('<span class="fa fa-th-list"></span> Directory', false, $dirMenu);
63
    }
64
    
65
    public function isAdmin()
66
    {
67
        return $this->is_lead;
68
    }
69
}
70
?>
0 ignored issues
show
Best Practice introduced by
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...
71