# HG changeset patch # User Dan # Date 1185055930 14400 # Node ID 0a74676a2f2f31f02483a1407c84abe37e8ff54c # Parent bda11e521e8adc8db75b2cdebafa2d659298ae0e Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too diff -r bda11e521e8a -r 0a74676a2f2f ajax.php --- a/ajax.php Sat Jul 21 11:28:59 2007 -0400 +++ b/ajax.php Sat Jul 21 18:12:10 2007 -0400 @@ -1,7 +1,8 @@ enable_errorhandler(); if(!$this->_conn) return false; diff -r bda11e521e8a -r 0a74676a2f2f includes/email.php --- a/includes/email.php Sat Jul 21 11:28:59 2007 -0400 +++ b/includes/email.php Sat Jul 21 18:12:10 2007 -0400 @@ -2,7 +2,7 @@ /* * 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 diff -r bda11e521e8a -r 0a74676a2f2f includes/functions.php --- a/includes/functions.php Sat Jul 21 11:28:59 2007 -0400 +++ b/includes/functions.php Sat Jul 21 18:12:10 2007 -0400 @@ -2,7 +2,7 @@ /* * 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 diff -r bda11e521e8a -r 0a74676a2f2f includes/graphs.php --- a/includes/graphs.php Sat Jul 21 11:28:59 2007 -0400 +++ b/includes/graphs.php Sat Jul 21 18:12:10 2007 -0400 @@ -2,7 +2,7 @@ /* * 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 diff -r bda11e521e8a -r 0a74676a2f2f includes/js-compressor.php --- a/includes/js-compressor.php Sat Jul 21 11:28:59 2007 -0400 +++ b/includes/js-compressor.php Sat Jul 21 18:12:10 2007 -0400 @@ -2,7 +2,7 @@ /* * 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 * Javascript compression library - used to compact the client-side Javascript code (all 72KB of it!) to save some bandwidth * diff -r bda11e521e8a -r 0a74676a2f2f includes/pageprocess.php --- a/includes/pageprocess.php Sat Jul 21 11:28:59 2007 -0400 +++ b/includes/pageprocess.php Sat Jul 21 18:12:10 2007 -0400 @@ -1,7 +1,8 @@ free_result(); + $return['page_groups'] = Array(); + $q = $db->sql_query('SELECT pg_id,pg_name FROM '.table_prefix.'page_groups ORDER BY pg_name ASC;'); + if ( !$q ) + return Array( + 'mode' => 'error', + 'error' => $db->get_error() + ); + while ( $row = $db->fetchrow() ) + { + $return['page_groups'][] = Array( + 'id' => $row['pg_id'], + 'name' => $row['pg_name'] + ); + } break; case 'seltarget': $return['mode'] = 'seltarget'; @@ -1739,7 +1753,7 @@ } $db->free_result(); // Eliminate types that don't apply to this namespace - if ( $namespace ) + if ( $namespace && $namespace != '__PageGroup' ) { foreach ( $return['current_perms'] AS $i => $perm ) { @@ -1786,7 +1800,7 @@ } $db->free_result(); // Eliminate types that don't apply to this namespace - if ( $namespace ) + if ( $namespace && $namespace != '__PageGroup' ) { foreach ( $return['current_perms'] AS $i => $perm ) { diff -r bda11e521e8a -r 0a74676a2f2f includes/paths.php --- a/includes/paths.php Sat Jul 21 11:28:59 2007 -0400 +++ b/includes/paths.php Sat Jul 21 18:12:10 2007 -0400 @@ -2,7 +2,7 @@ /** * 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 * paths.php - The part of Enano that actually manages content. Everything related to page handling and namespaces is in here. * @@ -81,6 +81,7 @@ $this->addAdminNode('General', 'Backup database', 'DBBackup'); $this->addAdminNode('Content', 'Manage Pages', 'PageManager'); $this->addAdminNode('Content', 'Edit page content', 'PageEditor'); + $this->addAdminNode('Content', 'Manage page groups', 'PageGroups'); $this->addAdminNode('Appearance', 'Manage themes', 'ThemeManager'); $this->addAdminNode('Users', 'Manage users', 'UserManager'); $this->addAdminNode('Users', 'Edit groups', 'GroupManager'); @@ -822,6 +823,57 @@ return $search; } + /** + * Returns a list of groups that a given page is a member of. + * @param string Page ID + * @param string Namespace + * @return array + */ + + function get_page_groups($page_id, $namespace) + { + global $db, $session, $paths, $template, $plugins; // Common objects + + $page_id = $db->escape(sanitize_page_id($page_id)); + if ( !isset($this->nslist[$namespace]) ) + die('$paths->get_page_groups(): HACKING ATTEMPT'); + + $group_list = array(); + + // What linked categories have this page? + $q = $db->sql_query('SELECT g.pg_id FROM '.table_prefix.'page_groups AS g + LEFT JOIN '.table_prefix.'categories AS c + ON ( c.category_id = g.pg_target AND g.pg_type = ' . PAGE_GRP_CATLINK . ' ) + WHERE c.page_id=\'' . $page_id . '\' AND c.namespace=\'' . $namespace . '\';'); + if ( !$q ) + $db->_die(); + + while ( $row = $db->fetchrow() ) + { + $group_list[] = $row['pg_id']; + } + + // Static-page groups + $q = $db->sql_query('SELECT g.pg_id FROM '.table_prefix.'page_groups AS g + LEFT JOIN '.table_prefix.'page_group_members AS m + ON ( g.pg_id = m.pg_id ) + WHERE m.page_id=\'' . $page_id . '\' AND m.namespace=\'' . $namespace . '\' + GROUP BY g.pg_id;'); + + if ( !$q ) + $db->_die(); + + while ( $row = $db->fetchrow() ) + { + $group_list[] = $row['pg_id']; + } + + // Tagging ain't implemented yet ;-) + + return $group_list; + + } + } ?> diff -r bda11e521e8a -r 0a74676a2f2f includes/plugins.php --- a/includes/plugins.php Sat Jul 21 11:28:59 2007 -0400 +++ b/includes/plugins.php Sat Jul 21 18:12:10 2007 -0400 @@ -2,7 +2,7 @@ /* * 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 diff -r bda11e521e8a -r 0a74676a2f2f includes/render.php --- a/includes/render.php Sat Jul 21 11:28:59 2007 -0400 +++ b/includes/render.php Sat Jul 21 18:12:10 2007 -0400 @@ -1,9 +1,10 @@ get_page_groups($paths->cpage['urlname_nons'], $paths->namespace); + $pg_info = ''; + foreach ( $pg_list as $g_id ) + { + $pg_info .= ' ( page_id=\'' . $g_id . '\' AND namespace=\'__PageGroup\' ) OR'; + } + // Build a query to grab ACL info $bs = 'SELECT rules,target_type,target_id FROM '.table_prefix.'acl WHERE ( '; $q = Array(); @@ -2077,7 +2085,7 @@ } // The reason we're using an ORDER BY statement here is because ACL_TYPE_GROUP is less than ACL_TYPE_USER, causing the user's individual // permissions to override group permissions. - $bs .= implode(' OR ', $q) . ' ) AND ( page_id=\''.$db->escape($paths->cpage['urlname_nons']).'\' AND namespace=\''.$db->escape($paths->namespace).'\' ) + $bs .= implode(' OR ', $q) . ' ) AND (' . $pg_info . ' ( page_id=\''.$db->escape($paths->cpage['urlname_nons']).'\' AND namespace=\''.$db->escape($paths->namespace).'\' ) ) ORDER BY target_type ASC, page_id ASC, namespace ASC;'; $q = $this->sql($bs); if ( $row = $db->fetchrow() ) @@ -2489,6 +2497,14 @@ $this->perms = $acl_types; $this->perms = $session->acl_merge_complete($this->perms, $base); + // PAGE group info + $pg_list = $paths->get_page_groups($page_id, $namespace); + $pg_info = ''; + foreach ( $pg_list as $g_id ) + { + $pg_info .= ' ( page_id=\'' . $g_id . '\' AND namespace=\'__PageGroup\' ) OR'; + } + // Build a query to grab ACL info $bs = 'SELECT rules FROM '.table_prefix.'acl WHERE ( '; $q = Array(); @@ -2502,7 +2518,7 @@ } // The reason we're using an ORDER BY statement here is because ACL_TYPE_GROUP is less than ACL_TYPE_USER, causing the user's individual // permissions to override group permissions. - $bs .= implode(' OR ', $q) . ' ) AND ( page_id=\''.$db->escape($page_id).'\' AND namespace=\''.$db->escape($namespace).'\' ) + $bs .= implode(' OR ', $q) . ' ) AND (' . $pg_info . ' page_id=\''.$db->escape($page_id).'\' AND namespace=\''.$db->escape($namespace).'\' ) ORDER BY target_type ASC, page_id ASC, namespace ASC;'; $q = $session->sql($bs); if ( $row = $db->fetchrow() ) diff -r bda11e521e8a -r 0a74676a2f2f includes/stats.php --- a/includes/stats.php Sat Jul 21 11:28:59 2007 -0400 +++ b/includes/stats.php Sat Jul 21 18:12:10 2007 -0400 @@ -1,7 +1,7 @@

