view = PATH::VIEW . "teams.php"; $this->parse_filters(); $s = $this->build_query(); $q = $db->query($s); while ($r = $q->fetchArray(SQLITE3_ASSOC)){ array_push($this->teams, new Team($r["id"])); } $statement = $db->prepare(" SELECT id FROM unit WHERE unit.uid = :uid; "); $statement->bindValue(':uid', $UID, SQLITE3_INTEGER); $q = $statement->execute(); while ($r = $q->fetchArray(SQLITE3_ASSOC)){ array_push($this->units, new Unit($r["id"], false)); } $this->title = "Teams - SWDB"; $this->description = "Teams"; $this->canonical = URL::BASE . "teams/"; } /** * Parses the request looking for the selected filters, validates them * and adds them to the $filters array. */ private function parse_filters(){ $this->filters = FILTER::TEAM; if (isset($_GET["area"]) && APPLICATION::valid_id("AREA_TYPE_ID", $_GET["area"])){ $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 string The query to be executed. */ private function build_query(){ global $UID; $s = " SELECT id FROM team WHERE uid = '$UID' ORDER BY area_type, area "; if (APPLICATION::valid_id("AREA_ID", $this->filters["AREA"])){ $s = $s . " AND area = '" . strtoupper($this->filters["AREA"]) . "') "; } if ($this->filters["NAME"] != ""){ $s = $s . " AND upper(name) LIKE '%" . strtoupper($this->filters["NAME"]) . "%' "; } return $s; } } ?>