static function get_rounds($match_id) { global $wpdb; return $wpdb->get_results($wpdb->prepare('SELECT t1.*, t2.title, t2.screenshot FROM `' . self::table() . '` AS t1 LEFT JOIN `' . \WP_Clanwars\Maps::table() . '` AS t2 ON t2.id = t1.map_id WHERE t1.match_id=%d ORDER BY t1.id ASC, t1.group_n ASC', $match_id)); }
function prepare_items() { $per_page = $this->get_items_per_page(static::PER_PAGE_OPTION, static::PER_PAGE_DEFAULT); $current_page = $this->get_pagenum(); $orderby = isset($_REQUEST['orderby']) ? $_REQUEST['orderby'] : 'title'; $order = isset($_REQUEST['order']) ? $_REQUEST['order'] : 'desc'; $offset = ($current_page - 1) * $per_page; $limit = $per_page; $game_id = $_REQUEST['game_id']; $args = array('id' => 'all', 'game_id' => $game_id, 'order' => $order, 'orderby' => $orderby, 'order' => $order, 'limit' => $limit, 'offset' => $limit * ($current_page - 1)); $maps = \WP_Clanwars\Maps::get_map($args); $pagination = $maps->get_pagination(); $this->set_pagination_args(array('total_pages' => $pagination->get_num_pages(), 'total_items' => $pagination->get_num_rows(), 'per_page' => $per_page)); $this->items = $maps->getArrayCopy(); }
function on_ajax_get_maps() { if (!\WP_Clanwars\ACL::user_can('manage_games') && !\WP_Clanwars\ACL::user_can('manage_matches')) { wp_die(__('Cheatin’ uh?')); } $game_id = isset($_POST['game_id']) ? (int) $_POST['game_id'] : 0; if ($game_id > 0) { $maps = \WP_Clanwars\Maps::get_map(array('game_id' => $game_id, 'order' => 'asc', 'orderby' => 'title')); for ($i = 0; $i < sizeof($maps); $i++) { $url = wp_get_attachment_thumb_url($maps[$i]->screenshot); $maps[$i]->screenshot_url = !empty($url) ? $url : ''; } echo json_encode($maps); die; } }
static function delete_game($id) { global $wpdb; $table = self::table(); if (!is_array($id)) { $id = array($id); } $id = array_map('intval', $id); \WP_Clanwars\Maps::delete_map_by_game($id); \WP_Clanwars\Matches::delete_match_by_game($id); $id_list = implode(',', $id); return $wpdb->query("DELETE FROM `{$table}` WHERE id IN({$id_list})"); }