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
| class User {
// ATTRIBUTES
private $user_id;
private $right;
private $location;
private $user_last_name;
private $user_first_name;
private $phone;
private $email;
private $department;
private $login;
private $password;
private $last_login;
// CONSTRUCTOR
public function __construct() {
}
// SETTERS
public function setUserId($value) { $this->user_id = $value; }
public function setRight($r) { $this->right = new Right(); $this->right->setFromRight($r); }
public function setLocation($l) { $this->location = new Location(); $this->location->setFromLocation($l); }
public function setUserLastName($value) { $this->user_last_name = $value; }
public function setUserFirstName($value) { $this->user_first_name = $value; }
public function setPhone($value) { $this->phone = $value; }
public function setEmail($value) { $this->email = $value; }
public function setDepartment($value) { $this->department = $value; }
public function setLogin($value) { $this->login = $value; }
public function setPassword($value) { $this->password = $value; }
public function setLastLogin($value) { $this->last_login = $value; }
public function set($user_id, $right, $location, $user_last_name, $user_first_name, $phone, $email, $department, $login, $password, $last_login) {
$this->setUserId($user_id);
$this->setRight($right);
$this->setLocation($location);
$this->setUserLastName($user_last_name);
$this->setUserFirstName($user_first_name);
$this->setPhone($phone);
$this->setEmail($email);
$this->setDepartment($department);
$this->setLogin($login);
$this->setPassword($password);
$this->setLastLogin($last_login);
}
public function setFromUser($u) {
$this->setUserId($u->getUserId());
$this->setRight($u->getRight());
$this->setLocation($u->getLocation());
$this->setUserLastName($u->getUserLastName());
$this->setUserFirstName($u->getUserFirstName());
$this->setPhone($u->getPhone());
$this->setEmail($u->getEmail());
$this->setDepartment($u->getDepartment());
$this->setLogin($u->getLogin());
$this->setPassword($u->getPassword());
$this->setLastLogin($u->getLastLogin());
}
// GETTERS
public function getUserId() { return $this->user_id; }
public function getRight() { return $this->right; }
public function getLocation() { return $this->location; }
public function getUserLastName() { return $this->user_last_name; }
public function getUserFirstName() { return $this->user_first_name; }
public function getPhone() { return $this->phone; }
public function getEmail() { return $this->email; }
public function getDepartment() { return $this->department; }
public function getLogin() { return $this->login; }
public function getPassword() { return $this->password; }
public function getLastLogin() { return $this->last_login; }
public function get(){
return array(getUserId(), getFromRight(), getFromLocation(), getUserLastName(), getUserFirstName(), getPhone(),
getEmail(), getDepartment(), getLogin(), getPassword(), getLastLogin());
}
// DATABASE ACCESS
public function getUserFromDb($db, $idUser){
$query = "SELECT * FROM `user`
WHERE `id_user`=?";
$myUser = $db->prepare($query);
$myUser->execute(array($idUser));
$row = $myUser->fetch(PDO::FETCH_OBJ);
$myRight = new Right();
$myRight->getRightFromDb($db, $row->id_right);
$myLocation = new Location();
$myLocation->getLocationFromDb($db, $row->id_location);
$this->set($row->id_user, $myRight, $myLocation, $row->user_last_name, $row->user_fist_name, $row->phone,
$row->email, $row->department, $row->login, $row->password, $row->last_login);
}
public function addToDb(){
}
public function updateDb(){
}
public function deleteFromDb(){
}
} |
Partager