-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathclass.VolunteerPage.php
81 lines (76 loc) · 2.45 KB
/
class.VolunteerPage.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
if(file_exists('../SecurePage.php'))
{
require_once('../SecurePage.php');
}
require_once('app/VolunteerAutoload.php');
class VolunteerPage extends \Flipside\Secure\SecurePage
{
public $volunteerRoot;
/**
* @SuppressWarnings(PHPMD.Superglobals)
*/
public function __construct($title)
{
parent::__construct($title);
$root = $_SERVER['DOCUMENT_ROOT'];
$scriptDir = dirname(__FILE__);
$this->volunteerRoot = substr($scriptDir, strlen($root));
$this->addJS($this->volunteerRoot.'/js/volunteer.js');
$this->addTemplateDir(dirname(__FILE__).'/templates', 'Volunteer');
$this->setTemplateName('@Volunteer/main.html');
$this->addCSS('https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.7/css/select2.min.css');
$this->addJS('https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.7/js/select2.min.js', false);
if($this->isAdmin() || $this->isLead())
{
$this->addLink('Admin', '_admin/');
}
if($this->user !== false && $this->user !== null)
{
$this->addLink('Settings', 'settings.php');
}
$split = explode('/', $_SERVER["REQUEST_URI"]);
$page = end($split);
$noExt = pathinfo($page, PATHINFO_FILENAME);
$this->addLink('Help <i class="fas fa-question"></i>', 'docs/help.html#'.$noExt);
$browser = get_browser();
if(strpos($browser->parent, 'IE') !== false)
{
header('Location: /badBrowser.php');
exit;
}
}
public function printPage()
{
if($this->user === false || $this->user === null)
{
$this->body = '
<div id="content">
<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>
</div>';
}
parent::printPage();
}
public function isAdmin()
{
if($this->user === false || $this->user === null)
{
return false;
}
return $this->user->isInGroupNamed('VolunteerAdmins');
}
public function isLead()
{
if($this->user === false || $this->user === null)
{
return false;
}
if($this->user->isInGroupNamed('Leads'))
{
return true;
}
return false;
}
}