From 51d99728286212717003009dd5706bb74edcb272 Mon Sep 17 00:00:00 2001 From: Patrick Davison Date: Wed, 1 May 2013 01:54:08 -0700 Subject: Challengesss Challenges... DB Updates. Challenges --- ajax/challenges.ajax.php | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'ajax') diff --git a/ajax/challenges.ajax.php b/ajax/challenges.ajax.php index f27f3bb..cac9e75 100644 --- a/ajax/challenges.ajax.php +++ b/ajax/challenges.ajax.php @@ -6,7 +6,7 @@ include('../includes/maps.php'); include_once('../includes/sqlEmbedded.php'); if ($_GET['getChallengeIDs'] == 'true') { - echo getChallengesByTier($_GET['userID']); + echo getChallengesByTier($_GET['tier'], $_GET['userID']); exit; } @@ -50,10 +50,11 @@ function getChallengeCode($challengeID) { -function getChallengesByTier($userIdUnsanitized) { +function getChallengesByTier($tierUnsanitized, $userIdUnsanitized) { include_once('../includes/sqlEmbedded.php'); $userID = mysql_escape_string($userIdUnsanitized); + $tier = mysql_escape_string($tierUnsanitized); $sql = "SELECT challengeMaps.ID AS challengeMapID, challengeMaps.challengeTier, challengeMaps.name AS name, challengeSolutions.dateSolved, challengeSolutions.challengeID AS challengeID, @@ -62,12 +63,17 @@ function getChallengesByTier($userIdUnsanitized) { INNER JOIN challengeMaps ON challenges.mapID = challengeMaps.ID LEFT JOIN challengeSolutions ON challenges.ID = challengeSolutions.challengeID AND challengeSolutions.userID = '$userID' WHERE challenges.enabled = 1 - AND challengeMaps.challengeTier <= (SELECT challengeTier FROM users WHERE ID = '$userID' LIMIT 1) OR 1 + AND challengeMaps.challengeTier = '$tier' ORDER BY challengeMaps.challengeTier, challengeMaps.challengeSuborder, challenges.ordering"; + //AND challengeMaps.challengeTier <= (SELECT challengeTier FROM users WHERE ID = '$userID' LIMIT 1) OR 1 + $result = mysql_query($sql) OR die(mysql_error()."SQL: $sql"); if (mysql_num_rows($result) >= 1) { - while($data = mysql_fetch_array($result)) { + $i = 0; + //$layer['x'] = ''; + while($data = mysql_fetch_assoc($result)) { + $i++; //echo $data['challengeMapID']; $tier = $data['challengeTier']; $challengeSuborder = $data['challengeSuborder']; @@ -79,8 +85,10 @@ function getChallengesByTier($userIdUnsanitized) { $mapObj = new map($data['mapCode']); $mapObj->ID = $challengeMapID; - $layer[$data['challengeMapID']][$challengeID] = $data; - $layer[$data['challengeMapID']]['mapObject'] = $mapObj; + $layer['CM'.$data['challengeMapID']][$challengeID] = $data; + $layer['CM'.$data['challengeMapID']]['mapObject'] = $mapObj; + $challenges = getChallenges($data['challengeMapID'], $userID); + $layer['CM'.$data['challengeMapID']]['challenges'] = $challenges; //$layer[] = $data; } return json_encode($layer); @@ -112,7 +120,8 @@ function loadChallengesForMap($mapIdUnsanitized, $userIdUnsanitized) SELECT challenges.ID AS challengeID, challenges.inequality, challenges.goal, challenges.hint, challenges.restrictWallCount, challenges.restrictWallPlacement, challenges.restrictTeleportCount, challenges.restrictTeleportsUsed, challenges.restrictStartPoint, challenges.restrictEndPoint, - challengeSolutions.dateSolved + challengeSolutions.dateSolved, + challenges.dialogStart, challenges.dialogFail, challenges.dialogSuccess FROM challenges LEFT JOIN challengeSolutions ON challenges.ID = challengeSolutions.challengeID AND challengeSolutions.userID = '$userID' WHERE challenges.mapID = '$mapID' AND challenges.enabled = 1 -- cgit v1.2.3