Welcome to Enano

version 1.0 – stable
- also affectionately known as "banshee" :)

+ also affectionately known as "loch ness" :) Search for page title (remember prefixes like User: and File:) pagename_field('page_url'); ?>

Select page title from a list: '; + while ( $row = $db->fetchrow() ) + { + $catlist .= ''; + } + $catlist .= ''; + } + + echo '

'; + + echo '
+ + + + '; + + // Name + echo ' + + + '; + + // Group type + echo ' + + + '; + + // Titles + echo ' + + '; + + echo ' + '; + + echo ' + '; + + // Submit button + echo ' + + '; + + echo '
Create page group
+ Group name:
+ This should be short, descriptive, and human-readable. +
+ +
+ Group type: + + +
+ + Static group of pages + + + Group of commonly tagged pages + + + Mirror a category + +
+
+ Member pages:
+ Click the "plus" button to add more fields. +
+ +
+ Include pages with this tag: +
+
+
+
+
+
+
+
+ +
+
+ +
+ +
+
'; + + 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 '
'; + echo ''; + echo '
'; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo '
Confirm deletion
Are you sure you want to delete this page group?
'; + echo ' '; + echo ' '; + echo '
'; + echo ''; + + return; + } + } + else if ( isset($_POST['action']['del_confirm']) ) + { + $delete_id = intval($_POST['delete_id']); + if ( empty($delete_id) ) + { + echo 'Hack attempt'; + return; + } + // Obtain group name + $q = $db->sql_query('SELECT pg_name FROM '.table_prefix.'page_groups WHERE pg_id=' . $delete_id . ';'); + if ( !$q ) + $db->_die(); + if ( $db->numrows() < 1 ) + { + echo 'Page group dun exist.'; + return; + } + $row = $db->fetchrow(); + $pg_name = $row['pg_name']; + unset($row); + // Delete the group + $q = $db->sql_query('DELETE FROM '.table_prefix.'page_groups WHERE pg_id=' . $delete_id . ';'); + if ( !$q ) + $db->_die(); + $q = $db->sql_query('DELETE FROM '.table_prefix.'page_group_members WHERE pg_id=' . $delete_id . ';'); + if ( !$q ) + $db->_die(); + echo "
The group ".'"'."$pg_name".'"'." has been deleted.
"; + } + else if ( isset($_POST['action']['edit']) ) + { + return; + } + else if ( isset($_POST['action']['noop']) ) + { + // Do nothing + } + else + { + echo '
Invalid format of $_POST[action].
'; + } + } + // No action defined - show default menu + $q = $db->sql_query('SELECT pg_id, pg_type, pg_name, pg_target FROM '.table_prefix.'page_groups;'); + if ( !$q ) + $db->_die(); + + echo '
'; + + echo '
+ + + + + + + '; + + if ( $row = $db->fetchrow() ) + { + do + { + $name = htmlspecialchars($row['pg_name']); + $type = 'Invalid'; + switch ( $row['pg_type'] ) + { + case PAGE_GRP_CATLINK: + $type = 'Link to category'; + break; + case PAGE_GRP_TAGGED: + $type = 'Set of tagged pages'; + break; + case PAGE_GRP_NORMAL: + $type = 'Static set of pages'; + break; + } + $target = ''; + if ( $row['pg_type'] == PAGE_GRP_TAGGED ) + { + $target = 'Tag: ' . htmlspecialchars($row['pg_target']); + } + else if ( $row['pg_type'] == PAGE_GRP_CATLINK ) + { + $target = 'Category: ' . htmlspecialchars(get_page_title($paths->nslist['Category'] . sanitize_page_id($row['pg_target']))); + } + $btn_edit = ''; + $btn_del = ''; + // stupid jEdit bug/hack + $quot = '"'; + echo " + + + + + + "; + } + while ( $row = $db->fetchrow() ); + } + else + { + echo ' '; + } + + echo ' + + '; + + echo '
Group nameTypeTargetActions
$name$type$target$btn_edit$btn_del
No page groups defined.
+ +
+
'; + + echo '
'; + +} + function page_Admin_ThemeManager() { diff -r bda11e521e8a -r 0a74676a2f2f plugins/SpecialPageFuncs.php --- a/plugins/SpecialPageFuncs.php Sat Jul 21 11:28:59 2007 -0400 +++ b/plugins/SpecialPageFuncs.php Sat Jul 21 18:12:10 2007 -0400 @@ -357,7 +357,7 @@ if(file_exists(ENANO_ROOT.'/GPL')) { echo '

