Completed
Push — master ( 1ffb94...a28409 )
by Michael
01:22
created

functions_update.php ➔ xoops_module_update_contact()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 58
Code Lines 24

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 24
nc 4
nop 2
dl 0
loc 58
rs 9.639
c 0
b 0
f 0

How to fix   Long Method   

Long Method

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:

1
<?php
2
/*
3
 You may not change or alter any portion of this comment or credits
4
 of supporting developers from this source code or any supporting source code
5
 which is considered copyrighted (c) material of the original comment or credit authors.
6
7
 This program is distributed in the hope that it will be useful,
8
 but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
*/
11
12
/**
13
 * Contact module
14
 *
15
 * @copyright   The XOOPS Project http://sourceforge.net/projects/xoops/
16
 * @license     http://www.fsf.org/copyleft/gpl.html GNU public license
17
 * @author      Kazumi Ono (aka Onokazu)
18
 * @author      Trabis <[email protected]>
19
 * @author      Hossein Azizabadi (AKA Voltan)
20
 * @version     $Id$
21
 */
22
23
function xoops_module_update_contact($module, $version)
0 ignored issues
show
Unused Code introduced by
The parameter $module is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
24
{
25
    $xoopsDB = XoopsDatabaseFactory::getDatabaseConnection();
26
27
    if ($version < 180) {
28
        $sql = "CREATE TABLE " . $xoopsDB->prefix('contact') . " (
29
        contact_id int(10) unsigned NOT NULL auto_increment,
30
        contact_uid int(10) NOT NULL,
31
        contact_cid int(10) NOT NULL,
32
        contact_create int(10) NOT NULL,
33
        contact_subject varchar(255) NOT NULL,
34
        contact_name varchar(255) NOT NULL,
35
        contact_mail varchar(255) NOT NULL,
36
        contact_url varchar(255) NOT NULL,
37
        contact_icq varchar(255) NOT NULL,
38
        contact_company varchar(255) NOT NULL,
39
        contact_location varchar(255) NOT NULL,
40
        contact_department varchar(60) NOT NULL,
41
        contact_ip varchar(20) NOT NULL,
42
        contact_phone varchar(20) NOT NULL,
43
        contact_message text NOT NULL,
44
        contact_address text NOT NULL,
45
        contact_reply tinyint(1) NOT NULL,
46
        PRIMARY KEY  (contact_id)
47
        ) ENGINE=MyISAM;";
48
        $xoopsDB->query($sql);
49
    }
50
51
    if ($version < 181) {
52
        // Add contact_platform
53
        $sql = "ALTER TABLE `" . $xoopsDB->prefix('contact') . "` ADD `contact_platform` ENUM('Android','Ios','Web') NOT NULL DEFAULT 'Web'";
54
        $xoopsDB->query($sql);
55
        // Add contact_type
56
        $sql = "ALTER TABLE `" . $xoopsDB->prefix('contact') . "` ADD `contact_type` ENUM('Contact','Phone','Mail') NOT NULL DEFAULT 'Contact'";
57
        $xoopsDB->query($sql);
58
        // Add index contact_uid
59
        $sql = "ALTER TABLE `" . $xoopsDB->prefix('contact') . "` ADD INDEX `contact_uid` ( `contact_uid` )";
60
        $xoopsDB->query($sql);
61
        // Add index contact_cid
62
        $sql = "ALTER TABLE `" . $xoopsDB->prefix('contact') . "` ADD INDEX `contact_cid` ( `contact_cid` )";
63
        $xoopsDB->query($sql);
64
        // Add index contact_create
65
        $sql = "ALTER TABLE `" . $xoopsDB->prefix('contact') . "` ADD INDEX `contact_create` ( `contact_create` )";
66
        $xoopsDB->query($sql);
67
        // Add index contact_mail
68
        $sql = "ALTER TABLE `" . $xoopsDB->prefix('contact') . "` ADD INDEX `contact_mail` ( `contact_mail` )";
69
        $xoopsDB->query($sql);
70
        // Add index contact_phone
71
        $sql = "ALTER TABLE `" . $xoopsDB->prefix('contact') . "` ADD INDEX `contact_phone` ( `contact_phone` )";
72
        $xoopsDB->query($sql);
73
        // Add index contact_platform
74
        $sql = "ALTER TABLE `" . $xoopsDB->prefix('contact') . "` ADD INDEX `contact_platform` ( `contact_platform` )";
75
        $xoopsDB->query($sql);
76
        // Add index contact_type
77
        $sql = "ALTER TABLE `" . $xoopsDB->prefix('contact') . "` ADD INDEX `contact_type` ( `contact_type` )";
78
        $xoopsDB->query($sql);
79
    }
80
}
81