Autoinstall Feature

From GeeklogWiki
Jump to: navigation, search

From Geeklog 1.6 onwards, plugins have an alternate installation method, the 'Autoinstall'. This is implemented in the form of a file named autoinstall.php in the same location within the plugin directory as the functions.inc file. To install a plugin using the Autoinstall function, all users need to do is go to the 'Plugins' section of the Admin panel and choose the relevant tarball for the plugin and upload it. The Autoinstall function will take care of the rest, as in creation of database tables, new plugin-specific user groups, as well as moving the required plugin files to the relevant locations within the Geeklog installation. However, this only works with Geeklog 1.6 and above. For backward compatibility, plugin developers might feel the need to include the old install.php script along with their plugins as well. The main function included in autoinstall.php is plugin_autoinstall_{plugin}, where {plugin} is replaced by the name of the plugin. There are optional functions available for inclusion within authoinstall.php. You can read about them in the [documentation : http://wiki.geeklog.net/index.php/Plugin_Autoinstall]. As an example we will take a look at the autoinstall.php file written by Javed Khan for the Boilerplate plugin:

<?php

/**
* Plugin autoinstall function
*
* @param    string  $pi_name    Plugin name
* @return   array               Plugin information
*
*/
function plugin_autoinstall_sample($pi_name)
{
    $pi_name         = 'sample';
    $pi_display_name = 'Boilerplate Plugin';    
    
    $info = array(
        'pi_name'         => $pi_name,
        'pi_display_name' => $pi_display_name,
        'pi_version'      => '1.6.3',
        'pi_gl_version'   => '1.6.1',
        'pi_homepage'     => 'http://www.geeklog.net/'
    );
    
    $tables = array(
        'base',
        'financialData'
    );
    
    $inst_parms = array(
        'info'      => $info,
        'tables'    => $tables
    );

    return $inst_parms;
}

?>

As you can see, it's fairly simple. For further clarification, we will take a look at each set of values implemented here.


$info = array(
        'pi_name'         => $pi_name,
        'pi_display_name' => $pi_display_name,
        'pi_version'      => '1.6.3',
        'pi_gl_version'   => '1.6.1',
        'pi_homepage'     => 'http://www.geeklog.net/'
    );

This array holds general information regarding the plugin and should be fairly self-explanatory.


$tables = array(
        'base',
        'financialData'
    );

This array holds the table names that should be created in the database when the plugin is installed. The table creation scripts would normally be included in /admin/install.php. For the Boilerplate plugin, the table creation scripts are included in special install files based on the type of database query language being used. (The Boilerplate plugin has been built to demonstrate compatibility with different query languages)


$inst_parms = array(
        'info'      => $info,
        'tables'    => $tables
    );

This is the array in the autoinstall script which holds all the parameters that the plugin refers to. It assigns all the variables defined above to special array keys which are recognized by Geeklog during installation.


Of course, more parameters could be added for usergroups, features, permissions etc.

As always, the best way to get a good idea about how Geeklog handles plugins would be to take a good look at lib-plugins.php.