The following text represents the license that the Enano content management system is under. To make it easier to read, the text has been wiki-formatted; in no other way has it been changed.

'; - echo RenderMan::render( htmlspecialchars ( file_get_contents ( ENANO_ROOT . '/GPL' ) ) ); + echo RenderMan::render( file_get_contents ( ENANO_ROOT . '/GPL' ) ); } else { diff -r bda11e521e8a -r 0a74676a2f2f schema.sql --- a/schema.sql Sat Jul 21 11:28:59 2007 -0400 +++ b/schema.sql Sat Jul 21 18:12:10 2007 -0400 @@ -223,6 +223,26 @@ PRIMARY KEY ( search_id ) ) CHARACTER SET `utf8` COLLATE `utf8_bin`; +-- Added in 1.0.1 + +CREATE TABLE {{TABLE_PREFIX}}page_groups( + pg_id mediumint(8) NOT NULL auto_increment, + pg_type tinyint(2) NOT NULL DEFAULT 1, + pg_name varchar(255) NOT NULL DEFAULT '', + pg_target varchar(255) DEFAULT NULL, + PRIMARY KEY ( pg_id ) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + +-- Added in 1.0.1 + +CREATE TABLE {{TABLE_PREFIX}}page_group_members( + pg_member_id int(12) NOT NULL auto_increment, + pg_id mediumint(8) NOT NULL, + page_id varchar(63) NOT NULL, + namespace varchar(63) NOT NULL DEFAULT 'Article', + PRIMARY KEY ( pg_member_id ) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + INSERT INTO {{TABLE_PREFIX}}config(config_name, config_value) VALUES ('site_name', '{{SITE_NAME}}'), ('main_page', 'Main_Page'), diff -r bda11e521e8a -r 0a74676a2f2f upgrade.php --- a/upgrade.php Sat Jul 21 11:28:59 2007 -0400 +++ b/upgrade.php Sat Jul 21 18:12:10 2007 -0400 @@ -2,7 +2,7 @@ /* * 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) * upgrade.php - upgrade script * Copyright (C) 2006-2007 Dan Fuhry * @@ -61,7 +61,7 @@ // Everything related to versions goes here! // Valid versions to upgrade from -$valid_versions = Array('1.0b1', '1.0b2', '1.0b3', '1.0b4', '1.0RC1', '1.0RC2', '1.0RC3'); +$valid_versions = Array('1.0b1', '1.0b2', '1.0b3', '1.0b4', '1.0RC1', '1.0RC2', '1.0RC3', '1.0'); // Basically a list of dependencies, which should be resolved automatically // If, for example, upgrading from 1.0b1 to 1.0RC1 requires one extra query that would not @@ -72,9 +72,10 @@ '1.0b3' => Array('1.0b4'), '1.0b4' => Array('1.0RC1'), '1.0RC1' => Array('1.0RC2'), - '1.0RC2' => Array('1.0RC3') + '1.0RC2' => Array('1.0RC3'), + '1.0RC3' => Array('1.0') ); -$this_version = '1.0'; +$this_version = '1.0.1'; $func_list = Array( '1.0b4' => Array('u_1_0_RC1_update_user_ids', 'u_1_0_RC1_add_admins_to_group', 'u_1_0_RC1_alter_files_table', 'u_1_0_RC1_destroy_session_cookie', 'u_1_0_RC1_set_contact_email', 'u_1_0_RC1_update_page_text'), // , // '1.0RC2' => Array('u_1_0_populate_userpage_comments') diff -r bda11e521e8a -r 0a74676a2f2f upgrade.sql --- a/upgrade.sql Sat Jul 21 11:28:59 2007 -0400 +++ b/upgrade.sql Sat Jul 21 18:12:10 2007 -0400 @@ -3,7 +3,11 @@ -- ALL NON-SQL LINES, even otherwise blank lines, must start with "--" or they will get sent to MySQL! -- Common tasks (version numbers) DELETE FROM {{TABLE_PREFIX}}config WHERE config_name='enano_version' OR config_name='enano_beta_version' OR config_name='enano_alpha_version' OR config_name='enano_rc_version'; -INSERT INTO {{TABLE_PREFIX}}config (config_name, config_value) VALUES( 'enano_version', '1.0' ); +INSERT INTO {{TABLE_PREFIX}}config (config_name, config_value) VALUES( 'enano_version', '1.0.1' ); +---BEGIN 1.0--- +CREATE TABLE {{TABLE_PREFIX}}page_groups( pg_id mediumint(8) NOT NULL auto_increment, pg_type tinyint(2) NOT NULL DEFAULT 1, pg_name varchar(255) NOT NULL DEFAULT '', pg_target varchar(255) DEFAULT NULL, PRIMARY KEY ( pg_id ) ) CHARACTER SET `utf8` COLLATE `utf8_bin`; +CREATE TABLE {{TABLE_PREFIX}}page_group_members( pg_member_id int(12) NOT NULL auto_increment, pg_id mediumint(8) NOT NULL, page_id varchar(63) NOT NULL, namespace varchar(63) NOT NULL DEFAULT 'Article', PRIMARY KEY ( pg_member_id ) ) CHARACTER SET `utf8` COLLATE `utf8_bin`; +---END 1.0--- ---BEGIN 1.0RC3--- ALTER TABLE {{TABLE_PREFIX}}users ADD COLUMN user_coppa tinyint(1) NOT NULL DEFAULT 0; UPDATE {{TABLE_PREFIX}}sidebar SET block_content='[[$NS_SPECIAL$CreatePage|Create a page]]\n[[$NS_SPECIAL$UploadFile|Upload file]]\n[[$NS_SPECIAL$SpecialPages|Special pages]]\n{if auth_admin}\n[[$NS_SPECIAL$EditSidebar|Edit the sidebar]]\n$ADMIN_LINK$\n{/if}' WHERE item_id=2;