From 7391d526c17f6d4f9720957df73c49ac4cfdbec3 Mon Sep 17 00:00:00 2001 From: SirCotare Date: Mon, 25 Jun 2012 15:04:51 +0200 Subject: [PATCH] #1470 admin tool workprint; menu admin almost complete; wip!! --- .../class/ADM_inter.php | 17 ++ .../class/AdmAchievement_class.php | 129 ++++++++++++ .../class/AdmAtom_class.php | 67 +++++++ .../class/AdmCategory_class.php | 54 +++++ .../class/AdmDispatcher_inter.php | 11 ++ .../class/AdmMenuNode_class.php | 185 ++++++++++++++++++ .../class/AdmMenu_class.php | 95 +++++++++ .../class/AdmObjective_class.php | 75 +++++++ .../class/AdmPerk_class.php | 77 ++++++++ .../class/CSRAchievement_class.php | 20 ++ .../class/CSRAtom_class.php | 22 +++ .../class/CSRObjective_class.php | 38 ++++ .../class/CSRPerk_class.php | 28 +++ .../class/CSR_inter.php | 7 + .../class/Dispatcher_trait.php | 30 +++ .../class/RyzomAdmin_class.php | 15 ++ code/web/app/app_achievements_admin/conf.php | 13 +- .../include/ach_render_admin.php | 171 ++++++++++++++++ code/web/app/app_achievements_admin/index.php | 130 +++++++++++- .../app/app_achievements_admin/pic/b_drop.png | Bin 0 -> 311 bytes .../app_achievements_admin/pic/b_insrow.png | Bin 0 -> 283 bytes .../app/app_achievements_admin/pic/green.gif | Bin 0 -> 1503 bytes .../app_achievements_admin/pic/icon_edit.gif | Bin 0 -> 125 bytes .../app/app_achievements_admin/pic/red.gif | Bin 0 -> 1321 bytes 24 files changed, 1175 insertions(+), 9 deletions(-) create mode 100644 code/web/app/app_achievements_admin/class/ADM_inter.php create mode 100644 code/web/app/app_achievements_admin/class/AdmAchievement_class.php create mode 100644 code/web/app/app_achievements_admin/class/AdmAtom_class.php create mode 100644 code/web/app/app_achievements_admin/class/AdmCategory_class.php create mode 100644 code/web/app/app_achievements_admin/class/AdmDispatcher_inter.php create mode 100644 code/web/app/app_achievements_admin/class/AdmMenuNode_class.php create mode 100644 code/web/app/app_achievements_admin/class/AdmMenu_class.php create mode 100644 code/web/app/app_achievements_admin/class/AdmObjective_class.php create mode 100644 code/web/app/app_achievements_admin/class/AdmPerk_class.php create mode 100644 code/web/app/app_achievements_admin/class/CSRAchievement_class.php create mode 100644 code/web/app/app_achievements_admin/class/CSRAtom_class.php create mode 100644 code/web/app/app_achievements_admin/class/CSRObjective_class.php create mode 100644 code/web/app/app_achievements_admin/class/CSRPerk_class.php create mode 100644 code/web/app/app_achievements_admin/class/CSR_inter.php create mode 100644 code/web/app/app_achievements_admin/class/Dispatcher_trait.php create mode 100644 code/web/app/app_achievements_admin/class/RyzomAdmin_class.php create mode 100644 code/web/app/app_achievements_admin/include/ach_render_admin.php create mode 100644 code/web/app/app_achievements_admin/pic/b_drop.png create mode 100644 code/web/app/app_achievements_admin/pic/b_insrow.png create mode 100644 code/web/app/app_achievements_admin/pic/green.gif create mode 100644 code/web/app/app_achievements_admin/pic/icon_edit.gif create mode 100644 code/web/app/app_achievements_admin/pic/red.gif diff --git a/code/web/app/app_achievements_admin/class/ADM_inter.php b/code/web/app/app_achievements_admin/class/ADM_inter.php new file mode 100644 index 000000000..e158827c7 --- /dev/null +++ b/code/web/app/app_achievements_admin/class/ADM_inter.php @@ -0,0 +1,17 @@ + \ No newline at end of file diff --git a/code/web/app/app_achievements_admin/class/AdmAchievement_class.php b/code/web/app/app_achievements_admin/class/AdmAchievement_class.php new file mode 100644 index 000000000..ea76b144e --- /dev/null +++ b/code/web/app/app_achievements_admin/class/AdmAchievement_class.php @@ -0,0 +1,129 @@ +insert(); + $this->nodes[] = $n; + } + + function removeNode($id) { // remove a Perk + $res = $this->getNode($id); + if($res != null) { + $res->delete_me(); + $this->unsetChild($id); + } + } + + function updateNode($id,$data) { // update a Perk + $res = $this->getNode($id); + if($res != null) { + #MISSING: set new data + # + $res->update(); + } + } + + function getNode($id) { // find a Perk + foreach($this->nodes as $elem) { + if($elem->getID == $id) { + return $elem; + } + } + + return null; + } + + function delete_me() { + global $DBc; + + $DBc->sqlQuery("DELETE FROM ach_achievement WHERE aa_id='".$this->getID()."'"); + $DBc->sqlQuery("DELETE FROM ach_player_achievement WHERE apa_id='".$this->getID()."'"); + $DBc->sqlQuery("DELETE FROM ach_achievement_lang WHERE NOT EXISTS (SELECT * FROM ach_achievement WHERE aa_id=aal_achievement)"); + + foreach($this->nodes as $elem) { + $elem->delete_me(); + $this->unsetChild($elem->getID()); + } + } + + function update() { + global $DBc; + + $DBc->sqlQuery("UPDATE ach_achievement SET aa_parent='".$this->getParent())."',aa_tie_race='".mysql_real_escape_string($this->getTieRace())."',aa_tie_cult='".mysql_real_escape_string($this->getTieCult())."',aa_tie_civ='".mysql_real_escape_string($this->getTieCiv())."',aa_image='".mysql_real_escape_string($this->getImage())."',aa_dev='".$this->getDev()."' WHERE aa_id='".$this->geID()."'"); + + #MISSING: update lang entry + } + + function insert() { + + } + + function unsetChild($id) { // remove child with given ID from nodes list; unset should destruct it. + foreach($this->nodes as $key=>$elem) { + if($elem->getID() == $id) { + unset($this->nodes[$key]); + return null; + } + } + } + + function setInDev($tf) { + if($tf == true) { + $this->setDev(1); + } + else { + $this->setDev(0); + } + + $this->update(); + } + + function setDev($d) { + $this->dev = $d; + } + + function setID($id) { + $this->id = $id; + } + + function setParent($p) { + $this->parent = $p + } + + function setCategory($c) { + $this->category = $c; + } + + function setTieRace($t) { + $this->tie_race = $t; + } + + function setTieCiv($t) { + $this->tie_civ = $t; + } + + function setTieCult($t) { + $this->tie_cult = $t; + } + + function setImage($i) { + $this->image = $i; + } + + function setName($n) { + $this->name = $n; + } + + function setTemplate($i) { + $this->template = $t; + } + } +?> \ No newline at end of file diff --git a/code/web/app/app_achievements_admin/class/AdmAtom_class.php b/code/web/app/app_achievements_admin/class/AdmAtom_class.php new file mode 100644 index 000000000..17bde5bc9 --- /dev/null +++ b/code/web/app/app_achievements_admin/class/AdmAtom_class.php @@ -0,0 +1,67 @@ +parent = $parent; + $this->id = $data['atom_id']; + $this->objective = $data['atom_objective']; + $this->mandatory = $data['atom_mandatory']; + $this->ruleset = $data['atom_ruleset']; + $this->ruleset_parsed = $data['atom_ruleset_parsed']; + } + + function delete_me() { // aaaaand... it's gone ^^ + global $DBc; + + $DBc->sqlQuery("DELETE FROM ach_atom WHERE atom_id='".$this->id."'"); + $DBc->sqlQuery("DELETE FROM ach_player_atom WHERE apa_atom='".$this->id."'"); + } + + function update() { + $DBc->sqlQuery("UPDATE ach_atom SET atom_mandatory='".."',atom_ruleset='".."',atom_ruleset_parsed='".."' WHERE atom_id='".$this->id."'"); + } + + function insert() { + $DBc->sqlQuery("INSERT INTO ach_atom (atom_objective,atom_mandatory,atom_ruleset,atom_ruleset_parsed) VALUES ('".."','".."','".."','".."')"); + $id = mysql_insert_id(); + $this->setID($id); + } + + function setMandatory($ft) { + if($ft == true) { + $this->mandatory = 1; + } + else { + $this->mandatory = 0; + } + } + + function setRuleset($r) { + $this->ruleset = $r; + $this->parse(); + } + + function getMandatory() { + return $this->mandatory; + } + + function isMandatory() { + return ($this->mandatory == 1); + } + + function getRuleset() { + return $this->ruleset; + } + + private function parse() { + + } + } +?> \ No newline at end of file diff --git a/code/web/app/app_achievements_admin/class/AdmCategory_class.php b/code/web/app/app_achievements_admin/class/AdmCategory_class.php new file mode 100644 index 000000000..1ae64f0e1 --- /dev/null +++ b/code/web/app/app_achievements_admin/class/AdmCategory_class.php @@ -0,0 +1,54 @@ +insert(); + $this->nodes[] = $n; + } + + function removeNode($id) { + $res = $this->getNode($id); + if($res != null) { + $res->delete_me(); + $this->unsetChild($id); + } + } + + function updateNode($id,$data) { + $res = $this->getNode($id); + if($res != null) { + #MISSING: set new data + #aa_id aa_category aa_parent aa_tie_race aa_tie_cult aa_tie_civ aa_image aa_dev + $res->update(); + } + } + + function getNode($id) { // try to find the Achievement node that has the given ID. Return null on failure. + foreach($this->nodes as $elem) { + if($elem->getID == $id) { + return $elem; + } + } + + return null; + } + + function unsetChild($id) { // remove child with given ID from nodes list; unset should destruct it. + foreach($this->nodes as $key=>$elem) { + if($elem->getID() == $id) { + unset($this->nodes[$key]); + return null; + } + } + } + + } +?> \ No newline at end of file diff --git a/code/web/app/app_achievements_admin/class/AdmDispatcher_inter.php b/code/web/app/app_achievements_admin/class/AdmDispatcher_inter.php new file mode 100644 index 000000000..102b7c893 --- /dev/null +++ b/code/web/app/app_achievements_admin/class/AdmDispatcher_inter.php @@ -0,0 +1,11 @@ + \ No newline at end of file diff --git a/code/web/app/app_achievements_admin/class/AdmMenuNode_class.php b/code/web/app/app_achievements_admin/class/AdmMenuNode_class.php new file mode 100644 index 000000000..79f60c9df --- /dev/null +++ b/code/web/app/app_achievements_admin/class/AdmMenuNode_class.php @@ -0,0 +1,185 @@ +sqlQuery("SELECT count(*) as anz FROM ach_achievement WHERE aa_category='".$this->id."'"); + $this->ach_count = $res[0]['anz']; + } + + protected function makeChild($d) { // override child generator to use admin classes + return new AdmMenuNode($d,$this); + } + + function hasAchievements() { + if($this->ach_count != 0) { + return true; + } + else { + foreach($this->nodes as $elem) { + $res = $elem->hasAchievements(); + if($res == true) { + return true; + } + } + + return false; + } + } + + function getNode($id) { // try to find the child node that has the given ID. Return null on failure. + if($id == $this->getID()) { // found! + return $this; + } + else { + foreach($this->nodes as $elem) { // check children + $tmp = $elem->getNode($id); + if($tmp != null) { + return $tmp; + } + } + return null; + } + } + + function delete_me() { // remove this node + global $DBc; + + // remove from database + $DBc->sqlQuery("DELETE FROM ach_category WHERE ac_id='".$this->getID()."'"); + $DBc->sqlQuery("DELETE FROM ach_category WHERE ac_parent='".$this->getID()."'"); + $DBc->sqlQuery("DELETE FROM ach_category_lang WHERE NOT EXISTS (SELECT * FROM ach_category WHERE ac_id=acl_category)"); + + // call delete function for all children + foreach($this->nodes as $elem) { + $elem->delete_me(); + $this->unsetChild($elem->getID()); + } + } + + function unsetChild($id) { // remove child with given ID from nodes list; unset should destruct. + foreach($this->nodes as $key=>$elem) { + if($elem->getID() == $id) { + unset($this->nodes[$key]); + return null; + } + } + } + + function insertChild(&$n) { // insert a new child + // insert command to create database entry + $n->insert(); + + // set the new child's parent and add it to the node list + $n->setParent($this); + $this->nodes[] = $n; + } + + function update() { + global $DBc,$_USER; + + $DBc->sqlQuery("UPDATE ach_category SET ac_parent=".mkn($this->getParentID()).",ac_order='".$this->getOrder()."',ac_image=".mkn($this->getImage()).",ac_dev='".$this->getDev()."' WHERE ac_id='".$this->getID()."'"); + + #MISSING: update lang entry + $DBc->sqlQuery("INSERT IGNORE INTO ach_category_lang (acl_category,acl_lang,acl_name) VALUES ('".$this->getID()."','".$_USER->getLang()."','".mysql_real_escape_string($this->getName())."') ON DUPLICATE KEY UPDATE acl_name='".mysql_real_escape_string($this->getName())."'"); + } + + function insert() { // write $this to the database as a new entry + global $DBc,$_USER; + + $this->setOrder($this->parent->getNextOrder()); + + $DBc->sqlQuery("INSERT INTO ach_category (ac_parent,ac_order,ac_image,ac_dev) VALUES (".mkn($this->getParentID()).",'".$this->getOrder()."',".mkn($this->getImage()).",'1')"); + $id = mysql_insert_id(); + $this->setID($id); + #MISSING: insert lang entry + $DBc->sqlQuery("INSERT INTO ach_category_lang (acl_category,acl_lang,acl_name) VALUES ('".$this->getID()."','".$_USER->getLang()."','".mysql_real_escape_string($this->getName())."')"); + + } + + function setInDev($tf) { + if($tf == true) { + $this->setDev(1); + } + else { + $this->setDev(0); + } + + $this->update(); + } + + private function setDev($d) { + $this->dev = $d; + } + + private function setOrder($o) { + $this->order = $o; + $this->update(); + } + + function swapChild($a,$b) { + $ids = array(); + foreach($this->nodes as $key=>$elem) { + if($a == $elem->getID() || $b == $elem->getID()) { + $ids[] = $key; + } + + if(sizeof($ids) == 2) { + break; + } + } + + $tmp = $this->nodes[$ids[0]]; + $this->nodes[$ids[0]] = $this->nodes[$tmp[1]]; + $this->nodes[$ids[1]] = $tmp; + } + + function setName($n) { + $this->name = $n; + } + + function setImage($i) { + if($i == null || strtolower($i) == "null") { + $this->image = null; + } + else { + $this->image = $i; + } + } + + function setParent(&$p) { + $this->parent = $p; + } + + function setParentID($p) { + if($p == null || strtolower($p) == "null") { + $this->parent_id = null; + } + else { + $this->parent_id = $p; + } + } + + function setID($id) { + $this->id = $id; + } + + function getNextOrder() { + if($this->isEmpty()) { + return 0; + } + + $val = array(); + foreach($this->nodes as $elem) { + $val[] = $elem->getOrder(); + } + + return (max($val)+1); + } + } + +?> \ No newline at end of file diff --git a/code/web/app/app_achievements_admin/class/AdmMenu_class.php b/code/web/app/app_achievements_admin/class/AdmMenu_class.php new file mode 100644 index 000000000..524f249d0 --- /dev/null +++ b/code/web/app/app_achievements_admin/class/AdmMenu_class.php @@ -0,0 +1,95 @@ +nodes[0]); // unset the auto-generated "summary" node + } + + protected function makeChild($d) { // override child generator to use admin classes + return new AdmMenuNode($d,$this); + } + + function removeNode($id) { // find the node that has the ID we want to delete. If found, call it's delete function. + $res = $this->getNode($id); + if($res != null) { + $res->delete_me(); + $this->unsetChild($id); + } + } + + function insertNode(&$n) { + if($n->getParentID() != null) { + $res = $this->getNode($n->getParentID()); + if($res != null) { + $n->setParent($res); + $res->insertChild($n); + } + } + else { + $n->setParent($this); + $n->insert(); + $this->nodes[] = $n; + } + } + + function updateNode($id,$data) { #MISSING: data handling... + $res = $this->getNode($id); + if($res != null) { + $res->setName($data['acl_name']); + $res->setImage($data['ac_image']); + $res->update(); + } + } + + function swapOrder($a,$b) { + $tmp_a = $this->getNode($a); + if($tmp_a != null) { + $tmp_b = $this->getNode($a); + if($tmp_b != null) { + $tmp = $tmp_b->getOrder(); + $tmp_b->setOrder($tmp_a->getOrder()); + $tmp_a->setOrder($tmp); + + if($tmp_a->getParentID() == $tmp_b->getParentID()) { + $tmp_a->getParent()->swapChild($a,$b); + } + } + } + } + + function getNode($id) { // try to find the MenuNode that has the given ID. Return null on failure. + foreach($this->nodes as $elem) { + $tmp = $elem->getNode($id); + if($tmp != null) { + return $tmp; + } + } + + return null; + } + + function getNextOrder() { + if($this->isEmpty()) { + return 0; + } + + $val = array(); + foreach($this->nodes as $elem) { + $val[] = $elem->getOrder(); + } + + return (max($val)+1); + } + + function unsetChild($id) { // remove child with given ID from nodes list; unset should destruct it. + foreach($this->nodes as $key=>$elem) { + if($elem->getID() == $id) { + unset($this->nodes[$key]); + return null; + } + } + } + } +?> \ No newline at end of file diff --git a/code/web/app/app_achievements_admin/class/AdmObjective_class.php b/code/web/app/app_achievements_admin/class/AdmObjective_class.php new file mode 100644 index 000000000..c1a4ebc2d --- /dev/null +++ b/code/web/app/app_achievements_admin/class/AdmObjective_class.php @@ -0,0 +1,75 @@ +sqlQuery("SELECT atom_id FROM ach_atom WHERE atom_objective='".$this->getID()."'"); + $sz = sizeof($res); + for($i=0;$i<$sz;$i++) { + $this->nodes[] = $this->makeChild($res[$i]); + } + } + + private function makeChild($d) { + return new AdmAtom($d,$this); + } + + function insertNode(&$n) { // insert an Atom + $n->insert(); + $this->nodes[] = $n; + } + + function removeNode($id) { // remove an Atom + $res = $this->getNode($id); + if($res != null) { + $res->delete_me(); + $this->unsetChild($id); + } + } + + function updateNode($id,$data) { // update an Atom + $res = $this->getNode($id); + if($res != null) { + #MISSING: set new data + # + $res->update(); + } + } + + function getNode($id) { // find an atom + foreach($this->nodes as $elem) { + if($elem->getID == $id) { + return $elem; + } + } + + return null; + } + + function delete_me() { + global $DBc; + + $DBc->sqlQuery("DELETE FROM ach_objective WHERE ao_id='".$this->getID()."'"); + $DBc->sqlQuery("DELETE FROM ach_player_objective WHERE apo_objective='".$this->getID()."'"); + + foreach($this->nodes as $elem) { + $elem->delete_me(); + } + } + + function update() { + + } + + function insert() { + + } + + function setInDev($tf) { + + } + } +?> \ No newline at end of file diff --git a/code/web/app/app_achievements_admin/class/AdmPerk_class.php b/code/web/app/app_achievements_admin/class/AdmPerk_class.php new file mode 100644 index 000000000..f0af45979 --- /dev/null +++ b/code/web/app/app_achievements_admin/class/AdmPerk_class.php @@ -0,0 +1,77 @@ +insert(); + $this->nodes[] = $n; + } + + function removeNode($id) { // remove an Objective + $res = $this->getNode($id); + if($res != null) { + $res->delete_me(); + $this->unsetChild($id); + } + } + + function updateNode($id,$data) { // update an Objective + $res = $this->getNode($id); + if($res != null) { + #MISSING: set new data + # + $res->update(); + } + } + + function getNode($id) { // find an Objective + foreach($this->nodes as $elem) { + if($elem->getID == $id) { + return $tmp; + } + } + + return null; + } + + function delete_me() { + global $DBc; + + $DBc->sqlQuery("DELETE FROM ach_perk WHERE ap_id='".$this->getID()."'"); + $DBc->sqlQuery("DELETE FROM ach_player_perk WHERE app_perk='".$this->getID()."'"); + + foreach($this->nodes as $elem) { + $elem->delete_me(); + $this->unsetChild($elem->getID()); + } + } + + function update() { + + } + + function insert() { + + } + + function unsetChild($id) { // remove child with given ID from nodes list; unset should destruct it. + foreach($this->nodes as $key=>$elem) { + if($elem->getID() == $id) { + unset($this->nodes[$key]); + return null; + } + } + } + + function setInDev($tf) { + + } + } +?> \ No newline at end of file diff --git a/code/web/app/app_achievements_admin/class/CSRAchievement_class.php b/code/web/app/app_achievements_admin/class/CSRAchievement_class.php new file mode 100644 index 000000000..f5cec8840 --- /dev/null +++ b/code/web/app/app_achievements_admin/class/CSRAchievement_class.php @@ -0,0 +1,20 @@ +nodes as $elem) { + $elem->grant($pid); + } + } + + function deny($pid) { + foreach($this->nodes as $elem) { + $elem->deny($pid); + } + } + } +?> \ No newline at end of file diff --git a/code/web/app/app_achievements_admin/class/CSRAtom_class.php b/code/web/app/app_achievements_admin/class/CSRAtom_class.php new file mode 100644 index 000000000..38f04299a --- /dev/null +++ b/code/web/app/app_achievements_admin/class/CSRAtom_class.php @@ -0,0 +1,22 @@ +id = $data['atom_id']; + } + + function grant($pid) { + $this->clear_all($pid); #empty database + } + + function deny($pid) { + $this->clear_all($pid); #empty database + } + + private function clear_all($pid) { + global $DBc; + $DBc->sqlQuery("DELETE FROM ach_player_atom WHERE apa_atom='".$this->getID()."' AND apa_player='".$pid."'"); + } + } +?> \ No newline at end of file diff --git a/code/web/app/app_achievements_admin/class/CSRObjective_class.php b/code/web/app/app_achievements_admin/class/CSRObjective_class.php new file mode 100644 index 000000000..7fba5a3b0 --- /dev/null +++ b/code/web/app/app_achievements_admin/class/CSRObjective_class.php @@ -0,0 +1,38 @@ +sqlQuery("SELECT atom_id FROM ach_atom WHERE atom_objective='".$this->getID()."'"); + $sz = sizeof($res); + for($i=0;$i<$sz;$i++) { + $this->nodes[] = new CSRAtom($res[$i]); + } + } + + function grant($pid) { + global $DBc; + + $DBc->sqlQuery("INSERT INTO ach_player_objective (apo_objective,apo_player,apo_date) VALUES ('".$this->getID()."','".$pid."','".time()."')"); + + foreach($this->nodes as $elem) { + $elem->grant($pid); + } + } + + function deny($pid) { + global $DBc; + + $DBc->sqlQuery("DELETE FROM ach_player_objective WHERE apo_objective='".$this->getID()."' AND apo_player='".$pid."'"); + + foreach($this->nodes as $elem) { + $elem->deny($pid); + } + } + } +?> \ No newline at end of file diff --git a/code/web/app/app_achievements_admin/class/CSRPerk_class.php b/code/web/app/app_achievements_admin/class/CSRPerk_class.php new file mode 100644 index 000000000..69eceacf5 --- /dev/null +++ b/code/web/app/app_achievements_admin/class/CSRPerk_class.php @@ -0,0 +1,28 @@ +sqlQuery("INSERT INTO ach_player_perk (app_perk,app_player,app_date) VALUES ('".$this->getID()."','".$pid."','".time()."')"); + + foreach($this->nodes as $elem) { + $elem->grant(); + } + } + + function deny($pid) { + global $DBc; + + $DBc->sqlQuery("DELETE FROM ach_player_perk WHERE app_perk='".$this->getID()."' AND app_player='".$pid."'"); + + foreach($this->nodes as $elem) { + $elem->deny($pid); + } + } + } +?> \ No newline at end of file diff --git a/code/web/app/app_achievements_admin/class/CSR_inter.php b/code/web/app/app_achievements_admin/class/CSR_inter.php new file mode 100644 index 000000000..e62b98ef7 --- /dev/null +++ b/code/web/app/app_achievements_admin/class/CSR_inter.php @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/code/web/app/app_achievements_admin/class/Dispatcher_trait.php b/code/web/app/app_achievements_admin/class/Dispatcher_trait.php new file mode 100644 index 000000000..455c4453f --- /dev/null +++ b/code/web/app/app_achievements_admin/class/Dispatcher_trait.php @@ -0,0 +1,30 @@ +insert(); + $this->nodes[] = $n; + } + + function removeNode($id) { + $res = $this->getNode($id); + if($res != null) { + $res->delete_me(); + $this->removeNode($res); + } + } + + function updateNode($id,$data) { + $res = $this->getNode($id); + if($res != null) { + #MISSING: set new data + # + $res->update(); + } + } + + function getNode($id) { + return $this->getIdx($id); + } + } +?> \ No newline at end of file diff --git a/code/web/app/app_achievements_admin/class/RyzomAdmin_class.php b/code/web/app/app_achievements_admin/class/RyzomAdmin_class.php new file mode 100644 index 000000000..e7361364f --- /dev/null +++ b/code/web/app/app_achievements_admin/class/RyzomAdmin_class.php @@ -0,0 +1,15 @@ + \ No newline at end of file diff --git a/code/web/app/app_achievements_admin/conf.php b/code/web/app/app_achievements_admin/conf.php index e4e3a504e..2032c079f 100644 --- a/code/web/app/app_achievements_admin/conf.php +++ b/code/web/app/app_achievements_admin/conf.php @@ -3,11 +3,12 @@ die(-1); } - $achConf = array(); + $_CONF = array(); - $achConf['summary_size'] = 12; - $achConf['default_lang'] = 'en'; - $achConf['enable_webig'] = true; - $achConf['enable_offgame'] = true; - $achConf['use_cache'] = false; + $_CONF['app_achievements_path'] = "../app_achievements/"; + $_CONF['image_url'] = "http://www.3025-game.de/special/app_achievements/"; + $_CONF['enable_webig'] = true; + $_CONF['enable_offgame'] = true; + $_CONF['enable_CSR'] = true; + $_CONF['enable_ADM'] = true; ?> \ No newline at end of file diff --git a/code/web/app/app_achievements_admin/include/ach_render_admin.php b/code/web/app/app_achievements_admin/include/ach_render_admin.php new file mode 100644 index 000000000..2e231bfff --- /dev/null +++ b/code/web/app/app_achievements_admin/include/ach_render_admin.php @@ -0,0 +1,171 @@ + + .ach_menu { + display:block; + padding:2px; + border:1px solid #000000; + margin-bottom:2px; + color:#FFFFFF; + } + .ach_menu:hover { + color:orange; + } + + .ach_mspan a { + text-decoration:none; + } + "; + + $html .= "
+
+ + "; + + if($_REQUEST['ac_id'] > 0 && $_REQUEST['confirm'] == "delete") { + $curr = $menu->getNode($_REQUEST['ac_id']); + $html .= "
+
+ Are you sure you want to delete this category?"; + if($curr->hasAchievements()) { + $html .= "You may NOT DELETE this category since there are still achievements tied to it or one of its sub-categories!"; + } + else { + $html .= "".$curr->getName()."

