2012-06-25 13:04:51 +00:00
|
|
|
<?php
|
|
|
|
class CSRPerk extends AchPerk implements CSR {
|
2012-07-02 16:56:13 +00:00
|
|
|
use CSRDispatcher;
|
2012-06-25 13:04:51 +00:00
|
|
|
|
2012-07-02 16:56:13 +00:00
|
|
|
function CSRPerk($data,$parent) {
|
|
|
|
$this->init();
|
|
|
|
parent::__construct($data,$parent);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function makeChild($d) {
|
|
|
|
return new CSRObjective($d,$this);
|
2012-06-25 13:04:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function grant($pid) {
|
|
|
|
global $DBc;
|
|
|
|
|
|
|
|
$DBc->sqlQuery("INSERT INTO ach_player_perk (app_perk,app_player,app_date) VALUES ('".$this->getID()."','".$pid."','".time()."')");
|
2012-07-02 16:56:13 +00:00
|
|
|
$this->done = time();
|
|
|
|
#echo $this->idx."<br>";
|
|
|
|
$this->parent->setPerkDone($this->idx);
|
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->grant($pid);
|
2012-06-25 13:04:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function deny($pid) {
|
|
|
|
global $DBc;
|
|
|
|
|
|
|
|
$DBc->sqlQuery("DELETE FROM ach_player_perk WHERE app_perk='".$this->getID()."' AND app_player='".$pid."'");
|
2012-07-02 16:56:13 +00:00
|
|
|
$this->done = 0;
|
|
|
|
$this->parent->setPerkOpen($this->idx);
|
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->deny($pid);
|
2012-06-25 13:04:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|