Completed
Push — master ( df6d12...eab9e2 )
by Patrick
01:41 queued 10s
created

VolunteerPage::isLead()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
nc 2
nop 0
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
<?php
2
ini_set('display_errors', 1);
3
error_reporting(E_ALL);
4
require_once('class.SecurePage.php');
5
require_once('class.FlipSession.php');
6
require_once('app/VolunteerAutoload.php');
7
class VolunteerPage extends SecurePage
8
{
9
    public  $volunteerRoot;
10
11
    public function __construct($title)
12
    {
13
        parent::__construct($title);
14
        $root = $_SERVER['DOCUMENT_ROOT'];
15
        $script_dir = dirname(__FILE__);
16
        $this->volunteerRoot = substr($script_dir, strlen($root));
17
        $this->addJS($this->volunteerRoot.'/js/volunteer.js');
18
        $this->addTemplateDir(dirname(__FILE__).'/templates', 'Volunteer');
19
        $this->setTemplateName('@Volunteer/main.html');
20
        $this->addCSS('https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.7/css/select2.min.css');
21
        $this->addJS('https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.7/js/select2.min.js');
22
        if($this->isAdmin() || $this->isLead())
23
        {
24
            $this->addLink('Admin', '_admin/');
25
        }
26
        if($this->user !== false && $this->user !== null)
27
        {
28
            $this->addLink('Settings', 'settings.php');
29
        }
30
    }
31
32
    public function printPage()
33
    {
34
        if($this->user === false || $this->user === null)
35
        {
36
            $this->body = '
37
<div id="content">
38
    <h1>You must <a href="https://profiles.burningflipside.com/login.php?return='.$this->currentURL().'">log in <span class="fa fa-sign-in-alt"></span></a> to access the Burning Flipside Volunteer system!</h1>
39
</div>';
40
        }
41
        parent::printPage();
42
    }
43
44
    public function isAdmin()
45
    {
46
        if($this->user === false || $this->user === null)
47
        {
48
            return false;
49
        }
50
        return $this->user->isInGroupNamed('VolunteerAdmins');
51
    }
52
53
    public function isLead()
54
    {
55
        if($this->user === false || $this->user === null)
56
        {
57
            return false;
58
        }
59
        return $this->user->isInGroupNamed('Leads');
60
    }
61
}
62