/
user.php
115 lines (96 loc) · 2.2 KB
/
user.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<?php
// @author jack krawczyk -- @jackk
// last updated: Mar 3, 2012
// User profile class definition
// This class is the predominant object upon which floathope is built.
// There are a few methods that still need to have validation implemented.
class user
{
public $firstName;
public $lastName;
public $email;
public $userID;
public $guiltySites;
public $charityList;
// billing info
public $addressLine1;
public $addressLine2;
public $billingCity;
public $billingState;
public $billingZip;
public $billingCountry;
public function __construct($userid)
{
$this->firstName = "";
$this->lastName = "";
$this->userID = $userid;
$this->guiltySites = array();
$this->charityList = array();
}
public function setFirstName($fn)
{
$this->firstName = $fn;
}
public function setLastName($ln)
{
$this->lastName = $ln;
}
public function setEmail($inputEmail)
{
$this->email = $inputEmail;
}
public function addGuiltySite($site)
{
$this->guiltySites[count($this->guiltySites)] = $site;
}
public function getGuiltySiteByIndex($inputIndex)
{
if(count($this->guiltySites) < $inputIndex)
{
$indexItem = $this->guiltySites[$inputIndex];
return $indexItem;
}
else
{
// handle incorrect input index
}
}
public function addCharity($charity)
{
$this->charityList[count($this->charityList)] = $charity;
}
public function getCharityByIndex($inputIndex)
{
if(count($this->charityList) < $inputIndex)
{
$indexItem = $this->charityList[$inputIndex];
return $indexItem;
}
else
{
// handle incorrect input index
}
}
public function getUserInfo($inputUser)
{
$this->firstName = $inputUser->firstName;
$this->lastName = $inputUser->lastName;
$this->userID = $inputUser->userID;
return $this;
}
public function getName()
{
return $this->firstName . " " .$this->lastName;
}
// return all user data into JSON for communication across PHP & Chrome Extension
public function printUserJSON()
{
$jsonArray = array('userid' => $this->userID,
'name' => $this->getName(),
'guiltySites' => $this->guiltySites,
'charityList' => $this->charityList);
$jsonToReturn = json_encode($jsonArray);
return $jsonToReturn;
}
}
?>