* @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; } }