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

(-)a/C4/Auth.pm (-8 / +14 lines)
Lines 976-982 sub checkauth { Link Here
976
                }
976
                }
977
            }
977
            }
978
978
979
            # $return: 1 = valid user, 2 = superlibrarian
979
            # $return: 1 = valid user, 2 = DB user
980
            if ($return) {
980
            if ($return) {
981
981
982
                #_session_log(sprintf "%20s from %16s logged in  at %30s.\n", $userid,$ENV{'REMOTE_ADDR'},(strftime '%c', localtime));
982
                #_session_log(sprintf "%20s from %16s logged in  at %30s.\n", $userid,$ENV{'REMOTE_ADDR'},(strftime '%c', localtime));
Lines 1073-1079 sub checkauth { Link Here
1073
                }
1073
                }
1074
                elsif ( $return == 2 ) {
1074
                elsif ( $return == 2 ) {
1075
1075
1076
                    #We suppose the user is the superlibrarian
1076
                    # It's the DB user, again!
1077
                    # He won't be able to do something interesting
1077
                    $borrowernumber = 0;
1078
                    $borrowernumber = 0;
1078
                    $session->param( 'number',       0 );
1079
                    $session->param( 'number',       0 );
1079
                    $session->param( 'id',           C4::Context->config('user') );
1080
                    $session->param( 'id',           C4::Context->config('user') );
Lines 1082-1088 sub checkauth { Link Here
1082
                    $session->param( 'surname',      C4::Context->config('user') );
1083
                    $session->param( 'surname',      C4::Context->config('user') );
1083
                    $session->param( 'branch',       'NO_LIBRARY_SET' );
1084
                    $session->param( 'branch',       'NO_LIBRARY_SET' );
1084
                    $session->param( 'branchname',   'NO_LIBRARY_SET' );
1085
                    $session->param( 'branchname',   'NO_LIBRARY_SET' );
1085
                    $session->param( 'flags',        1 );
1086
                    $session->param( 'flags',        0 );
1086
                    $session->param( 'emailaddress', C4::Context->preference('KohaAdminEmailAddress') );
1087
                    $session->param( 'emailaddress', C4::Context->preference('KohaAdminEmailAddress') );
1087
                    $session->param( 'ip',           $session->remote_addr() );
1088
                    $session->param( 'ip',           $session->remote_addr() );
1088
                    $session->param( 'lasttime',     time() );
1089
                    $session->param( 'lasttime',     time() );
Lines 1203-1208 sub checkauth { Link Here
1203
        PatronSelfRegistrationDefaultCategory => C4::Context->preference("PatronSelfRegistrationDefaultCategory"),
1204
        PatronSelfRegistrationDefaultCategory => C4::Context->preference("PatronSelfRegistrationDefaultCategory"),
1204
        persona                               => C4::Context->preference("Persona"),
1205
        persona                               => C4::Context->preference("Persona"),
1205
        opac_css_override                     => $ENV{'OPAC_CSS_OVERRIDE'},
1206
        opac_css_override                     => $ENV{'OPAC_CSS_OVERRIDE'},
1207
        user_added                            => $query->param('user_added'),
1206
    );
1208
    );
1207
1209
1208
    $template->param( OpacPublic => C4::Context->preference("OpacPublic") );
1210
    $template->param( OpacPublic => C4::Context->preference("OpacPublic") );
Lines 1499-1505 sub check_api_auth { Link Here
1499
                $session->param( 'lasttime',     time() );
1501
                $session->param( 'lasttime',     time() );
1500
            } elsif ( $return == 2 ) {
1502
            } elsif ( $return == 2 ) {
1501
1503
1502
                #We suppose the user is the superlibrarian
1504
                # It's the DB user, again!
1505
                # He won't be able to do something interesting
1503
                $session->param( 'number',       0 );
1506
                $session->param( 'number',       0 );
1504
                $session->param( 'id',           C4::Context->config('user') );
1507
                $session->param( 'id',           C4::Context->config('user') );
1505
                $session->param( 'cardnumber',   C4::Context->config('user') );
1508
                $session->param( 'cardnumber',   C4::Context->config('user') );
Lines 1507-1513 sub check_api_auth { Link Here
1507
                $session->param( 'surname',      C4::Context->config('user') );
1510
                $session->param( 'surname',      C4::Context->config('user') );
1508
                $session->param( 'branch',       'NO_LIBRARY_SET' );
1511
                $session->param( 'branch',       'NO_LIBRARY_SET' );
1509
                $session->param( 'branchname',   'NO_LIBRARY_SET' );
1512
                $session->param( 'branchname',   'NO_LIBRARY_SET' );
1510
                $session->param( 'flags',        1 );
1513
                $session->param( 'flags',        0 );
1511
                $session->param( 'emailaddress', C4::Context->preference('KohaAdminEmailAddress') );
1514
                $session->param( 'emailaddress', C4::Context->preference('KohaAdminEmailAddress') );
1512
                $session->param( 'ip',           $session->remote_addr() );
1515
                $session->param( 'ip',           $session->remote_addr() );
1513
                $session->param( 'lasttime',     time() );
1516
                $session->param( 'lasttime',     time() );
Lines 1934-1942 sub haspermission { Link Here
1934
    my $row = $sth->fetchrow();
1937
    my $row = $sth->fetchrow();
1935
    my $flags = getuserflags( $row, $userid );
1938
    my $flags = getuserflags( $row, $userid );
1936
    if ( $userid eq C4::Context->config('user') ) {
1939
    if ( $userid eq C4::Context->config('user') ) {
1937
1940
        # DB User Account from /etc/koha.conf
1938
        # Super User Account from /etc/koha.conf
1941
        if ( $flagsrequired->{DB_user} == 1 ) {
1939
        $flags->{'superlibrarian'} = 1;
1942
            $flags->{DB_user} = 1;
1943
            return $flags;
1944
        }
1945
        return 0;
1940
    }
1946
    }
1941
    elsif ( $userid eq 'demo' && C4::Context->config('demo') ) {
1947
    elsif ( $userid eq 'demo' && C4::Context->config('demo') ) {
1942
1948
(-)a/about.pl (-1 / +1 lines)
Lines 44-50 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
44
        query           => $query,
44
        query           => $query,
45
        type            => "intranet",
45
        type            => "intranet",
46
        authnotrequired => 0,
46
        authnotrequired => 0,
47
        flagsrequired   => { catalogue => 1 },
47
        flagsrequired   => { catalogue => 1, DB_user => 1 },
48
        debug           => 1,
48
        debug           => 1,
49
    }
49
    }
50
);
50
);
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc (-11 / +17 lines)
Lines 5-25 Link Here
5
            [% IF ( CAN_user_circulate ) %]<li><a href="/cgi-bin/koha/circ/circulation-home.pl">Circulation</a></li>[% END %]
5
            [% IF ( CAN_user_circulate ) %]<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="[% url %]" method="post" name="loginform" id="loginform">
47
<form action="[% url %]" 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 19-25 Link Here
19
    [% IF adminWarning %]
19
    [% IF adminWarning %]
20
        <div id="adminwarning" class="dialog alert">
20
        <div id="adminwarning" class="dialog alert">
21
            <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>
21
            <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>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>
22
            <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>
23
        </div>
23
        </div>
24
    [% END %]
24
    [% END %]
25
    <div class="yui-u first">
25
    <div class="yui-u first">
Lines 44-52 Link Here
44
                    </li>
44
                    </li>
45
                    [% END %]
45
                    [% END %]
46
46
47
                    [% IF ( CAN_user_catalogue ) %]
47
                    <li>
48
                    <li>
48
                        <a class="icon_general icon_lists" href="/cgi-bin/koha/virtualshelves/shelves.pl">Lists</a>
49
                        <a class="icon_general icon_lists" href="/cgi-bin/koha/virtualshelves/shelves.pl">Lists</a>
49
                    </li>
50
                    </li>
51
                    [% END %]
50
52
51
                    [% IF ( UseCourseReserves ) %]
53
                    [% IF ( UseCourseReserves ) %]
52
                        <li>
54
                        <li>
Lines 59-67 Link Here
59
                        <a class="icon_general icon_cataloging" href="/cgi-bin/koha/cataloguing/addbooks.pl">Cataloging</a>
61
                        <a class="icon_general icon_cataloging" href="/cgi-bin/koha/cataloguing/addbooks.pl">Cataloging</a>
60
                    </li>
62
                    </li>
61
                    [% END %]
63
                    [% END %]
64
65
                    [% IF ( CAN_user_catalogue ) %]
62
                    <li>
66
                    <li>
63
                        <a class="icon_general icon_authorities" href="/cgi-bin/koha/authorities/authorities-home.pl">Authorities</a>
67
                        <a class="icon_general icon_authorities" href="/cgi-bin/koha/authorities/authorities-home.pl">Authorities</a>
64
                    </li>
68
                    </li>
69
                    [% END %]
65
                </ul>
70
                </ul>
66
            </div><!-- /area-list-left -->
71
            </div><!-- /area-list-left -->
67
        </div><!-- /yui-u first -->
72
        </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 60-71 my %data; Link Here
60
60
61
my $dbh = C4::Context->dbh;
61
my $dbh = C4::Context->dbh;
62
62
63
my ($template, $loggedinuser, $cookie)
63
my ($template, $loggedinuser, $cookie, $flags)
64
    = get_template_and_user({template_name => "members/memberentrygen.tt",
64
    = get_template_and_user({template_name => "members/memberentrygen.tt",
65
           query => $input,
65
           query => $input,
66
           type => "intranet",
66
           type => "intranet",
67
           authnotrequired => 0,
67
           authnotrequired => 0,
68
           flagsrequired => {borrowers => 1},
68
           flagsrequired => {borrowers => 1, DB_user => 1},
69
           debug => ($debug) ? 1 : 0,
69
           debug => ($debug) ? 1 : 0,
70
       });
70
       });
71
71
Lines 365-370 $nok = $nok || scalar(@errors); Link Here
365
if ((!$nok) and $nodouble and ($op eq 'insert' or $op eq 'save')){
365
if ((!$nok) and $nodouble and ($op eq 'insert' or $op eq 'save')){
366
	$debug and warn "$op dates: " . join "\t", map {"$_: $newdata{$_}"} qw(dateofbirth dateenrolled dateexpiry);
366
	$debug and warn "$op dates: " . join "\t", map {"$_: $newdata{$_}"} qw(dateofbirth dateenrolled dateexpiry);
367
	if ($op eq 'insert'){
367
	if ($op eq 'insert'){
368
        # It's a patron created by the DB user, set him the superlibrarian permissions
369
        if ( $flags->{DB_user} == 1 ) {
370
            $newdata{flags} = 1
371
        }
368
		# we know it's not a duplicate borrowernumber or there would already be an error
372
		# we know it's not a duplicate borrowernumber or there would already be an error
369
        $borrowernumber = &AddMember(%newdata);
373
        $borrowernumber = &AddMember(%newdata);
370
        $newdata{'borrowernumber'} = $borrowernumber;
374
        $newdata{'borrowernumber'} = $borrowernumber;
Lines 429-434 if ((!$nok) and $nodouble and ($op eq 'insert' or $op eq 'save')){ Link Here
429
            C4::Form::MessagingPreferences::handle_form_action($input, { borrowernumber => $borrowernumber }, $template);
433
            C4::Form::MessagingPreferences::handle_form_action($input, { borrowernumber => $borrowernumber }, $template);
430
        }
434
        }
431
	}
435
	}
436
437
    # The DB user has added the user, he can be logged out.
438
    if ( $flags->{DB_user} == 1 ) {
439
        print $input->redirect("/cgi-bin/koha/mainpage.pl?logout.x=1&user_added=1");
440
        exit;
441
    }
442
432
	print scalar ($destination eq "circ") ? 
443
	print scalar ($destination eq "circ") ? 
433
		$input->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber") :
444
		$input->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber") :
434
		$input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$borrowernumber") ;
445
		$input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$borrowernumber") ;
435
- 

Return to bug 11590