"; + + if($curr->getParentID() == null) { + $html .= "WARNING: Deleting this category will also delete ALL sub-categories!
"; + } + $html .= "delete"; + } + $html .= "

+
"; + } + + $html .= "
"; + + return $html.ach_render_mnode($menu,$sub); + } + + function ach_render_mnode(&$menu,$sub) { + global $_CONF; + + # echo "1"; + + $iter = $menu->getIterator(); + while($iter->hasNext()) { + $curr = $iter->getNext(); + #$sz = $menu->getSize(); + #for($i=0;$i<$sz;$i++) { + # $curr = $menu->getChild($i); + + $html .= " + "; + if($sub == 0) { + $html .= ""; + } + $html .= " + + +
getImage()."' />"; + if($curr->inDev()) { + $html .= ""; + } + + $html .= $curr->getName(); + + if($curr->inDev()) { + $html .= ""; + } + $html .= " "; + + if($sub == 0) { + $html .= " "; + } + + $html .= "   
"; + if($sub == 0) { + $html .= ""; + } + + $html .= ""; + + if(!$curr->isEmpty()) { + $html .= "
".ach_render_mnode($curr,($sub+4))."
"; + } + } + + return $html; + } +?> \ No newline at end of file diff --git a/code/web/app/app_achievements_admin/index.php b/code/web/app/app_achievements_admin/index.php index d228a16e0..cc6b6cbda 100644 --- a/code/web/app/app_achievements_admin/index.php +++ b/code/web/app/app_achievements_admin/index.php @@ -5,8 +5,8 @@ ini_set("display_errors","1"); define('APP_NAME', 'app_achievements_admin'); -require_once('../config.php'); -include_once('../lang.php'); +require_once('../webig/config.php'); +include_once('../webig/lang.php'); include_once('lang.php'); require_once('conf.php'); @@ -22,14 +22,138 @@ $user['civilization'] = "c_neutral"; $user['cult'] = "c_neutral"; $user['admin'] = true; +require_once($_CONF['app_achievements_path']."class/RyzomUser_class.php"); require_once("class/RyzomAdmin_class.php"); $_USER = new RyzomAdmin($user); +require_once("include/ach_render_admin.php"); +#require_once("include/ach_render_csr.php"); + +require_once($_CONF['app_achievements_path']."class/RenderNodeIterator_abstract.php"); +require_once($_CONF['app_achievements_path']."class/NodeIterator_class.php"); +require_once($_CONF['app_achievements_path']."class/AchList_abstract.php"); +require_once($_CONF['app_achievements_path']."class/Tieable_inter.php"); + +require_once($_CONF['app_achievements_path']."class/AchMenu_class.php"); +require_once($_CONF['app_achievements_path']."class/AchMenuNode_class.php"); +#require_once($_CONF['app_achievements_path']."class/AchCategory_class.php"); +#require_once($_CONF['app_achievements_path']."class/AchAchievement_class.php"); +#require_once($_CONF['app_achievements_path']."class/AchPerk_class.php"); +#require_once($_CONF['app_achievements_path']."class/AchObjective_class.php"); + +require_once("class/ADM_inter.php"); +require_once("class/AdmDispatcher_inter.php"); +require_once("class/AdmMenu_class.php"); +require_once("class/AdmMenuNode_class.php"); +#require_once("class/AdmCategory_class.php"); +#require_once("class/AdmAchievement_class.php"); +#require_once("class/AdmPerk_class.php"); +#require_once("class/AdmObjective_class.php"); + +/*require_once("class/CSR_inter.php"); +require_once("class/CSRMenu_class.php"); +require_once("class/CSRCategory_class.php"); +require_once("class/CSRAchievement_class.php"); +require_once("class/CSRPerk_class.php"); +require_once("class/CSRObjective_class.php");*/ + if($_USER->isIG()) { die("IG disabled for admin tool!"); } -$DBc = ryDB::getInstance("app_achievements"); +$DBc = ryDB::getInstance("ahufler"); + +function mkn($x) { + if($x == null || strtolower($x) == "null") { + return "NULL"; + } + else { + return "'".mysql_real_escape_string($x)."'"; + } +} + + +$c = " + +
+ + + + +
"; + + if($_USER->isAdmin()) { + $c .= "Admin
+

