diff -r bda11e521e8a -r 0a74676a2f2f plugins/SpecialAdmin.php
--- a/plugins/SpecialAdmin.php Sat Jul 21 11:28:59 2007 -0400
+++ b/plugins/SpecialAdmin.php Sat Jul 21 18:12:10 2007 -0400
@@ -4,13 +4,13 @@
Plugin URI: http://enanocms.org/
Description: Provides the page Special:Administration, which is the AJAX frontend to the various Admin:
Author: Dan Fuhry
-Version: 1.0
+Version: 1.0.1
Author URI: http://enanocms.org/
*/
/*
* Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between
- * Version 1.0 (Banshee)
+ * Version 1.0.1 (Loch Ness)
* Copyright (C) 2006-2007 Dan Fuhry
*
* This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License
@@ -1699,7 +1699,7 @@
Search for page title (remember prefixes like User: and File:) pagename_field('page_url'); ?>
Select page title from a list:
pages)/2;$i++)
+ for ( $i = 0; $i < sizeof($paths->pages) / 2; $i++ )
{
if($paths->pages[$i]['namespace'] != 'Admin' && $paths->pages[$i]['namespace'] != 'Special') echo ''.$paths->nslist[$paths->pages[$i]['namespace']].$paths->pages[$i]['name'].' '."\n";
}
@@ -1710,6 +1710,487 @@
}
}
+function page_Admin_PageGroups()
+{
+ global $db, $session, $paths, $template, $plugins; // Common objects
+ if ( $session->auth_level < USER_LEVEL_ADMIN || $session->user_level < USER_LEVEL_ADMIN )
+ {
+ echo 'Error: Not authenticated It looks like your administration session is invalid or you are not authorized to access this administration page. Please re-authenticate to continue.
';
+ return;
+ }
+
+ if ( isset($_POST['action']) )
+ {
+ if ( isset($_POST['action']['create']) || isset($_POST['action']['create_stage2']) )
+ {
+ switch ( isset($_POST['action']['create_stage2']) )
+ {
+ case true:
+ if ( empty($_POST['pg_name']) || empty($_POST['group_type']) )
+ {
+ echo 'Please enter a name for the page group.
';
+ return;
+ }
+ if ( $_POST['group_type'] == PAGE_GRP_TAGGED && empty($_POST['member_tag']) )
+ {
+ echo 'Please enter a page tag.
';
+ return;
+ }
+ if ( $_POST['group_type'] == PAGE_GRP_CATLINK && empty($_POST['member_cat']) )
+ {
+ echo 'Please create a category page before linking a page group to a category.
';
+ return;
+ }
+ if ( $_POST['group_type'] == PAGE_GRP_NORMAL && empty($_POST['member_page_0']) )
+ {
+ echo 'Please specify at least one page to place in this group.
';
+ return;
+ }
+ if ( $_POST['group_type'] != PAGE_GRP_TAGGED && $_POST['group_type'] != PAGE_GRP_CATLINK && $_POST['group_type'] != PAGE_GRP_NORMAL )
+ {
+ echo 'Umm, you sent an invalid group type. I\'d put a real error message here but this will only be shown if you try to hack the system.
';
+ return;
+ }
+ // All checks passed, create the group
+ switch($_POST['group_type'])
+ {
+ case PAGE_GRP_TAGGED:
+ $name = $db->escape($_POST['pg_name']);
+ $tag = $db->escape($_POST['member_tag']);
+ $sql = 'INSERT INTO '.table_prefix.'page_groups(pg_type,pg_name,pg_target) VALUES(' . PAGE_GRP_TAGGED . ', \'' . $name . '\', \'' . $tag . '\');';
+ $q = $db->sql_query($sql);
+ if ( !$q )
+ $db->_die();
+ break;
+ case PAGE_GRP_CATLINK:
+ $name = $db->escape($_POST['pg_name']);
+ $cat = $db->escape($_POST['member_cat']);
+ $sql = 'INSERT INTO '.table_prefix.'page_groups(pg_type,pg_name,pg_target) VALUES(' . PAGE_GRP_CATLINK . ', \'' . $name . '\', \'' . $cat . '\');';
+ $q = $db->sql_query($sql);
+ if ( !$q )
+ $db->_die();
+ break;
+ case PAGE_GRP_NORMAL:
+ $name = $db->escape($_POST['pg_name']);
+ $sql = 'INSERT INTO '.table_prefix.'page_groups(pg_type,pg_name) VALUES(' . PAGE_GRP_NORMAL . ', \'' . $name . '\');';
+ $q = $db->sql_query($sql);
+ if ( !$q )
+ $db->_die();
+
+ $ins_id = $db->insert_id();
+
+ // Page list
+ $keys = array_keys($_POST);
+ $arr_pages = array();
+ foreach ( $keys as $val )
+ {
+ if ( preg_match('/^member_page_([0-9]+?)$/', $val) && !empty($_POST[$val]) )
+ {
+ $arr_pages[] = $_POST[$val];
+ }
+ }
+ $arr_sql = array();
+ foreach ( $arr_pages as $page )
+ {
+ list($id, $ns) = RenderMan::strToPageID($page);
+ $id = sanitize_page_id($id);
+ $arr_sql[] = '(' . $ins_id . ',\'' . $db->escape($id) . '\', \'' . $ns . '\')';
+ }
+ $sql = 'INSERT INTO '.table_prefix.'page_group_members(pg_id,page_id,namespace) VALUES' . implode(',', $arr_sql) . ';';
+ $q = $db->sql_query($sql);
+ if ( !$q )
+ $db->_die();
+ break;
+ }
+ echo 'The page group "' . htmlspecialchars($_POST['pg_name']) . '" has been created.
';
+ break;
+ }
+ // A little Javascript magic
+ ?>
+
+ sql_query('SELECT name,urlname FROM '.table_prefix.'pages WHERE namespace=\'Category\';');
+ if ( !$q )
+ $db->_die();
+
+ if ( $db->numrows() < 1 )
+ {
+ $catlist = 'There aren\'t any categories on this site.';
+ }
+ else
+ {
+ $catlist = '';
+ while ( $row = $db->fetchrow() )
+ {
+ $catlist .= '' . htmlspecialchars($row['name']) . ' ';
+ }
+ $catlist .= ' ';
+ }
+
+ echo '';
+ return;
+ }
+ else if ( isset($_POST['action']['del']) )
+ {
+ // Confirmation to delete a group (this is really only a stub)
+
+ $delete_id = array_keys($_POST['action']['del']);
+ $delete_id = intval($delete_id[0]);
+
+ if ( !empty($delete_id) )
+ {
+ echo '