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

(-)a/C4/Auth.pm (-4 / +7 lines)
Lines 387-392 sub get_template_and_user { Link Here
387
        my $opac_name = '';
387
        my $opac_name = '';
388
        if (($opac_search_limit && $opac_search_limit =~ /branch:(\w+)/ && $opac_limit_override) || ($in->{'query'}->param('limit') && $in->{'query'}->param('limit') =~ /branch:(\w+)/)){
388
        if (($opac_search_limit && $opac_search_limit =~ /branch:(\w+)/ && $opac_limit_override) || ($in->{'query'}->param('limit') && $in->{'query'}->param('limit') =~ /branch:(\w+)/)){
389
            $opac_name = $1;   # opac_search_limit is a branch, so we use it.
389
            $opac_name = $1;   # opac_search_limit is a branch, so we use it.
390
        } elsif ( $in->{'query'}->param('multibranchlimit') ) {
391
            $opac_name = $in->{'query'}->param('multibranchlimit');
390
        } elsif (C4::Context->preference("SearchMyLibraryFirst") && C4::Context->userenv && C4::Context->userenv->{'branch'}) {
392
        } elsif (C4::Context->preference("SearchMyLibraryFirst") && C4::Context->userenv && C4::Context->userenv->{'branch'}) {
391
            $opac_name = C4::Context->userenv->{'branch'};
393
            $opac_name = C4::Context->userenv->{'branch'};
392
        }
394
        }
Lines 395-407 sub get_template_and_user { Link Here
395
            AnonSuggestions           => "" . C4::Context->preference("AnonSuggestions"),
397
            AnonSuggestions           => "" . C4::Context->preference("AnonSuggestions"),
396
            AuthorisedValueImages     => C4::Context->preference("AuthorisedValueImages"),
398
            AuthorisedValueImages     => C4::Context->preference("AuthorisedValueImages"),
397
            BranchesLoop              => GetBranchesLoop($opac_name),
399
            BranchesLoop              => GetBranchesLoop($opac_name),
398
            CalendarFirstDayOfWeek      => (C4::Context->preference("CalendarFirstDayOfWeek") eq "Sunday")?0:1,
400
            BranchCategoriesLoop      => GetBranchCategories( undef, undef, 1, $opac_name ),
401
            CalendarFirstDayOfWeek    => (C4::Context->preference("CalendarFirstDayOfWeek") eq "Sunday")?0:1,
399
            LibraryName               => "" . C4::Context->preference("LibraryName"),
402
            LibraryName               => "" . C4::Context->preference("LibraryName"),
400
            LibraryNameTitle          => "" . $LibraryNameTitle,
403
            LibraryNameTitle          => "" . $LibraryNameTitle,
401
            LoginBranchname           => C4::Context->userenv?C4::Context->userenv->{"branchname"}:"",
404
            LoginBranchname           => C4::Context->userenv?C4::Context->userenv->{"branchname"}:"",
402
            OPACAmazonCoverImages     => C4::Context->preference("OPACAmazonCoverImages"),
405
            OPACAmazonCoverImages     => C4::Context->preference("OPACAmazonCoverImages"),
403
            OPACFRBRizeEditions       => C4::Context->preference("OPACFRBRizeEditions"),
406
            OPACFRBRizeEditions       => C4::Context->preference("OPACFRBRizeEditions"),
404
            OpacHighlightedWords       => C4::Context->preference("OpacHighlightedWords"),
407
            OpacHighlightedWords      => C4::Context->preference("OpacHighlightedWords"),
405
            OPACItemHolds             => C4::Context->preference("OPACItemHolds"),
408
            OPACItemHolds             => C4::Context->preference("OPACItemHolds"),
406
            OPACShelfBrowser          => "". C4::Context->preference("OPACShelfBrowser"),
409
            OPACShelfBrowser          => "". C4::Context->preference("OPACShelfBrowser"),
407
            OpacShowRecentComments    => C4::Context->preference("OpacShowRecentComments"),
410
            OpacShowRecentComments    => C4::Context->preference("OpacShowRecentComments"),
Lines 412-418 sub get_template_and_user { Link Here
412
            OpacAuthorities           => C4::Context->preference("OpacAuthorities"),
415
            OpacAuthorities           => C4::Context->preference("OpacAuthorities"),
413
            OPACBaseURL               => ($in->{'query'}->https() ? "https://" : "http://") . $ENV{'SERVER_NAME'} .
416
            OPACBaseURL               => ($in->{'query'}->https() ? "https://" : "http://") . $ENV{'SERVER_NAME'} .
414
                   ($ENV{'SERVER_PORT'} eq ($in->{'query'}->https() ? "443" : "80") ? '' : ":$ENV{'SERVER_PORT'}"),
417
                   ($ENV{'SERVER_PORT'} eq ($in->{'query'}->https() ? "443" : "80") ? '' : ":$ENV{'SERVER_PORT'}"),
415
            opac_css_override           => $ENV{'OPAC_CSS_OVERRIDE'},
418
            opac_css_override         => $ENV{'OPAC_CSS_OVERRIDE'},
416
            opac_search_limit         => $opac_search_limit,
419
            opac_search_limit         => $opac_search_limit,
417
            opac_limit_override       => $opac_limit_override,
420
            opac_limit_override       => $opac_limit_override,
418
            OpacBrowser               => C4::Context->preference("OpacBrowser"),
421
            OpacBrowser               => C4::Context->preference("OpacBrowser"),
Lines 426-432 sub get_template_and_user { Link Here
426
            OpacNavRight              => "" . C4::Context->preference("OpacNavRight"),
429
            OpacNavRight              => "" . C4::Context->preference("OpacNavRight"),
427
            OpacNavBottom             => "" . C4::Context->preference("OpacNavBottom"),
430
            OpacNavBottom             => "" . C4::Context->preference("OpacNavBottom"),
428
            OpacPasswordChange        => C4::Context->preference("OpacPasswordChange"),
431
            OpacPasswordChange        => C4::Context->preference("OpacPasswordChange"),
429
            OPACPatronDetails        => C4::Context->preference("OPACPatronDetails"),
432
            OPACPatronDetails         => C4::Context->preference("OPACPatronDetails"),
430
            OPACPrivacy               => C4::Context->preference("OPACPrivacy"),
433
            OPACPrivacy               => C4::Context->preference("OPACPrivacy"),
431
            OPACFinesTab              => C4::Context->preference("OPACFinesTab"),
434
            OPACFinesTab              => C4::Context->preference("OPACFinesTab"),
432
            OpacTopissue              => C4::Context->preference("OpacTopissue"),
435
            OpacTopissue              => C4::Context->preference("OpacTopissue"),
(-)a/C4/Branch.pm (-26 / +42 lines)
Lines 328-334 sub GetBranchCategory { Link Here
328
328
329
=head2 GetBranchCategories
329
=head2 GetBranchCategories
330
330
331
  my $categories = GetBranchCategories($branchcode,$categorytype);
331
  my $categories = GetBranchCategories($branchcode,$categorytype,$show_in_pulldown,$selected_in_pulldown);
332
332
333
Returns a list ref of anon hashrefs with keys eq columns of branchcategories table,
333
Returns a list ref of anon hashrefs with keys eq columns of branchcategories table,
334
i.e. categorycode, categorydescription, categorytype, categoryname.
334
i.e. categorycode, categorydescription, categorytype, categoryname.
Lines 338-364 $branchcode is a member of , and to $categorytype. Link Here
338
=cut
338
=cut
339
339
340
sub GetBranchCategories {
340
sub GetBranchCategories {
341
    my ($branchcode,$categorytype) = @_;
341
    my ( $branchcode, $categorytype, $show_in_pulldown, $selected_in_pulldown ) = @_;
342
	my $dbh = C4::Context->dbh();
342
    my $dbh = C4::Context->dbh();
343
	my $query = "SELECT c.* FROM branchcategories c";
343
344
	my (@where, @bind);
344
    my $query = "SELECT c.* FROM branchcategories c";
345
	if($branchcode) {
345
    my ( @where, @bind );
346
		$query .= ",branchrelations r, branches b ";
346
347
		push @where, "c.categorycode=r.categorycode and r.branchcode=? ";  
347
    if( $branchcode ) {
348
		push @bind , $branchcode;
348
        $query .= ",branchrelations r, branches b ";
349
	}
349
        push @where, "c.categorycode = r.categorycode AND r.branchcode = ? ";
350
	if ($categorytype) {
350
        push @bind , $branchcode;
351
		push @where, " c.categorytype=? ";
351
    }
352
		push @bind, $categorytype;
352
353
	}
353
    if ( $categorytype ) {
354
	$query .= " where " . join(" and ", @where) if(@where);
354
        push @where, " c.categorytype = ? ";
355
	$query .= " order by categorytype,c.categorycode";
355
        push @bind, $categorytype;
356
	my $sth=$dbh->prepare( $query);
356
    }
357
	$sth->execute(@bind);
357
358
	
358
    if ( defined( $show_in_pulldown ) ) {
359
	my $branchcats = $sth->fetchall_arrayref({});
359
        push( @where, " c.show_in_pulldown = ? " );
360
	$sth->finish();
360
        push( @bind, $show_in_pulldown );
361
	return( $branchcats );
361
    }
362
363
    $query .= " WHERE " . join(" AND ", @where) if(@where);
364
    $query .= " ORDER BY categorytype,c.categorycode";
365
    my $sth=$dbh->prepare( $query);
366
    $sth->execute(@bind);
367
368
    my $branchcats = $sth->fetchall_arrayref({});
369
    $sth->finish();
370
371
    if ( $selected_in_pulldown ) {
372
        foreach my $bc ( @$branchcats ) {
373
            $bc->{'selected'} = 1 if ( $bc->{'categorycode'} eq $selected_in_pulldown );
374
        }
375
    }
376
377
    return( $branchcats );
362
}
378
}
363
379
364
=head2 GetCategoryTypes
380
=head2 GetCategoryTypes
Lines 506-519 sub ModBranchCategoryInfo { Link Here
506
    my $dbh    = C4::Context->dbh;
522
    my $dbh    = C4::Context->dbh;
507
    if ($data->{'add'}){
523
    if ($data->{'add'}){
508
	# we are doing an insert
524
	# we are doing an insert
509
	my $sth   = $dbh->prepare("INSERT INTO branchcategories (categorycode,categoryname,codedescription,categorytype) VALUES (?,?,?,?)");
525
  my $sth   = $dbh->prepare("INSERT INTO branchcategories (categorycode,categoryname,codedescription,categorytype,show_in_pulldown) VALUES (?,?,?,?,?)");
510
	$sth->execute(uc( $data->{'categorycode'} ),$data->{'categoryname'}, $data->{'codedescription'},$data->{'categorytype'} );
526
        $sth->execute(uc( $data->{'categorycode'} ),$data->{'categoryname'}, $data->{'codedescription'},$data->{'categorytype'},$data->{'show_in_pulldown'} );
511
	$sth->finish();		
527
	$sth->finish();		
512
    }
528
    }
513
    else {
529
    else {
514
	# modifying
530
	# modifying
515
	my $sth = $dbh->prepare("UPDATE branchcategories SET categoryname=?,codedescription=?,categorytype=? WHERE categorycode=?");
531
        my $sth = $dbh->prepare("UPDATE branchcategories SET categoryname=?,codedescription=?,categorytype=?,show_in_pulldown=? WHERE categorycode=?");
516
	$sth->execute($data->{'categoryname'}, $data->{'codedescription'},$data->{'categorytype'},uc( $data->{'categorycode'} ) );
532
        $sth->execute($data->{'categoryname'}, $data->{'codedescription'},$data->{'categorytype'},$data->{'show_in_pulldown'},uc( $data->{'categorycode'} ) );
517
	$sth->finish();
533
	$sth->finish();
518
    }
534
    }
519
}
535
}
(-)a/admin/branches.pl (+3 lines)
Lines 168-173 elsif ( $op eq 'addcategory_validate' ) { Link Here
168
    $template->param( else => 1 );
168
    $template->param( else => 1 );
169
    # confirm settings change...
169
    # confirm settings change...
170
    my $params = $input->Vars;
170
    my $params = $input->Vars;
171
    $params->{'show_in_pulldown'} = ( $params->{'show_in_pulldown'} eq 'on' ) ? 1 : 0;
172
171
    unless ( $params->{'categorycode'} && $params->{'categoryname'} ) {
173
    unless ( $params->{'categorycode'} && $params->{'categoryname'} ) {
172
        default("MESSAGE4",$template);
174
        default("MESSAGE4",$template);
173
    }
175
    }
Lines 294-299 sub editcatform { Link Here
294
            categorycode    => $data->{'categorycode'},
296
            categorycode    => $data->{'categorycode'},
295
            categoryname    => $data->{'categoryname'},
297
            categoryname    => $data->{'categoryname'},
296
            codedescription => $data->{'codedescription'},
298
            codedescription => $data->{'codedescription'},
299
            show_in_pulldown => $data->{'show_in_pulldown'},
297
		);
300
		);
298
    }
301
    }
299
	for my $ctype (GetCategoryTypes()) {
302
	for my $ctype (GetCategoryTypes()) {
(-)a/installer/data/mysql/kohastructure.sql (-1 / +3 lines)
Lines 340-346 CREATE TABLE `branchcategories` ( -- information related to library/branch group Link Here
340
  `categoryname` varchar(32), -- name of the library/branch group
340
  `categoryname` varchar(32), -- name of the library/branch group
341
  `codedescription` mediumtext, -- longer description of the library/branch group
341
  `codedescription` mediumtext, -- longer description of the library/branch group
342
  `categorytype` varchar(16), -- says whether this is a search group or a properties group
342
  `categorytype` varchar(16), -- says whether this is a search group or a properties group
343
  PRIMARY KEY  (`categorycode`)
343
  `show_in_pulldown` tinyint(1) NOT NULL DEFAULT '0', -- says this group should be in the opac libararies pulldown if it is enabled
344
  PRIMARY KEY  (`categorycode`),
345
  KEY `show_in_pulldown` (`show_in_pulldown`)
344
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
346
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
345
347
346
--
348
--
(-)a/installer/data/mysql/updatedatabase.pl (+9 lines)
Lines 6486-6491 if ( CheckVersion($DBversion) ) { Link Here
6486
    SetVersion($DBversion);
6486
    SetVersion($DBversion);
6487
}
6487
}
6488
6488
6489
$DBversion = "3.11.00.XXX";
6490
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
6491
    $dbh->do(q{
6492
        ALTER TABLE branchcategories ADD show_in_pulldown BOOLEAN NOT NULL DEFAULT '0',
6493
        ADD INDEX ( show_in_pulldown )
6494
    });
6495
    print "Upgrade to $DBversion done (Bug 9257 - Add groups to normal search pulldown)\n";
6496
    SetVersion ($DBversion);
6497
}
6489
6498
6490
=head1 FUNCTIONS
6499
=head1 FUNCTIONS
6491
6500
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt (+8 lines)
Lines 335-340 tinyMCE.init({ Link Here
335
            [% END %]
335
            [% END %]
336
            </select>
336
            </select>
337
		</li>
337
		</li>
338
        <li>
339
            <label for="show_in_pulldown">Show in search pulldown: </label>
340
            [% IF ( show_in_pulldown ) %]
341
                <input type="checkbox" name="show_in_pulldown" id="show_in_pulldown" checked="checked"/>
342
            [% ELSE %]
343
                <input type="checkbox" name="show_in_pulldown" id="show_in_pulldown" />
344
            [% END %]
345
        </li>
338
		</ol>
346
		</ol>
339
    </fieldset>
347
    </fieldset>
340
	<fieldset class="action"><input type="submit" value="Update" /></fieldset>
348
	<fieldset class="action"><input type="submit" value="Update" /></fieldset>
(-)a/koha-tmpl/opac-tmpl/ccsr/en/includes/masthead.inc (-7 / +22 lines)
Lines 168-180 Link Here
168
        [% ELSE %]
168
        [% ELSE %]
169
            <div id="libraries" class="mobile-hidden">
169
            <div id="libraries" class="mobile-hidden">
170
        [% END %]
170
        [% END %]
171
      <select name="limit" id="select_library" class="left">
171
172
         <option value="">All libraries</option>
172
        <select name="branch_group_limit" id="select_library" class="left">
173
         [% FOREACH BranchesLoo IN BranchesLoop %]
173
           <option value="">All libraries</option>
174
            [% IF ( BranchesLoo.selected ) %]<option selected="selected" value="branch:[% BranchesLoo.value %]">[% BranchesLoo.branchname %]</option>
174
           <optgroup label="Libraries">
175
            [% ELSE %]<option value="branch:[% BranchesLoo.value %]">[% BranchesLoo.branchname %]</option>[% END %]
175
               [% FOREACH BranchesLoo IN BranchesLoop %]
176
         [% END %]
176
                  [% IF ( BranchesLoo.selected ) %]<option selected="selected" value="branch:[% BranchesLoo.value %]">[% BranchesLoo.branchname %]</option>
177
      </select>
177
                  [% ELSE %]<option value="branch:[% BranchesLoo.value %]">[% BranchesLoo.branchname %]</option>[% END %]
178
               [% END %]
179
           </optgroup>
180
           [% IF BranchCategoriesLoop %]
181
               <optgroup label="Groups">
182
                   [% FOREACH bc IN BranchCategoriesLoop %]
183
                       [% IF ( bc.selected ) %]
184
                           <option selected="selected" value="multibranchlimit-[% bc.categorycode %]">[% bc.categoryname %]</option>
185
                       [% ELSE %]
186
                           <option value="multibranchlimit-[% bc.categorycode %]">[% bc.categoryname %]</option>
187
                       [% END %]
188
                   [% END %]
189
               </optgroup>
190
           [% END %]
191
        </select>
192
178
    </div>
193
    </div>
179
   [% ELSE %]
194
   [% ELSE %]
180
      [% IF ( opac_limit_override ) %]
195
      [% IF ( opac_limit_override ) %]
(-)a/koha-tmpl/opac-tmpl/prog/en/includes/masthead.inc (-4 / +17 lines)
Lines 85-95 Link Here
85
        <input type="text" title="Type search term" id = "transl1" name="q" class="left" style="width: 35%; font-size: 111%;"/><div id="translControl"></div>
85
        <input type="text" title="Type search term" id = "transl1" name="q" class="left" style="width: 35%; font-size: 111%;"/><div id="translControl"></div>
86
[% END %]
86
[% END %]
87
   [% IF ( OpacAddMastheadLibraryPulldown ) %]
87
   [% IF ( OpacAddMastheadLibraryPulldown ) %]
88
      <select name="limit" id="select_library" class="left">
88
      <select name="branch_group_limit" id="select_library" class="left">
89
         <option value="">All libraries</option>
89
         <option value="">All libraries</option>
90
         [% FOREACH BranchesLoo IN BranchesLoop %]
90
         <optgroup label="Libraries">
91
            [% IF ( BranchesLoo.selected ) %]<option selected="selected" value="branch:[% BranchesLoo.value %]">[% BranchesLoo.branchname %]</option>
91
             [% FOREACH BranchesLoo IN BranchesLoop %]
92
            [% ELSE %]<option value="branch:[% BranchesLoo.value %]">[% BranchesLoo.branchname %]</option>[% END %]
92
                [% IF ( BranchesLoo.selected ) %]<option selected="selected" value="branch:[% BranchesLoo.value %]">[% BranchesLoo.branchname %]</option>
93
                [% ELSE %]<option value="branch:[% BranchesLoo.value %]">[% BranchesLoo.branchname %]</option>[% END %]
94
             [% END %]
95
         </optgroup>
96
         [% IF BranchCategoriesLoop %]
97
             <optgroup label="Groups">
98
                 [% FOREACH bc IN BranchCategoriesLoop %]
99
                     [% IF ( bc.selected ) %]
100
                         <option selected="selected" value="multibranchlimit-[% bc.categorycode %]">[% bc.categoryname %]</option>
101
                     [% ELSE %]
102
                         <option value="multibranchlimit-[% bc.categorycode %]">[% bc.categoryname %]</option>
103
                     [% END %]
104
                 [% END %]
105
             </optgroup>
93
         [% END %]
106
         [% END %]
94
      </select>
107
      </select>
95
   [% ELSE %]
108
   [% ELSE %]
(-)a/opac/opac-search.pl (-1 / +16 lines)
Lines 63-68 my $DisplayMultiPlaceHold = C4::Context->preference("DisplayMultiPlaceHold"); Link Here
63
use CGI qw('-no_undef_params');
63
use CGI qw('-no_undef_params');
64
my $cgi = new CGI;
64
my $cgi = new CGI;
65
65
66
my $branch_group_limit = $cgi->param("branch_group_limit");
67
if ( $branch_group_limit ) {
68
    if ( $branch_group_limit =~ /^multibranchlimit/ ) {
69
        $cgi->param(
70
            -name => 'multibranchlimit',
71
            -values => [ ( split( 'multibranchlimit-', $branch_group_limit ) )[1] ]
72
        );
73
    } else {
74
        $cgi->append(
75
            -name => 'limit',
76
            -values => [ $branch_group_limit ]
77
        );
78
    }
79
}
80
66
BEGIN {
81
BEGIN {
67
    if (C4::Context->preference('BakerTaylorEnabled')) {
82
    if (C4::Context->preference('BakerTaylorEnabled')) {
68
        require C4::External::BakerTaylor;
83
        require C4::External::BakerTaylor;
Lines 77-82 my $template_name; Link Here
77
my $template_type = 'basic';
92
my $template_type = 'basic';
78
my @params = $cgi->param("limit");
93
my @params = $cgi->param("limit");
79
94
95
80
my $format = $cgi->param("format") || '';
96
my $format = $cgi->param("format") || '';
81
my $build_grouped_results = C4::Context->preference('OPACGroupResults');
97
my $build_grouped_results = C4::Context->preference('OPACGroupResults');
82
if ($format =~ /(rss|atom|opensearchdescription)/) {
98
if ($format =~ /(rss|atom|opensearchdescription)/) {
83
- 

Return to bug 9257