1 | <?php |
---|
2 | /* ----------------------------------------------------------------------------- |
---|
3 | Plugin : Advanced Menu Manager |
---|
4 | Author : Grum |
---|
5 | email : grum@grum.dnsalias.com |
---|
6 | website : http://photos.grum.fr |
---|
7 | PWG user : http://forum.phpwebgallery.net/profile.php?id=3706 |
---|
8 | |
---|
9 | << May the Little SpaceFrog be with you ! >> |
---|
10 | ------------------------------------------------------------------------------ |
---|
11 | See main.inc.php for release information |
---|
12 | |
---|
13 | MyPolls_Install : classe to manage plugin install |
---|
14 | |
---|
15 | --------------------------------------------------------------------------- */ |
---|
16 | include_once('amm_version.inc.php'); |
---|
17 | include_once('amm_root.class.inc.php'); |
---|
18 | include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCTables.class.inc.php'); |
---|
19 | |
---|
20 | |
---|
21 | class AMM_install extends AMM_root |
---|
22 | { |
---|
23 | private $tablesManager; |
---|
24 | private $exportfile; |
---|
25 | |
---|
26 | public function AMM_install($prefixeTable, $filelocation) |
---|
27 | { |
---|
28 | parent::__construct($prefixeTable, $filelocation); |
---|
29 | $this->tablesManager= new GPCTables($this->tables); |
---|
30 | $this->exportfile=dirname($this->getFileLocation()).'/'.$this->getPluginNameFiles().'.sql'; |
---|
31 | } |
---|
32 | |
---|
33 | /* |
---|
34 | function for installation process |
---|
35 | return true if install process is ok, otherwise false |
---|
36 | */ |
---|
37 | public function install() |
---|
38 | { |
---|
39 | $this->initConfig(); |
---|
40 | $this->loadConfig(); |
---|
41 | $this->config['installed']=AMM_VERSION2; |
---|
42 | $this->saveConfig(); |
---|
43 | |
---|
44 | $tables_def=array( |
---|
45 | "CREATE TABLE `".$this->tables['urls']."` ( |
---|
46 | `id` int(11) NOT NULL auto_increment, |
---|
47 | `label` varchar(50) NOT NULL default '', |
---|
48 | `url` varchar(255) NOT NULL default '', |
---|
49 | `mode` int(11) NOT NULL default '0', |
---|
50 | `icon` varchar(50) NOT NULL default '', |
---|
51 | `position` int(11) NOT NULL default '0', |
---|
52 | `visible` char(1) NOT NULL default 'y', |
---|
53 | PRIMARY KEY (`id`), |
---|
54 | KEY `order_key` (`position`) |
---|
55 | )", |
---|
56 | |
---|
57 | "CREATE TABLE `".$this->tables['personalised']."` ( |
---|
58 | `id` int(11) NOT NULL default '0', |
---|
59 | `lang` varchar(5) NOT NULL default '', |
---|
60 | `title` varchar(255) NOT NULL default '', |
---|
61 | `content` text NOT NULL, |
---|
62 | `visible` char(1) NOT NULL default 'y', |
---|
63 | `nfo` varchar(255) NOT NULL default '', |
---|
64 | PRIMARY KEY (`id`,`lang`) |
---|
65 | )" |
---|
66 | ); |
---|
67 | //$table_def array |
---|
68 | $tables_def = create_table_add_character_set($tables_def); |
---|
69 | $result=$this->tablesManager->create($tables_def); |
---|
70 | return($result); |
---|
71 | } |
---|
72 | |
---|
73 | |
---|
74 | /* |
---|
75 | function for uninstall process |
---|
76 | */ |
---|
77 | public function uninstall() |
---|
78 | { |
---|
79 | $this->tablesManager->export($this->exportfile); |
---|
80 | $this->deleteConfig(); |
---|
81 | $this->tablesManager->drop(); |
---|
82 | } |
---|
83 | |
---|
84 | public function activate() |
---|
85 | { |
---|
86 | global $template; |
---|
87 | |
---|
88 | $this->initConfig(); |
---|
89 | $this->loadConfig(); |
---|
90 | |
---|
91 | $this->udpateTablesDef(); |
---|
92 | |
---|
93 | $this->config['installed']=AMM_VERSION2; //update the installed release number |
---|
94 | $this->saveConfig(); |
---|
95 | } |
---|
96 | |
---|
97 | public function deactivate() |
---|
98 | { |
---|
99 | } |
---|
100 | |
---|
101 | |
---|
102 | /** |
---|
103 | * update tables & config between releases |
---|
104 | * |
---|
105 | */ |
---|
106 | protected function udpateTablesDef() |
---|
107 | { |
---|
108 | /* AMM release earlier than the 2.1.3 uses two parameters to manage the display |
---|
109 | * of the menu items ("amm_sections_modspecials" and "amm_sections_modmenu") |
---|
110 | * |
---|
111 | * These two parameters are replaced by a single parameter "amm_sections_items" |
---|
112 | * |
---|
113 | * This function aim to import the old conf into the new conf property |
---|
114 | */ |
---|
115 | if(isset($this->config['amm_sections_modspecials'])) |
---|
116 | { |
---|
117 | foreach($this->config['amm_sections_modspecials'] as $key=>$val) |
---|
118 | { |
---|
119 | $this->config['amm_sections_items'][$key]['visibility']=($val=="y")?"guest,generic,normal,admin/":"admin/"; |
---|
120 | } |
---|
121 | unset($this->config['amm_sections_modspecials']); |
---|
122 | } |
---|
123 | |
---|
124 | if(isset($this->config['amm_sections_modmenu'])) |
---|
125 | { |
---|
126 | foreach($this->config['amm_sections_modmenu'] as $key=>$val) |
---|
127 | { |
---|
128 | $this->config['amm_sections_items'][$key]['visibility']=($val=="y")?"guest,generic,normal,admin/":"admin/"; |
---|
129 | } |
---|
130 | unset($this->config['amm_sections_modmenu']); |
---|
131 | } |
---|
132 | |
---|
133 | if(!array_key_exists('installed', $this->config)) |
---|
134 | { |
---|
135 | /* |
---|
136 | * if key does not exist, probably try to update a plugin older than the |
---|
137 | * 2.2.0 release |
---|
138 | */ |
---|
139 | $this->config['installed']="02.01.06"; |
---|
140 | } |
---|
141 | |
---|
142 | if($this->config['installed']<="02.01.06") |
---|
143 | { |
---|
144 | /* |
---|
145 | * 2.2.0 updates |
---|
146 | * |
---|
147 | * - update fields length for table 'personalised' |
---|
148 | * - update config for menu translation |
---|
149 | */ |
---|
150 | $sql="ALTER TABLE `".$this->tables['personalised']."` |
---|
151 | MODIFY COLUMN `title` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, |
---|
152 | MODIFY COLUMN `nfo` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;"; |
---|
153 | pwg_query($sql); |
---|
154 | |
---|
155 | foreach($this->config['amm_sections_items'] as $key => $val) |
---|
156 | { |
---|
157 | $this->config['amm_sections_items'][$key]['translation'] = $this->defaultMenus[$key]['translation']; |
---|
158 | } |
---|
159 | } |
---|
160 | } |
---|
161 | |
---|
162 | } //class |
---|
163 | |
---|
164 | ?> |
---|