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/delete.php | 43 +++++++++++++ htdocs/moderate/users/editor.php | 126 +++++++++++++++++++++++++++++++++++++++ htdocs/moderate/users/index.php | 47 +++++++++++++++ 3 files changed, 216 insertions(+) create mode 100644 htdocs/moderate/users/delete.php create mode 100644 htdocs/moderate/users/editor.php create mode 100644 htdocs/moderate/users/index.php (limited to 'htdocs/moderate/users') diff --git a/htdocs/moderate/users/delete.php b/htdocs/moderate/users/delete.php new file mode 100644 index 0000000..f721f30 --- /dev/null +++ b/htdocs/moderate/users/delete.php @@ -0,0 +1,43 @@ + + * + */ + +require_once('../../src/base.inc.php'); + +$error = ''; + +$user = false; +if (isset($_GET['id']) and is_numeric($_GET['id'])) { + $user = User::getById($_GET['id']); + + if ($user !== false and isset($_GET['confirmed'])) { + $user->delete(); + + header('Location: index.php'); + } + +} + +require_once('../src/header.inc.php'); + +echo "

Delete Users

"; + +if ($user !== false) { + echo "

Are you sure you want to delete " . $user->getName() ."?

" + . "

getId() ."&confirmed\">Yes" + . " No

"; + +} else { + echo "

No user to delete.

"; +} + +require_once('../src/footer.inc.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'); + +?> + diff --git a/htdocs/moderate/users/index.php b/htdocs/moderate/users/index.php new file mode 100644 index 0000000..cda6232 --- /dev/null +++ b/htdocs/moderate/users/index.php @@ -0,0 +1,47 @@ + + * + */ + +require_once('../../src/base.inc.php'); + +$error = ''; + +require_once('../src/header.inc.php'); + +echo "

Users

"; + +echo "

Create User

"; + +$ui = new UserIterator(); +$ui->query(); + +echo "
" + . "Name" + . " Email" + . " Admin" + . " Actions
"; + +foreach ($ui as $user) { + printf("
" + . "%s" + . " %s" + . " %s" + . " " + . " edit" + . " delete
", + $user->getName(), + $user->getEmail(), $user->getEmail(), + $user->isAdmin() ? 'Yes' : 'No', + $user->getId(), $user->getId() + ); +} + +require_once('../src/footer.inc.php'); + +?> -- cgit v1.2.3