view = $path["view"] . "teams.php"; $this->parse_filters(); $s = $this->build_query(); $q = $this->db->query($s); while ($r = $q->fetchArray(SQLITE3_ASSOC)){ array_push($this->teams, new Team($db, $r["id"])); } $s = " SELECT id FROM unit WHERE unit.uid = '$UID'; "; $q = $this->db->query($s); while ($r = $q->fetchArray(SQLITE3_ASSOC)){ array_push($this->units, new Unit($this->db, $r["id"], false)); } $this->title = "Teams - SWDB"; $this->description = "Teams"; $this->canonical = $root . "teams/"; } /** * Parses the request looking for the selected filters, validates them * and adds them to the $filters array. */ private function parse_filters(){ global $FILTER_TEAM; global $AREA_TYPE; $this->filters = $FILTER_TEAM; if (isset($_GET["area"]) && in_array($_GET["area"], $AREA_TYPE)){ $this->filters["area"] = $_GET["area"]; } if (isset($_GET["name"]) && strlen($_GET["name"]) > 0){ $this->filters["name"] = SQLite3::escapeString($_GET["name"]); } return; } /** * Builds the query to the rune table using the selected or default * filters. * * @return The query to be executed. */ private function build_query(){ global $ELEMENT; global $UID; $s = " SELECT id FROM team WHERE uid = '$UID' "; if (in_array($this->filters["area"], $ELEMENT)){ $s = $s . " AND area = '" . strtoupper($this->filters["area"]) . "') "; } if ($this->filters["name"] != ""){ $s = $s . " AND upper(name) LIKE '%" . strtoupper($this->filters["name"]) . "%' "; } return $s; } } ?>