-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclass.userData.php
131 lines (110 loc) · 2.92 KB
/
class.userData.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<?php
error_reporting(E_ALL);
/**
* class.userData.php
*
* @author Philippe Gref-Viau, <[email protected]>
*/
require_once("class.database.php");
require_once("class.authentification.php");
require_once("class.util.php");
class userData
{
private $matricule = null;
private $database = null;
private $auth = null;
const MATRICULE_DB_FIELD = "matricule";
const EMAIL_DB_FIELD = "email";
const FIRST_NAME_DB_FIELD = "firstname";
const LAST_NAME_DB_FIELD = "lastname";
const PHONE_DB_FIELD = "tel_1";
const ADDRESS_DB_FIELD = "address";
const CITY__DB_FIELD = "city";
const ZIP_CODE_DB_FIELD = "zipcode";
const EMAIL_TAG = "Adresse courriel";
const FIRST_NAME_TAG = "Prénom";
const LAST_NAME_TAG = "Nom";
const PHONE_TAG = "Numéro de téléphone";
const ADDRESS_TAG = "Adresse";
const CITY_TAG = "Ville";
const ZIP_CODE_TAG = "Code postal";
private $email = "";
private $firstName = "";
private $lastName = "";
private $phone = "";
private $address = "";
private $city = "";
private $zipCode = "";
private $exist = false;
public function userData($matricule)
{
$this->database = database::instance();
$this->auth = authentification::instance();
$this->matricule = $matricule;
$this->getUserData();
}
public function getUserData()
{
if(empty($this->database) ) {
$this->exist = false;
return $this->exist;
}
if(empty($this->matricule)) {
$this->exist = false;
return $this->exist;
}
$result = $this->database->requete("SELECT * FROM st_user_metadata WHERE matricule = '$this->matricule'");
$resultDataArray = mysql_fetch_array($result);
$this->email = $resultDataArray[userData::EMAIL_DB_FIELD];
$this->firstName = $resultDataArray[userData::FIRST_NAME_DB_FIELD];
$this->lastName = $resultDataArray[userData::LAST_NAME_DB_FIELD];
$this->phone = $resultDataArray[userData::PHONE_DB_FIELD];
$this->address = $resultDataArray[userData::ADDRESS_DB_FIELD];
$this->city = $resultDataArray[userData::CITY__DB_FIELD];
$this->zipCode = $resultDataArray[userData::ZIP_CODE_DB_FIELD];
$this->exist = true;
return $this->exist;
}
public function getCurrentUserData()
{
if(!isset($this->auth) )
return false;
$this->matricule = $this->auth->getUsager();
return $this->getUserData();
}
public function getExist() {
return $this->exist;
}
public function getMatricule() {
return $this->matricule;
}
public function getEmail()
{
return $this->email;
}
public function getFirstName()
{
return util::cleanUTF8($this->firstName);
}
public function getLastName()
{
return util::cleanUTF8($this->lastName);
}
public function getPhone()
{
return $this->phone;
}
public function getAddress()
{
return util::cleanUTF8($this->address);
}
public function getCity()
{
return util::cleanUTF8($this->city);
}
public function getZipCode()
{
return $this->zipCode;
}
}
?>