summaryrefslogtreecommitdiff
path: root/htdocs/moderate
diff options
context:
space:
mode:
authorJesse Morgan <jesse@jesterpm.net>2011-06-02 17:20:54 -0700
committerJesse Morgan <jesse@jesterpm.net ; true>2011-06-02 17:20:54 -0700
commit0720091ca73b9714aab2b38c3682c15a0cbd4533 (patch)
tree0d77e48eb52d3f39123659550976c5999effddff /htdocs/moderate
parent1800a1e9022a9f4316e0d57a650faed9da0e8df4 (diff)
Added pages
Diffstat (limited to 'htdocs/moderate')
-rw-r--r--htdocs/moderate/pages/delete.php49
-rw-r--r--htdocs/moderate/pages/editor.php100
-rw-r--r--htdocs/moderate/pages/index.php52
-rw-r--r--htdocs/moderate/src/header.inc.php10
4 files changed, 211 insertions, 0 deletions
diff --git a/htdocs/moderate/pages/delete.php b/htdocs/moderate/pages/delete.php
new file mode 100644
index 0000000..91ee209
--- /dev/null
+++ b/htdocs/moderate/pages/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 (!$_SESSION['currentUser']->isAdmin()) {
+ header('Location: ' . buildUrl('moderate/'));
+ exit;
+}
+
+$error = '';
+
+$page = false;
+if (isset($_GET['id']) and is_numeric($_GET['id'])) {
+ $page = Page::getById($_GET['id']);
+
+ if ($page !== false and isset($_GET['confirmed'])) {
+ $page->delete();
+
+ header('Location: index.php');
+ }
+
+}
+
+require_once('../src/header.inc.php');
+
+echo "<h3>Delete Pages</h3>";
+
+if ($page !== false) {
+ echo "<p>Are you sure you want to delete " . $page->getTitle() ."?</p>"
+ . "<p><a href=\"delete.php?id=". $page->getId() ."&confirmed\">Yes</a>"
+ . " <a href=\"index.php\">No</a></p>";
+
+} else {
+ echo "<p>No page to delete.</p>";
+}
+
+require_once('../src/footer.inc.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 @@
+<?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 (!$_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 .= '<p>Title is a required field.</p>';
+ }
+
+ // URL
+ if (isset($_POST['url']) and trim($_POST['url']) != '') {
+ $page->setURL($_POST['url']);
+
+ } else {
+ $error .= '<p>URL is a required field.</p>';
+ }
+
+ // Content
+ if (isset($_POST['content']) and trim($_POST['content']) != '') {
+ $page->setContent($_POST['content']);
+
+ } else {
+ $error .= '<p>Content is a required field.</p>';
+ }
+
+ // Save
+ if ($error == '') {
+ if ($page->save()) {
+ // Return to pages list
+ header("Location: index.php");
+
+ } else {
+ $error .= '<p>An error has occured.</p>';
+ }
+ }
+}
+
+require_once('../src/header.inc.php');
+
+echo "<h3>Edit Page</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>Title: <input type="text" name="title" value="<?= $page->getTitle() ?>" /></label></p>
+<p><label>URL: <input type="text" name="url" value="<?= $page->getURL() ?>" /></label></p>
+<p><textarea id="contentarea" name="content" rows="50" cols="120"><?= $page->getContent() ?></textarea></p>
+
+<p>
+<input type="submit" class="bigbutton" value="Save" />
+<a href="index.php" class="bigbutton">Cancel</a>
+</p>
+
+
+</form>
+
+<?php
+
+require_once('../src/footer.inc.php');
+
+?>
+
diff --git a/htdocs/moderate/pages/index.php b/htdocs/moderate/pages/index.php
new file mode 100644
index 0000000..d6ffd87
--- /dev/null
+++ b/htdocs/moderate/pages/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');
+
+// Verify User is admin
+if (!$_SESSION['currentUser']->isAdmin()) {
+ header('Location: ' . buildUrl('moderate/'));
+ exit;
+}
+
+$error = '';
+
+require_once('../src/header.inc.php');
+
+echo "<h3>Pages</h3>";
+
+echo "<p><a class=\"bigbutton\" href=\"editor.php\">Create Page</a></p>";
+
+$pi = new PageIterator();
+$pi->query();
+
+if ($pi->valid()) {
+ echo "<div class=\"userrow header\">"
+ . "<span class=\"name\">Title</span>"
+ . " <span class=\"actions\">Actions</span></div>";
+
+ foreach ($pi as $page) {
+ printf("<div class=\"userrow\">"
+ . "<span class=\"name\"><a href=\"%s.html\">%s</a></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>",
+ buildUrl('page/' . $page->getURL()), $page->getTitle(),
+ $page->getId(), $page->getId()
+ );
+ }
+
+} else {
+ echo "<p>There are no pages to edit. Click the button above to create one.</p>";
+}
+
+require_once('../src/footer.inc.php');
+
+?>
diff --git a/htdocs/moderate/src/header.inc.php b/htdocs/moderate/src/header.inc.php
index 30910ec..8ad7e0c 100644
--- a/htdocs/moderate/src/header.inc.php
+++ b/htdocs/moderate/src/header.inc.php
@@ -14,6 +14,16 @@ if (!isset($_SESSION['currentUser'])) {
<link rel="stylesheet" href="<?= $CONFIG['urlroot'] ?>/css/main.css" />
<link rel="stylesheet" href="<?= $CONFIG['urlroot'] ?>/moderate/admin.css" />
+ <script type="text/javascript" src="<?= $CONFIG['urlroot'] ?>/js/tiny_mce/tiny_mce.js" ></script>
+ <script type="text/javascript" >
+ tinyMCE.init({
+ mode : "exact",
+ elements : "contentarea",
+ theme : "advanced",
+ theme_advanced_toolbar_location : "top",
+ theme_advanced_toolbar_align : "left"
+ });
+ </script>
</head>
<body>
<div id="header">