Completed
Push — FVSv2 ( e85196...534a54 )
by Patrick
01:34
created

class.VolunteerPage.php (4 issues)

Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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
    function __construct($title)
0 ignored issues
show
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...
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', false);
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
    function printPage($header = true)
0 ignored issues
show
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...
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($header);
42
    }
43
44
    function isAdmin()
0 ignored issues
show
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...
45
    {
46
        if($this->user === false || $this->user === null)
47
        {
48
            return false;
49
        }
50
        return $this->user->isInGroupNamed('VolunteerAdmins');
51
    }
52
53
    function isLead()
0 ignored issues
show
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...
54
    {
55
        if($this->user === false || $this->user === null)
56
        {
57
            return false;
58
        }
59
        return $this->user->isInGroupNamed('Leads');
60
    }
61
}
62