1 | <?php |
---|
2 | if(!defined('REGFLUXBB_PATH')) |
---|
3 | { |
---|
4 | define('REGFLUXBB_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/'); |
---|
5 | } |
---|
6 | |
---|
7 | include_once (PHPWG_ROOT_PATH.'/include/constants.php'); |
---|
8 | include_once (REGFLUXBB_PATH.'include/functions.inc.php'); |
---|
9 | |
---|
10 | function plugin_install($id, $version, &$errors) |
---|
11 | { |
---|
12 | global $prefixeTable, $conf; |
---|
13 | |
---|
14 | // Set current plugin version in config table |
---|
15 | $plugin = RegFluxBB_Infos(REGFLUXBB_PATH); |
---|
16 | $version = $plugin['version']; |
---|
17 | |
---|
18 | // Default global parameters for RegisterFluxBB conf |
---|
19 | // ------------------------------------------------- |
---|
20 | $defaultRegFluxBB = array( |
---|
21 | 'REGFLUXBB_VERSION' => $version, |
---|
22 | 'FLUXBB_PREFIX' => '', |
---|
23 | 'FLUXBB_ADMIN' => '', |
---|
24 | 'FLUXBB_GUEST' => '', |
---|
25 | 'FLUXBB_DEL_PT' => 'false', |
---|
26 | 'FLUXBB_CONFIRM' => 'false', |
---|
27 | 'FLUXBB_DETAIL' => 'false', |
---|
28 | 'FLUXBB_UAM_LINK' => 'false', |
---|
29 | 'FLUXBB_GROUP' => '' |
---|
30 | ); |
---|
31 | |
---|
32 | // Create RegisterFluxBB conf if not already exists |
---|
33 | // ------------------------------------------------ |
---|
34 | $query = ' |
---|
35 | SELECT param |
---|
36 | FROM '.CONFIG_TABLE.' |
---|
37 | WHERE param = "Register_FluxBB" |
---|
38 | ;'; |
---|
39 | $count = pwg_db_num_rows(pwg_query($query)); |
---|
40 | |
---|
41 | if ($count == 0) |
---|
42 | { |
---|
43 | $q = ' |
---|
44 | INSERT INTO '.CONFIG_TABLE.' (param, value, comment) |
---|
45 | VALUES ("Register_FluxBB","'.pwg_db_real_escape_string(serialize($defaultRegFluxBB)).'","Register_FluxBB parameters") |
---|
46 | ;'; |
---|
47 | pwg_query($q); |
---|
48 | } |
---|
49 | |
---|
50 | // Create relation table between FluxBB and Piwigo |
---|
51 | // ----------------------------------------------- |
---|
52 | $q = ' |
---|
53 | CREATE TABLE IF NOT EXISTS '.Register_FluxBB_ID_TABLE.' ( |
---|
54 | id_user_pwg smallint(5) NOT NULL default "0", |
---|
55 | id_user_FluxBB int(10) NOT NULL default "0", |
---|
56 | PwdSynch varchar(3) default NULL, |
---|
57 | PRIMARY KEY (id_user_pwg), |
---|
58 | KEY id_user_pwg (id_user_pwg, id_user_FluxBB, PwdSynch) |
---|
59 | ) |
---|
60 | ;'; |
---|
61 | |
---|
62 | pwg_query($q); |
---|
63 | |
---|
64 | } |
---|
65 | |
---|
66 | function plugin_activate($id, $version, &$errors) |
---|
67 | { |
---|
68 | global $conf; |
---|
69 | |
---|
70 | /* Cleaning obsolete files */ |
---|
71 | /* *********************** */ |
---|
72 | regfluxbb_obsolete_files(); |
---|
73 | |
---|
74 | include_once (REGFLUXBB_PATH.'include/upgradedb.inc.php'); |
---|
75 | |
---|
76 | /* Database upgrade */ |
---|
77 | /* **************** */ |
---|
78 | $conf_RegFluxBB = isset($conf['Register_FluxBB']) ? explode(";" , $conf['Register_FluxBB']) : array(); |
---|
79 | |
---|
80 | if (isset($conf_RegFluxBB[0]) and strpos($conf_RegFluxBB[0],"{") === false) /* Version < 2.5.0 */ |
---|
81 | { |
---|
82 | upgrade_240_250(); |
---|
83 | } |
---|
84 | |
---|
85 | /* Check database upgrade for version > 2.5.0 */ |
---|
86 | /* ****************************************** */ |
---|
87 | $conf_Register_FluxBB = unserialize($conf['Register_FluxBB']); |
---|
88 | |
---|
89 | if (isset($conf_Register_FluxBB['REGFLUXBB_VERSION'])) |
---|
90 | { |
---|
91 | if (version_compare($conf_Register_FluxBB['REGFLUXBB_VERSION'], '2.5.5') < 0) |
---|
92 | { |
---|
93 | /* upgrade from 2.5.x to 2.5.5 */ |
---|
94 | /* *************************** */ |
---|
95 | upgrade_250_255(); |
---|
96 | } |
---|
97 | } |
---|
98 | |
---|
99 | /* Update plugin version number in #_config table */ |
---|
100 | /* and check consistency of #_plugins table */ |
---|
101 | /* ********************************************** */ |
---|
102 | RegFluxBB_version_update(); |
---|
103 | |
---|
104 | /* Reload plugin parameters */ |
---|
105 | /* ************************ */ |
---|
106 | load_conf_from_db('param like \'Register_FluxBB\''); |
---|
107 | } |
---|
108 | |
---|
109 | function plugin_uninstall() |
---|
110 | { |
---|
111 | global $conf; |
---|
112 | |
---|
113 | if (isset($conf['Register_FluxBB'])) |
---|
114 | { |
---|
115 | $q = ' |
---|
116 | DELETE FROM '.CONFIG_TABLE.' |
---|
117 | WHERE param="Register_FluxBB" LIMIT 1 |
---|
118 | ;'; |
---|
119 | |
---|
120 | pwg_query($q); |
---|
121 | } |
---|
122 | |
---|
123 | $q = 'DROP TABLE '.Register_FluxBB_ID_TABLE.';'; |
---|
124 | pwg_query( $q ); |
---|
125 | |
---|
126 | } |
---|
127 | ?> |
---|