Passed
Push — master ( d7e703...d0dd1b )
by Patrick
09:55
created

VolunteerEvent::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 3
rs 10
1
<?php
2
class VolunteerEvent extends VolunteerObject
3
{
4
    public function __construct($departmentID, $dbData = null)
5
    {
6
        parent::__construct($departmentID, $dbData, 'events', '_id');
7
    }
8
9
    public function hasVolOnEEList($uid, $eeListIndex)
10
    {
11
        if($eeListIndex === 1 || $eeListIndex === 0)
12
        {
13
            //Check earlier EE lists too
14
            $val = $this->hasVolOnEEList($uid, $eeListIndex + 1);
15
            if($val === true)
16
            {
17
                return true;
18
            }
19
        }
20
        if(isset($this->dbData['eeLists']) && isset($this->dbData['eeLists'][$eeListIndex]))
21
        {
22
            $eeList = $this->dbData['eeLists'][$eeListIndex];
23
            if(isset($eeList[$uid]) && $eeList[$uid]['AAR'] === true && $eeList[$uid]['AF'] === true && $eeList[$uid]['Lead'] === true)
24
            {
25
                return true;
26
            }
27
        }
28
        return false;
29
    }
30
31
    public function addToEEList($uid, $eeListIndex)
32
    {
33
        if(!isset($this->dbData['eeLists']))
34
        {
35
            $this->dbData['eeLists'] = array();
36
        }
37
        if(!isset($this->dbData['eeLists'][$eeListIndex]))
38
        {
39
            $this->dbData['eeLists'][$eeListIndex] = array();
40
        }
41
        $eeList = $this->dbData['eeLists'][$eeListIndex];
0 ignored issues
show
Unused Code introduced by
The assignment to $eeList is dead and can be removed.
Loading history...
42
        if(!isset($this->dbData['eeLists'][$eeListIndex][$uid]))
43
        {
44
            $this->dbData['eeLists'][$eeListIndex][$uid] = array('AAR'=>false, 'AF'=>false, 'Lead'=>false);
45
            $dt = $this->getDataTable();
46
            $filter = $this->getDataFilter();
47
            return $dt->update($filter, $this->dbData);
48
        }
49
        return true;
50
    }
51
}
52
/* vim: set tabstop=4 shiftwidth=4 expandtab: */
53