# 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 @@
Select page title from a list: