mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-22 23:06:18 +00:00
#1470 tasks may now inherit objectives from their parent tasks
This commit is contained in:
parent
5419e57fc7
commit
cdfc7dcd94
7 changed files with 88 additions and 19 deletions
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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") {
|
||||
|
||||
|
|
|
@ -200,7 +200,7 @@
|
|||
<td><input type='text' name='at_condition_value' /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan='2'><input type='submit' value='create' /></td>
|
||||
<td colspan='2'><input type='hidden' value='0' name='at_inherit' /><input type='submit' value='create' /></td>
|
||||
</tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
|
@ -382,6 +382,10 @@
|
|||
$html .= "</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class='bw'>inherit objectives:</td>
|
||||
<td><input type='hidden' value='0' name='at_inherit' /><input type='checkbox' name='at_inherit' value='1' /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class='bw'>condition:</td>
|
||||
<td>
|
||||
|
@ -520,6 +524,14 @@
|
|||
$html .= "</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class='bw'>inherit objectives:</td>
|
||||
<td><input type='hidden' value='0' name='at_inherit' /><input type='checkbox' name='at_inherit' value='1'";
|
||||
if($task->getHeritage() == 1) {
|
||||
$html .= " checked='checked'";
|
||||
}
|
||||
$html .= "/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class='bw'>condition:</td>
|
||||
<td>
|
||||
|
@ -624,13 +636,13 @@
|
|||
</form>
|
||||
</div>";
|
||||
|
||||
$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 = "<center><table width='90%'>";
|
||||
|
@ -640,24 +652,30 @@
|
|||
|
||||
while($obj->hasNext()) {
|
||||
#foreach($obj as $elem) {
|
||||
$inh = "";
|
||||
$elem = $obj->getNext();
|
||||
|
||||
if($task->isInherited($elem->getID())) {
|
||||
$inh = "<i>inherited</i>: ";
|
||||
}
|
||||
|
||||
#if(($i%2) == 0) {
|
||||
$html .= "<tr><td><table><tr>";
|
||||
#}
|
||||
|
||||
switch($elem->getDisplay()) {
|
||||
case "meta":
|
||||
$html .= "<td>".ach_render_obj_meta($elem)."<td>";
|
||||
$html .= "<td>".$inh.ach_render_obj_meta($elem)."<td>";
|
||||
break;
|
||||
case "value":
|
||||
#if(($i%2) == 1) {
|
||||
# $html .= "</tr><tr>";
|
||||
#}
|
||||
$html .= "<td>".ach_render_obj_value($elem)."</td>";
|
||||
$html .= "<td>".$inh.ach_render_obj_value($elem)."</td>";
|
||||
#$i++;
|
||||
break;
|
||||
case "simple":
|
||||
$html .= "<td>".ach_render_obj_simple($elem)."</td>";
|
||||
$html .= "<td>".$inh.ach_render_obj_simple($elem)."</td>";
|
||||
break;
|
||||
case "hidden":
|
||||
default:
|
||||
|
@ -666,7 +684,7 @@
|
|||
#if(($i%2) == 1) {
|
||||
# $html .= "</tr><tr>";
|
||||
#}
|
||||
$html .= "<td>".ach_render_obj_hidden($elem)."</td>";
|
||||
$html .= "<td>".$inh.ach_render_obj_hidden($elem)."</td>";
|
||||
#$i++;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -168,20 +168,23 @@ function catchTab(item,e){
|
|||
|
||||
$html .= "<div style='display: block; margin-bottom: 5px;'>
|
||||
<div style='display:block;font-size:16px;' class='bar'><a href='javascript:hs(\"task_".$task->getID()."\",\"block\");'>[+]</a> ".$task->getDisplayName()." <span style='font-size:12px;'>(condition= ".$task->getCondition().": ".$task->getConditionValue().")</span></div>
|
||||
<div style='margin-left:25px;display:".$o.";' id='task_".$task->getID()."'>".ach_render_obj_list($task->getIterator())."</div>
|
||||
<div style='margin-left:25px;display:".$o.";' id='task_".$task->getID()."'>".ach_render_obj_list($task->getIterator(),$task)."</div>
|
||||
</div>";
|
||||
}
|
||||
|
||||
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";
|
||||
|
||||
|
|
|
@ -170,14 +170,14 @@
|
|||
</div>
|
||||
|
||||
</div>
|
||||
<div style='margin-left:25px;display:".$o.";' id='task_".$task->getID()."'>".ach_render_obj_list($task->getIterator())."</div>
|
||||
<div style='margin-left:25px;display:".$o.";' id='task_".$task->getID()."'>".ach_render_obj_list($task->getIterator(),$task)."</div>
|
||||
</div>";
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -420,6 +420,7 @@ $c .= "</div></td>
|
|||
$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 .= "</div></td>
|
|||
$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 .= "</div></td>
|
|||
$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']);
|
||||
|
||||
|
|
Loading…
Reference in a new issue