| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- <?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(){
- parent::__construct();
- $this->set_public(true);
- $this->set_view("guild.php");
- $this->set_canonical("player/" . get_context()->get_player()->get_id() . "/guild/");
- $this->add_css("guild.css");
-
- $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->set_title($this->guild->get_name());
- $this->set_description($this->guild->get_name() . " Guild");
- $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->set_title("Guild");
- $this->set_description("The player is not in a guild");
- }
- $this->set_code(200);
- $this->set_message("OK");
- }
-
- /**
- * 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;
- }
- }
|