150, 'square' => true, 'randompicture_preload' => 25, // number preloaded random pictures 'title' => 'A random photo', 'delay' => 4000, 'apply_to_albums' => 'all', ); function __construct($plugin_id) { parent::__construct($plugin_id); } function install($plugin_version, &$errors=array()) { global $conf; if (empty($conf['MRP'])) { conf_update_param('MRP', $this->default_conf, true); } else { $old_conf = safe_unserialize($conf['MRP']); $new_param = 'apply_to_albums'; if (empty($old_conf[$new_param])) { // use case: this parameter was added in a new version $old_conf[$new_param] = $this->default_conf[$new_param]; } conf_update_param('MRP', $old_conf, true); } // add a new column to existing CATEGORIES table, if it doesn't already exist $result = pwg_query('SHOW COLUMNS FROM `'.CATEGORIES_TABLE.'` LIKE "menurandomphoto_active";'); if (!pwg_db_num_rows($result)) { pwg_query('ALTER TABLE `'.CATEGORIES_TABLE.'` ADD `menurandomphoto_active` enum(\'true\', \'false\') default \'false\';'); } $this->installed = true; } function activate($plugin_version, &$errors=array()) { if (!$this->installed) { $this->install($plugin_version, $errors); } } function deactivate() { } /** * Plugin (auto)update * * This function is called when Piwigo detects that the registered version of * the plugin is older than the version exposed in main.inc.php * Thus it's called after a plugin update from admin panel or a manual update by FTP */ function update($old_version, $new_version, &$errors=array()) { $this->install($new_version, $errors); } function uninstall() { conf_delete_param('MRP'); // delete field pwg_query('ALTER TABLE `'. CATEGORIES_TABLE .'` DROP COLUMN `menurandomphoto_active`;'); } } ?>