From 6a32131dd80049622ca51ded7f9f5efb8df291a9 Mon Sep 17 00:00:00 2001 From: SirCotare Date: Mon, 2 Jul 2012 18:55:13 +0200 Subject: [PATCH] #1470 misc --HG-- branch : gsoc2012-achievements --- .../app_achievements/class/AVLTree_class.php | 10 ++++- .../class/AchCategory_class.php | 6 ++- .../class/AchList_abstract.php | 39 +++++-------------- .../app_achievements/class/InDev_trait.php | 20 ++++++++++ .../class/NodeIterator_class.php | 11 ++++++ .../app/app_achievements/class/Node_trait.php | 6 +++ .../class/Parentum_abstract.php | 4 -- .../app_achievements/class/Tieable_inter.php | 6 +++ 8 files changed, 66 insertions(+), 36 deletions(-) diff --git a/code/web/app/app_achievements/class/AVLTree_class.php b/code/web/app/app_achievements/class/AVLTree_class.php index d77283632..cf2270c3c 100644 --- a/code/web/app/app_achievements/class/AVLTree_class.php +++ b/code/web/app/app_achievements/class/AVLTree_class.php @@ -1,8 +1,16 @@ root = null; $this->debug = $log; diff --git a/code/web/app/app_achievements/class/AchCategory_class.php b/code/web/app/app_achievements/class/AchCategory_class.php index d31d6eb90..7df1c8898 100644 --- a/code/web/app/app_achievements/class/AchCategory_class.php +++ b/code/web/app/app_achievements/class/AchCategory_class.php @@ -11,6 +11,9 @@ function AchCategory($id,$cult = null,$civ = null) { global $DBc,$_USER; + $civ = mysql_real_escape_string($civ); + $cult = mysql_real_escape_string($cult); + if($cult == null) { $cult = $_USER->getCult(); } @@ -24,7 +27,8 @@ $this->id = mysql_real_escape_string($id); - $res = $DBc->sqlQuery("SELECT * FROM ach_achievement LEFT JOIN (ach_achievement_lang) ON (aal_lang='".$_USER->getLang()."' AND aal_achievement=aa_id) WHERE aa_category='".$this->id."' AND (aa_parent IS NULL OR NOT EXISTS (SELECT * FROM ach_perk WHERE ap_achievement=aa_id AND NOT EXISTS (SELECT * FROM ach_player_perk WHERE app_player='".$_USER->getID()."' AND app_perk=ap_id))) AND (aa_tie_race IS NULL OR aa_tie_race='".$_USER->getRace()."') AND (aa_tie_cult IS NULL OR aa_tie_cult='".mysql_real_escape_string($cult)."') AND (aa_tie_civ IS NULL OR aa_tie_civ='".mysql_real_escape_string($civ)."') ORDER by aal_name ASC"); + $res = $DBc->sqlQuery("SELECT * FROM ach_achievement LEFT JOIN (ach_achievement_lang) ON (aal_lang='".$_USER->getLang()."' AND aal_achievement=aa_id) WHERE aa_category='".$this->id."' AND (aa_parent IS NULL OR NOT EXISTS (SELECT * FROM ach_perk WHERE ap_achievement=aa_id AND NOT EXISTS (SELECT * FROM ach_player_perk WHERE app_player='".$_USER->getID()."' AND app_perk=ap_id))) AND (aa_tie_race IS NULL OR aa_tie_race LIKE '".$_USER->getRace()."') AND (aa_tie_cult IS NULL OR aa_tie_cult LIKE '".$cult."') AND (aa_tie_civ IS NULL OR aa_tie_civ LIKE '".$civ."') ORDER by aal_name ASC"); + #parent!!!! $sz = sizeof($res); for($i=0;$i<$sz;$i++) { diff --git a/code/web/app/app_achievements/class/AchList_abstract.php b/code/web/app/app_achievements/class/AchList_abstract.php index 819d4892a..4338173cb 100644 --- a/code/web/app/app_achievements/class/AchList_abstract.php +++ b/code/web/app/app_achievements/class/AchList_abstract.php @@ -1,5 +1,11 @@ child_done); - #if($res != false) { - # unset($this->child_done[$res]); - # echo " ... done
"; - #} + foreach($this->child_done as $key=>$elem) { if($elem == $idx) { unset($this->child_done[$key]); @@ -74,12 +76,7 @@ final function removeChildOpen($idx) { echo "try removing open child: ".$idx; - - #$res = array_search($idx,$this->child_open); - #if($res != false) { - # unset($this->child_open[$res]); - # echo " ... done
"; - #} + foreach($this->child_open as $key=>$elem) { if($elem == $idx) { unset($this->child_open[$key]); @@ -89,26 +86,8 @@ } echo var_export($this->child_open,true); } - - /*final function unsetOpen($idx) { - foreach($this->child_open as $key=>$elem) { - if($elem == $idx) { - unset($this->child_open[$key]); - break; - } - } - } - - final function unsetDone($idx) { - foreach($this->child_done as $key=>$elem) { - if($elem == $idx) { - unset($this->child_done[$key]); - break; - } - } - }*/ - #OVERRIDE Parentum::removeChild() + #@OVERRIDE Parentum::removeChild() function removeChild($id) { $n = parent::removeChild($id); if($n != false && $n != null) { diff --git a/code/web/app/app_achievements/class/InDev_trait.php b/code/web/app/app_achievements/class/InDev_trait.php index 843389dba..3f749526a 100644 --- a/code/web/app/app_achievements/class/InDev_trait.php +++ b/code/web/app/app_achievements/class/InDev_trait.php @@ -1,5 +1,10 @@ dev; } + + function setInDev($tf) { + if($tf == true) { + $this->setDev(1); + } + else { + $this->setDev(0); + } + + $this->update(); + } + + function setDev($d) { + $this->dev = $d; + } } ?> \ No newline at end of file diff --git a/code/web/app/app_achievements/class/NodeIterator_class.php b/code/web/app/app_achievements/class/NodeIterator_class.php index 3bd4fd4b9..1d939e5c4 100644 --- a/code/web/app/app_achievements/class/NodeIterator_class.php +++ b/code/web/app/app_achievements/class/NodeIterator_class.php @@ -1,5 +1,16 @@ hasNext()) { + $curr = $iter->getNext(); + // ... + } + ---------------------------*/ private $nodes; private $curr; diff --git a/code/web/app/app_achievements/class/Node_trait.php b/code/web/app/app_achievements/class/Node_trait.php index ead5edea3..d9bf1a42a 100644 --- a/code/web/app/app_achievements/class/Node_trait.php +++ b/code/web/app/app_achievements/class/Node_trait.php @@ -1,5 +1,11 @@ avl->inorder(); - #} - function removeChild($id) { if($this->isEmpty()) { return null; diff --git a/code/web/app/app_achievements/class/Tieable_inter.php b/code/web/app/app_achievements/class/Tieable_inter.php index ce472e055..75b86ad80 100644 --- a/code/web/app/app_achievements/class/Tieable_inter.php +++ b/code/web/app/app_achievements/class/Tieable_inter.php @@ -1,5 +1,11 @@