151 lines
4.7 KiB
PHP
151 lines
4.7 KiB
PHP
<?php
|
|
if(!isset($_SESSION)) { session_start(); }
|
|
include_once '../classes/TestProjektSmarty.class_subdir.php';
|
|
require_once("../config.inc.php");
|
|
$templatename = substr(basename($_SERVER['PHP_SELF']),0,-3)."html";
|
|
$smarty = new SmartyAdmin();
|
|
require_once "../language/german.inc.php";
|
|
require_once("../func_get_restplatz.php");
|
|
require_once("../func_get_parameter.php");
|
|
|
|
if (isset($_GET['action'])) {
|
|
$action = $_GET['action'];
|
|
} else {
|
|
$action = '';
|
|
}
|
|
|
|
|
|
if ($action == '') {
|
|
|
|
if (isset($_GET['edit'])) {
|
|
$_SESSION["news_status"] = 'edit';
|
|
$pn_id = $_GET['edit'];
|
|
$_SESSION["news_pn_id"] = $pn_id;
|
|
} else {
|
|
$_SESSION["news_status"] = 'neu';
|
|
}
|
|
|
|
# -- Fehlermeldungen -- #
|
|
if (isset($_GET['error'])) {
|
|
|
|
$errorno = $_GET['error'];
|
|
|
|
$smarty->assign('news_error', 1);
|
|
|
|
$smarty->assign('news_value_headline', $_SESSION["news_value_headline"]);
|
|
$smarty->assign('news_value_text', $_SESSION["news_value_text"]);
|
|
|
|
if ($errorno == 1) {
|
|
# ungültiges Datum
|
|
$smarty->assign('news_error_text', "Bitte füllen Sie alle Felder aus!");
|
|
}
|
|
}
|
|
|
|
# --- Wenn Werte editiert werden ------------
|
|
if ($_SESSION["news_status"] == 'edit') {
|
|
$result_edit = $db->query("SELECT pn_id, pn_headline, pn_text
|
|
FROM bpm_prxnews
|
|
WHERE pn_id = $pn_id");
|
|
$row_edit = $result_edit->fetch_array();
|
|
$smarty->assign('news_value_headline', "$row_edit[pn_headline]");
|
|
$smarty->assign('news_value_text', "$row_edit[pn_text]");
|
|
|
|
}
|
|
# --- Wenn Werte editiert werden Ende -------
|
|
|
|
if ($_GET['editende'] == 1) {
|
|
# Editieren ist beendet, als ein update auf einen Datensatz. Dann ist der status wieder Neu, damit wird wieder ein Insert durchgeführt
|
|
$_SESSION["news_status"] = 'neu';
|
|
}
|
|
|
|
|
|
# Gespeicherte Werte
|
|
$query1 = "SELECT pn_id, pn_headline, pn_text, date_format(pn_date, '%d.%m.%Y - %H:%i Uhr') pn_date_form
|
|
FROM bpm_prxnews
|
|
ORDER BY pn_date DESC";
|
|
|
|
$result1 = $db->query($query1) or die("Cannot execute query1");
|
|
|
|
while ($row1 = $result1->fetch_array()) {
|
|
$table_data1[] = $row1;
|
|
}
|
|
$smarty->assign('table_data1', $table_data1);
|
|
|
|
}
|
|
|
|
|
|
if ($action == 'save') {
|
|
|
|
$headline = $_POST['headline'];
|
|
$text = $_POST['text'];
|
|
|
|
$_SESSION["news_value_headline"] = $headline;
|
|
$_SESSION["news_value_text"] = $text;
|
|
|
|
|
|
if($text == "" or $headline == ""){
|
|
echo "<meta http-equiv=\"refresh\" content=\"0; URL=" . $_SERVER['PHP_SELF'] . "?error=1\">";
|
|
exit;
|
|
}
|
|
|
|
|
|
$datum = date("Y-m-d H:i:s");
|
|
$headline_db = addslashes($headline);
|
|
$text_db = addslashes($text);
|
|
|
|
if ($_SESSION["news_status"] == 'neu') {
|
|
|
|
$sql1 = $db->query("INSERT INTO bpm_prxnews ( pn_headline
|
|
, pn_text
|
|
, pn_date
|
|
)
|
|
VALUES
|
|
( '$headline_db'
|
|
, '$text_db'
|
|
, '$datum'
|
|
)
|
|
");
|
|
}
|
|
|
|
if ($_SESSION["news_status"] == 'edit') {
|
|
$pn_id = $_SESSION["news_pn_id"];
|
|
|
|
$result = $db->query("UPDATE bpm_prxnews
|
|
SET pn_headline = '$headline_db'
|
|
, pn_text = '$text_db'
|
|
WHERE pn_id = $pn_id
|
|
");
|
|
|
|
unset($_SESSION['news_pn_id']);
|
|
|
|
}
|
|
# Dann bekommts beim refresh den status neu, also es wird beim Abschicken ein Insert gemacht
|
|
$editende = 1;
|
|
echo "<meta http-equiv=\"refresh\" content=\"0; URL=" . $_SERVER['PHP_SELF'] . "?editende=$editende\">";
|
|
|
|
|
|
}
|
|
|
|
if ($action == 'show') {
|
|
$pn_id = $_GET['pn_id'];
|
|
$result_show = $db->query("SELECT pn_headline, pn_text
|
|
FROM bpm_prxnews
|
|
WHERE pn_id = $pn_id
|
|
");
|
|
$row_show = $result_show->fetch_array();
|
|
$smarty->assign('prx_show_headline', $row_show['pn_headline']);
|
|
$smarty->assign('prx_show_text', $row_show['pn_text']);
|
|
}
|
|
|
|
if ($action == 'del') {
|
|
$pn_id = $_GET['pn_id'];
|
|
|
|
$del1 = $db->query("DELETE FROM bpm_prxnews WHERE pn_id = $pn_id");
|
|
|
|
echo "<meta http-equiv=\"refresh\" content=\"0; URL=" . $_SERVER['PHP_SELF'] . "\">";
|
|
}
|
|
|
|
$smarty->assign('action', "$action");
|
|
$smarty->display("$template/admin/$templatename");
|
|
|
|
?>
|