4381526b55906b232e9ce068526afc6aa45b3a86
[kivitendo-erp.git] / sql / Pg-upgrade2 / defaults_feature.pl
1 # @tag: defaults_feature
2 # @description: Einstellen der Feature vom Config-File in die DB verlagern.
3 # @depends: release_3_0_0
4 # @ignore: 0
5 package SL::DBUpgrade2::defaults_feature;
6
7 use utf8;
8
9 use parent qw(SL::DBUpgrade2::Base);
10 use strict;
11
12 sub run {
13   my ($self) = @_;
14
15   # this query will fail if column already exist (new database)
16   $self->db_query(qq|ALTER TABLE defaults ADD COLUMN webdav boolean DEFAULT false|, may_fail => 1);
17   $self->db_query(qq|ALTER TABLE defaults ADD COLUMN webdav_documents boolean   DEFAULT false|, may_fail => 1);
18   $self->db_query(qq|ALTER TABLE defaults ADD COLUMN vertreter boolean DEFAULT false|, may_fail => 1);
19   $self->db_query(qq|ALTER TABLE defaults ADD COLUMN parts_show_image boolean   DEFAULT true|, may_fail => 1);
20   $self->db_query(qq|ALTER TABLE defaults ADD COLUMN parts_listing_image boolean   DEFAULT true|, may_fail => 1);
21   $self->db_query(qq|ALTER TABLE defaults ADD COLUMN parts_image_css text   DEFAULT 'border:0;float:left;max-width:250px;margin-top:20px:margin-right:10px;margin-left:10px;' |, may_fail => 1);
22
23   # check current configuration and set default variables accordingly, so that
24   # kivitendo's behaviour isn't changed by this update
25   # if checks are not set in config set it to true
26   foreach my $check (qw(webdav vertreter parts_show_image parts_listing_image)) {
27     my $check_set = 1;
28     if (!$::lx_office_conf{features}->{$check}) {
29       $check_set = 0;
30     }
31
32     my $update_column = "UPDATE defaults SET $check = '$check_set';";
33     $self->db_query($update_column);
34   }
35   my $update_column = "UPDATE defaults SET parts_image_css = '$::lx_office_conf{features}->{parts_image_css};'";
36   $self->db_query($update_column);
37
38
39   return 1;
40 }
41
42 1;