BurningFlipside /
VolunteerSystem
| 1 | <?php |
||||
| 2 | require_once('class.FlipSession.php'); |
||||
| 3 | require_once('app/VolunteerAutoload.php'); |
||||
| 4 | require_once('../../class.SecurePage.php'); |
||||
| 5 | class VolunteerAdminPage extends \Http\FlipAdminPage |
||||
| 6 | { |
||||
| 7 | use SecureWebPage; |
||||
| 8 | |||||
| 9 | public $isLead; |
||||
| 10 | public $isAuthorized; |
||||
| 11 | public $secure_root; |
||||
| 12 | |||||
| 13 | public function __construct($title) |
||||
| 14 | { |
||||
| 15 | $this->isLead = false; |
||||
| 16 | $this->isAuthorized = false; |
||||
| 17 | parent::__construct($title, 'VolunteerAdmins'); |
||||
| 18 | $this->getAdminInfo(); |
||||
| 19 | $this->addLinks(); |
||||
| 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 | //Neither Firefox nor Safari have support for datetime-local. This is roughly equivalent |
||||
| 23 | $this->addCSS('https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.min.css'); |
||||
| 24 | $this->addJS('https://cdn.jsdelivr.net/npm/flatpickr'); |
||||
| 25 | $this->addJS('js/admin.js'); |
||||
| 26 | $this->addJS('../js/dialog.js'); |
||||
| 27 | $this->secure_root = $this->getSecureRoot(); |
||||
| 28 | $this->content['loginUrl'] = $this->secure_root.'api/v1/login'; |
||||
| 29 | $split = explode('/', $_SERVER["REQUEST_URI"]); |
||||
| 30 | $page = end($split); |
||||
| 31 | $noExt = pathinfo($page, PATHINFO_FILENAME); |
||||
| 32 | $this->addLink('Help <i class="fas fa-question"></i>', '../docs/admin_help.html#'.$noExt); |
||||
| 33 | } |
||||
| 34 | |||||
| 35 | protected function getAdminInfo() |
||||
| 36 | { |
||||
| 37 | if($this->is_admin === false && $this->user) |
||||
| 38 | { |
||||
| 39 | //Is the user a lead or otherwise authorized to manipulate a department? |
||||
| 40 | $this->isLead = $this->user->isInGroupNamed('Leads'); |
||||
| 41 | if($this->isLead) |
||||
| 42 | { |
||||
| 43 | $this->is_admin = true; |
||||
| 44 | } |
||||
| 45 | else |
||||
| 46 | { |
||||
| 47 | //Is this user the assistant for a department? |
||||
| 48 | $uid = $this->user->uid; |
||||
| 49 | $email = $this->user->mail; |
||||
| 50 | $filter = new \Data\Filter("others eq $uid or others eq $email"); |
||||
| 51 | $dataTable = DataSetFactory::getDataTableByNames('fvs', 'departments'); |
||||
| 52 | $depts = $dataTable->read($filter); |
||||
| 53 | $this->isLead = !empty($depts); |
||||
| 54 | $this->is_admin = true; |
||||
| 55 | } |
||||
| 56 | } |
||||
| 57 | } |
||||
| 58 | |||||
| 59 | protected function addLinks() |
||||
| 60 | { |
||||
| 61 | $this->content['header']['sidebar'] = array(); |
||||
| 62 | if($this->user === false || $this->user === null) |
||||
| 63 | { |
||||
| 64 | return; |
||||
| 65 | } |
||||
| 66 | $this->content['header']['sidebar']['Dashboard'] = array('icon' => 'fa-tachometer-alt', 'url' => 'index.php'); |
||||
| 67 | if($this->isLead === false) |
||||
| 68 | { |
||||
| 69 | $this->content['header']['sidebar']['Events'] = array('icon' => 'fa-calendar-alt', 'url' => 'events.php'); |
||||
| 70 | $this->content['header']['sidebar']['Departments'] = array('icon' => 'fa-building', 'url' => 'departments.php'); |
||||
| 71 | } |
||||
| 72 | $charts_menu = array( |
||||
| 73 | 'Shift Schedules' => 'shift_schedules.php', |
||||
| 74 | 'Shift Stats' => 'shift_stats.php', |
||||
| 75 | 'T-Shirts' => 'tshirts.php', |
||||
| 76 | 'Participant Shifts' => 'vol_shifts.php', |
||||
| 77 | 'Volunteers without Shifts' => 'no_shifts.php', |
||||
| 78 | 'Empty Shifts' => 'report_empty_shifts.php', |
||||
| 79 | 'Early Entry' => 'report_early_entry.php' |
||||
| 80 | ); |
||||
| 81 | $shifts_menu = array( |
||||
| 82 | 'Add/Edit Shifts' => 'shifts.php', |
||||
| 83 | 'Pending Shifts' => 'pending.php', |
||||
| 84 | 'Early Entry/Late Stay Approval' => 'ee.php' |
||||
| 85 | ); |
||||
| 86 | $certApprovalCount = 0; |
||||
| 87 | $certTable = \DataSetFactory::getDataTableByNames('fvs', 'certifications'); |
||||
| 88 | $userTable = \DataSetFactory::getDataTableByNames('fvs', 'participants'); |
||||
| 89 | $certs = $certTable->read(); |
||||
| 90 | if($certs !== false) |
||||
| 91 | { |
||||
| 92 | $count = count($certs); |
||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
| 93 | for($i = 0; $i < $count; $i++) |
||||
| 94 | { |
||||
| 95 | $filter = new \Data\Filter('certs.'.$certs[$i]['certID'].'.status eq pending'); |
||||
| 96 | $users = $userTable->read($filter); |
||||
| 97 | $certApprovalCount += count($users); |
||||
|
0 ignored issues
–
show
It seems like
$users can also be of type boolean; however, parameter $var of count() does only seem to accept Countable|array, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 98 | } |
||||
| 99 | } |
||||
| 100 | $certBadge = ''; |
||||
| 101 | if($certApprovalCount > 0) |
||||
| 102 | { |
||||
| 103 | $certBadge = '<span class="badge badge-secondary">'.$certApprovalCount.'</span>'; |
||||
| 104 | } |
||||
| 105 | $this->content['header']['sidebar']['Roles'] = array('icon' => 'fa-address-card', 'url' => 'roles.php'); |
||||
| 106 | $this->content['header']['sidebar']['Shifts'] = array('icon' => 'fa-tshirt', 'menu' => $shifts_menu); |
||||
| 107 | $this->content['header']['sidebar']['Volunteers'] = array('icon' => 'fa-user', 'url' => 'volunteers.php'); |
||||
| 108 | $this->content['header']['sidebar']['Certification Approval '.$certBadge] = array('icon' => 'fa-stamp', 'url' => 'cert_approval.php'); |
||||
| 109 | $this->content['header']['sidebar']['Reports'] = array('icon' => 'fa-chart-bar', 'menu' => $charts_menu); |
||||
| 110 | $this->content['header']['sidebar']['Contact'] = array('icon' => 'fa-envelope', 'url' => 'contact.php'); |
||||
| 111 | if($this->user && $this->user->isInGroupNamed('VolunteerAdmins')) |
||||
| 112 | { |
||||
| 113 | $admin_menu = array( |
||||
| 114 | 'Email Text' => 'emails.php', |
||||
| 115 | 'Certifications' => 'certs.php' |
||||
| 116 | ); |
||||
| 117 | $this->content['header']['sidebar']['Admin'] = array('icon' => 'fa-cog', 'menu' => $admin_menu); |
||||
| 118 | } |
||||
| 119 | } |
||||
| 120 | } |
||||
| 121 | /* vim: set tabstop=4 shiftwidth=4 expandtab: */ |
||||
| 122 |