Profile_Page.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /**
  3. * User profile page file.
  4. *
  5. * Provides a class with all the properties and methods to display the page.
  6. *
  7. * @category Page
  8. */
  9. /**
  10. * Require dependent files if not present.
  11. */
  12. require_once(PATH::PAGE . "Page.php");
  13. /**
  14. * User profile page model.
  15. *
  16. * @category Page
  17. */
  18. class Profile_Page extends Page{
  19. /**
  20. * @var string Player name.
  21. */
  22. public $name;
  23. /**
  24. * @var string Player email.
  25. */
  26. public $mail;
  27. /**
  28. * @var string Player API key.
  29. */
  30. public $api_key;
  31. /**
  32. * Constructor.
  33. *
  34. * Retrieves the data and initializes the variables.
  35. */
  36. public function __construct(){
  37. $this->view = PATH::VIEW . "profile.php";
  38. $s = "
  39. SELECT
  40. name,
  41. mail,
  42. api_key
  43. FROM user
  44. WHERE id = '" . get_context()->get_user()->id . "';
  45. ";
  46. $q = get_context()->get_db()->query($s);
  47. if ($r = $q->fetchArray(SQLITE3_ASSOC)){
  48. $this->name = $r["name"];
  49. $this->mail = $r["mail"];
  50. $this->api_key = $r["api_key"];
  51. }
  52. $this->title = $this->name ." - SWDB";
  53. $this->description = $this->name . " user profile";
  54. $this->canonical = URL::BASE . "profile/";
  55. }
  56. }
  57. ?>