Passed
Push — master ( f762ef...190e8a )
by Julito
09:11
created

Version20160610142700   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 75
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 38
dl 0
loc 75
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A down() 0 2 1
A up() 0 57 3
1
<?php
2
/* For licensing terms, see /license.txt */
3
4
namespace Chamilo\CoreBundle\Migrations\Schema\V111;
5
6
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
7
use Doctrine\DBAL\Schema\Schema;
8
use Doctrine\DBAL\Types\Type;
9
10
/**
11
 * Class Version20160610142700
12
 * Integrate the Skype plugin and create new settings current to enable it
13
 * @package Chamilo\CoreBundle\Migrations\Schema\V111
14
 */
15
class Version20160610142700 extends AbstractMigrationChamilo
16
{
17
    /**
18
     * @param Schema $schema
19
     * @throws \Doctrine\DBAL\DBALException
20
     * @throws \Doctrine\DBAL\Schema\SchemaException
21
     */
22
    public function up(Schema $schema)
23
    {
24
        $connection = $this->connection;
25
        $sql = "SELECT id FROM extra_field WHERE variable = 'skype' AND extra_field_type = 1";
26
        $result = $connection->executeQuery($sql)->fetchAll();
27
28
        if (empty($result)) {
29
            $this->addSql("
30
                INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, visible, changeable, created_at)
31
                VALUES (1, 1, 'skype', 'Skype', 1, 1, NOW())
32
            ");
33
        }
34
35
        $sql = "SELECT id FROM extra_field WHERE variable = 'skype' AND extra_field_type = 1";
36
        $result = $connection->executeQuery($sql)->fetchAll();
37
        if (empty($result)) {
38
            $this->addSql("
39
            INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, visible, changeable, created_at)
40
            VALUES (1, 1, 'linkedin_url', 'LinkedInUrl', 1, 1, NOW())"
41
            );
42
        }
43
44
        $this->addSettingCurrent(
45
            'allow_show_skype_account',
46
            null,
47
            'radio',
48
            'Platform',
49
            'true',
50
            'AllowShowSkypeAccountTitle',
51
            'AllowShowSkypeAccountComment',
52
            null,
53
            null,
54
            1,
55
            true,
56
            false,
57
            [
58
                ['value' => 'false', 'text' => 'No'],
59
                ['value' => 'true', 'text' => 'Yes']
60
            ]
61
        );
62
63
        $this->addSettingCurrent(
64
            'allow_show_linkedin_url',
65
            null,
66
            'radio',
67
            'Platform',
68
            'true',
69
            'AllowShowLinkedInUrlTitle',
70
            'AllowShowLinkedInUrlComment',
71
            null,
72
            null,
73
            1,
74
            true,
75
            false,
76
            [
77
                ['value' => 'false', 'text' => 'No'],
78
                ['value' => 'true', 'text' => 'Yes']
79
            ]
80
        );
81
    }
82
83
    /**
84
     * @param Schema $schema
85
     * @throws \Doctrine\DBAL\DBALException
86
     * @throws \Doctrine\DBAL\Schema\SchemaException
87
     */
88
    public function down(Schema $schema)
89
    {
90
91
    }
92
}
93