summaryrefslogtreecommitdiff
path: root/includes/pages
diff options
context:
space:
mode:
authorPhilip Häusler <msquare@notrademark.de>2011-06-02 17:48:27 +0200
committerPhilip Häusler <msquare@notrademark.de>2011-06-02 17:48:27 +0200
commit1c38d62127e45a9703b834144aa02e8d24b6a62a (patch)
tree470d08d6adb094ea57cd839ab1b665e66d2c8dc3 /includes/pages
parent04b07bff254655d8236abc8814182e4d0e438541 (diff)
admin angel types done
Diffstat (limited to 'includes/pages')
-rw-r--r--includes/pages/admin_angel_types.php76
1 files changed, 73 insertions, 3 deletions
diff --git a/includes/pages/admin_angel_types.php b/includes/pages/admin_angel_types.php
index e5952d10..7ca4fe2b 100644
--- a/includes/pages/admin_angel_types.php
+++ b/includes/pages/admin_angel_types.php
@@ -1,10 +1,80 @@
<?php
function admin_angel_types() {
include ("includes/funktion_db.php");
-
+
$html = "";
- if(!isset($_REQUEST['action'])) {
- $html .= template_render('../templates/admin_angel_types.html', array());
+ if (!isset ($_REQUEST['action'])) {
+ $table = "";
+ $angel_types = sql_select("SELECT * FROM `AngelTypes` ORDER BY `Name`");
+ foreach ($angel_types as $angel_type)
+ $table .= '<tr><td>' . $angel_type['Name'] . '</td><td>' . $angel_type['Man'] . '</td><td><a href="' . page_link_to("admin_angel_types") . '&action=edit&id=' . $angel_type['TID'] . '">Edit</a></td></tr>';
+
+ $html .= template_render('../templates/admin_angel_types.html', array (
+ 'link' => page_link_to("admin_angel_types"),
+ 'table' => $table
+ ));
+ } else {
+ switch ($_REQUEST['action']) {
+ case 'create' :
+ $name = preg_replace("/([^\p{L}\p{P}\p{Z}\p{N}]{1,})/ui", '', strip_tags($_REQUEST['name']));
+ $man = preg_replace("/([^\p{L}\p{P}\p{Z}\p{N}]{1,})/ui", '', strip_tags($_REQUEST['man']));
+ sql_query("INSERT INTO `AngelTypes` SET `Name`='" . sql_escape($name) . "', `Man`='" . sql_escape($man) . "'");
+ header("Location: " . page_link_to("admin_angel_types"));
+ break;
+
+ case 'edit' :
+ if (isset ($_REQUEST['id']) && preg_match("/^[0-9]{1,11}$/", $_REQUEST['id']))
+ $id = $_REQUEST['id'];
+ else
+ return error("Incomplete call, missing AngelType ID.");
+
+ $angel_type = sql_select("SELECT * FROM `AngelTypes` WHERE `TID`=" . sql_escape($id) . " LIMIT 1");
+ if (count($angel_type) > 0) {
+ list ($angel_type) = $angel_type;
+
+ $html .= template_render('../templates/admin_angel_types_edit_form.html', array (
+ 'link' => page_link_to("admin_angel_types"),
+ 'id' => $id,
+ 'name' => $angel_type['Name'],
+ 'man' => $angel_type['Man']
+ ));
+ } else
+ return error("No Angel Type found.");
+ break;
+
+ case 'save' :
+ if (isset ($_REQUEST['id']) && preg_match("/^[0-9]{1,11}$/", $_REQUEST['id']))
+ $id = $_REQUEST['id'];
+ else
+ return error("Incomplete call, missing AngelType ID.");
+
+ $angel_type = sql_select("SELECT * FROM `AngelTypes` WHERE `TID`=" . sql_escape($id) . " LIMIT 1");
+ if (count($angel_type) > 0) {
+ list ($angel_type) = $angel_type;
+
+ $name = preg_replace("/([^\p{L}\p{P}\p{Z}\p{N}]{1,})/ui", '', strip_tags($_REQUEST['name']));
+ $man = preg_replace("/([^\p{L}\p{P}\p{Z}\p{N}]{1,})/ui", '', strip_tags($_REQUEST['man']));
+ sql_query("UPDATE `AngelTypes` SET `Name`='" . sql_escape($name) . "', `Man`='" . sql_escape($man) . "' WHERE `TID`=" . sql_escape($id) . " LIMIT 1");
+ header("Location: " . page_link_to("admin_angel_types"));
+ } else
+ return error("No Angel Type found.");
+ break;
+
+ case 'delete' :
+ if (isset ($_REQUEST['id']) && preg_match("/^[0-9]{1,11}$/", $_REQUEST['id']))
+ $id = $_REQUEST['id'];
+ else
+ return error("Incomplete call, missing AngelType ID.");
+
+ $angel_type = sql_select("SELECT * FROM `AngelTypes` WHERE `TID`=" . sql_escape($id) . " LIMIT 1");
+ if (count($angel_type) > 0) {
+ sql_query("DELETE FROM `AngelTypes` WHERE `TID`=" . sql_escape($id) . " LIMIT 1");
+ sql_query("DELETE FROM `RoomAngelTypes` WHERE `angel_type_id`=" . sql_escape($id) . " LIMIT 1");
+ header("Location: " . page_link_to("admin_angel_types"));
+ } else
+ return error("No Angel Type found.");
+ break;
+ }
}
return $html;