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

(-)a/C4/Auth.pm (-8 / +14 lines)
Lines 1018-1024 sub checkauth { Link Here
1018
                }
1018
                }
1019
            }
1019
            }
1020
1020
1021
            # $return: 1 = valid user, 2 = superlibrarian
1021
            # $return: 1 = valid user, 2 = DB user
1022
            if ($return) {
1022
            if ($return) {
1023
1023
1024
                #_session_log(sprintf "%20s from %16s logged in  at %30s.\n", $userid,$ENV{'REMOTE_ADDR'},(strftime '%c', localtime));
1024
                #_session_log(sprintf "%20s from %16s logged in  at %30s.\n", $userid,$ENV{'REMOTE_ADDR'},(strftime '%c', localtime));
Lines 1115-1121 sub checkauth { Link Here
1115
                }
1115
                }
1116
                elsif ( $return == 2 ) {
1116
                elsif ( $return == 2 ) {
1117
1117
1118
                    #We suppose the user is the superlibrarian
1118
                    # It's the DB user, again!
1119
                    # He won't be able to do something interesting
1119
                    $borrowernumber = 0;
1120
                    $borrowernumber = 0;
1120
                    $session->param( 'number',       0 );
1121
                    $session->param( 'number',       0 );
1121
                    $session->param( 'id',           C4::Context->config('user') );
1122
                    $session->param( 'id',           C4::Context->config('user') );
Lines 1124-1130 sub checkauth { Link Here
1124
                    $session->param( 'surname',      C4::Context->config('user') );
1125
                    $session->param( 'surname',      C4::Context->config('user') );
1125
                    $session->param( 'branch',       'NO_LIBRARY_SET' );
1126
                    $session->param( 'branch',       'NO_LIBRARY_SET' );
1126
                    $session->param( 'branchname',   'NO_LIBRARY_SET' );
1127
                    $session->param( 'branchname',   'NO_LIBRARY_SET' );
1127
                    $session->param( 'flags',        1 );
1128
                    $session->param( 'flags',        0 );
1128
                    $session->param( 'emailaddress', C4::Context->preference('KohaAdminEmailAddress') );
1129
                    $session->param( 'emailaddress', C4::Context->preference('KohaAdminEmailAddress') );
1129
                    $session->param( 'ip',           $session->remote_addr() );
1130
                    $session->param( 'ip',           $session->remote_addr() );
1130
                    $session->param( 'lasttime',     time() );
1131
                    $session->param( 'lasttime',     time() );
Lines 1246-1251 sub checkauth { Link Here
1246
        PatronSelfRegistrationDefaultCategory => C4::Context->preference("PatronSelfRegistrationDefaultCategory"),
1247
        PatronSelfRegistrationDefaultCategory => C4::Context->preference("PatronSelfRegistrationDefaultCategory"),
1247
        persona                               => C4::Context->preference("Persona"),
1248
        persona                               => C4::Context->preference("Persona"),
1248
        opac_css_override                     => $ENV{'OPAC_CSS_OVERRIDE'},
1249
        opac_css_override                     => $ENV{'OPAC_CSS_OVERRIDE'},
1250
        user_added                            => $query->param('user_added'),
1249
    );
1251
    );
1250
1252
1251
    $template->param( OpacPublic => C4::Context->preference("OpacPublic") );
1253
    $template->param( OpacPublic => C4::Context->preference("OpacPublic") );
Lines 1543-1549 sub check_api_auth { Link Here
1543
                $session->param( 'lasttime',     time() );
1545
                $session->param( 'lasttime',     time() );
1544
            } elsif ( $return == 2 ) {
1546
            } elsif ( $return == 2 ) {
1545
1547
1546
                #We suppose the user is the superlibrarian
1548
                # It's the DB user, again!
1549
                # He won't be able to do something interesting
1547
                $session->param( 'number',       0 );
1550
                $session->param( 'number',       0 );
1548
                $session->param( 'id',           C4::Context->config('user') );
1551
                $session->param( 'id',           C4::Context->config('user') );
1549
                $session->param( 'cardnumber',   C4::Context->config('user') );
1552
                $session->param( 'cardnumber',   C4::Context->config('user') );
Lines 1551-1557 sub check_api_auth { Link Here
1551
                $session->param( 'surname',      C4::Context->config('user') );
1554
                $session->param( 'surname',      C4::Context->config('user') );
1552
                $session->param( 'branch',       'NO_LIBRARY_SET' );
1555
                $session->param( 'branch',       'NO_LIBRARY_SET' );
1553
                $session->param( 'branchname',   'NO_LIBRARY_SET' );
1556
                $session->param( 'branchname',   'NO_LIBRARY_SET' );
1554
                $session->param( 'flags',        1 );
1557
                $session->param( 'flags',        0 );
1555
                $session->param( 'emailaddress', C4::Context->preference('KohaAdminEmailAddress') );
1558
                $session->param( 'emailaddress', C4::Context->preference('KohaAdminEmailAddress') );
1556
                $session->param( 'ip',           $session->remote_addr() );
1559
                $session->param( 'ip',           $session->remote_addr() );
1557
                $session->param( 'lasttime',     time() );
1560
                $session->param( 'lasttime',     time() );
Lines 1980-1988 sub haspermission { Link Here
1980
    my $row = $sth->fetchrow();
1983
    my $row = $sth->fetchrow();
1981
    my $flags = getuserflags( $row, $userid );
1984
    my $flags = getuserflags( $row, $userid );
1982
    if ( $userid eq C4::Context->config('user') ) {
1985
    if ( $userid eq C4::Context->config('user') ) {
1983
1986
        # DB User Account from /etc/koha.conf
1984
        # Super User Account from /etc/koha.conf
1987
        if ( $flagsrequired->{DB_user} == 1 ) {
1985
        $flags->{'superlibrarian'} = 1;
1988
            $flags->{DB_user} = 1;
1989
            return $flags;
1990
        }
1991
        return 0;
1986
    }
1992
    }
1987
    elsif ( $userid eq 'demo' && C4::Context->config('demo') ) {
1993
    elsif ( $userid eq 'demo' && C4::Context->config('demo') ) {
1988
1994
(-)a/about.pl (-1 / +1 lines)
Lines 46-52 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
46
        query           => $query,
46
        query           => $query,
47
        type            => "intranet",
47
        type            => "intranet",
48
        authnotrequired => 0,
48
        authnotrequired => 0,
49
        flagsrequired   => { catalogue => 1 },
49
        flagsrequired   => { catalogue => 1, DB_user => 1 },
50
        debug           => 1,
50
        debug           => 1,
51
    }
51
    }
52
);
52
);
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc (-11 / +17 lines)
Lines 5-25 Link Here
5
            [% IF ( CAN_user_circulate_circulate_remaining_permissions ) %]<li><a href="/cgi-bin/koha/circ/circulation-home.pl">Circulation</a></li>[% END %]
5
            [% IF ( CAN_user_circulate_circulate_remaining_permissions ) %]<li><a href="/cgi-bin/koha/circ/circulation-home.pl">Circulation</a></li>[% END %]
6
            [% IF ( CAN_user_borrowers ) %]<li><a href="/cgi-bin/koha/members/members-home.pl">Patrons</a></li>[% END %]
6
            [% IF ( CAN_user_borrowers ) %]<li><a href="/cgi-bin/koha/members/members-home.pl">Patrons</a></li>[% END %]
7
            [% IF ( CAN_user_catalogue ) %]<li><a href="/cgi-bin/koha/catalogue/search.pl">Search</a></li>[% END %]
7
            [% IF ( CAN_user_catalogue ) %]<li><a href="/cgi-bin/koha/catalogue/search.pl">Search</a></li>[% END %]
8
            [% IF ( intranetbookbag ) %]
8
            [% IF ( intranetbookbag and loggedinusernumber) %]
9
            <li><a href="#" id="cartmenulink">Cart<span id="basketcount"></span></a></li>
9
            <li><a href="#" id="cartmenulink">Cart<span id="basketcount"></span></a></li>
10
            [% END %]
10
            [% END %]
11
            [% IntranetNav %]
11
            [% IntranetNav %]
12
            <li class="dropdown">
12
            <li class="dropdown">
13
                <a href="#" class="dropdown-toggle" data-toggle="dropdown">More <b class="caret"></b></a>
13
                <a href="#" class="dropdown-toggle" data-toggle="dropdown">More <b class="caret"></b></a>
14
                <ul class="dropdown-menu">
14
                <ul class="dropdown-menu">
15
                    [% IF ( loggedinusernumber ) %]
15
                    <li><a href="/cgi-bin/koha/virtualshelves/shelves.pl">Lists</a></li>
16
                    <li><a href="/cgi-bin/koha/virtualshelves/shelves.pl">Lists</a></li>
17
                    [% END %]
16
                    [% IF ( CAN_user_editcatalogue_edit_catalogue || CAN_user_editcatalogue_edit_items ) %]
18
                    [% IF ( CAN_user_editcatalogue_edit_catalogue || CAN_user_editcatalogue_edit_items ) %]
17
                    <li><a href="/cgi-bin/koha/cataloguing/addbooks.pl">Cataloging</a></li>
19
                    <li><a href="/cgi-bin/koha/cataloguing/addbooks.pl">Cataloging</a></li>
18
                    [% END %]
20
                    [% END %]
19
                    [% IF ( CAN_user_acquisition ) %]
21
                    [% IF ( CAN_user_acquisition ) %]
20
                    <li><a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a></li>
22
                    <li><a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a></li>
21
                    [% END %]
23
                    [% END %]
24
                    [% IF ( loggedinusernumber ) %]
22
                    <li><a href="/cgi-bin/koha/authorities/authorities-home.pl">Authorities</a></li>
25
                    <li><a href="/cgi-bin/koha/authorities/authorities-home.pl">Authorities</a></li>
26
                    [% END %]
23
                    [% IF ( CAN_user_serials ) %]
27
                    [% IF ( CAN_user_serials ) %]
24
                    <li><a href="/cgi-bin/koha/serials/serials-home.pl">Serials</a></li>
28
                    <li><a href="/cgi-bin/koha/serials/serials-home.pl">Serials</a></li>
25
                    [% END %]
29
                    [% END %]
Lines 62-79 Link Here
62
                    <b class="caret"></b>
66
                    <b class="caret"></b>
63
                </a>
67
                </a>
64
                <ul class="dropdown-menu" role="menu" aria-labelledby="drop3">
68
                <ul class="dropdown-menu" role="menu" aria-labelledby="drop3">
65
                    [% IF ( IndependentBranches ) %]
69
                    [% IF loggedinusernumber %]
66
                        [% IF ( CAN_user_management || CAN_user_editcatalogue_edit_catalogue ) %]
70
                        [% IF ( IndependentBranches ) %]
67
                    <li>
71
                            [% IF ( CAN_user_management || CAN_user_editcatalogue_edit_catalogue ) %]
68
                        <a class="toplinks" href="/cgi-bin/koha/circ/selectbranchprinter.pl">Set library</a>
72
                        <li>
69
                    </li>
73
                            <a class="toplinks" href="/cgi-bin/koha/circ/selectbranchprinter.pl">Set library</a>
74
                        </li>
75
                            [% END %]
76
                        [% ELSE %]
77
                        <li>
78
                            <a class="toplinks" href="/cgi-bin/koha/circ/selectbranchprinter.pl">Set library</a>
79
                        </li>
70
                        [% END %]
80
                        [% END %]
71
                    [% ELSE %]
72
                    <li>
73
                        <a class="toplinks" href="/cgi-bin/koha/circ/selectbranchprinter.pl">Set library</a>
74
                    </li>
75
                    [% END %]
81
                    [% END %]
76
                    [% IF EnableSearchHistory %]
82
                    [% IF EnableSearchHistory and loggedinusernumber %]
77
                    <li>
83
                    <li>
78
                        <a class="toplinks" href="/cgi-bin/koha/catalogue/search-history.pl">Search history</a>
84
                        <a class="toplinks" href="/cgi-bin/koha/catalogue/search-history.pl">Search history</a>
79
                    </li>
85
                    </li>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/auth.tt (+4 lines)
Lines 39-44 Link Here
39
<div id="login_error"><strong>Error: </strong>Invalid username or password</div>
39
<div id="login_error"><strong>Error: </strong>Invalid username or password</div>
40
[% END %]
40
[% END %]
41
41
42
[% IF user_added %]
43
<div id="login_info"><strong>Info: </strong>The account has been correctly created, use it to continue.</div>
44
[% END %]
45
42
<!-- login prompt time-->
46
<!-- login prompt time-->
43
<form action="/cgi-bin/koha/mainpage.pl" method="post" name="loginform" id="loginform">
47
<form action="/cgi-bin/koha/mainpage.pl" method="post" name="loginform" id="loginform">
44
    <input type="hidden" name="koha_login_context" value="intranet" />
48
    <input type="hidden" name="koha_login_context" value="intranet" />
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt (-1 / +6 lines)
Lines 20-26 Link Here
20
    [% IF adminWarning %]
20
    [% IF adminWarning %]
21
        <div id="adminwarning" class="dialog alert">
21
        <div id="adminwarning" class="dialog alert">
22
            <p><strong>Warning:</strong> You're logged in with the database administrator account. This is a bad idea, and you are likely to encounter problems.</p>
22
            <p><strong>Warning:</strong> You're logged in with the database administrator account. This is a bad idea, and you are likely to encounter problems.</p>
23
            <p>You should <a href="/cgi-bin/koha/members/members-home.pl">create a patron</a> to use when administering Koha and give it superlibrarian permissions.</p>
23
            <p>You should <a href="/cgi-bin/koha/members/memberentry.pl?op=add">create a patron</a> to use when administering Koha and give it superlibrarian permissions.</p>
24
        </div>
24
        </div>
25
    [% END %]
25
    [% END %]
26
    <div class="yui-u first">
26
    <div class="yui-u first">
Lines 45-53 Link Here
45
                    </li>
45
                    </li>
46
                    [% END %]
46
                    [% END %]
47
47
48
                    [% IF ( CAN_user_catalogue ) %]
48
                    <li>
49
                    <li>
49
                        <a class="icon_general icon_lists" href="/cgi-bin/koha/virtualshelves/shelves.pl">Lists</a>
50
                        <a class="icon_general icon_lists" href="/cgi-bin/koha/virtualshelves/shelves.pl">Lists</a>
50
                    </li>
51
                    </li>
52
                    [% END %]
51
53
52
                    [% IF ( UseCourseReserves ) %]
54
                    [% IF ( UseCourseReserves ) %]
53
                        <li>
55
                        <li>
Lines 60-68 Link Here
60
                        <a class="icon_general icon_cataloging" href="/cgi-bin/koha/cataloguing/addbooks.pl">Cataloging</a>
62
                        <a class="icon_general icon_cataloging" href="/cgi-bin/koha/cataloguing/addbooks.pl">Cataloging</a>
61
                    </li>
63
                    </li>
62
                    [% END %]
64
                    [% END %]
65
66
                    [% IF ( CAN_user_catalogue ) %]
63
                    <li>
67
                    <li>
64
                        <a class="icon_general icon_authorities" href="/cgi-bin/koha/authorities/authorities-home.pl">Authorities</a>
68
                        <a class="icon_general icon_authorities" href="/cgi-bin/koha/authorities/authorities-home.pl">Authorities</a>
65
                    </li>
69
                    </li>
70
                    [% END %]
66
                </ul>
71
                </ul>
67
            </div><!-- /area-list-left -->
72
            </div><!-- /area-list-left -->
68
        </div><!-- /yui-u first -->
73
        </div><!-- /yui-u first -->
(-)a/mainpage.pl (-1 / +1 lines)
Lines 39-45 my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user( Link Here
39
        query           => $query,
39
        query           => $query,
40
        type            => "intranet",
40
        type            => "intranet",
41
        authnotrequired => 0,
41
        authnotrequired => 0,
42
        flagsrequired   => { catalogue => 1, },
42
        flagsrequired   => { catalogue => 1, DB_user => 1 },
43
    }
43
    }
44
);
44
);
45
45
(-)a/members/memberentry.pl (-3 / +13 lines)
Lines 61-72 my %data; Link Here
61
61
62
my $dbh = C4::Context->dbh;
62
my $dbh = C4::Context->dbh;
63
63
64
my ($template, $loggedinuser, $cookie)
64
my ($template, $loggedinuser, $cookie, $flags)
65
    = get_template_and_user({template_name => "members/memberentrygen.tt",
65
    = get_template_and_user({template_name => "members/memberentrygen.tt",
66
           query => $input,
66
           query => $input,
67
           type => "intranet",
67
           type => "intranet",
68
           authnotrequired => 0,
68
           authnotrequired => 0,
69
           flagsrequired => {borrowers => 1},
69
           flagsrequired => {borrowers => 1, DB_user => 1},
70
           debug => ($debug) ? 1 : 0,
70
           debug => ($debug) ? 1 : 0,
71
       });
71
       });
72
72
Lines 378-383 $nok = $nok || scalar(@errors); Link Here
378
if ((!$nok) and $nodouble and ($op eq 'insert' or $op eq 'save')){
378
if ((!$nok) and $nodouble and ($op eq 'insert' or $op eq 'save')){
379
	$debug and warn "$op dates: " . join "\t", map {"$_: $newdata{$_}"} qw(dateofbirth dateenrolled dateexpiry);
379
	$debug and warn "$op dates: " . join "\t", map {"$_: $newdata{$_}"} qw(dateofbirth dateenrolled dateexpiry);
380
	if ($op eq 'insert'){
380
	if ($op eq 'insert'){
381
        # It's a patron created by the DB user, set him the superlibrarian permissions
382
        if ( $flags->{DB_user} == 1 ) {
383
            $newdata{flags} = 1
384
        }
381
		# we know it's not a duplicate borrowernumber or there would already be an error
385
		# we know it's not a duplicate borrowernumber or there would already be an error
382
        $borrowernumber = &AddMember(%newdata);
386
        $borrowernumber = &AddMember(%newdata);
383
        $newdata{'borrowernumber'} = $borrowernumber;
387
        $newdata{'borrowernumber'} = $borrowernumber;
Lines 442-447 if ((!$nok) and $nodouble and ($op eq 'insert' or $op eq 'save')){ Link Here
442
            C4::Form::MessagingPreferences::handle_form_action($input, { borrowernumber => $borrowernumber }, $template);
446
            C4::Form::MessagingPreferences::handle_form_action($input, { borrowernumber => $borrowernumber }, $template);
443
        }
447
        }
444
	}
448
	}
449
450
    # The DB user has added the user, he can be logged out.
451
    if ( $flags->{DB_user} == 1 ) {
452
        print $input->redirect("/cgi-bin/koha/mainpage.pl?logout.x=1&user_added=1");
453
        exit;
454
    }
455
445
	print scalar ($destination eq "circ") ? 
456
	print scalar ($destination eq "circ") ? 
446
		$input->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber") :
457
		$input->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber") :
447
		$input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$borrowernumber") ;
458
		$input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$borrowernumber") ;
448
- 

Return to bug 11590