#1470 admin tool workprint; menu admin almost complete; wip!!

This commit is contained in:
SirCotare 2012-06-25 15:04:51 +02:00
parent 234db34335
commit f32c42b16f
24 changed files with 1175 additions and 9 deletions

View file

@ -0,0 +1,17 @@
<?php
interface ADM {
/*---------------------------
The admin interface defines the basic operations every node must handle.
These are needed to invoke the database operations insert, update and delete.
---------------------------*/
function delete_me();
function update();
function insert();
function setInDev($true_false);
function getID(); // needed to identify a node
}
?>

View file

@ -0,0 +1,129 @@
<?php
class AdmAchievement extends AchAchievement implements ADM, AdmDispatcher {
function AdmAchievement($data,$parent) {
parent::__construct($data,$parent);
}
protected function makeChild(&$d) {
return new AdmPerk($d,$this);
}
function insertNode(&$n) { // add a Perk
$n->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;
}
}
?>

View file

@ -0,0 +1,67 @@
<?php
class AdmAtom implements ADM {
protected $id;
protected $objective;
protected $mandatory;
protected $ruleset;
protected $ruleset_parsed;
protected $parent;
function AdmAtom($data,$parent) {
$this->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() {
}
}
?>

View file

@ -0,0 +1,54 @@
<?php
class AdmCategory extends AchCategory implements AdmDispatcher {
function AdmCategory($id,$cult = null,$civ = null) {
parent::__construct($id,$cult,$civ);
}
protected function makeChild(&$d) {
return new AdmAchievement($d,$this);
}
function insertNode(&$n) {
$n->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;
}
}
}
}
?>

View file

@ -0,0 +1,11 @@
<?php
interface AdmDispatcher {
/*---------------------------
The admin dispatcher allows us to perform operations on child nodes.
---------------------------*/
function insertNode(&$n);
function removeNode($id);
function updateNode($id,$data);
function getNode($id);
}
?>

View file

@ -0,0 +1,185 @@
<?php
class AdmMenuNode extends AchMenuNode implements ADM { #MISSING: da fehlt die komplette logik für sub-sub-menüs!!! DU VOLLHIRT!
private $ach_count;
function AdmMenuNode($data,$parent) {
parent::__construct($data,$parent);
global $DBc;
$res = $DBc->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);
}
}
?>

View file

@ -0,0 +1,95 @@
<?php
class AdmMenu extends AchMenu implements AdmDispatcher {
function AdmMenu($open) {
parent::__construct($open);
unset($this->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;
}
}
}
}
?>

View file

@ -0,0 +1,75 @@
<?php
class AdmObjective extends AchObjective implements ADM, AdmDispatcher {
function AdmObjective($data,$parent) {
parent::__construct($data,$parent);
global $DBc;
$res = $DBc->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) {
}
}
?>

View file

@ -0,0 +1,77 @@
<?php
class AdmPerk extends AchPerk implements ADM, AdmDispatcher {
function AdmPerk($data,$parent) {
parent::__construct($data,$parent);
}
protected function makeChild($d) {
return new AdmObjective($d,$this);
}
function insertNode(&$n) { // insert an Objective
$n->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) {
}
}
?>

View file

@ -0,0 +1,20 @@
<?php
class CSRAchievement extends AchAchievement implements CSR {
function CSRAchievement(&$data) {
parent::__construct($data);
}
function grant($pid) {
foreach($this->nodes as $elem) {
$elem->grant($pid);
}
}
function deny($pid) {
foreach($this->nodes as $elem) {
$elem->deny($pid);
}
}
}
?>

View file

@ -0,0 +1,22 @@
<?php
class CSRAtom implements CSR {
private $id;
function CSRAtom(&$data) {
$this->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."'");
}
}
?>

View file

@ -0,0 +1,38 @@
<?php
class CSRObjective extends AchObjective implements CSR {
private $nodes;
function CSRObjective(&$data) {
parent::__construct($data);
global $DBc;
$res = $DBc->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);
}
}
}
?>

View file

@ -0,0 +1,28 @@
<?php
class CSRPerk extends AchPerk implements CSR {
function CSRPerk(&$data) {
parent::__construct($data);
}
function grant($pid) {
global $DBc;
$DBc->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);
}
}
}
?>

