Guild_Page.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. require_once($path["page"] . "Page.php");
  3. require_once($path["entity"] . "Guild.php");
  4. require_once($path["entity"] . "K_Guild_Skill_Group.php");
  5. /**
  6. * Guild page.
  7. */
  8. class Guild_Page extends Page{
  9. /**
  10. * @{see Guild}.
  11. */
  12. public $guild = [];
  13. /**
  14. * List of {@see K_Guild_Skill_Group}s.
  15. */
  16. public $skill_groups = [];
  17. /**
  18. * Constructor.
  19. *
  20. * Retrieves the data and initializes the variables.
  21. *
  22. * @param SQLite3 $db Connection to the database.
  23. */
  24. public function __construct($db){
  25. global $path;
  26. global $root;
  27. global $UID;
  28. parent::__construct($db);
  29. $this->view = $path["view"] . "guild.php";
  30. $s = "
  31. SELECT id
  32. FROM guild
  33. WHERE id = (SELECT guild FROM guild_member WHERE id = '$UID');
  34. ";
  35. // TODO: Where guild.member.player = ...
  36. $q = $this->db->query($s);
  37. $r = $q->fetchArray(SQLITE3_ASSOC);
  38. if ($r){
  39. $guild_id = $r["id"];
  40. $this->guild = new Guild($db, $guild_id);
  41. $this->title = $this->guild->name . " - SWDB";
  42. $this->description = $this->guild->name . " Guild details";
  43. $s = "
  44. SELECT id
  45. FROM k_guild_skill_group
  46. ORDER BY id;
  47. ";
  48. $q = $this->db->query($s);
  49. while ($r = $q->fetchArray(SQLITE3_ASSOC)){
  50. array_push($this->skill_groups, new K_Guild_Skill_Group($db, $r["id"]));
  51. }
  52. }
  53. else{
  54. $this->title = "Guild - SWDB";
  55. $this->description = "No guild";
  56. }
  57. $this->canonical = $root . "guild/";
  58. }
  59. }
  60. ?>