From f08eb1640388e1f067102a22ec40c30f263d92c6 Mon Sep 17 00:00:00 2001 From: Jesse Morgan Date: Thu, 2 Jun 2011 16:17:25 -0700 Subject: Added user management --- htdocs/moderate/users/editor.php | 126 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 htdocs/moderate/users/editor.php (limited to 'htdocs/moderate/users/editor.php') diff --git a/htdocs/moderate/users/editor.php b/htdocs/moderate/users/editor.php new file mode 100644 index 0000000..21be99e --- /dev/null +++ b/htdocs/moderate/users/editor.php @@ -0,0 +1,126 @@ + + * + */ + +require_once('../../src/base.inc.php'); + +$error = ''; + +// Get the current user object. +$user = new User(); +if (isset($_GET['id']) and is_numeric($_GET['id'])) { + $user = User::getById($_GET['id']); +} + +// Save changes? +if ($_SERVER['REQUEST_METHOD'] == 'POST') { + // Name + if (isset($_POST['name']) and trim($_POST['name']) != '') { + $user->setName($_POST['name']); + + } else { + $error .= '

Name is a required field.

'; + } + + // Email + if (isset($_POST['email']) and trim($_POST['email']) != '') { + $user->setEmail($_POST['email']); + + } else { + $error .= '

Email is a required field.

'; + } + + // Source + if (isset($_POST['source']) and trim($_POST['source']) != '') { + $user->setSource($_POST['source']); + + } else { + $error .= '

Source is a required field.

'; + } + + // Set Admin + $admin = isset($_POST['admin']) and $_POST['admin'] == '1'; + $user->setAdmin($admin); + + // Set Notify + $notify = isset($_POST['notify']) and $_POST['notify'] == '1'; + $user->setNotify($notify); + + // Save the user + if ($error == '') { + if ($user->save()) { + // Return to users list + header("Location: index.php"); + + } else { + $error .= '

An error has occured.

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

Edit User

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

+

+

+

+

+ +

+ +Cancel +

+ + +
+ +"; + + foreach(Source::getSources() as $source) { + if ($source->getId() == $select) { + echo ""; + + } else { + echo ""; + } + } + + echo ""; +} + +require_once('../src/footer.inc.php'); + +?> + -- cgit v1.2.3