2012-06-25 13:04:51 +00:00
< ? php
2012-07-02 16:56:13 +00:00
class AdmPerk extends AchPerk implements ADM {
use AdmDispatcher ;
protected $condition ;
protected $condition_value ;
2012-07-09 17:10:44 +00:00
protected $porder ;
2012-07-02 16:56:13 +00:00
2012-06-25 13:04:51 +00:00
function AdmPerk ( $data , $parent ) {
parent :: __construct ( $data , $parent );
2012-07-02 16:56:13 +00:00
$this -> condition = $data [ " ap_condition " ];
$this -> condition_value = $data [ " ap_condition_value " ];
2012-07-09 17:10:44 +00:00
$this -> porder = $data [ " ap_porder " ];
2012-06-25 13:04:51 +00:00
}
protected function makeChild ( $d ) {
return new AdmObjective ( $d , $this );
}
2012-07-02 16:56:13 +00:00
function delete_me () {
global $DBc ;
2012-06-25 13:04:51 +00:00
2012-07-02 16:56:13 +00:00
$DBc -> sqlQuery ( " DELETE FROM ach_perk WHERE ap_id=' " . $this -> getID () . " ' " );
$DBc -> sqlQuery ( " DELETE FROM ach_player_perk WHERE app_perk=' " . $this -> getID () . " ' " );
2012-06-25 13:04:51 +00:00
2012-07-02 16:56:13 +00:00
$iter = $this -> getIterator ();
while ( $iter -> hasNext ()) {
$curr = $iter -> getNext ();
$curr -> delete_me ();
$this -> removeChild ( $curr -> getID ());
2012-06-25 13:04:51 +00:00
}
}
2012-07-02 16:56:13 +00:00
function update () {
global $DBc ;
2012-07-09 17:10:44 +00:00
$DBc -> sqlQuery ( " UPDATE ach_perk SET ap_parent= " . mkn ( $this -> getParentID ()) . " ,ap_value=' " . mysql_real_escape_string ( $this -> getValue ()) . " ',ap_condition=' " . mysql_real_escape_string ( $this -> getCondition ()) . " ',ap_condition_value= " . mkn ( $this -> getConditionValue ()) . " ,ap_dev=' " . $this -> getDev () . " ',ap_porder=' " . $this -> porder . " ' WHERE ap_id=' " . $this -> getID () . " ' " );
2012-06-25 13:04:51 +00:00
2012-07-02 16:56:13 +00:00
$DBc -> sqlQuery ( " INSERT INTO ach_perk_lang (apl_perk,apl_lang,apl_name,apl_template) VALUES (' " . $this -> getID () . " ','en',' " . mysql_real_escape_string ( $this -> getName ()) . " ', " . mkn ( $this -> getTemplate ()) . " ) ON DUPLICATE KEY UPDATE apl_name=' " . mysql_real_escape_string ( $this -> getName ()) . " ',apl_template= " . mkn ( $this -> getTemplate ()) . " " );
2012-06-25 13:04:51 +00:00
}
2012-07-02 16:56:13 +00:00
function insert () {
2012-06-25 13:04:51 +00:00
global $DBc ;
2012-07-02 16:56:13 +00:00
$this -> dev = 1 ;
2012-06-25 13:04:51 +00:00
2012-07-09 17:10:44 +00:00
$DBc -> sqlQuery ( " INSERT INTO ach_perk (ap_achievement,ap_parent,ap_value,ap_condition,ap_condition_value,ap_dev,ap_porder) VALUES (' " . $this -> getAchievement () . " ', " . mkn ( $this -> getParentID ()) . " ,' " . mysql_real_escape_string ( $this -> getValue ()) . " ',' " . mysql_real_escape_string ( $this -> getCondition ()) . " ', " . mkn ( $this -> getConditionValue ()) . " ,'1',' " . $this -> porder . " ') " );
2012-07-02 16:56:13 +00:00
$id = mysql_insert_id ();
$this -> setID ( $id );
$DBc -> sqlQuery ( " INSERT INTO ach_perk_lang (apl_perk,apl_lang,apl_name,apl_template) VALUES (' " . $this -> getID () . " ','en',' " . mysql_real_escape_string ( $this -> getName ()) . " ', " . mkn ( $this -> getTemplate ()) . " ) " );
2012-06-25 13:04:51 +00:00
}
2012-07-02 16:56:13 +00:00
function setAchievement ( $a ) {
$this -> achievement = $a ;
}
2012-06-25 13:04:51 +00:00
2012-07-02 16:56:13 +00:00
function setName ( $name ) {
$this -> name = $name ;
2012-06-25 13:04:51 +00:00
}
2012-07-02 16:56:13 +00:00
function setTemplate ( $t ) {
$this -> template = $t ;
}
2012-06-25 13:04:51 +00:00
2012-07-02 16:56:13 +00:00
function setValue ( $v ) {
$this -> value = $v ;
2012-06-25 13:04:51 +00:00
}
2012-07-02 16:56:13 +00:00
function getCondition () {
return $this -> condition ;
2012-06-25 13:04:51 +00:00
}
2012-07-02 16:56:13 +00:00
function getConditionValue () {
return $this -> condition_value ;
}
function setCondition ( $c ) {
$this -> condition = $c ;
}
2012-06-25 13:04:51 +00:00
2012-07-02 16:56:13 +00:00
function setConditionValue ( $v ) {
$this -> condition_value = $v ;
2012-06-25 13:04:51 +00:00
}
2012-07-09 17:10:44 +00:00
function getPorder () {
return $this -> porder ;
}
function setPorder ( $p ) {
$this -> porder = $p ;
}
function setParentID ( $p ) { #!! CUTTING KILLS NODES! HAVE TO BE REROUTED!
if ( $p == null || $p == " null " ) {
//remove from ach list; insert as first!
$this -> parent_id = null ;
$this -> parent -> removeChild ( $this -> id );
$iter = $this -> parent -> getIterator ();
$this -> parent -> addOpen ( $this , $iter -> getNext ());
}
else {
//remove from ach list; insert after parent
echo " -- " . $p . " <br> " ;
$this -> parent_id = $p ;
$this -> parent -> removeChild ( $this -> id );
$item = $this -> parent -> getChildByID ( $this -> parent_id );
$tmp = $item -> getChild ();
if ( $tmp != null ) {
$this -> parent -> addOpen ( $this , $tmp -> getID ());
}
else {
$this -> parent -> addOpen ( $this , null );
}
}
}
2012-06-25 13:04:51 +00:00
}
?>