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 3534-3545 CREATE TABLE `identity_provider_domains` ( Link Here
3534
  `identity_provider_domain_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique key, used to identify providers domain',
3534
  `identity_provider_domain_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique key, used to identify providers domain',
3535
  `identity_provider_id` int(11) NOT NULL COMMENT 'Reference to provider',
3535
  `identity_provider_id` int(11) NOT NULL COMMENT 'Reference to provider',
3536
  `domain` varchar(100) DEFAULT NULL COMMENT 'Domain name. If null means all domains',
3536
  `domain` varchar(100) DEFAULT NULL COMMENT 'Domain name. If null means all domains',
3537
  `auto_register` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Allow user auto register',
3538
  `update_on_auth` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Update user data on auth login',
3537
  `update_on_auth` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Update user data on auth login',
3539
  `default_library_id` varchar(10) DEFAULT NULL COMMENT 'Default library to create user if auto register is enabled',
3538
  `default_library_id` varchar(10) DEFAULT NULL COMMENT 'Default library to create user if auto register is enabled',
3540
  `default_category_id` varchar(10) DEFAULT NULL COMMENT 'Default category to create user if auto register is enabled',
3539
  `default_category_id` varchar(10) DEFAULT NULL COMMENT 'Default category to create user if auto register is enabled',
3541
  `allow_opac` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Allow provider from opac interface',
3540
  `allow_opac` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Allow provider from opac interface',
3542
  `allow_staff` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Allow provider from staff interface',
3541
  `allow_staff` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Allow provider from staff interface',
3542
  `auto_register_opac` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Allow user auto register (OPAC)',
3543
  `auto_register_staff` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Allow user auto register (Staff interface)',
3543
  PRIMARY KEY (`identity_provider_domain_id`),
3544
  PRIMARY KEY (`identity_provider_domain_id`),
3544
  UNIQUE KEY `identity_provider_id` (`identity_provider_id`,`domain`),
3545
  UNIQUE KEY `identity_provider_id` (`identity_provider_id`,`domain`),
3545
  KEY `domain` (`domain`),
3546
  KEY `domain` (`domain`),
3546
- 

Return to bug 37711