| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- <?php
- /**
- * Guild page file.
- *
- * Provides a class with all the properties and methods to display the page.
- *
- * @author Iñigo Valentin <i@inigovalentin.com>
- * @license https://www.gnu.org/licenses/gpl-3.0.en.html GNU General Public License V3
- * @package SWDB
- */
- require_once(PATH::PAGE . "Page.php");
- require_once(PATH::ENTITY . "Guild.php");
- require_once(PATH::ENTITY . "Guild_Skill_Group.php");
- /**
- * Guild page model.
- *
- * @category Page
- */
- class Guild_Page extends Page{
- /**
- * @var bool Indicates if the player is in a guild.
- */
- private $in_guild = false;
-
- /**
- * @var Guild Player guild.
- */
- private $guild;
- /**
- * @var Guild_Skill_Group[] List of Guild skill groups.
- */
- private $skill_groups = [];
- /**
- * Constructor.
- *
- * Retrieves the data and initializes the variables.
- */
- public function __construct(){
- $this->view = PATH::VIEW . "guild.php";
- $statement = get_context()->get_db()->prepare("
- SELECT id
- FROM guild
- WHERE id = (SELECT guild FROM guild_member WHERE member = :player);
- ");
- $statement->bindValue(":player", get_context()->get_player()->get_id(), SQLITE3_TEXT);
- $result_set = $statement->execute();
- $result = $result_set->fetchArray(SQLITE3_ASSOC);
- if ($result){
- $this->in_guild = true;
- $this->guild = new Guild($result["id"]);
- $this->title = $this->guild->get_name() . " - SWDB";
- $this->description = $this->guild->get_name() . " Guild details";
- $statement = get_context()->get_db()->prepare("SELECT id FROM guild_skill_group ORDER BY id;");
- $skill_result_set = $statement->execute();
- while ($result = $skill_result_set->fetchArray(SQLITE3_ASSOC)){
- array_push($this->skill_groups, new Guild_Skill_Group($result["id"]));
- }
- }
- else{
- $this->in_guild = false;
- $this->title = "Guild - SWDB";
- $this->description = "No guild";
- }
- $this->canonical = URL::BASE . "guild/";
- }
-
- /**
- * Checks if the player is in a guild.
- *
- * @return bool True if the player is in a guild, false if not.
- */
- public function in_guild(){
- return $this->in_guild;
- }
- /**
- * Retrieves the guild.
- *
- * @return Guild Selected guild
- */
- public function get_guild(){
- return $this->guild;
- }
- /**
- * Retrieves the guild skil groups.
- *
- * @return Guild_Skill_Group[] Guild skill groups
- */
- public function get_skill_groups(){
- return $this->skill_groups;
- }
- }
|