From 0720091ca73b9714aab2b38c3682c15a0cbd4533 Mon Sep 17 00:00:00 2001 From: Jesse Morgan Date: Thu, 2 Jun 2011 17:20:54 -0700 Subject: Added pages --- htdocs/moderate/pages/editor.php | 100 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 htdocs/moderate/pages/editor.php (limited to 'htdocs/moderate/pages/editor.php') diff --git a/htdocs/moderate/pages/editor.php b/htdocs/moderate/pages/editor.php new file mode 100644 index 0000000..e2f9d25 --- /dev/null +++ b/htdocs/moderate/pages/editor.php @@ -0,0 +1,100 @@ + + * + */ + +require_once('../../src/base.inc.php'); + +// Verify User is admin +if (!$_SESSION['currentUser']->isAdmin()) { + header('Location: ' . buildUrl('moderate/')); + exit; +} + +$error = ''; + +// Get the current user object. +$page = new Page(); +if (isset($_GET['id']) and is_numeric($_GET['id'])) { + $page = Page::getById($_GET['id']); +} + +// Save changes? +if ($_SERVER['REQUEST_METHOD'] == 'POST') { + // Title + if (isset($_POST['title']) and trim($_POST['title']) != '') { + $page->setTitle($_POST['title']); + + } else { + $error .= '

Title is a required field.

'; + } + + // URL + if (isset($_POST['url']) and trim($_POST['url']) != '') { + $page->setURL($_POST['url']); + + } else { + $error .= '

URL is a required field.

'; + } + + // Content + if (isset($_POST['content']) and trim($_POST['content']) != '') { + $page->setContent($_POST['content']); + + } else { + $error .= '

Content is a required field.

'; + } + + // Save + if ($error == '') { + if ($page->save()) { + // Return to pages list + header("Location: index.php"); + + } else { + $error .= '

An error has occured.

'; + } + } +} + +require_once('../src/header.inc.php'); + +echo "

Edit Page

"; + +if ($error != '') { + echo "
$error
"; +} + +$url = "editor.php"; + +if (isset($_GET['id'])) { + $url .= '?id=' . $_GET['id']; +} + +echo "
"; + +?> + +

+

+

+ +

+ +Cancel +

+ + +
+ + + -- cgit v1.2.3