function process_filter_to_query($filter) { $generic_query = DEFAULT_LISTING; $user_id = fetch_current_user_id(); $generic_query = $user_id == false ? $generic_query . " and public=1 " : $generic_query . " and owner={$user_id}"; if ($filter == "clear" || $filter == "default" || empty($filter)) { return $generic_query; } $query = $generic_query; if (isset($filter['show_only'])) { foreach ($filter['show_only'] as $show) { $query = $query . process_show_only_to_query($show); } } if (isset($filter["filter_tags"])) { foreach ($filter["filter_tags"] as $tag) { $tag = fetch_tag($tag); $tag_filter = !isset($tag_filter) ? "(name=\"{$tag->name}\"" : $tag_filter . " or name=\"{$tag->name}\""; } $tag_filter = $tag_filter . "))"; $query = $query . " and \n id in (select distinct achievement_id from tags where active=1 and {$tag_filter}"; } if ($filter["required"]) { $query = $query . " and id not in (select distinct required_for from requirements where active=1)"; } return $query; }
function delete_tag($id) { $connection = new PDO("mysql:host=" . DB_HOST . ";dbname=" . DB_NAME, DB_USER, DB_PWD); $tag = fetch_tag($id); deactivate_tag($id); $statement = $connection->prepare("update tags set tally=tally-1 where active=1 and achievement_id=0 and name=?"); $statement->bindValue(1, $tag->name, PDO::PARAM_STR); $statement->execute(); $connection->exec("update tags set active=0 where achievement_id=0 and tally=0"); }
function gettag($get, $post) { $name = $get['id']; if (! API_GETTAG) { return API_RETURN_FORBIDDEN; } $tags = fetch_tag($name); $return = array( $name, $tags ); include_once (ROOT_PATH . 'plugins/uc_client/client.php'); return uc_serialize($return, 1); }