Skip to content
Permalink
Browse files

Dumping support for UserManagement plugin

The UserManagement plugin is now quite old, un-maintained and has many
issues. This commit completely removes support for it.
A new User Management plugin is in the works (also by me) and support
for it will be added instead.
Part of #116
  • Loading branch information...
johnstray committed Jan 30, 2017
1 parent 098f451 commit 692f7ea4a026cb49fb602b1c3514bdb94187acea
Showing with 10 additions and 116 deletions.
  1. +10 −11 gs-blog/inc/adminFunctions.php
  2. +0 −105 gs-blog/inc/common.php
@@ -16,14 +16,13 @@
function blog_admin_controller() {
$Blog = new Blog;
getBlogUserPermissions();
GLOBAL $blogUserPermissions, $SITEURL;
GLOBAL $SITEURL;
if(isset($_GET['edit_post']) && $blogUserPermissions['blogeditpost'] == true) {
if(isset($_GET['edit_post'])) {
editPost($_GET['edit_post']);
} elseif(isset($_GET['create_post']) && $blogUserPermissions['blogcreatepost'] == true) {
} elseif(isset($_GET['create_post'])) {
editPost();
} elseif(isset($_GET['categories']) && $blogUserPermissions['blogcategories'] == true) {
} elseif(isset($_GET['categories'])) {
if(isset($_GET['edit_category'])) {
$add_category = $Blog->saveCategory($_POST['new_category']);
if($add_category == true) {
@@ -38,7 +37,7 @@ function blog_admin_controller() {
#edit_categories
$category_file = getXML(BLOGCATEGORYFILE);
require_once('html/category-management.php');
} elseif(isset($_GET['auto_importer']) && $blogUserPermissions['blogrssimporter'] == true) {
} elseif(isset($_GET['auto_importer'])) {
if(isset($_POST['post-rss'])) {
$post_data = array();
$post_data['name'] = $_POST['post-rss'];
@@ -60,13 +59,13 @@ function blog_admin_controller() {
#edit_rss
$rss_file = getXML(BLOGRSSFILE);
require_once('html/feed-management.php');
} elseif(isset($_GET['settings']) && $blogUserPermissions['blogsettings'] == true) {
} elseif(isset($_GET['settings'])) {
show_settings_admin();
} elseif(isset($_GET['update']) && $blogUserPermissions['blogsettings'] == true) {
} elseif(isset($_GET['update'])) {
show_update_admin();
} elseif(isset($_GET['help']) && $blogUserPermissions['bloghelp'] == true) {
} elseif(isset($_GET['help'])) {
require_once('html/help-admin.php');
} elseif(isset($_GET['custom_fields']) && $blogUserPermissions['blogcustomfields'] == true) {
} elseif(isset($_GET['custom_fields'])) {
$CustomFields = new customFields;
if(isset($_POST['save_custom_fields'])) {
$saveCustomFields = $CustomFields->saveCustomFields();
@@ -99,7 +98,7 @@ function blog_admin_controller() {
} else {
if(isset($_GET['save_post'])) {
savePost();
} elseif(isset($_GET['delete_post']) && $blogUserPermissions['blogdeletepost'] == true) {
} elseif(isset($_GET['delete_post'])) {
$post_id = urldecode($_GET['delete_post']);
$delete_post = $Blog->deletePost($post_id);
if($delete_post == true) {
@@ -65,8 +65,6 @@ function add_filter(){}
add_action('index-pretemplate', 'blog_display_posts'); // Displays posts on front end
add_action('theme-header', 'includeRssFeed'); // Add RSS link to site header
add_action('index-pretemplate', 'set_post_description'); // Place excerpt into meta description
add_action('common', 'checkPermissions'); // Check what permission the user has
add_action('common', 'reorderUserManagement'); // Reorder the User Management Plugin
/**-------------------------------------------------------------------------------------------------
* formatPostDate($date)
@@ -95,106 +93,3 @@ function includeRssFeed() {
rel="alternate" type="application/rss+xml" title="'.$blogTitle.'">'; // Echo out the <link>
}
/**-------------------------------------------------------------------------------------------------
* checkPermissions()
* Checks what permissions are set (if any) or sets them to allow all if none are found
*
* @return bool (bool)
* @return $blogUserPermissions (array) - Array of Allow/Deny permissions
*/
function checkPermissions() {
# If possible, let the core know what permissions can be set here
if(function_exists('add_mu_permission')) {
add_mu_permission('blogsettings', 'Blog Settings');
add_mu_permission('blogeditpost', 'Blog Edit Post');
add_mu_permission('blogcreatepost', 'Blog Create Post');
add_mu_permission('blogrssimporter', 'Blog RSS Importer');
add_mu_permission('blogcategories', 'Blog Categories');
add_mu_permission('bloghelp', 'Blog Help');
add_mu_permission('blogcustomfields', 'Blog Custom Fields');
add_mu_permission('blogdeletepost', 'Blog Delete Post');
}
# Creates check_user_permission function that returns Allow All if the core function is not available
if(!function_exists('check_user_permission')) {
function check_user_permission() {
return true;
}
}
# If unable to get a users permission, set them to allow all.
if(!function_exists('check_user_permissions')) {
function check_user_permissions() {
$blogUserPermissions = array();
$blogUserPermissions['blogsettings'] = true;
$blogUserPermissions['blogeditpost'] = true;
$blogUserPermissions['blogcreatepost'] = true;
$blogUserPermissions['blogcategories'] = true;
$blogUserPermissions['blogrssimporter'] = true;
$blogUserPermissions['bloghelp'] = true;
$blogUserPermissions['blogcustomfields'] = true;
$blogUserPermissions['blogdeletepost'] = true;
return $blogUserPermissions;
}
}
}
/**-------------------------------------------------------------------------------------------------
* getBlogUserPermissions()
* Gets permissions for areas of admin panel for blog plugin.
* These are defined using the Multi User Plugin
*
* @return void (void)
*/
function getBlogUserPermissions() {
global $blogUserPermissions;
$current_user = get_cookie('GS_ADMIN_USERNAME');
$blogUserPermissions = check_user_permissions($current_user);
}
/**-------------------------------------------------------------------------------------------------
* reorderUserManagement()
* Tries to reorder the loading of the MultiUser plugin so that it loads first allowing it's
* functions to work as expected.
*
* @return void (void)
*/
function reorderUserManagement() {
GLOBAL $live_plugins;
if (file_exists(GSPLUGINPATH)){
$pluginfiles = getFiles(GSPLUGINPATH);
}
$phpfiles = array();
foreach ($pluginfiles as $fi) {
if (lowercase(pathinfo($fi, PATHINFO_EXTENSION))=='php') {
$phpfiles[] = $fi;
}
}
if($phpfiles[0] !== 'user-managment.php') { # Only reorder if user-managment is not first
if(($key = array_search('user-managment.php', $phpfiles)) !== false) {
unset($phpfiles[$key]);
}
$temp = array('user-managment.php');
$phpfiles = $temp + $phpfiles;
# Re-write the plugins.xml file with the new ordering
$xml = @new SimpleXMLExtended('<?xml version="1.0" encoding="UTF-8"?><channel></channel>');
foreach ($phpfiles as $fi) {
$plugins = $xml->addChild('item');
$p_note = $plugins->addChild('plugin');
$p_note->addCData($fi);
$p_note = $plugins->addChild('enabled');
if (isset($live_plugins[(string)$fi])){
$p_note->addCData($live_plugins[(string)$fi]);
} else {
$p_note->addCData('false');
}
}
XMLsave($xml, GSDATAOTHERPATH."plugins.xml");
read_pluginsxml();
}
}

0 comments on commit 692f7ea

Please sign in to comment.
You can’t perform that action at this time.