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

(-)a/C4/Auth.pm (+17 lines)
Lines 2029-2034 sub get_all_subpermissions { Link Here
2029
    return $all_perms;
2029
    return $all_perms;
2030
}
2030
}
2031
2031
2032
=head2 check_onboarding_required
2033
2034
my $onboardingrequired = C4::Auth->check_onboarding_required();
2035
2036
Returns 1 from the userflags table if the authenticating user is required to go through the onboarding process. The 'onboardingrequired' field is set in the mainpage.pl
2037
2038
=cut
2039
2040
sub check_onboarding_required {
2041
    my $dbh = C4::Context->dbh;
2042
    my $sth = $dbh->prepare("
2043
          SELECT onboardingrequired FROM userflags WHERE bit = 0");
2044
    $sth->execute();
2045
    my $onboardingrequired = $sth->fetchrow();
2046
    return $onboardingrequired;
2047
}
2048
2032
=head2 haspermission
2049
=head2 haspermission
2033
2050
2034
  $flags = ($userid, $flagsrequired);
2051
  $flags = ($userid, $flagsrequired);
(-)a/Koha/Patron.pm (+20 lines)
Lines 638-643 sub get_enrollable_clubs { Link Here
638
    return wantarray ? $e->as_list : $e;
638
    return wantarray ? $e->as_list : $e;
639
}
639
}
640
640
641
=head3 check_if_patrons_have_flags
642
643
my $patron_has_flag = Koha::Patron->check_if_patrons_have_flags    ();
644
645
All sample patrons that can optionally be installed whilst running the Koha web installer have the flag value of NULL, this subroutine checks if any borrower records in the borrowers table contain a number, and so this means that they must have been manually added. If there is a numberical flag returned then this subroutine will return a 1 to mainpage.pl script to ensure that users are appropriately redirected to the onboarding tool
646
647
=cut
648
649
sub check_if_patrons_have_flags {
650
    my $dbh = C4::Context->dbh;
651
    my $sth = $dbh->prepare("
652
           select * from borrowers where flags != 'NULL'");
653
    $sth->execute();
654
    my $no_patrons_with_flags;
655
    if ( $sth->rows ) {
656
        $no_patrons_with_flags = 1;
657
    }
658
    return $no_patrons_with_flags;
659
}
660
641
=head3 account_locked
661
=head3 account_locked
642
662
643
my $is_locked = $patron->account_locked
663
my $is_locked = $patron->account_locked
(-)a/installer/data/mysql/kohastructure.sql (+1 lines)
Lines 2257-2262 CREATE TABLE `userflags` ( Link Here
2257
  `flag` varchar(30) default NULL,
2257
  `flag` varchar(30) default NULL,
2258
  `flagdesc` varchar(255) default NULL,
2258
  `flagdesc` varchar(255) default NULL,
2259
  `defaulton` int(11) default NULL,
2259
  `defaulton` int(11) default NULL,
2260
  `onboardingrequired` int(1) default NULL,
2260
  PRIMARY KEY  (`bit`)
2261
  PRIMARY KEY  (`bit`)
2261
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2262
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2262
2263
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/installer/step3.tt (-9 / +2 lines)
Lines 32-41 Link Here
32
     [% END %]
32
     [% END %]
33
</title>
33
</title>
34
34
35
[% IF ( finish ) %]
36
 <!--   [%- metacontent= '10; url=/cgi-bin/koha/installer/onboarding.pl' -%]
37
    <meta http-equiv="refresh" content="[% metacontent %]">-->
38
[% END %]
39
[% INCLUDE 'installer-doc-head-close.inc' %]
35
[% INCLUDE 'installer-doc-head-close.inc' %]
40
</head>
36
</head>
41
37
Lines 47-57 Link Here
47
                [% IF ( finish ) %]
43
                [% IF ( finish ) %]
48
                    <h2>Web installer &rsaquo; Installation complete</h2>
44
                    <h2>Web installer &rsaquo; Installation complete</h2>
49
                    <h3>Congratulations, installation complete</h3>
45
                    <h3>Congratulations, installation complete</h3>
50
                    <form name="navigationform" method="post" action="onboarding.pl">
46
                    <p><a href="/cgi-bin/koha/installer/onboarding.pl">Click here to start onboarding process.</a></p>
51
                        <input type="hidden" name="op" value="skip"/>
47
                    <p><a href="/cgi-bin/koha/mainpage.pl"> Skip the onboarding process (this is recommended for users not familiar with library business rules)</a></p>
52
                        <button type="submit" value="submit">Skip onboarding process.</button>
53
                    </form>
54
                    <p>This page will redirect in 10 seconds. <a href="/cgi-bin/koha/installer/onboarding.pl">If not, click here to start onboarding process.</a></p>
55
                [% END %]
48
                [% END %]
56
49
57
                [% IF ( choosemarc ) %]
50
                [% IF ( choosemarc ) %]
(-)a/mainpage.pl (-2 / +14 lines)
Lines 88-94 $template->param( Link Here
88
# warn user if they are using mysql/admin login
88
# warn user if they are using mysql/admin login
89
#
89
#
90
unless ($loggedinuser) {
90
unless ($loggedinuser) {
91
    $template->param(adminWarning => 1);
91
    my $patrons = Koha::Patrons->search( { flags => 1 } )->count;
92
    my $patron_has_flag = Koha::Patron->check_if_patrons_have_flags();
93
    my $dbh        = C4::Context->dbh;
94
    if (!$patrons && !$patron_has_flag){
95
        my $onboardingrequired = C4::Auth->check_onboarding_required();
96
        if (!$onboardingrequired) {
97
                $dbh->do(q{UPDATE userflags SET onboardingrequired = 1 WHERE bit = ?}, {}, 0 );
98
        } else {
99
                print $query->redirect("/cgi-bin/koha/installer/onboarding.pl");
100
                exit;
101
        }
102
    } else {
103
        $template->param(adminWarning => 1);
104
    }
92
}
105
}
93
106
94
output_html_with_http_headers $query, $cookie, $template->output;
107
output_html_with_http_headers $query, $cookie, $template->output;
95
- 

Return to bug 19394