From: <gi...@ma...> - 2009-08-22 17:13:52
|
The branch, master has been updated via 7f84b8c16b6003fb17f1071bd04cc32967ffcfef (commit) via 9cb18739e769bacb93056bcfa79e43744be14f68 (commit) via df475bdce50d5f5a2ab09c2b3514113de33a0310 (commit) from f63e8c666080fc26e7947458574a0e6743adfc20 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 7f84b8c16b6003fb17f1071bd04cc32967ffcfef Author: John Reese <jr...@le...> Date: Fri Aug 21 14:33:34 2009 -0400 Add forced plugin support in management interface Follow-up to commit 9cb18739. Plugins installed via the configuration file show up in the management interface with the priority and protection input elements disabled, in order to make it more obvious to the user that the values for that plugin cannot be modified. commit 9cb18739e769bacb93056bcfa79e43744be14f68 Author: John Reese <jr...@le...> Date: Fri Aug 21 12:15:29 2009 -0400 Allow config to force install/protect plugins This will allow site administrators to select a set of plugins that will not be able to be uninstalled or change priority through the normal plugin management interface. commit df475bdce50d5f5a2ab09c2b3514113de33a0310 Author: John Reese <jr...@le...> Date: Fri Aug 21 12:13:55 2009 -0400 Fix: API allows protected plugin to be uninstalled ----------------------------------------------------------------------- Summary of changes: config_defaults_inc.php | 21 ++++++++++++++++++++- core/plugin_api.php | 18 +++++++++++++++++- manage_plugin_page.php | 11 ++++++++--- 3 files changed, 45 insertions(+), 5 deletions(-) ----------------------------------------------------------------------- commit 7f84b8c16b6003fb17f1071bd04cc32967ffcfef Author: John Reese <jr...@le...> Date: Fri Aug 21 14:33:34 2009 -0400 Add forced plugin support in management interface Follow-up to commit 9cb18739. Plugins installed via the configuration file show up in the management interface with the priority and protection input elements disabled, in order to make it more obvious to the user that the values for that plugin cannot be modified. diff --git a/manage_plugin_page.php b/manage_plugin_page.php index 924e157..d3b7403 100644 --- a/manage_plugin_page.php +++ b/manage_plugin_page.php @@ -42,6 +42,7 @@ global $g_plugin_cache; $t_plugins_installed = array(); $t_plugins_available = array(); +$t_forced_plugins = config_get_global( 'plugins_force_installed' ); foreach( $t_plugins as $t_basename => $t_plugin ) { if ( isset( $g_plugin_cache[$t_basename] ) ) { @@ -85,6 +86,7 @@ foreach ( $t_plugins_installed as $t_basename => $t_plugin ) { $t_url = $t_plugin->url; $t_requires = $t_plugin->requires; $t_depends = array(); + $t_forced = isset( $t_forced_plugins[ $t_basename ] ); $t_priority = plugin_priority( $t_basename ); $t_protected = plugin_protected( $t_basename ); @@ -139,11 +141,14 @@ foreach ( $t_plugins_installed as $t_basename => $t_plugin ) { echo '<td class="small center">',$t_name,'<input type="hidden" name="change_',$t_basename,'" value="1"/></td>'; echo '<td class="small">',$t_description,$t_author,$t_url,'</td>'; echo '<td class="small center">',$t_depends,'</td>'; - if ( 'MantisCore' != $t_basename ) { + if ( 'MantisCore' == $t_basename ) { + echo '<td> </td><td> </td>'; + } else if ( $t_forced ) { + echo '<td class="center">','<select disabled="disabled">',print_plugin_priority_list( $t_priority ),'</select>','</td>'; + echo '<td class="center">','<input type="checkbox" checked="checked" disabled="disabled"/>','</td>'; + } else { echo '<td class="center">','<select name="priority_',$t_basename,'">',print_plugin_priority_list( $t_priority ),'</select>','</td>'; echo '<td class="center">','<input type="checkbox" name="protected_',$t_basename,'" '.( $t_protected ? 'checked="checked" ' : '').'/>','</td>'; - } else { - echo '<td> </td><td> </td>'; } echo '<td class="center">'; if ( $t_upgrade ) { print_bracket_link( 'manage_plugin_upgrade.php?name=' . $t_basename . form_security_param( 'manage_plugin_upgrade' ), lang_get( 'plugin_upgrade' ) ); } commit 9cb18739e769bacb93056bcfa79e43744be14f68 Author: John Reese <jr...@le...> Date: Fri Aug 21 12:15:29 2009 -0400 Allow config to force install/protect plugins This will allow site administrators to select a set of plugins that will not be able to be uninstalled or change priority through the normal plugin management interface. diff --git a/config_defaults_inc.php b/config_defaults_inc.php index 6535d57..3d4af79 100644 --- a/config_defaults_inc.php +++ b/config_defaults_inc.php @@ -3695,6 +3695,25 @@ */ $g_manage_plugin_threshold = ADMINISTRATOR; + /** + * Force installation and protection of certain plugins. + * Note that this is not the preferred method of installing plugins, + * which should generally be done directly through the plugin management + * interface. However, this method will prevent users with admin access + * from uninstalling plugins through the plugin management interface. + * + * Entries in the array must be in the form of a key/value pair + * consisting of the plugin basename and priority, as such: + * + * = array( + * 'PluginA' => 5, + * 'PluginB' => 5, + * ... + * + * @global $g_plugins_force_installed + */ + $g_plugins_force_installed = array(); + /************ * Due Date * ************/ @@ -3870,5 +3889,5 @@ $g_global_settings = array( '_table$', 'cookie', '^db_', 'hostname', 'allow_signup', 'database_name', 'show_queries_count', 'admin_checks', 'version_suffix', 'global_settings', '_path$', 'use_iis', 'language', 'use_javascript', 'minimal_jscss', 'display_errors', 'show_detailed_errors', 'stop_on_errors', 'login_method', '_file$', - 'anonymous', 'content_expire', 'html_valid_tags', 'custom_headers', 'rss_key_seed', 'plugins_enabled', 'session_', 'form_security_', 'compress_html' + 'anonymous', 'content_expire', 'html_valid_tags', 'custom_headers', 'rss_key_seed', 'plugins_enabled', 'plugins_installed', 'session_', 'form_security_', 'compress_html', ); diff --git a/core/plugin_api.php b/core/plugin_api.php index dc841c8..6e33437 100644 --- a/core/plugin_api.php +++ b/core/plugin_api.php @@ -493,6 +493,13 @@ function plugin_priority( $p_basename ) { function plugin_is_installed( $p_basename ) { $t_plugin_table = db_get_table( 'mantis_plugin_table' ); + $t_forced_plugins = config_get_global( 'plugins_force_installed' ); + foreach( $t_forced_plugins as $t_basename => $t_priority ) { + if ( $t_basename == $p_basename ) { + return true; + } + } + $t_query = "SELECT COUNT(*) FROM $t_plugin_table WHERE basename=" . db_param(); $t_result = db_query_bound( $t_query, array( $p_basename ) ); return( 0 < db_result( $t_result ) ); @@ -737,6 +744,15 @@ function plugin_register( $p_basename, $p_return = false, $p_child = null ) { function plugin_register_installed() { global $g_plugin_cache_priority, $g_plugin_cache_protected; + # register plugins specified in the site configuration + $t_forced_plugins = config_get_global( 'plugins_force_installed' ); + foreach( $t_forced_plugins as $t_basename => $t_priority ) { + plugin_register( $t_basename ); + $g_plugin_cache_priority[$t_basename] = $t_priority; + $g_plugin_cache_protected[$t_basename] = true; + } + + # register plugins installed via the interface/database $t_plugin_table = db_get_table( 'mantis_plugin_table' ); $t_query = "SELECT basename, priority, protected FROM $t_plugin_table WHERE enabled=" . db_param() . ' ORDER BY priority DESC'; commit df475bdce50d5f5a2ab09c2b3514113de33a0310 Author: John Reese <jr...@le...> Date: Fri Aug 21 12:13:55 2009 -0400 Fix: API allows protected plugin to be uninstalled diff --git a/core/plugin_api.php b/core/plugin_api.php index 9521fc3..dc841c8 100644 --- a/core/plugin_api.php +++ b/core/plugin_api.php @@ -618,7 +618,7 @@ function plugin_upgrade( $p_plugin ) { function plugin_uninstall( $p_plugin ) { access_ensure_global_level( config_get_global( 'manage_plugin_threshold' ) ); - if( !plugin_is_installed( $p_plugin->basename ) ) { + if( !plugin_is_installed( $p_plugin->basename ) || plugin_protected( $p_plugin->basename ) ) { return; } ----------------------------------------------------------------------- -- Mantis Bug Tracker |