View file

@ -0,0 +1,7 @@
<?php
interface CSR {
function grant($player_id);
function deny($player_id);
}
?>

View file

@ -0,0 +1,30 @@
<?php
trait Dispatcher {
function insertNode(&$n) {
#MISSING: set this as parent
$n->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);
}
}
?>

View file

@ -0,0 +1,15 @@
<?php
class RyzomAdmin extends RyzomUser {
function RyzomAdmin($data) {
parent::__construct($data);
}
function isAdmin() {
return true;
}
function isCSR() {
return true;
}
}
?>

View file

@ -3,11 +3,12 @@
die(-1); die(-1);
} }
$achConf = array(); $_CONF = array();
$achConf['summary_size'] = 12; $_CONF['app_achievements_path'] = "../app_achievements/";
$achConf['default_lang'] = 'en'; $_CONF['image_url'] = "http://www.3025-game.de/special/app_achievements/";
$achConf['enable_webig'] = true; $_CONF['enable_webig'] = true;
$achConf['enable_offgame'] = true; $_CONF['enable_offgame'] = true;
$achConf['use_cache'] = false; $_CONF['enable_CSR'] = true;
$_CONF['enable_ADM'] = true;
?> ?>

View file

@ -0,0 +1,171 @@
<?php
function adm_render_menu(&$menu,$sub = 0) {
$html = "<style>
.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;
}
</style>";
$html .= "<div style='display:block;background-color:#FFFFFF;padding:3px;margin-bottom:5px;color:#000000;'>
<div style='display:block;text-align:right;'><a href='javascript:hs(\"new_main\",\"block\");'><img src='pic/b_insrow.png'></a></div>
<div style='display:none;' id='new_main'>
<form method='post' action='?mode=menu&act=insert'>
<fieldset>
<legend>create new category</legend>
<input type='hidden' name='ac_parent' value='NULL' />
<table>
<tr>
<td>name</td>
<td><input type='text' name='acl_name' /></td>
</tr>
<tr>
<td>image</td>
<td><input type='text' name='ac_image' /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type='submit' value='create' /></td>
</tr>
</table>
</fieldset>
</form>
</div>";
if($_REQUEST['ac_id'] > 0 && $_REQUEST['confirm'] == "delete") {
$curr = $menu->getNode($_REQUEST['ac_id']);
$html .= "<div style='display:block;'>
<fieldset>
<legend>Are you sure you want to delete this category?</legend>";
if($curr->hasAchievements()) {
$html .= "<b>You may NOT DELETE this category since there are still achievements tied to it or one of its sub-categories!</b>";
}
else {
$html .= "<b style='font-size:16px;'>".$curr->getName()."</b><p>";
if($curr->getParentID() == null) {
$html .= "<b>WARNING:</b> Deleting this category will also delete ALL sub-categories!<br>";
}
$html .= "<a href='?mode=menu&act=delete&ac_id=".$_REQUEST['ac_id']."'><b>delete</b></a>";
}
$html .= "</fieldset>
</div>";
}
$html .= "</div>";
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 .= "<span class='ach_mspan'><table class='ach_menu'>
<tr>";
if($sub == 0) {
$html .= "<td><img src='".$_CONF['image_url']."pic/menu/".$curr->getImage()."' /></td>";
}
$html .= "<td style='font-size:".(20-$sub)."px;font-weight:bold;' width='100%'>";
if($curr->inDev()) {
$html .= "<s>";
}
$html .= $curr->getName();
if($curr->inDev()) {
$html .= "</s>";
}
$html .= "</td>
<td style='background-color:#FFFFFF;padding:3px;'><nobr><a href='?mode=menu&act=dev&state=".$curr->getDev()."&ac_id=".$curr->getID()."'><img src='pic/";
if($curr->inDev()) {
$html .= "red";
}
else {
$html .= "green";
}
$html .= ".gif' /></a>&nbsp;<a href='javascript:hs(\"edit_m".$curr->getID()."\",\"block\");'><img src='pic/icon_edit.gif'></a>";
if($sub == 0) {
$html .= "&nbsp;<a href='javascript:hs(\"ins_m".$curr->getID()."\",\"block\");'><img src='pic/b_insrow.png'></a>";
}
$html .= "&nbsp;&nbsp;&nbsp;<a href='?mode=menu&confirm=delete&ac_id=".$curr->getID()."'><img src='pic/b_drop.png'></a></nobr></td>
</tr>
</table></span>";
if($sub == 0) {
$html .= "<div style='display:none;color:#000000;background-color:#FFFFFF;' id='ins_m".$curr->getID()."'>
<form method='post' action='?mode=menu&act=insert'>
<fieldset>
<legend>create new sub-category</legend>
<input type='hidden' name='ac_parent' value='".$curr->getID()."' />
<input type='hidden' name='ac_image' value='NULL' />
<table>
<tr>
<td>name</td>
<td><input type='text' name='acl_name' /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type='submit' value='create' /></td>
</tr>
</table>
</fieldset>
</form>
</div>";
}
$html .= "<div style='display:none;color:#000000;background-color:#FFFFFF;' id='edit_m".$curr->getID()."'>
<form method='post' action='?mode=menu&act=update&ac_id=".$curr->getID()."'>
<fieldset>
<legend>edit category</legend>";
if($sub != 0) {
$html .= "<input type='hidden' name='ac_image' value='NULL' />";
}
$html .= "<table>
<tr>
<td>name</td>
<td><input type='text' name='acl_name' value='".$curr->getName()."' /></td>
</tr>";
if($sub == 0) {
$html .= "<tr>
<td>image</td>
<td><input type='text' name='ac_image' value='".$curr->getImage()."' /></td>
</tr>";
}
$html .= "<tr>
<td>&nbsp;</td>
<td><input type='submit' value='save' /></td>
</tr>
</table>
</fieldset>
</form>
</div>";
if(!$curr->isEmpty()) {
$html .= "<div style='display:block;margin-left:25px;'>".ach_render_mnode($curr,($sub+4))."</div>";
}
}
return $html;
}
?>

