...
- Create a libraries folder within your plugin (if you don't already have one).
- Within this folder, create a file called [my_plugin_name]_install.php. Please note that [my_plugin_name] is the same exact unique name of your plugin.
- This library file is actually a PHP class that contains 2 methods. A constructor is optional. The required methods are run_install() and uninstall(). The plugin activator built into Ushahidi looks for these two methods when activating or deleting plugins.
- Please note that the class name must begin with a capitalized letter.
Here's an example:
Code Block language php class My_plugin_name_Install { /** * Constructor to load the shared database library */ public function __construct() { $this->db = new Database(); } /** * Creates the required database tables for my_plugin_name */ public function run_install() { // Create the database tables // Include the table_prefix $this->db->query(" CREATE TABLE IF NOT EXISTS `".Kohana::config('database.default.table_prefix')."ELLO_table` ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `incident_id` INT NOT NULL COMMENT 'incident_id of the new report that is created', `user_id` INT NOT NULL COMMENT 'user_id of the user that performed this assessment', PRIMARY KEY (id) );"); } /** * Deletes the database tables for my_plugin_name */ public function uninstall() { $this->db->query(" DROP TABLE ".Kohana::config('database.default.table_prefix')."jasd_table; "); } }
Adding a New Page
Admin Settings
See Adding Admin Settings to your Plugin
...