View | Details | Raw Unified | Return to bug 37711
Collapse All | Expand All

(-)a/installer/data/mysql/atomicupdate/bug_37711.pl (+52 lines)
Line 0 Link Here
1
use Modern::Perl;
2
use Koha::Installer::Output qw(say_warning say_failure say_success say_info);
3
4
return {
5
    bug_number  => "37711",
6
    description => "Allow setting auto-register per interface (identity providers)",
7
    up          => sub {
8
        my ($args) = @_;
9
        my ( $dbh, $out ) = @$args{qw(dbh out)};
10
11
        if ( !column_exists( 'identity_provider_domains', 'auto_register_opac' ) ) {
12
            $dbh->do(
13
                q{
14
                ALTER TABLE identity_provider_domains
15
                    ADD COLUMN `auto_register_opac` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Allow user auto register (OPAC)'
16
                        AFTER `allow_staff`;
17
            }
18
            );
19
            say $out "Added column 'identity_provider_domains.auto_register_opac'";
20
        }
21
22
        if ( !column_exists( 'identity_provider_domains', 'auto_register_staff' ) ) {
23
            $dbh->do(
24
                q{
25
                ALTER TABLE identity_provider_domains
26
                    ADD COLUMN `auto_register_staff` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Allow user auto register (OPAC)'
27
                        AFTER `auto_register_opac`;
28
            }
29
            );
30
            say $out "Added column 'identity_provider_domains.auto_register_staff'";
31
        }
32
33
        # if this is a sane upgrade, then the column exists and to keep the current
34
        # behavior we only enable OPAC auto-register, if enabled previously
35
        if ( column_exists( 'identity_provider_domains', 'auto_register' ) ) {
36
            $dbh->do(
37
                q{
38
                UPDATE identity_provider_domains
39
                SET auto_register_opac=auto_register;
40
            }
41
            );
42
43
            $dbh->do(
44
                q{
45
                ALTER TABLE identity_provider_domains
46
                    DROP COLUMN `auto_register`;
47
            }
48
            );
49
            say $out "Removed column 'identity_provider_domains.auto_register'";
50
        }
51
    },
52
};
(-)a/installer/data/mysql/kohastructure.sql (-2 / +2 lines)
Lines 3526-3537 CREATE TABLE `identity_provider_domains` ( Link Here
3526
  `identity_provider_domain_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique key, used to identify providers domain',
3526
  `identity_provider_domain_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique key, used to identify providers domain',
3527
  `identity_provider_id` int(11) NOT NULL COMMENT 'Reference to provider',
3527
  `identity_provider_id` int(11) NOT NULL COMMENT 'Reference to provider',
3528
  `domain` varchar(100) DEFAULT NULL COMMENT 'Domain name. If null means all domains',
3528
  `domain` varchar(100) DEFAULT NULL COMMENT 'Domain name. If null means all domains',
3529
  `auto_register` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Allow user auto register',
3530
  `update_on_auth` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Update user data on auth login',
3529
  `update_on_auth` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Update user data on auth login',
3531
  `default_library_id` varchar(10) DEFAULT NULL COMMENT 'Default library to create user if auto register is enabled',
3530
  `default_library_id` varchar(10) DEFAULT NULL COMMENT 'Default library to create user if auto register is enabled',
3532
  `default_category_id` varchar(10) DEFAULT NULL COMMENT 'Default category to create user if auto register is enabled',
3531
  `default_category_id` varchar(10) DEFAULT NULL COMMENT 'Default category to create user if auto register is enabled',
3533
  `allow_opac` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Allow provider from opac interface',
3532
  `allow_opac` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Allow provider from opac interface',
3534
  `allow_staff` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Allow provider from staff interface',
3533
  `allow_staff` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Allow provider from staff interface',
3534
  `auto_register_opac` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Allow user auto register (OPAC)',
3535
  `auto_register_staff` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Allow user auto register (Staff interface)',
3535
  PRIMARY KEY (`identity_provider_domain_id`),
3536
  PRIMARY KEY (`identity_provider_domain_id`),
3536
  UNIQUE KEY `identity_provider_id` (`identity_provider_id`,`domain`),
3537
  UNIQUE KEY `identity_provider_id` (`identity_provider_id`,`domain`),
3537
  KEY `domain` (`domain`),
3538
  KEY `domain` (`domain`),
3538
- 

Return to bug 37711