Plugin Auto-Uninstall

From GeeklogWiki
Revision as of 15:33, 23 February 2009 by Dirk (talk | contribs) (Plugin Auto-Uninstall)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Uninstalling a plugin usually requires a series of steps that are identical for most, if not all, plugins:

  • drop plugin-specific tables
  • remove plugin groups and permissions
  • unregister plugin from Geeklog

For easy uninstallation of plugins, Geeklog provides the plugin_autouninstall_ API function, where the plugin simply returns information about the data to be removed and Geeklog then does the rest. This also reduces the risk of any coding errors for the uninstall, which may lead the database in an undefined state.

function plugin_autouninstall_foo()

This function simply returns an array specifying the data to be removed from the database:

  • 'tables': a list of the tables to be dropped
  • 'groups': a list of the plugin's groups to be removed from the database
  • 'features': a list of plugin features to be removed
  • 'php_blocks': a list of blocks associated with the plugin and to be removed from the gl_blocks table
  • 'vars': a list of names to be removed from the gl_vars table

As an example, here's the uninstall function for Geeklog' Calendar plugin:

function plugin_autouninstall_calendar ()
    $out = array (
        /* give the name of the tables, without $_TABLES[] */
        'tables' => array('events', 'eventsubmission', 'personal_events'),

        /* give the full name of the group, as in the db */
        'groups' => array('Calendar Admin'),

        /* give the full name of the feature, as in the db */
        'features' => array('calendar.edit', 'calendar.moderate', 'calendar.submit'),

        /* give the full name of the block, including 'phpblock_', etc */
        'php_blocks' => array('phpblock_calendar'),

        /* give all vars with their name */
        'vars'=> array()

    return $out;

Note that table names are given as their index into the $_TABLES array, not as the actual table name.

Also see