diff options
author | Jesse Morgan <jesse@jesterpm.net> | 2011-08-30 12:29:19 -0700 |
---|---|---|
committer | Jesse Morgan <jesse@jesterpm.net> | 2017-09-04 11:16:53 -0700 |
commit | e121bbebe3ccd990b66a7b04289adf481a4aa2af (patch) | |
tree | 5955357921d66db47769cba75d950cea3894dd04 /htdocs/moderate | |
parent | 558684e32769d9dbd0d27a6feb3bbb9cf9aa22d7 (diff) |
Working on the moderation schedule iterator
Diffstat (limited to 'htdocs/moderate')
-rw-r--r-- | htdocs/moderate/schedule/delete.php | 49 | ||||
-rw-r--r-- | htdocs/moderate/schedule/editor.php | 144 | ||||
-rw-r--r-- | htdocs/moderate/schedule/index.php | 52 |
3 files changed, 245 insertions, 0 deletions
diff --git a/htdocs/moderate/schedule/delete.php b/htdocs/moderate/schedule/delete.php new file mode 100644 index 0000000..76b8866 --- /dev/null +++ b/htdocs/moderate/schedule/delete.php @@ -0,0 +1,49 @@ +<?php + +/* Foursquare Community Site + * + * Copyright (C) 2011 Foursquare Church. + * + * Developers: Jesse Morgan <jmorgan@foursquarestaff.com> + * + */ + +require_once('../../src/base.inc.php'); + +// Verify User is admin +if (!isset($_SESSION['currentUser']) or !$_SESSION['currentUser']->isAdmin()) { + header('Location: ' . buildUrl('moderate/')); + exit; +} + +$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 "<h3>Delete Users</h3>"; + +if ($user !== false) { + echo "<p>Are you sure you want to delete " . $user->getName() ."?</p>" + . "<p><a href=\"delete.php?id=". $user->getId() ."&confirmed\">Yes</a>" + . " <a href=\"index.php\">No</a></p>"; + +} else { + echo "<p>No user to delete.</p>"; +} + +require_once('../src/footer.inc.php'); + +?> + diff --git a/htdocs/moderate/schedule/editor.php b/htdocs/moderate/schedule/editor.php new file mode 100644 index 0000000..fe715f7 --- /dev/null +++ b/htdocs/moderate/schedule/editor.php @@ -0,0 +1,144 @@ +<?php + +/* Foursquare Community Site + * + * Copyright (C) 2011 Foursquare Church. + * + * Developers: Jesse Morgan <jmorgan@foursquarestaff.com> + * + */ + +require_once('../../src/base.inc.php'); + +// Verify User is admin +if (!isset($_SESSION['currentUser']) or !$_SESSION['currentUser']->isAdmin()) { + header('Location: ' . buildUrl('moderate/')); + exit; +} + +$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 .= '<p>Name is a required field.</p>'; + } + + // Email + if (isset($_POST['email']) and trim($_POST['email']) != '') { + $user->setEmail($_POST['email']); + + } else { + $error .= '<p>Email is a required field.</p>'; + } + + // Source + if (isset($_POST['source']) and trim($_POST['source']) != '') { + $user->setSource($_POST['source']); + + } else { + $error .= '<p>Source is a required field.</p>'; + } + + // 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); + + // Send new password + if (isset($_POST['newpass']) and $_POST['newpass'] == '1') { + $user->sendNewPassword(); + } + + // Save the user + if ($error == '') { + if ($user->save()) { + // Return to users list + header("Location: index.php"); + + } else { + $error .= '<p>An error has occured.</p>'; + } + } +} + +require_once('../src/header.inc.php'); + +echo "<h3>Edit User</h3>"; + +if ($error != '') { + echo "<div class=\"errorbox\">$error</div>"; +} + +$url = "editor.php"; + +if (isset($_GET['id'])) { + $url .= '?id=' . $_GET['id']; +} + +echo "<form action=\"$url\" method=\"post\">"; + +?> + +<p><label>Name: <input type="text" name="name" value="<?= $user->getName() ?>" /></label></p> +<p><label>Email: <input type="text" name="email" value="<?= $user->getEmail() ?>" /></label></p> +<p><label>Source: <?php sourceDropdown('source', $user->getSource()) ?></label></p> +<p><label> +<input type="checkbox" name="admin" value="1" <?= $user->isAdmin() ? 'checked="checked"' : '' ?> /> +Administrator</label></p> +<p><label> +<input type="checkbox" name="notify" value="1" <?= $user->getNotify() ? 'checked="checked"' : '' ?> /> +Notify of posts</label></p> + +<?php + if (isset($_GET['id'])) { + echo "<p><label><input type=\"checkbox\" name=\"newpass\" value=\"1\" />" + . "Send new password</label></p>"; + } +?> + +<p> +<input type="submit" class="bigbutton" value="Save" /> +<a href="index.php" class="bigbutton">Cancel</a> +</p> + + +</form> + +<?php + +function sourceDropdown($name, $select) { + echo "<select name=\"$name\">"; + + foreach(Source::getSources() as $source) { + if ($source->getId() == $select) { + echo "<option value=\"". $source->getId() + ."\" selected=\"selected\">" + . $source->getName() ."</option>"; + + } else { + echo "<option value=\"". $source->getId() ."\">" + . $source->getName() ."</option>"; + } + } + + echo "</select>"; +} + +require_once('../src/footer.inc.php'); + +?> + diff --git a/htdocs/moderate/schedule/index.php b/htdocs/moderate/schedule/index.php new file mode 100644 index 0000000..93dfc3a --- /dev/null +++ b/htdocs/moderate/schedule/index.php @@ -0,0 +1,52 @@ +<?php + +/* Foursquare Community Site + * + * Copyright (C) 2011 Foursquare Church. + * + * Developers: Jesse Morgan <jmorgan@foursquarestaff.com> + * + */ + +require_once('../../src/base.inc.php'); + + +require_once('../src/header.inc.php'); + +echo "<h3>Moderation Schedule</h3>"; + +// List out moderators in order with next moderation week + + +echo "<h3>Exceptions</h3>"; +echo "<p><a href=\"exception.php\">New Exception</a></p>"; + +// List out exceptions in order. + +$ui = new UserIterator(); +$ui->query(); + +echo "<div class=\"userrow header\">" + . "<span class=\"name\">Name</span>" + . " <span class=\"email\">Email</span>" + . " <span class=\"admin\">Admin</span>" + . " <span class=\"actions\">Actions</span></div>"; + +foreach ($ui as $user) { + printf("<div class=\"userrow\">" + . "<span class=\"name\">%s</span>" + . " <span class=\"email\"><a href=\"mailto:%s\">%s</a></span>" + . " <span class=\"admin\">%s</span>" + . " <span class=\"actions\">" + . " <a class=\"smallbutton\" href=\"editor.php?id=%s\">edit</a>" + . " <a class=\"smallbutton\" href=\"delete.php?id=%s\">delete</a></span></div>", + $user->getName(), + $user->getEmail(), $user->getEmail(), + $user->isAdmin() ? 'Yes' : 'No', + $user->getId(), $user->getId() + ); +} + +require_once('../src/footer.inc.php'); + +?> |