source: extensions/Ldap_Login/maintain.inc.php @ 31969

Revision 27288, 1.9 KB checked in by 22decembre, 5 years ago (diff)

add functions unistall and desactivate, yet void

  • Property svn:executable set to *
Line 
1<?php
2defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
3
4include_once('class.ldap.php');
5
6/**
7 * This class is used to expose maintenance methods to the plugins manager
8 * It must extends PluginMaintain and be named "PLUGINID_maintain"
9 * where PLUGINID is the directory name of your plugin
10 */
11class Ldap_Login_maintain extends PluginMaintain
12{
13  /*
14   * My pattern uses a single installation method, which handles both installation
15   * and activation, where Piwigo always calls 'activate' just after 'install'
16   * As a result I use a marker in order to not execute the installation method twice
17   *
18   * The installation function is called by main.inc.php and maintain.inc.php
19   * in order to install and/or update the plugin.
20   *
21   * That's why all operations must be conditionned :
22   *    - use "if empty" for configuration vars
23   *    - use "IF NOT EXISTS" for table creation
24   */
25  private $installed = false;
26 
27  /**
28   * plugin installation
29   *
30   * perform here all needed step for the plugin installation
31   * such as create default config, add database tables,
32   * add fields to existing tables, create local folders...
33   */
34  function install($plugin_version, &$errors=array())
35  {
36    global $conf;
37    $config=new Ldap();
38   
39    if (file_exists(LDAP_LOGIN_PATH.'data.dat' )) {
40    $config->load_config();
41    }
42   
43    else {
44    $config->load_default_config();
45    }
46
47    $config->save_config();
48
49    $this->installed = true;
50  }
51
52  /**
53   * plugin activation
54   *
55   * this function is triggered after installation, by manual activation
56   * or after a plugin update
57   * for this last case you must manage updates tasks of your plugin in this function
58   */
59  function activate($plugin_version, &$errors=array())
60  {
61    if (!$this->installed)
62    {
63      $this->install($plugin_version, $errors);
64    }
65  }
66 
67  function deactivate()
68  {
69  }
70
71  function uninstall()
72  {
73  }
74
75}
Note: See TracBrowser for help on using the repository browser.