Conditions | 46 |
Paths | > 20000 |
Total Lines | 428 |
Code Lines | 126 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
22 | function xoops_module_update_oledrion($module, $version) |
||
23 | { |
||
24 | global $xoopsDB; |
||
25 | |||
26 | // Présence des nouvelles tables et nouvelles zones dans la base de données |
||
27 | // Nouvelle table oledrion_gateways_options |
||
28 | $tableName = $xoopsDB->prefix('oledrion_gateways_options'); |
||
29 | if (!oledrion_utils::tableExists($tableName)) { |
||
30 | $sql = "CREATE TABLE " . $tableName . " ( |
||
31 | `option_id` int(10) unsigned NOT NULL auto_increment, |
||
32 | `option_gateway` varchar(50) NOT NULL COMMENT 'nom de la passerelle de paiement', |
||
33 | `option_name` varchar(50) NOT NULL, |
||
34 | `option_value` text NOT NULL, |
||
35 | PRIMARY KEY (`option_id`), |
||
36 | KEY `option_gateway` (`option_gateway`), |
||
37 | KEY `option_name` (`option_name`), |
||
38 | KEY `option_gateway_name` (`option_gateway`,`option_name`) |
||
39 | ) ENGINE=InnoDB"; |
||
40 | $xoopsDB->queryF($sql); |
||
41 | } |
||
42 | |||
43 | // Nouveau champ cmd_comment dans oledrion_commands |
||
44 | $tableName = $xoopsDB->prefix('oledrion_commands'); |
||
45 | if (!oledrion_utils::fieldExists('cmd_comment', $tableName)) { |
||
46 | oledrion_utils::addField('`cmd_comment` TEXT NOT NULL', $tableName); |
||
47 | } |
||
48 | |||
49 | if (!oledrion_utils::fieldExists('cmd_vat_number', $tableName)) { |
||
50 | oledrion_utils::addField('`cmd_vat_number` VARCHAR( 255 ) NOT NULL', $tableName); |
||
51 | } |
||
52 | |||
53 | /** |
||
54 | * Nouvelle table oledrion_lists |
||
55 | * @since 2.2.2009.01.29 |
||
56 | */ |
||
57 | $tableName = $xoopsDB->prefix('oledrion_lists'); |
||
58 | if (!oledrion_utils::tableExists($tableName)) { |
||
59 | $sql = "CREATE TABLE " . $tableName . " ( |
||
60 | `list_id` int(10) unsigned NOT NULL auto_increment, |
||
61 | `list_uid` mediumint(8) unsigned NOT NULL, |
||
62 | `list_title` varchar(255) NOT NULL, |
||
63 | `list_date` int(10) unsigned NOT NULL, |
||
64 | `list_productscount` mediumint(8) unsigned NOT NULL, |
||
65 | `list_views` mediumint(8) unsigned NOT NULL, |
||
66 | `list_password` varchar(50) NOT NULL, |
||
67 | `list_type` tinyint(3) unsigned NOT NULL, |
||
68 | `list_description` text NOT NULL, |
||
69 | PRIMARY KEY (`list_id`), |
||
70 | KEY `list_uid` (`list_uid`) |
||
71 | ) ENGINE=InnoDB"; |
||
72 | $xoopsDB->queryF($sql); |
||
73 | } |
||
74 | |||
75 | /** |
||
76 | * Nouvelle table oledrion_lists |
||
77 | * @since 2.2.2009.01.29 |
||
78 | */ |
||
79 | $tableName = $xoopsDB->prefix('oledrion_products_list'); |
||
80 | if (!oledrion_utils::tableExists($tableName)) { |
||
81 | $sql = "CREATE TABLE " . $tableName . " ( |
||
82 | `productlist_id` int(10) unsigned NOT NULL auto_increment, |
||
83 | `productlist_list_id` int(10) unsigned NOT NULL, |
||
84 | `productlist_product_id` int(10) unsigned NOT NULL, |
||
85 | PRIMARY KEY (`productlist_id`), |
||
86 | KEY `productlist_list_id` (`productlist_list_id`), |
||
87 | KEY `productlist_product_id` (`productlist_product_id`) |
||
88 | ) ENGINE=InnoDB"; |
||
89 | $xoopsDB->queryF($sql); |
||
90 | } |
||
91 | |||
92 | if (!oledrion_utils::fieldExists('productlist_date', $tableName)) { |
||
93 | oledrion_utils::addField('productlist_date DATE NOT NULL', $tableName); |
||
94 | } |
||
95 | |||
96 | /** |
||
97 | * Nouvelle table oledrion_attributes |
||
98 | * @since 2.3.2009.03.09 |
||
99 | */ |
||
100 | $tableName = $xoopsDB->prefix('oledrion_attributes'); |
||
101 | if (!oledrion_utils::tableExists($tableName)) { |
||
102 | $sql = "CREATE TABLE `$tableName` ( |
||
103 | `attribute_id` int(10) unsigned NOT NULL auto_increment, |
||
104 | `attribute_weight` mediumint(7) unsigned default NULL, |
||
105 | `attribute_title` varchar(255) default NULL, |
||
106 | `attribute_name` varchar(255) NOT NULL, |
||
107 | `attribute_type` tinyint(3) unsigned default NULL, |
||
108 | `attribute_mandatory` tinyint(1) unsigned default NULL, |
||
109 | `attribute_values` text, |
||
110 | `attribute_names` text, |
||
111 | `attribute_prices` text, |
||
112 | `attribute_stocks` text, |
||
113 | `attribute_product_id` int(11) unsigned default NULL, |
||
114 | `attribute_default_value` varchar(255) default NULL, |
||
115 | `attribute_option1` mediumint(7) unsigned default NULL, |
||
116 | `attribute_option2` mediumint(7) unsigned default NULL, |
||
117 | PRIMARY KEY (`attribute_id`), |
||
118 | KEY `attribute_product_id` (`attribute_product_id`), |
||
119 | KEY `attribute_weight` (`attribute_weight`) |
||
120 | ) ENGINE=InnoDB;"; |
||
121 | $xoopsDB->queryF($sql); |
||
122 | } |
||
123 | |||
124 | /** |
||
125 | * Nouvelle table oledrion_caddy_attributes |
||
126 | * @since 2.3.2009.03.10 |
||
127 | */ |
||
128 | $tableName = $xoopsDB->prefix('oledrion_caddy_attributes'); |
||
129 | if (!oledrion_utils::tableExists($tableName)) { |
||
130 | $sql = "CREATE TABLE `$tableName` ( |
||
131 | `ca_id` int(10) unsigned NOT NULL auto_increment, |
||
132 | `ca_cmd_id` int(10) unsigned NOT NULL, |
||
133 | `ca_caddy_id` int(10) unsigned NOT NULL, |
||
134 | `ca_attribute_id` int(10) unsigned NOT NULL, |
||
135 | `ca_attribute_values` text NOT NULL, |
||
136 | `ca_attribute_names` text NOT NULL, |
||
137 | `ca_attribute_prices` text NOT NULL, |
||
138 | PRIMARY KEY (`ca_id`), |
||
139 | KEY `ca_cmd_id` (`ca_cmd_id`), |
||
140 | KEY `ca_caddy_id` (`ca_caddy_id`), |
||
141 | KEY `ca_attribute_id` (`ca_attribute_id`) |
||
142 | ) ENGINE=InnoDB;"; |
||
143 | $xoopsDB->queryF($sql); |
||
144 | } |
||
145 | |||
146 | /** |
||
147 | * Augmentation des types numéraires pour accepter le million |
||
148 | * @since 2.3.2009.04.20 |
||
149 | */ |
||
150 | $definition = oledrion_utils::getFieldDefinition('product_price', $xoopsDB->prefix('oledrion_products')); |
||
151 | if ($definition != '') { |
||
152 | if (xoops_trim($definition['Type']) == 'decimal(7,2)') { |
||
153 | $tablesToUpdates = array( |
||
154 | 'oledrion_products' => array('product_price', 'product_shipping_price', 'product_discount_price', 'product_ecotaxe'), |
||
155 | 'oledrion_caddy' => array('caddy_price'), |
||
156 | 'oledrion_commands' => array('cmd_shipping'), |
||
157 | 'oledrion_discounts' => array('disc_price_degress_l1total', 'disc_price_degress_l2total', 'disc_price_degress_l3total', 'disc_price_degress_l4total', 'disc_price_degress_l5total'), |
||
158 | ); |
||
159 | foreach ($tablesToUpdates as $tableName => $fields) { |
||
160 | foreach ($fields as $field) { |
||
161 | $sql = 'ALTER TABLE ' . $xoopsDB->prefix($tableName) . ' CHANGE `' . $field . '` `' . $field . '` DECIMAL( 16, 2 ) NOT NULL'; |
||
162 | $xoopsDB->queryF($sql); |
||
163 | } |
||
164 | } |
||
165 | } |
||
166 | } |
||
167 | |||
168 | /** |
||
169 | * Add product_property |
||
170 | * @since 2.3.2012.08.03 |
||
171 | */ |
||
172 | $tableName = $xoopsDB->prefix('oledrion_products'); |
||
173 | if (!oledrion_utils::fieldExists('product_property1', $tableName)) { |
||
174 | oledrion_utils::addField('`product_property1` varchar(255) NOT NULL', $tableName); |
||
175 | } |
||
176 | |||
177 | if (!oledrion_utils::fieldExists('product_property2', $tableName)) { |
||
178 | oledrion_utils::addField('`product_property2` varchar(255) NOT NULL', $tableName); |
||
179 | } |
||
180 | |||
181 | if (!oledrion_utils::fieldExists('product_property3', $tableName)) { |
||
182 | oledrion_utils::addField('`product_property3` varchar(255) NOT NULL', $tableName); |
||
183 | } |
||
184 | |||
185 | if (!oledrion_utils::fieldExists('product_property4', $tableName)) { |
||
186 | oledrion_utils::addField('`product_property4` varchar(255) NOT NULL', $tableName); |
||
187 | } |
||
188 | |||
189 | if (!oledrion_utils::fieldExists('product_property5', $tableName)) { |
||
190 | oledrion_utils::addField('`product_property5` varchar(255) NOT NULL', $tableName); |
||
191 | } |
||
192 | |||
193 | if (!oledrion_utils::fieldExists('product_property6', $tableName)) { |
||
194 | oledrion_utils::addField('`product_property6` varchar(255) NOT NULL', $tableName); |
||
195 | } |
||
196 | |||
197 | if (!oledrion_utils::fieldExists('product_property7', $tableName)) { |
||
198 | oledrion_utils::addField('`product_property7` varchar(255) NOT NULL', $tableName); |
||
199 | } |
||
200 | |||
201 | if (!oledrion_utils::fieldExists('product_property8', $tableName)) { |
||
202 | oledrion_utils::addField('`product_property8` varchar(255) NOT NULL', $tableName); |
||
203 | } |
||
204 | |||
205 | if (!oledrion_utils::fieldExists('product_property9', $tableName)) { |
||
206 | oledrion_utils::addField('`product_property9` varchar(255) NOT NULL', $tableName); |
||
207 | } |
||
208 | |||
209 | if (!oledrion_utils::fieldExists('product_property10', $tableName)) { |
||
210 | oledrion_utils::addField('`product_property10` varchar(255) NOT NULL', $tableName); |
||
211 | } |
||
212 | |||
213 | /** |
||
214 | * Nouvelle table oledrion_packing |
||
215 | * @since 2.3.4 2013.03.5 |
||
216 | */ |
||
217 | $tableName = $xoopsDB->prefix('oledrion_packing'); |
||
218 | if (!oledrion_utils::tableExists($tableName)) { |
||
219 | $sql = "CREATE TABLE `$tableName` ( |
||
220 | `packing_id` int(5) unsigned NOT NULL auto_increment, |
||
221 | `packing_title` varchar(255) NOT NULL default '', |
||
222 | `packing_width` varchar(50) NOT NULL, |
||
223 | `packing_length` varchar(50) NOT NULL, |
||
224 | `packing_weight` varchar(50) NOT NULL, |
||
225 | `packing_image` varchar(255) NOT NULL, |
||
226 | `packing_description` text, |
||
227 | `packing_price` decimal(16,2) NOT NULL, |
||
228 | `packing_online` tinyint(1) NOT NULL default '1', |
||
229 | PRIMARY KEY (`packing_id`), |
||
230 | KEY `packing_title` (`packing_title`), |
||
231 | KEY `packing_online` (`packing_online`), |
||
232 | KEY `packing_price` (`packing_price`) |
||
233 | ) ENGINE=InnoDB;"; |
||
234 | $xoopsDB->queryF($sql); |
||
235 | } |
||
236 | |||
237 | /** |
||
238 | * Nouvelle table oledrion_location |
||
239 | * @since 2.3.4 2013.03.5 |
||
240 | */ |
||
241 | $tableName = $xoopsDB->prefix('oledrion_location'); |
||
242 | if (!oledrion_utils::tableExists($tableName)) { |
||
243 | $sql = "CREATE TABLE `$tableName` ( |
||
244 | `location_id` int(5) unsigned NOT NULL auto_increment, |
||
245 | `location_pid` int(5) unsigned NOT NULL default '0', |
||
246 | `location_title` varchar(255) NOT NULL default '', |
||
247 | `location_online` tinyint(1) NOT NULL default '1', |
||
248 | `location_type` enum('location','parent') NOT NULL, |
||
249 | PRIMARY KEY (`location_id`), |
||
250 | KEY `location_title` (`location_title`), |
||
251 | KEY `location_pid` (`location_pid`), |
||
252 | KEY `location_online` (`location_online`) |
||
253 | ) ENGINE=InnoDB;"; |
||
254 | $xoopsDB->queryF($sql); |
||
255 | } |
||
256 | |||
257 | /** |
||
258 | * Nouvelle table oledrion_delivery |
||
259 | * @since 2.3.4 2013.03.5 |
||
260 | */ |
||
261 | $tableName = $xoopsDB->prefix('oledrion_delivery'); |
||
262 | if (!oledrion_utils::tableExists($tableName)) { |
||
263 | $sql = "CREATE TABLE `$tableName` ( |
||
264 | `delivery_id` int(10) unsigned NOT NULL auto_increment, |
||
265 | `delivery_title` varchar(255) NOT NULL default '', |
||
266 | `delivery_description` text, |
||
267 | `delivery_online` tinyint(1) NOT NULL default '1', |
||
268 | `delivery_image` varchar(255) NOT NULL, |
||
269 | PRIMARY KEY (`delivery_id`), |
||
270 | KEY `delivery_title` (`delivery_title`), |
||
271 | KEY `delivery_online` (`delivery_online`) |
||
272 | ) ENGINE=InnoDB;"; |
||
273 | $xoopsDB->queryF($sql); |
||
274 | } |
||
275 | |||
276 | /** |
||
277 | * Nouvelle table oledrion_payment |
||
278 | * @since 2.3.4 2013.03.5 |
||
279 | */ |
||
280 | $tableName = $xoopsDB->prefix('oledrion_payment'); |
||
281 | if (!oledrion_utils::tableExists($tableName)) { |
||
282 | $sql = "CREATE TABLE `$tableName` ( |
||
283 | `payment_id` int(10) unsigned NOT NULL auto_increment, |
||
284 | `payment_title` varchar(255) NOT NULL default '', |
||
285 | `payment_description` text, |
||
286 | `payment_online` tinyint(1) NOT NULL default '1', |
||
287 | `payment_type` enum('online','offline') NOT NULL, |
||
288 | `payment_gateway` varchar(64) NOT NULL default '', |
||
289 | `payment_image` varchar(255) NOT NULL, |
||
290 | PRIMARY KEY (`payment_id`), |
||
291 | KEY `payment_title` (`payment_title`), |
||
292 | KEY `payment_online` (`payment_online`), |
||
293 | KEY `payment_type` (`payment_type`), |
||
294 | KEY `payment_gateway` (`payment_gateway`) |
||
295 | ) ENGINE=InnoDB;"; |
||
296 | $xoopsDB->queryF($sql); |
||
297 | } |
||
298 | |||
299 | /** |
||
300 | * Nouvelle table oledrion_location_delivery |
||
301 | * @since 2.3.4 2013.03.5 |
||
302 | */ |
||
303 | $tableName = $xoopsDB->prefix('oledrion_location_delivery'); |
||
304 | if (!oledrion_utils::tableExists($tableName)) { |
||
305 | $sql = "CREATE TABLE `$tableName` ( |
||
306 | `ld_id` int(5) unsigned NOT NULL auto_increment, |
||
307 | `ld_location` int(5) unsigned NOT NULL, |
||
308 | `ld_delivery` int(5) unsigned NOT NULL, |
||
309 | `ld_price` decimal(16,2) NOT NULL, |
||
310 | `ld_delivery_time` mediumint(8) unsigned NOT NULL, |
||
311 | PRIMARY KEY (`ld_id`), |
||
312 | KEY `ld_location` (`ld_location`), |
||
313 | KEY `ld_delivery` (`ld_delivery`) |
||
314 | ) ENGINE=InnoDB;"; |
||
315 | $xoopsDB->queryF($sql); |
||
316 | } |
||
317 | |||
318 | /** |
||
319 | * Nouvelle table oledrion_delivery_payment |
||
320 | * @since 2.3.4 2013.03.5 |
||
321 | */ |
||
322 | |||
323 | $tableName = $xoopsDB->prefix('oledrion_delivery_payment'); |
||
324 | if (!oledrion_utils::tableExists($tableName)) { |
||
325 | $sql = "CREATE TABLE `$tableName` ( |
||
326 | `dp_id` int(5) unsigned NOT NULL auto_increment, |
||
327 | `dp_delivery` int(5) unsigned NOT NULL, |
||
328 | `dp_payment` int(5) unsigned NOT NULL, |
||
329 | PRIMARY KEY (`dp_id`), |
||
330 | KEY `dp_delivery` (`dp_delivery`), |
||
331 | KEY `dp_payment` (`dp_payment`) |
||
332 | ) ENGINE=InnoDB;"; |
||
333 | $xoopsDB->queryF($sql); |
||
334 | } |
||
335 | |||
336 | /** |
||
337 | * Nouvelle table oledrion_delivery_payment |
||
338 | * @since 2.3.4 2013.03.15 |
||
339 | */ |
||
340 | |||
341 | $tableName = $xoopsDB->prefix('oledrion_payment_log'); |
||
342 | if (!oledrion_utils::tableExists($tableName)) { |
||
343 | $sql = "CREATE TABLE `$tableName` ( |
||
344 | `log_id` int(10) unsigned NOT NULL auto_increment, |
||
345 | `log_create` int(10) unsigned NOT NULL, |
||
346 | `log_status` tinyint(1) unsigned NOT NULL, |
||
347 | `log_ip` varchar(32) NOT NULL, |
||
348 | `log_type` enum('online','offline') NOT NULL, |
||
349 | `log_payment` int(10) unsigned NOT NULL, |
||
350 | `log_gateway` varchar(64) NOT NULL default '', |
||
351 | `log_uid` int(10) unsigned NOT NULL, |
||
352 | `log_command` int(10) unsigned NOT NULL, |
||
353 | `log_amount` double(16,2) NOT NULL, |
||
354 | `log_authority` varchar(255) NOT NULL, |
||
355 | PRIMARY KEY (`log_id`), |
||
356 | KEY `log_uid` (`log_uid`), |
||
357 | KEY `log_command` (`log_command`), |
||
358 | KEY `log_status` (`log_status`) |
||
359 | ) ENGINE=InnoDB;"; |
||
360 | $xoopsDB->queryF($sql); |
||
361 | } |
||
362 | |||
363 | /** |
||
364 | * Add New fields to oledrion_commands |
||
365 | * @since 2.3.2013.03.15 |
||
366 | */ |
||
367 | $tableName = $xoopsDB->prefix('oledrion_commands'); |
||
368 | if (!oledrion_utils::fieldExists('cmd_create', $tableName)) { |
||
369 | oledrion_utils::addField('`cmd_create` int(10) unsigned NOT NULL', $tableName); |
||
370 | } |
||
371 | |||
372 | if (!oledrion_utils::fieldExists('cmd_packing', $tableName)) { |
||
373 | oledrion_utils::addField('`cmd_packing` varchar(255) NOT NULL', $tableName); |
||
374 | } |
||
375 | |||
376 | if (!oledrion_utils::fieldExists('cmd_packing_id', $tableName)) { |
||
377 | oledrion_utils::addField('`cmd_packing_id` int(5) unsigned NOT NULL', $tableName); |
||
378 | } |
||
379 | |||
380 | if (!oledrion_utils::fieldExists('cmd_location', $tableName)) { |
||
381 | oledrion_utils::addField('`cmd_location` varchar(255) NOT NULL', $tableName); |
||
382 | } |
||
383 | |||
384 | if (!oledrion_utils::fieldExists('cmd_location_id', $tableName)) { |
||
385 | oledrion_utils::addField('`cmd_location_id` int(5) unsigned NOT NULL', $tableName); |
||
386 | } |
||
387 | |||
388 | if (!oledrion_utils::fieldExists('cmd_delivery', $tableName)) { |
||
389 | oledrion_utils::addField('`cmd_delivery` varchar(255) NOT NULL', $tableName); |
||
390 | } |
||
391 | |||
392 | if (!oledrion_utils::fieldExists('cmd_delivery_id', $tableName)) { |
||
393 | oledrion_utils::addField('`cmd_delivery_id` int(5) unsigned NOT NULL', $tableName); |
||
394 | } |
||
395 | |||
396 | if (!oledrion_utils::fieldExists('cmd_payment', $tableName)) { |
||
397 | oledrion_utils::addField('`cmd_payment` varchar(255) NOT NULL', $tableName); |
||
398 | } |
||
399 | |||
400 | if (!oledrion_utils::fieldExists('cmd_payment_id', $tableName)) { |
||
401 | oledrion_utils::addField('`cmd_payment_id` int(5) unsigned NOT NULL', $tableName); |
||
402 | } |
||
403 | |||
404 | if (!oledrion_utils::fieldExists('cmd_status', $tableName)) { |
||
405 | oledrion_utils::addField('`cmd_status` tinyint(1) unsigned NOT NULL default "1"', $tableName); |
||
406 | } |
||
407 | |||
408 | if (!oledrion_utils::fieldExists('cmd_mobile', $tableName)) { |
||
409 | oledrion_utils::addField('`cmd_mobile` varchar(30) NOT NULL', $tableName); |
||
410 | } |
||
411 | |||
412 | if (!oledrion_utils::fieldExists('cmd_packing_price', $tableName)) { |
||
413 | oledrion_utils::addField('`cmd_packing_price` decimal(16,2) NOT NULL', $tableName); |
||
414 | } |
||
415 | |||
416 | /** |
||
417 | * Add/update product urls |
||
418 | * @since 2.3.2013.08.03 |
||
419 | */ |
||
420 | $tableName = $xoopsDB->prefix('oledrion_products'); |
||
421 | |||
422 | if (!oledrion_utils::fieldExists('product_url2', $tableName)) { |
||
423 | oledrion_utils::addField('`product_url2` VARCHAR( 255 ) NOT NULL AFTER `product_url`', $tableName); |
||
424 | } |
||
425 | |||
426 | if (!oledrion_utils::fieldExists('product_url3', $tableName)) { |
||
427 | oledrion_utils::addField('`product_url3` VARCHAR( 255 ) NOT NULL AFTER `product_url`', $tableName); |
||
428 | } |
||
429 | |||
430 | /** |
||
431 | * Add cmd_track |
||
432 | * @since 2014.01.03 |
||
433 | */ |
||
434 | $tableName = $xoopsDB->prefix('oledrion_commands'); |
||
435 | |||
436 | if (!oledrion_utils::fieldExists('cmd_track', $tableName)) { |
||
437 | oledrion_utils::addField('`cmd_track` VARCHAR( 255 ) NOT NULL', $tableName); |
||
438 | } |
||
439 | |||
440 | /** |
||
441 | * Add cmd_track |
||
442 | * @since 2014.01.10 |
||
443 | */ |
||
444 | $tableName = $xoopsDB->prefix('oledrion_related'); |
||
445 | |||
446 | if (!oledrion_utils::fieldExists('related_product_percent', $tableName)) { |
||
447 | oledrion_utils::addField('`related_product_percent` INT( 4 ) NOT NULL', $tableName); |
||
448 | } |
||
449 | } |
||
450 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.