Plugin Install / De-install Functionality

Purpose: Plugins require an install/de-install program to be located in the admin/plugins/{plugin name} directory. The program install.php should be able to handle the install and de-install of the plugin. Here you will find an overview of this code function and the overall relationship to the other plugin code.

The plugin install requires the Geeklog site administrator to first uncompress the plugin archive and then copy (move) the admin and public related directory and files to their respective public_html and admin/plugins directories. Once the files are in place and permissions checked, the install.php for the plugin is executed to install the plugin.

The files under the admin directory will include:

Your admin page(s) will be in http://yourgeeklogdomain/admin/plugins/{plugin name}/

Creating Install.php:

Developer notes:

Program overview

The following is an outline of the universal installer program structure. Refer to the example install.php for complete sample code for the actual function routines and logic.

  1. Includes for any common functions or configuration variables
  2. Call to SEC_inGroup('Root') to verify the user has administrative rights
  3. The function plugin_install_pluginname() is the main plugin Install function. It is responsible for the following:
  4. The main code section first checks to see if it is being called from the install form and if so why - is user trying to install or uninstall. If this not a form process request - $action is not set - then determine if the plugin is installed or not. Depending on result - setup the form and post it to the user to get their input (install or to uninstall the plugin).


 

Plugin Uninstall

The function plugin_uninstall_pluginname() is called from the plugin install program under two conditions, the first being when there has been an error in one of the install steps. The second condition is that the install program has determined the plugin is already installed and presented the user with the option to delete the plugin. Under the first condition, you want to have all your plugin install procedures deleted and removed. The uninstall function should be written to completely back out or delete all plugin and security definition in the core plugin tables and then remove the plugin specific tables.

The uninstall function is also called by the PluginAPI remove() function which is called when the Plugin Editor Delete is used. The plugin editor will prompt the user to confirm that they really want to proceed and the user has to select Delete twice. In this case and in the case of undelete being called if there is an install error, you want the undelete function to proceed without any further checks.

The uninstall function is also called when the user runs the install.php after the plugin is installed and they select delete. The user could possibly execute the install and accidentally call the uninstall function. In this case, it would be good to have some form of confirmation. If the uninstall function is being called in this situation, the universal installer program will pass a value to the uninstall function. Example: plugin_uninstall_chatterblock('checkifenabled'). The uninstall function should be written to accept a variable but default it to blank if nothing passed. This is the only case where it is passed a value - check for a value in the uninstall function and if set then verify the Plugin is first not enabled. If it's a disabled plugin, then proceed and delete it - otherwise display a warning message and stop. Refer to the sample uninstall function for more details.

FAQ

1. What does enable/disable do in the Plugin Editor?

At the end of the lib-common.php, there is a call to all currently enabled plugins. For all enabled plugins, the associated functions.inc file is included. So enables/disables the controls whether the plugins functions.inc file is included. At the top of each plugins functions.inc are several more includes which will include the plugins config.php file and language file.

2. I've disabled the plugin and now I can't delete it

Once you have disabled the plugin, it functions.inc file is not included and the API call to the uninstall function returns as if the function did not exist. This one catches folks often. The plugin must be enabled

3. I don't see the phpblock function in lib-custom for this plugin

The developer can include his Block functions in the plugins functions.inc file. Since all enabled plugins have their associated functions loaded - the block function is made available and can be called from an GL core module or even another plugin.

 

Prev Index Next