Skip to content

Commit

Permalink
Prevent api to install unstackable plugins twice (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
onli committed May 26, 2014
1 parent 6d6570e commit 1fcdf78
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
3 changes: 3 additions & 0 deletions docs/NEWS
Expand Up @@ -4,6 +4,9 @@
Version 2.0-beta3 ()
------------------------------------------------------------------------

* Prevent "new" plugin api to install double instances of plugins
that are not stackable (issue #45)

* Back button in plugin-config

* Adapted serendipity_editor.js to provide more global (though
Expand Down
14 changes: 13 additions & 1 deletion include/admin/plugins.inc.php
Expand Up @@ -345,7 +345,19 @@
'install' => true);
serendipity_plugin_api::hook_event('backend_plugins_fetchplugin', $fetchplugin_data);

if ($fetchplugin_data['install']) {
// we now have to check that the plugin is not already installed or stackable to prevent invalid double instances
$existingPlugin =& serendipity_plugin_api::load_plugin($serendipity['GET']['install_plugin']);
$new_plugin = true;
if (is_object($existingPlugin)) {
$bag = new serendipity_property_bag();
$existingPlugin->introspect($bag);
if ($bag->get('stackable') != true) {
$new_plugin = false;
}
}
$data['new_plugin_failed'] = ! $new_plugin;

if ($fetchplugin_data['install'] && $new_plugin) {
$serendipity['debug']['pluginload'] = array();
$inst = serendipity_plugin_api::create_plugin_instance($serendipity['GET']['install_plugin'], null, (serendipity_plugin_api::is_event_plugin($serendipity['GET']['install_plugin']) ? 'event': 'right'), $authorid, serendipity_db_escape_string($serendipity['GET']['pluginPath']));

Expand Down
3 changes: 3 additions & 0 deletions templates/2k11/admin/plugins.inc.tpl
Expand Up @@ -146,6 +146,9 @@
{if $save}
<span class="msg_success"><span class="icon-ok-circled"></span> {$CONST.DONE}:{$CONST.SETTINGS_SAVED_AT|sprintf:"$timestamp"}</span>
{/if}
{if $new_plugin_failed}
<span class="msg_error"><span class="icon-attention-circled"></span> {$CONST.ERROR}: Plugin not stackable and already installed</span> {* i18n *}
{/if}
<script src="{serendipity_getFile file="admin/js/jquery.autoscroll.js"}"></script>
<script src="{serendipity_getFile file="admin/js/jquery.sortable.js"}"></script>
<script src="{serendipity_getFile file="admin/js/dragdrop.js"}"></script>
Expand Down

0 comments on commit 1fcdf78

Please sign in to comment.