userModel.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <?php
  2. class userModel extends Staple_Model
  3. {
  4. private $db;
  5. private $id;
  6. private $username;
  7. private $firstName;
  8. private $lastName;
  9. private $type;
  10. private $authLevel;
  11. private $supervisorId;
  12. private $batchId;
  13. private $pin;
  14. /**
  15. * @return mixed
  16. */
  17. public function getId()
  18. {
  19. return $this->id;
  20. }
  21. /**
  22. * @param mixed $id
  23. */
  24. public function setId($id)
  25. {
  26. $this->id = $id;
  27. }
  28. /**
  29. * @return mixed
  30. */
  31. public function getUsername()
  32. {
  33. return $this->username;
  34. }
  35. /**
  36. * @param mixed $username
  37. */
  38. public function setUsername($username)
  39. {
  40. $this->username = $username;
  41. }
  42. /**
  43. * @return mixed
  44. */
  45. public function getFirstName()
  46. {
  47. return $this->firstName;
  48. }
  49. /**
  50. * @param mixed $firstName
  51. */
  52. public function setFirstName($firstName)
  53. {
  54. $this->firstName = $firstName;
  55. }
  56. /**
  57. * @return mixed
  58. */
  59. public function getLastName()
  60. {
  61. return $this->lastName;
  62. }
  63. /**
  64. * @param mixed $lastName
  65. */
  66. public function setLastName($lastName)
  67. {
  68. $this->lastName = $lastName;
  69. }
  70. /**
  71. * @return mixed
  72. */
  73. public function getType()
  74. {
  75. return $this->type;
  76. }
  77. /**
  78. * @param mixed $type
  79. */
  80. public function setType($type)
  81. {
  82. $this->type = $type;
  83. }
  84. /**
  85. * @return mixed
  86. */
  87. public function getAuthLevel()
  88. {
  89. return $this->authLevel;
  90. }
  91. /**
  92. * @param mixed $authLevel
  93. */
  94. public function setAuthLevel($authLevel)
  95. {
  96. $this->authLevel = $authLevel;
  97. }
  98. /**
  99. * @return mixed
  100. */
  101. public function getSupervisorId()
  102. {
  103. return $this->supervisorId;
  104. }
  105. /**
  106. * @param mixed $supervisorId
  107. */
  108. public function setSupervisorId($supervisorId)
  109. {
  110. $this->supervisorId = $supervisorId;
  111. }
  112. /**
  113. * @return mixed
  114. */
  115. public function getBatchId()
  116. {
  117. return $this->batchId;
  118. }
  119. /**
  120. * @param mixed $batchId
  121. */
  122. public function setBatchId($batchId)
  123. {
  124. $this->batchId = $batchId;
  125. }
  126. /**
  127. * @return mixed
  128. */
  129. public function getPin()
  130. {
  131. return $this->pin;
  132. }
  133. /**
  134. * @param mixed $pin
  135. */
  136. public function setPin($pin)
  137. {
  138. $this->pin = $pin;
  139. }
  140. function __construct()
  141. {
  142. $this->db = Staple_DB::get();
  143. $auth = Staple_Auth::get();
  144. $username = $auth->getAuthId();
  145. $sql = "SELECT id, username, firstName, lastName, authLevel, batchId FROM accounts WHERE username = '".$this->db->real_escape_string($username)."'";
  146. if($this->db->query($sql)->fetch_row() > 0)
  147. {
  148. $query = $this->db->query($sql);
  149. $result = $query->fetch_assoc();
  150. $this->setid($result['id']);
  151. $this->setUsername($result['username']);
  152. $this->setFirstName($result['firstName']);
  153. $this->setLastName($result['lastName']);
  154. $this->setAuthLevel($result['authLevel']);
  155. $this->setBatchId($result['batchId']);
  156. }
  157. else
  158. {
  159. return false;
  160. }
  161. }
  162. }
  163. ?>