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', false); |
|
|
|
|
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
|
|
|
$split = explode('/', $_SERVER["REQUEST_URI"]); |
31
|
|
|
$page = end($split); |
32
|
|
|
$noExt = pathinfo($page, PATHINFO_FILENAME); |
33
|
|
|
$this->addLink('Help <i class="fas fa-question"></i>', 'docs/help.html#'.$noExt); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
public function printPage() |
37
|
|
|
{ |
38
|
|
|
if($this->user === false || $this->user === null) |
39
|
|
|
{ |
40
|
|
|
$this->body = ' |
41
|
|
|
<div id="content"> |
42
|
|
|
<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> |
43
|
|
|
</div>'; |
44
|
|
|
} |
45
|
|
|
parent::printPage(); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public function isAdmin() |
49
|
|
|
{ |
50
|
|
|
if($this->user === false || $this->user === null) |
51
|
|
|
{ |
52
|
|
|
return false; |
53
|
|
|
} |
54
|
|
|
return $this->user->isInGroupNamed('VolunteerAdmins'); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
public function isLead() |
58
|
|
|
{ |
59
|
|
|
if($this->user === false || $this->user === null) |
60
|
|
|
{ |
61
|
|
|
return false; |
62
|
|
|
} |
63
|
|
|
if($this->user->isInGroupNamed('Leads')) |
64
|
|
|
{ |
65
|
|
|
return true; |
66
|
|
|
} |
67
|
|
|
return false; |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|
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. Please note the @ignore annotation hint above.