From 93ad7022152b0dcf0d35125b61d4bfa09c0e1261 Mon Sep 17 00:00:00 2001 From: spelth <lukas.leidinger@gmail.com> Date: Sat, 2 May 2015 11:29:33 +0200 Subject: [PATCH] Basic Import --- maintain.inc.php | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+), 0 deletions(-) create mode 100644 maintain.inc.php diff --git a/maintain.inc.php b/maintain.inc.php new file mode 100644 index 0000000..ff5015b --- /dev/null +++ b/maintain.inc.php @@ -0,0 +1,75 @@ +<?php +defined('PHPWG_ROOT_PATH') or die('Hacking attempt!'); + +include_once('class.ldap.php'); + +/** + * This class is used to expose maintenance methods to the plugins manager + * It must extends PluginMaintain and be named "PLUGINID_maintain" + * where PLUGINID is the directory name of your plugin + */ +class Ldap_Login_maintain extends PluginMaintain +{ + /* + * My pattern uses a single installation method, which handles both installation + * and activation, where Piwigo always calls 'activate' just after 'install' + * As a result I use a marker in order to not execute the installation method twice + * + * The installation function is called by main.inc.php and maintain.inc.php + * in order to install and/or update the plugin. + * + * That's why all operations must be conditionned : + * - use "if empty" for configuration vars + * - use "IF NOT EXISTS" for table creation + */ + private $installed = false; + + /** + * plugin installation + * + * perform here all needed step for the plugin installation + * such as create default config, add database tables, + * add fields to existing tables, create local folders... + */ + function install($plugin_version, &$errors=array()) + { + global $conf; + $config=new Ldap(); + + if (file_exists(LDAP_LOGIN_PATH.'data.dat' )) { + $config->load_config(); + } + + else { + $config->load_default_config(); + } + + $config->save_config(); + + $this->installed = true; + } + + /** + * plugin activation + * + * this function is triggered after installation, by manual activation + * or after a plugin update + * for this last case you must manage updates tasks of your plugin in this function + */ + function activate($plugin_version, &$errors=array()) + { + if (!$this->installed) + { + $this->install($plugin_version, $errors); + } + } + + function deactivate() + { + } + + function uninstall() + { + } + +} \ No newline at end of file -- libgit2 0.22.2