diff --git a/code/web/app/app_achievements/class/AchAchievement_class.php b/code/web/app/app_achievements/class/AchAchievement_class.php
index b1e3e1511..8437f15cc 100644
--- a/code/web/app/app_achievements/class/AchAchievement_class.php
+++ b/code/web/app/app_achievements/class/AchAchievement_class.php
@@ -75,6 +75,12 @@
$this->addOpen($tmp);
}
}
+
+ $iter = $this->getIterator();
+ while($iter->hasNext()) {
+ $curr = $iter->getNext();
+ $curr->loadHeritage();
+ }
}
function parentDone() { // check if the parent is complete
diff --git a/code/web/app/app_achievements/class/AchTask_class.php b/code/web/app/app_achievements/class/AchTask_class.php
index f9c27eddd..96e758ad8 100644
--- a/code/web/app/app_achievements/class/AchTask_class.php
+++ b/code/web/app/app_achievements/class/AchTask_class.php
@@ -35,11 +35,15 @@
protected $done;
protected $template;
protected $parent_id;
+ protected $inherit_obj;
+ private $heritage_list;
function AchTask($data,$parent) {
global $DBc,$_USER;
parent::__construct();
+
+ $this->heritage_list = array();
$this->setParent($parent);
$this->setID($data['at_id']);
@@ -50,11 +54,32 @@
$this->dev = $data['at_dev'];
$this->template = $data['atl_template'];
$this->parent_id = $data['at_parent'];
+ $this->inherit_obj = $data['at_inherit'];
- $res = $DBc->sqlQuery("SELECT * FROM ach_objective LEFT JOIN (ach_objective_lang) ON (aol_lang='".$_USER->getLang()."' AND aol_objective=ao_id) LEFT JOIN (ach_player_objective) ON (apo_objective=ao_id AND apo_player='".$_USER->getID()."') LEFT JOIN (ach_achievement,ach_achievement_lang) ON (aa_id=ao_metalink AND aa_id=aal_achievement AND aal_lang='".$_USER->getLang()."') WHERE ao_task='".$this->id."' ORDER by aol_name ASC,aal_name ASC");
- $sz = sizeof($res);
- for($i=0;$i<$sz;$i++) {
- $this->addChild($this->makeChild($res[$i]));
+ #if($this->inherit_obj == 0) {
+
+ $res = $DBc->sqlQuery("SELECT * FROM ach_objective LEFT JOIN (ach_objective_lang) ON (aol_lang='".$_USER->getLang()."' AND aol_objective=ao_id) LEFT JOIN (ach_player_objective) ON (apo_objective=ao_id AND apo_player='".$_USER->getID()."') LEFT JOIN (ach_achievement,ach_achievement_lang) ON (aa_id=ao_metalink AND aa_id=aal_achievement AND aal_lang='".$_USER->getLang()."') WHERE ao_task='".$this->id."' ORDER by aol_name ASC,aal_name ASC");
+
+ $sz = sizeof($res);
+ for($i=0;$i<$sz;$i++) {
+ $this->addChild($this->makeChild($res[$i]));
+ }
+ #}
+ }
+
+ function loadHeritage() {
+ if($this->inherit_obj == 0) {
+ return false;
+ }
+ $child = $this->parent->getChildDataByID($this->parent_id);
+ if($child == null) {
+ return false;
+ }
+ $iter = $child->getIterator();
+ while($iter->hasNext()) {
+ $curr = $iter->getNext();
+ $this->addChild($curr);
+ $this->heritage_list[] = $curr->getID();
}
}
@@ -63,6 +88,14 @@
return new AchObjective($a,$this);
}
+ function getHeritage() {
+ return $this->inherit_obj;
+ }
+
+ function isInherited($id) {
+ return in_array($id,$this->heritage_list);
+ }
+
function getAchievement() {
return $this->achievement;
}
diff --git a/code/web/app/app_achievements_admin/class/AdmTask_class.php b/code/web/app/app_achievements_admin/class/AdmTask_class.php
index d581bdbae..57cb8d40e 100644
--- a/code/web/app/app_achievements_admin/class/AdmTask_class.php
+++ b/code/web/app/app_achievements_admin/class/AdmTask_class.php
@@ -108,7 +108,7 @@
function update() {
global $DBc;
- $DBc->sqlQuery("UPDATE ach_task SET at_parent=".mkn($this->getParentID()).",at_value='".$DBc->sqlEscape($this->getValue())."',at_condition='".$DBc->sqlEscape($this->getCondition())."',at_condition_value=".mkn($this->getConditionValue()).",at_dev='".$this->getDev()."',at_torder='".$this->torder."' WHERE at_id='".$this->getID()."'");
+ $DBc->sqlQuery("UPDATE ach_task SET at_parent=".mkn($this->getParentID()).",at_value='".$DBc->sqlEscape($this->getValue())."',at_condition='".$DBc->sqlEscape($this->getCondition())."',at_condition_value=".mkn($this->getConditionValue()).",at_dev='".$this->getDev()."',at_torder='".$this->torder."', at_inherit='".$this->inherit_obj."' WHERE at_id='".$this->getID()."'");
$DBc->sqlQuery("INSERT INTO ach_task_lang (atl_task,atl_lang,atl_name,atl_template) VALUES ('".$this->getID()."','en','".$DBc->sqlEscape($this->getName())."',".mkn($this->getTemplate()).") ON DUPLICATE KEY UPDATE atl_name='".$DBc->sqlEscape($this->getName())."',atl_template=".mkn($this->getTemplate())."");
}
@@ -118,7 +118,7 @@
$this->dev = 1;
- $DBc->sqlQuery("INSERT INTO ach_task (at_achievement,at_parent,at_value,at_condition,at_condition_value,at_dev,at_torder) VALUES ('".$this->getAchievement()."',".mkn($this->getParentID()).",'".$DBc->sqlEscape($this->getValue())."','".$DBc->sqlEscape($this->getCondition())."',".mkn($this->getConditionValue()).",'1','".$this->torder."')");
+ $DBc->sqlQuery("INSERT INTO ach_task (at_achievement,at_parent,at_value,at_condition,at_condition_value,at_dev,at_torder,at_inherit) VALUES ('".$this->getAchievement()."',".mkn($this->getParentID()).",'".$DBc->sqlEscape($this->getValue())."','".$DBc->sqlEscape($this->getCondition())."',".mkn($this->getConditionValue()).",'1','".$this->torder."','".$this->inherit_obj."')");
$id = $DBc->insertID();
$this->setID($id);
@@ -165,6 +165,10 @@
$this->torder = $t;
}
+ function setHeritage($i) {
+ $this->inherit_obj = $i;
+ }
+
function setParentID($p,$order = true) { #reordering must happen A) after insert B) when updating
if($p == null || $p == "null") {
diff --git a/code/web/app/app_achievements_admin/include/adm_render_ach.php b/code/web/app/app_achievements_admin/include/adm_render_ach.php
index 6f4475adc..7c1bc3a32 100644
--- a/code/web/app/app_achievements_admin/include/adm_render_ach.php
+++ b/code/web/app/app_achievements_admin/include/adm_render_ach.php
@@ -200,7 +200,7 @@
|
- |
+ |
@@ -382,6 +382,10 @@
$html .= "
+
+ inherit objectives: |
+ |
+
condition: |
@@ -520,6 +524,14 @@
$html .= "
|
+
+ inherit objectives: |
+ getHeritage() == 1) {
+ $html .= " checked='checked'";
+ }
+ $html .= "/> |
+
condition: |
@@ -624,13 +636,13 @@
";
- $html .= ach_render_obj_list($task->getIterator());
+ $html .= ach_render_obj_list($task->getIterator(),$task);
}
return $html;
}
- function ach_render_obj_list($obj) {
+ function ach_render_obj_list($obj,$task) {
#return null;
global $metalist;
$html = "";
@@ -640,24 +652,30 @@
while($obj->hasNext()) {
#foreach($obj as $elem) {
+ $inh = "";
$elem = $obj->getNext();
+
+ if($task->isInherited($elem->getID())) {
+ $inh = "inherited: ";
+ }
+
#if(($i%2) == 0) {
$html .= "";
#}
switch($elem->getDisplay()) {
case "meta":
- $html .= "".ach_render_obj_meta($elem)." | ";
+ $html .= " | ".$inh.ach_render_obj_meta($elem)." | ";
break;
case "value":
#if(($i%2) == 1) {
# $html .= " | ";
#}
- $html .= "".ach_render_obj_value($elem)." | ";
+ $html .= "".$inh.ach_render_obj_value($elem)." | ";
#$i++;
break;
case "simple":
- $html .= "".ach_render_obj_simple($elem)." | ";
+ $html .= "".$inh.ach_render_obj_simple($elem)." | ";
break;
case "hidden":
default:
@@ -666,7 +684,7 @@
#if(($i%2) == 1) {
# $html .= " ";
#}
- $html .= "".ach_render_obj_hidden($elem)." | ";
+ $html .= "".$inh.ach_render_obj_hidden($elem)." | ";
#$i++;
break;
}
diff --git a/code/web/app/app_achievements_admin/include/adm_render_atom.php b/code/web/app/app_achievements_admin/include/adm_render_atom.php
index ec8a1df40..3be3ea4b9 100644
--- a/code/web/app/app_achievements_admin/include/adm_render_atom.php
+++ b/code/web/app/app_achievements_admin/include/adm_render_atom.php
@@ -168,20 +168,23 @@ function catchTab(item,e){
$html .= "
[+] ".$task->getDisplayName()." (condition= ".$task->getCondition().": ".$task->getConditionValue().")
- ".ach_render_obj_list($task->getIterator())."
+ ".ach_render_obj_list($task->getIterator(),$task)."
";
}
return $html;
}
- function ach_render_obj_list($obj) {
+ function ach_render_obj_list($obj,$task) {
$html = "";
while($obj->hasNext()) {
$elem = $obj->getNext();
-
+
+ if($task->isInherited($elem->getID())) {
+ continue;
+ }
$o = "block";
diff --git a/code/web/app/app_achievements_admin/include/adm_render_lang.php b/code/web/app/app_achievements_admin/include/adm_render_lang.php
index 2882553d9..8f2fdf99f 100644
--- a/code/web/app/app_achievements_admin/include/adm_render_lang.php
+++ b/code/web/app/app_achievements_admin/include/adm_render_lang.php
@@ -170,14 +170,14 @@
- ".ach_render_obj_list($task->getIterator())."
+ ".ach_render_obj_list($task->getIterator(),$task)."
";
}
return $html;
}
- function ach_render_obj_list($obj) {
+ function ach_render_obj_list($obj,$task) {
global $_CONF;
$html = "";
@@ -186,7 +186,9 @@
while($obj->hasNext()) {
$elem = $obj->getNext();
-
+ if($task->isInherited($elem->getID())) {
+ continue;
+ }
diff --git a/code/web/app/app_achievements_admin/index.php b/code/web/app/app_achievements_admin/index.php
index 50da9cefc..98fee0066 100644
--- a/code/web/app/app_achievements_admin/index.php
+++ b/code/web/app/app_achievements_admin/index.php
@@ -420,6 +420,7 @@ $c .= "
$task->setValue($_REQUEST['at_value']);
$task->setCondition($_REQUEST['at_condition']);
$task->setConditionValue($_REQUEST['at_condition_value']);
+ $task->setHeritage(0);
$ach->insertNode($task);
}
@@ -450,6 +451,7 @@ $c .= "
$task->setValue($_REQUEST['at_value']);
$task->setCondition($_REQUEST['at_condition']);
$task->setConditionValue($_REQUEST['at_condition_value']);
+ $task->setHeritage($_REQUEST['at_inherit']);
$ach->insertNode($task);
$task->setParentID($_REQUEST['at_parent']);
@@ -467,6 +469,7 @@ $c .= "
$task->setValue($_REQUEST['at_value']);
$task->setCondition($_REQUEST['at_condition']);
$task->setConditionValue($_REQUEST['at_condition_value']);
+ $task->setHeritage($_REQUEST['at_inherit']);
$task->setParentID($_REQUEST['at_parent']);
| |