Plugins Management for AMS

AMS plugin Requirements and functionalities.

The following are AMS Plugin Requirements and functionalities for users and developers.

Plugin Management: Files included in the AMS

These are the files that must be in the plugins folder:
–> . info – This file contains the information related to plugins and is described in below section.
–> Plugin_Name.php – This file contains the hooks for the plugins . For more info related to hooks see last section: creating hooks.

Plugin Management: Supportable Extensions

Plugin management system always looks for the Plugins which are compressed with .zip extension.If the uploaded plugin is not a file type of "zip/application", it throws an error and stops updloading.

Plugin Management: .info File

Plugins always with a .info file inside it which contains the information related to plugins which will be displayed below, otherwise installation will not proceed further.
-----— Content of the .info File-------—
PluginName = Sample Plugin
Description = Sample Plugin shows sample
Version = 1.0.0
TemplatePath = Path to the template
Type = Manual or Automatic

If this is an update there must be a field in the .info file
UpdateInfo = what is updated?

Plugin Management: Versioning

For all plugins we have used semantic versioning
–>Format: X.Y.Z ,X->Major, Y->Minor, Z->Patch
–>change in the X Y & Z values refer the type of change in the plugin.
–>for initial development only Minor an Patch MUST be 0.
–>if there is bug fix then there MUST be an increment in the Z value.
–>if there is change in the functionality or addition of new functionality
–>then there MUST be an increment in the Y value.
–>When there is increment in the X value , Y and Z MUST be 0.
–>comparing if there is some change
–>For more info refer: https://semver.org

Plugin Management: Naming Conventions

–> The plugin folder and hooks file must have same names in the format
-—> Plugin Folder name = "Sample_Plugin"
-—> Plugin hooks file = "Sample_Plugin.php"
–> All the fields in the .info file must follow the pattern as written in sample above.

Plugin Management: Installing New plugins

To install a plugin we have to upload the plugin compressed with zip extension.There is an option to Install Plugin in the AMS plugins template which redirects the admin to the uploading pannel. Here, in uploading pannel user uploads the plugin which he want to install and an option to install will occur when uploads finished. Now, admin select the option to install plugin , AMS starts checking for the .info file and compare names for the plugin folder with hook file. If all successfully completed without error your plugin is installed.

Plugin Management: Activate Plugin

When a plugin is installed now you can perform many actions on it, one of them is Activate plugin. When admin selects Activate Plugin option , AMS start executing hooks available in the Plugin.

Plugin Management: Deactivate Plugin

When the admin wants to deactivate a running Plugin , Deactivate Plugin option can help him out.

Plugin Management: Delete Plugin

When a admin want to Delete a plugin from the AMS , he must have to check if the plugin is activated or not.
if active then to use delete option he must have to deactivate that plugin.
if inactive then the delete option is already there.

Plugin Management: Install Update

If admin wants to install the update follow the following steps:
–> Modify the changes or write the code which need to be added.
–> Improve the Versioning by following the Versioning sections.
–> Add a field 'UpdateInfo' (as described above in .info file section) in the .info file.
–> compress the plugin again with zip extension and upload it in the Install Plugin part.

When the upload is validated , the update is added to the updates template with proper information provided. If admin wants to apply update to the plugin , he have to select the Update option.

Creating Plugins for AMS:

Creating Local and Global Variables

Global Variables:
–> These variables are defined to store the Global information or information that are usable Globally in AMS.
–> These must be an array to store data with key => value pair.
–> This is the only variable which is returned after going through all hooks.
–> Sample:

$return_set = array();

All the information that hooks return will store in it to use with smarty loader or other functionalities.
–> Field that must be defined to display in menu bar :

$return_set[ 'menu_display'] = 'Name to display in menu bar'


Local Variables:
–> These variables are defined to store the local information or information that are usable in hooks.
–> It is used to store values which we get from GET and POST requests.
–> These must be an array to store data with key => value pair.
–> Sample:

$var_set = array();

All the information that needs to be usable in hooks is stored in this local array.

Creating Global Hooks

Defining Hooks:
–> Hooks are defined as $PluginName_hook_task().
–> Where $PluginName must be same as the file name in which hooks are defined.
Example:
–> Display hook:

function PluginName_hook_display()
{
$return_set[ 'menu_display'] = 'PluginName'
}

–> For creating hooks for storing and fetching data from databases. You have to define hook like $PluginName_hook_store_db() or $PluginName_hook_get_db(), Then create the object of the DBLayer class present in AMS libraries.


–> One Global hook must always be in hooks list that will return the Global variables.

Creating Local Hooks

Defining Hooks:
–> Hooks are defined as hook_task( $param, ..).
–> Where $param must be the values stored in Local variables.
Example:
–> cron hook:

function hook_set_cron( $var_set['connection'], $var_set['path'], $var_set['handle'], $var_set['cron_file'] )
{
... statements ......
}

–> Local hooks are created to set or use values from GET and POST request or stored values stored in local variables.
–> Local hooks are called according to requests made by the server.(for more info see sample apps at the end of this section)

Plugins Already installed with AMS

These plugins are already installed with AMS:
–> Achievements
–> API_key_management