Content last modified Tuesday 24 August 2021
hop to #bottom
Categories:
Author:
Current version:
1.01
About It:
Rate it:
  • Helpful?
  • 1 Yes
  • 1 No
Flag it:

If you'd like to provide updated information and do not have access to directly edit, please contact the site admin; thanks!

Don't disable plugins on the "Admin/Plugins"-tab

Benefits:

  • keep the “Extensions”-tab always visible
  • allow plugins like the indispensible soo_editarea to work on “Admin/Plugins/Edit”

To tame amok-running plugins there’s a parameter: with an URL like

http://example.com/txp/textpattern/index.php?event=plugin&plugins=0

you get to your “Admin/Plugins”-page with all plugins disabled. This works only for privs 1 and 2 (‘publisher’ and ‘managing_editor’), since we don’t want to allow the lower ranks to disable a possible security related plugin.

Instructions

In file textpattern/index.php find the line saying

	if (!empty($admin_side_plugins) and gps('event') != 'plugin')

(should be #118) and replace it by

	// TODO: Find all the other lines looking *exactly* like this one and use $GLOBALS['txp_privs'] instead
	$txp_privs = safe_field("privs", "txp_users", "name = '".doSlash($txp_user)."'");
	$no_plugins = (gps('plugins')==='0' && in_array($txp_privs, array(1, 2))) ? '&plugins=0' : '';

	if (!empty($admin_side_plugins) && empty($no_plugins))

In file textpattern/include/txp_plugin.php find the line saying

	$status.'&name='.urlencode($name).'"';

(should be #251) and replace it by

	$status.'&name='.urlencode($name).$GLOBALS['no_plugins'].'"';

In file textpattern/lib/txplib_misc.php find the block saying

	if (!isset($GLOBALS['event']) || ($GLOBALS['event'] !== 'plugin'))
	{
		$plugin_areas[$area][$title] = $event;
	}

(should be at #43), remove the “if”-line and the curly brackets, so that only

	$plugin_areas[$area][$title] = $event;

remains.

The same as a patch:

diff -Naur -x '*~' txp-4.3.0-orig/textpattern/include/txp_plugin.php txp-4.3.0/textpattern/include/txp_plugin.php
--- txp-4.3.0-orig/textpattern/include/txp_plugin.php	2010-07-17 15:41:18.000000000 +0200
+++ txp-4.3.0/textpattern/include/txp_plugin.php	2011-01-17 10:10:11.000000000 +0100
@@ -248,7 +248,7 @@
 	{
 		$out = '<a href="index.php?';
 		$out .= 'event=plugin&#38;step=switch_status&#38;status='.
-			$status.'&#38;name='.urlencode($name).'"';
+			$status.'&#38;name='.urlencode($name).$GLOBALS['no_plugins'].'"';
 		$out .= '>'.$linktext.'</a>';
 		return $out;
 	}
diff -Naur -x '*~' txp-4.3.0-orig/textpattern/index.php txp-4.3.0/textpattern/index.php
--- txp-4.3.0-orig/textpattern/index.php	2011-01-02 15:20:19.000000000 +0100
+++ txp-4.3.0/textpattern/index.php	2011-01-17 10:06:07.000000000 +0100
@@ -115,7 +115,11 @@

 		janitor();

-		if (!empty($admin_side_plugins) and gps('event') != 'plugin')
+		// TODO: Find all the other lines looking *exactly* like this one and use $GLOBALS['txp_privs'] instead
+		$txp_privs = safe_field("privs", "txp_users", "name = '".doSlash($txp_user)."'");
+		$no_plugins = (gps('plugins')==='0' && in_array($txp_privs, array(1, 2))) ? '&#38;plugins=0' : '';
+
+		if (!empty($admin_side_plugins) && empty($no_plugins))
 			load_plugins(1);

 		// plugins may have altered privilege settings
diff -Naur -x '*~' txp-4.3.0-orig/textpattern/lib/txplib_misc.php txp-4.3.0/textpattern/lib/txplib_misc.php
--- txp-4.3.0-orig/textpattern/lib/txplib_misc.php	2010-10-21 07:08:52.000000000 +0200
+++ txp-4.3.0/textpattern/lib/txplib_misc.php	2011-01-17 10:06:07.000000000 +0100
@@ -691,11 +691,8 @@
 	{
 		global $plugin_areas;

-		if (!isset($GLOBALS['event']) || ($GLOBALS['event'] !== 'plugin'))
-		{
 			$plugin_areas[$area][$title] = $event;
 		}
-	}

 // -------------------------------------------------------------
 	function pluggable_ui($event, $element, $default='')
Article Request Count:
Keywords/tags:
Initially released:
2010-01-14
Posted here:
14 Jan 2011

You know you want to visit the Archives.
Published with Textpattern