function AchSummary(&$menu, $size = 10) { global $DBc, $_USER; parent::__construct(); $this->menu = $menu; #die("x:".$size); //read all recent tasks of user //make distinct achievement list $res = $DBc->sqlQuery("SELECT DISTINCT apt_date,aa_id,ach.*,(SELECT aal_name FROM ach_achievement_lang WHERE aal_lang='" . $_USER->getLang() . "' AND aal_achievement=ach.aa_id) as aal_name, (SELECT aal_template FROM ach_achievement_lang WHERE aal_lang='" . $_USER->getLang() . "' AND aal_achievement=ach.aa_id) as aal_template FROM ach_achievement as ach,ach_task,ach_player_task WHERE at_achievement=aa_id AND ach.aa_dev='0' AND apt_player='" . $_USER->getID() . "' AND apt_task=at_id ORDER by apt_date DESC LIMIT 0," . $size); #echo var_export($res,true); $sz = sizeof($res); for ($i = 0; $i < $sz; $i++) { $this->addDone($this->makeChild($res[$i])); } }
function AchAchievement($data, &$parent) { global $DBc, $_USER, $_CONF; parent::__construct(); $this->setParent($parent); // real parent node $this->setID($data['aa_id']); $this->parent_id = $data['aa_parent']; // id of parent $this->category = $data['aa_category']; #$this->tie_race = $data['aa_tie_race']; #$this->tie_civ = $data['aa_tie_civ']; #$this->tie_cult = $data['aa_tie_cult']; $this->image = $data['aa_image']; $this->name = $data['aal_name']; $this->template = $data['aal_template']; $this->dev = $data['aa_dev']; $this->sticky = $data['aa_sticky']; if ($this->name == null) { $res = $DBc->sqlQuery("SELECT * FROM ach_achievement_lang WHERE aal_lang='" . $_CONF['default_lang'] . "' AND aal_achievement='" . $this->id . "'"); $this->name = $res[0]['aal_name']; $this->template = $res[0]['aal_template']; } $res = $DBc->sqlQuery("SELECT * FROM ach_task LEFT JOIN (ach_task_lang) ON (atl_lang='" . $_USER->getLang() . "' AND atl_task=at_id) LEFT JOIN (ach_player_task) ON (apt_task=at_id AND apt_player='" . $_USER->getID() . "') WHERE at_achievement='" . $this->id . "' AND (NOT EXISTS (SELECT * FROM ach_task_tie_align WHERE atta_task=at_id) OR EXISTS (SELECT * FROM ach_task_tie_align WHERE atta_task=at_id AND atta_alignment LIKE '" . $parent->getCurrentCult() . '|' . $parent->getCurrentCiv() . "')) ORDER by at_torder ASC"); $sz = sizeof($res); for ($i = 0; $i < $sz; $i++) { $tmp = $this->makeChild($res[$i]); if ($tmp->isDone()) { $this->addDone($tmp); } else { $this->addOpen($tmp); } } $iter = $this->getIterator(); while ($iter->hasNext()) { $curr = $iter->getNext(); $curr->loadHeritage(); } }
function AchCategory($id, $race = null, $cult = "c_neutral", $civ = "c_neutral") { global $DBc, $_USER; parent::__construct(); if ($civ != "%") { $civ = $DBc->sqlEscape($civ); } if ($cult != "%") { $cult = $DBc->sqlEscape($cult); } $race = $DBc->sqlEscape($race); /*if($race == null) { $race = $_USER->getRace(); } if($cult == null) { $cult = $_USER->getCult(); } if($civ == null) { $civ = $_USER->getCiv(); }*/ $this->cult = $cult; $this->civ = $civ; $this->rave = $race; $this->id = $DBc->sqlEscape($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 . "' ORDER by aa_sticky DESC, aal_name ASC"); $sz = sizeof($res); for ($i = 0; $i < $sz; $i++) { $tmp = $this->makeChild($res[$i]); if ($tmp->hasOpen()) { $this->addOpen($tmp); #AchList::addOpen() } if ($tmp->hasDone()) { $this->addDone($tmp); #AchList::addDone() } } $res = $DBc->sqlQuery("SELECT ac_heroic,ac_contest,ac_allow_civ,ac_allow_cult FROM ach_category WHERE ac_id='" . $this->id . "'"); $this->heroic = $res[0]['ac_heroic']; $this->contest = $res[0]['ac_contest']; $this->allow_civ = $res[0]['ac_allow_civ']; $this->allow_cult = $res[0]['ac_allow_cult']; $iter = $this->nodes->getIterator(); $tmp = false; while ($iter->hasNext()) { $curr = $iter->getNext(); if ($curr->hasTieRace_open() && !$curr->inDev()) { $tmp = true; break; } } $this->ties_race_open = $tmp; $iter = $this->nodes->getIterator(); $tmp = false; while ($iter->hasNext()) { $curr = $iter->getNext(); if ($curr->hasTieAlign_open() && !$curr->inDev()) { $tmp = true; break; } } $this->ties_align_open = $tmp; $iter = $this->nodes->getIterator(); $tmp = false; while ($iter->hasNext()) { $curr = $iter->getNext(); if ($curr->hasTieRace_done() && !$curr->inDev()) { $tmp = true; break; } } $this->ties_race_done = $tmp; $iter = $this->nodes->getIterator(); $tmp = false; while ($iter->hasNext()) { $curr = $iter->getNext(); if ($curr->hasTieAlign_done() && !$curr->inDev()) { $tmp = true; break; } } $this->ties_align_done = $tmp; $iter = $this->nodes->getIterator(); $tmp = false; while ($iter->hasNext()) { $curr = $iter->getNext(); if ($curr->hasTieRaceDev()) { $tmp = true; break; } } $this->ties_race_dev = $tmp; $iter = $this->nodes->getIterator(); $tmp = false; while ($iter->hasNext()) { $curr = $iter->getNext(); if ($curr->hasTieAlignDev()) { $tmp = true; break; } } $this->ties_align_dev = $tmp; }