2012-05-31 13:15:36 +00:00
< ? php
2012-06-03 21:03:33 +00:00
class AchCategory extends AchList implements Tieable {
2012-05-31 13:15:36 +00:00
private $id = false ;
private $ties_cult ;
private $ties_civ ;
2012-06-14 09:23:52 +00:00
private $ties_cult_dev ;
private $ties_civ_dev ;
2012-06-03 13:04:04 +00:00
private $cult ;
private $civ ;
2012-05-31 13:15:36 +00:00
2012-06-03 13:04:04 +00:00
function AchCategory ( $id , $cult = null , $civ = null ) {
2012-05-31 13:15:36 +00:00
global $DBc , $_USER ;
2012-06-03 13:04:04 +00:00
if ( $cult == null ) {
$cult = $_USER -> getCult ();
}
if ( $civ == null ) {
$civ = $_USER -> getCiv ();
}
$this -> cult = $cult ;
$this -> civ = $civ ;
$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 " );
2012-05-31 13:15:36 +00:00
$sz = sizeof ( $res );
for ( $i = 0 ; $i < $sz ; $i ++ ) {
#echo "Y";
2012-06-21 18:55:52 +00:00
$tmp = $this -> makeChild ( $res [ $i ]);
2012-05-31 13:15:36 +00:00
#echo var_export($tmp,true);
if ( $tmp -> hasOpen ()) {
$this -> child_open [] = sizeof ( $this -> nodes );
}
if ( $tmp -> hasDone ()) {
$this -> child_done [] = sizeof ( $this -> nodes );
}
$this -> nodes [] = $tmp ;
}
2012-06-14 09:23:52 +00:00
$res = $DBc -> sqlQuery ( " SELECT count(*) as anz FROM ach_achievement WHERE aa_tie_cult IS NOT NULL AND aa_category=' " . $this -> id . " ' AND aa_dev='0' " );
2012-05-31 13:15:36 +00:00
$this -> ties_cult = $res [ 0 ][ 'anz' ];
2012-06-14 09:23:52 +00:00
$res = $DBc -> sqlQuery ( " SELECT count(*) as anz FROM ach_achievement WHERE aa_tie_civ IS NOT NULL AND aa_category=' " . $this -> id . " ' AND aa_dev='0' " );
2012-05-31 13:15:36 +00:00
$this -> ties_civ = $res [ 0 ][ 'anz' ];
2012-06-14 09:23:52 +00:00
$res = $DBc -> sqlQuery ( " SELECT count(*) as anz FROM ach_achievement WHERE aa_tie_cult IS NOT NULL AND aa_category=' " . $this -> id . " ' " );
$this -> ties_cult_dev = $res [ 0 ][ 'anz' ];
$res = $DBc -> sqlQuery ( " SELECT count(*) as anz FROM ach_achievement WHERE aa_tie_civ IS NOT NULL AND aa_category=' " . $this -> id . " ' " );
$this -> ties_civ_dev = $res [ 0 ][ 'anz' ];
2012-05-31 13:15:36 +00:00
}
2012-06-24 10:44:24 +00:00
protected function makeChild ( & $a ) {
2012-06-21 18:55:52 +00:00
return new AchAchievement ( $a );
}
2012-05-31 13:15:36 +00:00
function getID () {
return $this -> id ;
}
function isTiedCult () {
return ( $this -> ties_cult > 0 );
}
function isTiedCiv () {
return ( $this -> ties_civ > 0 );
}
2012-06-03 13:04:04 +00:00
2012-06-14 09:23:52 +00:00
function isTiedCultDev () {
return ( $this -> ties_cult_dev > 0 );
}
function isTiedCivDev () {
return ( $this -> ties_civ_dev > 0 );
}
2012-06-03 13:04:04 +00:00
function getCurrentCiv () {
return $this -> civ ;
}
function getCurrentCult () {
return $this -> cult ;
}
2012-05-31 13:15:36 +00:00
}
?>