has_defense; } /** * Constructor. * * Searches the database and retrieves the information about the * guild, populating it and it's items. * * @param int $id Guild identifier. */ public function __construct($id){ $statement = get_context()->get_db()->prepare(" SELECT member, guild, name, level, grade, rating, arena_score, joined, last_login, in_war, has_defense FROM guild_member WHERE member = :member; "); $statement->bindValue(':member', $id, SQLITE3_TEXT); $r = $statement->execute()->fetchArray(SQLITE3_ASSOC); if ($r){ $this->id = $r["member"]; $this->guild = $r["guild"]; $this->name = HTML::e($r["name"]); $this->level = $r["level"]; $this->grade = $r["grade"]; $this->rating = $r["rating"]; $this->arena_score = $r["arena_score"]; $this->joined = new Datetime(); $this->joined->setTimestamp($r["joined"]); $this->last_login = new Datetime(); $this->last_login->setTimestamp($r["last_login"]); if ($r["in_war"] == 1){ $this->in_war = true; } else{ $this->in_war = false; } if ($r["has_defense"] == 1){ $this->has_defense = true; } else{ $this->has_defense = false; } } } /** * Retrieves the player identifier of the member. * * @return int Member ID. */ public function get_id(){ return $this->id; } /** * Retrieves the guild identifier. * * @return int Guild ID. */ public function get_guild_id(){ return $this->guild; } /** * Retrieves the member name. * * @return string Member name. */ public function get_name(){ return $this->name; } /** * Retrieves the member's level. * * @return int Member level. */ public function get_level(){ return $this->level; } /** * Retrieves the grade of the member in the guild. * * @return int Member grade. */ public function get_grade(){ return $this->grade; } /** * Retrieves the member's rating. * * @return int The members rating. */ public function get_rating(){ return $this->rating; } /** * Retrieves the member's arena score. * * @return int Arena score. */ public function get_arena_score(){ return $this->arena_score; } /** * Retrieves $joined * * @return DateTime */ public function get_joined(){ return $this->joined; } /** * Gets the date the member joined the guild. * * If $format is supplied, a string in the desired format will be returned. If not, the raw * DateTime object will e returned. * * @param string $format A date format (optional). * @return DateTime | string The raw date, or a formatted version. */ public function get_join_time($format = null){ if (null == $format){ return $this->joined; } else{ return $this->joined->format($format); } } /** * Gets the time the member las logged in. * * If $format is supplied, a string in the desired format will be returned. If not, the raw * DateTime object will e returned. * * @param string $format A date format (optional). * @return DateTime | string The raw date, or a formatted version. */ public function get_last_login($format = null){ if (null == $format){ return $this->last_login; } else{ return $this->last_login->format($format); } } /** * Checks if the member is inscribed in Guild Wars. * * @return boolean Tue if inscribed, false otherwise. */ public function is_in_war(){ return $this->in_war; } } ?>