View file

@ -5,8 +5,8 @@ ini_set("display_errors","1");
define('APP_NAME', 'app_achievements_admin'); define('APP_NAME', 'app_achievements_admin');
require_once('../config.php'); require_once('../webig/config.php');
include_once('../lang.php'); include_once('../webig/lang.php');
include_once('lang.php'); include_once('lang.php');
require_once('conf.php'); require_once('conf.php');
@ -22,14 +22,138 @@ $user['civilization'] = "c_neutral";
$user['cult'] = "c_neutral"; $user['cult'] = "c_neutral";
$user['admin'] = true; $user['admin'] = true;
require_once($_CONF['app_achievements_path']."class/RyzomUser_class.php");
require_once("class/RyzomAdmin_class.php"); require_once("class/RyzomAdmin_class.php");
$_USER = new RyzomAdmin($user); $_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()) { if($_USER->isIG()) {
die("IG disabled for admin tool!"); 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 = "<script type='text/javascript'>
<!--
function hs(id,mod) {
if(document.getElementById(id).style.display == 'none') {
document.getElementById(id).style.display=mod;
}
else {
document.getElementById(id).style.display='none';
}
}
function hs_force(id,mod,show) {
if(show == true) {
document.getElementById(id).style.display=mod;
}
else {
document.getElementById(id).style.display='none';
}
}
</script>
<center><table width='100%'>
<tr>
<td valign='top' width='230px'><div style='font-weight:bold;font-size:14px;'>";
if($_USER->isAdmin()) {
$c .= "<b>Admin</b><br>
<ul>
<li><a href='?mode=menu'>menu settings</a></li>
<li><a href='?mode=ach'>achievement settings</a></li>
</ul><p />";
}
if($_USER->isCSR()) {
$c .= "<b>CSR</b><br>
<ul>
<li><a href='?mode=player'>administrate player</a></li>
</ul><p />";
}
#$c .= ach_render_menu();
$c .= "</div></td>
<td valign='top'>";
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 .= "</td>
</tr>
</table></center>";
echo ryzom_app_render("achievements admin", $c, $_USER->isIG()); echo ryzom_app_render("achievements admin", $c, $_USER->isIG());

Binary file not shown.

After

Width:  |  Height:  |  Size: 311 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 283 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 125 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB