Actions

Plugins - advanced: Difference between revisions

From LimeSurvey Manual

No edit summary
Line 63: Line 63:


New functions can be added to the API object upon request.
New functions can be added to the API object upon request.
The API object is available via `$this->api` when extending from PluginBase, otherwise you can get it from the PluginManager instance that is passed to your plugins' constructor.


== Special plugins ==
== Special plugins ==

Revision as of 13:51, 10 May 2016

Overview

Starting from LimeSurvey 2.05, LimeSurvey will officially support plugins. Some plugins will be supported by the LimeSurvey team and will go into core. Some will be supported by others outside the LimeSurvey team. To help find them, check out the Available third party plugins and add your own plugin to it!

Plugins allow users to customize the functionality of their installation while still being able to benefit from regular software updates.

This documentation is meant for developers that are extending LimeSurvey for their own use or for their clients; end users will not be helped by this documentation.

Plugins must implement the iPlugin interface. We recommend extending your plugin class from the PluginBase class.

Plugins are developed around an event mechanism.

Plugin settings

By extending you benefit from common functionality required by plugins that we already have implemented for you. One of these function is the implementation of the getPluginSettings function. This function must return an array describing the configuration options for the user.

The example plugin exposes just 1 configurable setting, the message it'll show.

protected $settings = array(
    'logo' => array(
          'type' => 'logo',
          'path' => 'assets/logo.png'
     ),

     'message' => array(
          'type' => 'string',
          'label' => 'Message'
     )
);

The array contains a name for each setting as a key. The values are arrays containing the required meta data.

Supported types are:

  • logo
  • string
  • html
  • choice
  • relevance
  • info

Besides type a number of other keys are available:

  • label, defines a label (use English, the label specified here will be passed through the translation functions)
  • default, defines a value to show if no value is specified.
  • current, defines the current value.
  • readOnly, specifies the setting is read only.

You can find a plugin example using all actual settings at https://framagit.org/Shnoulle/exampleSettings

Events

Plugins subscribe to events and can interact with LimeSurvey when the event is fired. For a list of currently available events check Plugin events.

API

Plugins should only extend LimeSurvey via its "public" API. This means that directly using classes found in the source code is a bad practice. Though we can't force you not to, you risk having a broken plugin with every minor update we do.

As much as possible interact with LimeSurvey only via methods described here. Same as for events.

New functions can be added to the API object upon request.

The API object is available via `$this->api` when extending from PluginBase, otherwise you can get it from the PluginManager instance that is passed to your plugins' constructor.

Special plugins

Authentication plugin development

Available plugins