"; + } + if($_USER->isCSR()) { + $c .= "CSR
+

"; + } + + +#$c .= ach_render_menu(); + +$c .= "

"; + + if($_REQUEST['mode'] == "menu" && $_USER->isAdmin()) { + $menu = new AdmMenu(false); + + if($_REQUEST['act'] == "insert") { + $n = new AdmMenuNode(array(),null); + $n->setID(null); + $n->setDev(1); + $n->setName($_REQUEST['acl_name']); + $n->setImage($_REQUEST['ac_image']); + $n->setParentID($_REQUEST['ac_parent']); + + $menu->insertNode($n); + } + + if($_REQUEST['act'] == "delete") { + $menu->removeNode($_REQUEST['ac_id']); + } + + if($_REQUEST['act'] == "update") { + $menu->updateNode($_REQUEST['ac_id'],array("acl_name"=>$_REQUEST['acl_name'],"ac_image"=>$_REQUEST['ac_image'])); + } + + if($_REQUEST['act'] == "dev") { + $curr = $menu->getNode($_REQUEST['ac_id']); + $curr->setInDev(($_REQUEST['state'] != 1)); + } + + + $c .= adm_render_menu($menu); + } + +#$c .= ach_render_content(); + +$c .= "
"; echo ryzom_app_render("achievements admin", $c, $_USER->isIG()); diff --git a/code/web/app/app_achievements_admin/pic/b_drop.png b/code/web/app/app_achievements_admin/pic/b_drop.png new file mode 100644 index 0000000000000000000000000000000000000000..6fc4d3b2030ecf772fae856411c7b0968d99005b GIT binary patch literal 311 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJOS+@4BLli5Jei0#Y0$L4LviA%Njt^WI31l&6bhNX4zB1b1cz#v=#L9XQ1BeB*}A z%q#-T*4)b4(o?t>F*0#zoIb=Q$oTmtkhx|Ks|wRYkOCL`0G3nf>>LU!8g&ecZvf@i zF{v>LIB*y*Py(9O5Wuep(t6;`5vIViTuKZ~9gTA(-x+M+aA06$eNbb-z@e}}OvNsM m(}BTo!EZ5z1_KrbCLV@_U2LV?JKcpq4)=8Rb6Mw<&;$Tia9maZ literal 0 HcmV?d00001 diff --git a/code/web/app/app_achievements_admin/pic/b_insrow.png b/code/web/app/app_achievements_admin/pic/b_insrow.png new file mode 100644 index 0000000000000000000000000000000000000000..3913b4a652e93336162f1fcea21505720235a3e8 GIT binary patch literal 283 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJOS+@4BLl($dZV#qMa% zI|`&&OM?7@{{sQT?`?b_3mQFL978H@B_%jAGcX=GaEOCVK+c$(+kwGwgFz#MOT)~W zGg%cH7BKk~h%zv;h$ghnW)yHpFrG0(kO`=s;W9T%!eK_H4#q?5jACwVY;0l;3`q^2 z7Xl?)7BVR`7@T3?P~eGXVB$C|3lw@4qyXfL>~COjU|9G|jDvxRhhfELX3+;LGS>nf O!{F)a=d#Wzp$P!h|4*?1 literal 0 HcmV?d00001 diff --git a/code/web/app/app_achievements_admin/pic/green.gif b/code/web/app/app_achievements_admin/pic/green.gif new file mode 100644 index 0000000000000000000000000000000000000000..fa6957d516420fd76f1f361c0f24f0b8fcf3b4c7 GIT binary patch literal 1503 zcmV<51t9u~P)004R=004l4008;_004mK004C`008P>0026d000+nm#LZ5000GQ zNklGEhhxisgWq z2WsFiApQu%Pl5O@P~8n9BcuB_Zrpe!E-wE4&6_t2yu7>&00G3DnVHD|lw?s*P!M5f zX9pQ#3&i$7%dGzWzODD~?`_5ZzwgTZ`~6J*-#<1fMiw3!Mg|5MsLL5eL`1%+sHlAZ z@#DvzckkXY00a=oVa)RK^86ee9I8MCmOyOB@av)e->-*-{{DZ!`j6=w10%yB$M4^+zmayd}{cRM?~mv`>m`3(?2EXvBtJizb+g_ki9Tm1j^ z(tzQ^GBHMWMh0e1D+X3(AqGaqAHeYW$nclrHq-ByTR6Xeyvoilo5aMzDFh0JcR>6W z=)QGX1iI3Ifr-_g zflb1g;s3t}Oh2A(G~xETKa;|0=^42;Yw3~Yj;41b<)VgC8*q5uOVJVE+-fsw=l5I{`O zSQG|g!M|T0vj1oJ1`KLWhX0IA;K*fUWCXgB6-fUFS^#AKV`E_X^Ob?|`z^*lZ_j~j z1cjv_5QEq(009I_Htf*AW&88{7f}C82B!Z&%qY#k@Sho&Mt=hh1BU$9b3lWEM*e-m z@c+wQhJRmPGcf=9$PCoS3dJC^m;eF@MEnEdKOp@7|KI=rzX5IMy2ZfA#=`LTj|jt$ zPY)SbIQSTTy;;S;!p_6M1a$51_m3HVynWBWEYAdtexSo47z7vr0tjT_cOd=*#9vsr zCI9|@`G#g@?hYQvG@u~GC=$Wh(CY-{{0U?0D%nr48)H?*@=OP?IDYV|JQFHnHc^&yTriw z;~g+DKVta(;RwT@uXh=~zInm$@#Z@QW>ygfKBM@5%p80#!TJ~&9)j}urcIlE0|XEY zG=Dw-;`5*wW8qX_WtPrV`}}wzFW;Br3~b+?FnqjpgW=QD?+o8Q02BLf83qZ*%3mCE zmLNke0`WN@zJ2-f<@cvgpZ*IFKrB%IgS>nR8n9ov#f;v6{?DQP@KUq*|6hDezrQju zJb5j|@cJDOgQi3NJAU)zn~Y3MAcM{V@rB>Ne?Pf@|Nak95(5Yz7N{ZL{`~p#5SXvQ zMHDcVJYeFIy?OPMeIz4;nUJuEFvH7FuNkhtyv?8>sCfox*k+)*d%#laCNSJy0uA~G z)C*3t00G1VHIU)+=g;3yojUatXfVj@TYmrfz3=lczHcl%dJIZB{tQy8Rt*0*gc*MR z{&N*14=h>Ee*OCO;k|qJz5q+Be=u_Z0tn_pP~pn3ckf=H>wmuk7Dw-dgoJtj0aGQY zq~QQ2eGXt@0n8}CbjbV!sQl5DD_5BG_4WTSF~Qvg1^@vBHxN|Xf((89`0?Lw-@Y*b zUGU<`qsLF!S=rRSeEGug;lq1|_wV0-`}ON5C<6Zhz4(s-3jhcp7IXn%xyS%AVDjY2 zZ-Lc82`~t{freXt`0(K^(2K2&jg8y6xw#oY7#jcxFaUvx3R3A~{E`3w002ovPDHLk FV1hCd;ST@+ literal 0 HcmV?d00001 diff --git a/code/web/app/app_achievements_admin/pic/icon_edit.gif b/code/web/app/app_achievements_admin/pic/icon_edit.gif new file mode 100644 index 0000000000000000000000000000000000000000..9036904dc311148fa0df132415158f9a62cb5014 GIT binary patch literal 125 zcmZ?wbhEHb6k-r$Sj52a|Nnmm28M=)h64u<0GSOy4j3r@WC7DUAQGgOf!T>;*Bu#y zQ#YDci$tjJ(mR?~D#xaIZ2_OCW6rIuEP6JREdJUZc*SoO!885#$2#p<25P6z=*gZg SdO73Ny#CH004R=004l4008;_004mK004C`008P>0026d000+nm#LZ5000EE zNklpB3`NlgEUBt42DyLS=T-Gzm_m?@geK!5POiF3L?AOEB2d+>)~cnH z9l$|(@WepFd{+2p|?VHa2E0EiHa-Zf;ee0!tvad-dv-{?)5jg@6iJfBg6X_6i6CgM<_4 z8h%|}T`{0~exOSumN9U`6fWQZU0Ag-# zZWaX!XaTVe&=8X&M~=uaGcz-qnwm1m$jE@h1?UK0XGZw;6y2GJgL2nN?X? znHk9c2Gsi+7zeKe1qHtV1P~~&`G8mo6ahdlihlX>g%PL_YydDg7=VU@Qve79H84m> zNPsN?Mh5epJ9h+t`edN`d4Z9{0uVq<&{z}(V!@X$U$X!F`4bf5V3&X}Faki4#sC8# zOF+pC7*UM3Z{Owu3W35>5Qsr+7JvW(sbq%+E*sD=#&_@DF?{;;i9u9Ul;PK}UtrB3 zaO>7BFbxc224L(nynp{56t2ubAyy~`nZ*PUKp^5D5QB96`S?VGf?No69oS${5(eV`Pz(Z$009It@H-HH0^%>i!oq(+F8cQE8`uTF*RNj(I|CFfUS3`dprisyGC=$Wh(7}(^bbG)fgQFCywj#l`wb94Owj!K0Eo|nFfdu% z^7Qls*#?e?j~_oW?Ax~w>^hK(L53wKC;tMv4rI_pAU+4gw}F}A{f-?w{sIIL3)KH0 zFJFQN>{m@q&G(?}J$LS0aiDjZfRP2xdZ083%wq2X0s?LV*&u_?0`Uc)MNfdf_yI~{ z009I`VBdh=dh1wc zshdEbyacNM28w-9x&;UzCRl<62K4vs+qXXj8VvIK7GN6O2U4h{q{QIs>&pNPTX3=g zy5=fK9+-5_0)yk>rAwE-03GrVW)46A!3_lE)1^z7{@%KE>pNgxeFDs8w}9UK2J$M% zb`S;upzEFhsYk#({}vb&e?Y;23;+TMo~J-n{u2lv98%cyZ&#jVBx&9BQyM z35?-y!1M@;z<