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

(-)a/C4/Auth.pm (-4 / +7 lines)
Lines 385-390 sub get_template_and_user { Link Here
385
        my $opac_name = '';
385
        my $opac_name = '';
386
        if (($opac_search_limit && $opac_search_limit =~ /branch:(\w+)/ && $opac_limit_override) || ($in->{'query'}->param('limit') && $in->{'query'}->param('limit') =~ /branch:(\w+)/)){
386
        if (($opac_search_limit && $opac_search_limit =~ /branch:(\w+)/ && $opac_limit_override) || ($in->{'query'}->param('limit') && $in->{'query'}->param('limit') =~ /branch:(\w+)/)){
387
            $opac_name = $1;   # opac_search_limit is a branch, so we use it.
387
            $opac_name = $1;   # opac_search_limit is a branch, so we use it.
388
        } elsif ( $in->{'query'}->param('multibranchlimit') ) {
389
            $opac_name = $in->{'query'}->param('multibranchlimit');
388
        } elsif (C4::Context->preference("SearchMyLibraryFirst") && C4::Context->userenv && C4::Context->userenv->{'branch'}) {
390
        } elsif (C4::Context->preference("SearchMyLibraryFirst") && C4::Context->userenv && C4::Context->userenv->{'branch'}) {
389
            $opac_name = C4::Context->userenv->{'branch'};
391
            $opac_name = C4::Context->userenv->{'branch'};
390
        }
392
        }
Lines 393-405 sub get_template_and_user { Link Here
393
            AnonSuggestions           => "" . C4::Context->preference("AnonSuggestions"),
395
            AnonSuggestions           => "" . C4::Context->preference("AnonSuggestions"),
394
            AuthorisedValueImages     => C4::Context->preference("AuthorisedValueImages"),
396
            AuthorisedValueImages     => C4::Context->preference("AuthorisedValueImages"),
395
            BranchesLoop              => GetBranchesLoop($opac_name),
397
            BranchesLoop              => GetBranchesLoop($opac_name),
396
            CalendarFirstDayOfWeek      => (C4::Context->preference("CalendarFirstDayOfWeek") eq "Sunday")?0:1,
398
            BranchCategoriesLoop      => GetBranchCategories( undef, undef, 1, $opac_name ),
399
            CalendarFirstDayOfWeek    => (C4::Context->preference("CalendarFirstDayOfWeek") eq "Sunday")?0:1,
397
            LibraryName               => "" . C4::Context->preference("LibraryName"),
400
            LibraryName               => "" . C4::Context->preference("LibraryName"),
398
            LibraryNameTitle          => "" . $LibraryNameTitle,
401
            LibraryNameTitle          => "" . $LibraryNameTitle,
399
            LoginBranchname           => C4::Context->userenv?C4::Context->userenv->{"branchname"}:"",
402
            LoginBranchname           => C4::Context->userenv?C4::Context->userenv->{"branchname"}:"",
400
            OPACAmazonCoverImages     => C4::Context->preference("OPACAmazonCoverImages"),
403
            OPACAmazonCoverImages     => C4::Context->preference("OPACAmazonCoverImages"),
401
            OPACFRBRizeEditions       => C4::Context->preference("OPACFRBRizeEditions"),
404
            OPACFRBRizeEditions       => C4::Context->preference("OPACFRBRizeEditions"),
402
            OpacHighlightedWords       => C4::Context->preference("OpacHighlightedWords"),
405
            OpacHighlightedWords      => C4::Context->preference("OpacHighlightedWords"),
403
            OPACItemHolds             => C4::Context->preference("OPACItemHolds"),
406
            OPACItemHolds             => C4::Context->preference("OPACItemHolds"),
404
            OPACShelfBrowser          => "". C4::Context->preference("OPACShelfBrowser"),
407
            OPACShelfBrowser          => "". C4::Context->preference("OPACShelfBrowser"),
405
            OpacShowRecentComments    => C4::Context->preference("OpacShowRecentComments"),
408
            OpacShowRecentComments    => C4::Context->preference("OpacShowRecentComments"),
Lines 410-416 sub get_template_and_user { Link Here
410
            OpacAuthorities           => C4::Context->preference("OpacAuthorities"),
413
            OpacAuthorities           => C4::Context->preference("OpacAuthorities"),
411
            OPACBaseURL               => ($in->{'query'}->https() ? "https://" : "http://") . $ENV{'SERVER_NAME'} .
414
            OPACBaseURL               => ($in->{'query'}->https() ? "https://" : "http://") . $ENV{'SERVER_NAME'} .
412
                   ($ENV{'SERVER_PORT'} eq ($in->{'query'}->https() ? "443" : "80") ? '' : ":$ENV{'SERVER_PORT'}"),
415
                   ($ENV{'SERVER_PORT'} eq ($in->{'query'}->https() ? "443" : "80") ? '' : ":$ENV{'SERVER_PORT'}"),
413
            opac_css_override           => $ENV{'OPAC_CSS_OVERRIDE'},
416
            opac_css_override         => $ENV{'OPAC_CSS_OVERRIDE'},
414
            opac_search_limit         => $opac_search_limit,
417
            opac_search_limit         => $opac_search_limit,
415
            opac_limit_override       => $opac_limit_override,
418
            opac_limit_override       => $opac_limit_override,
416
            OpacBrowser               => C4::Context->preference("OpacBrowser"),
419
            OpacBrowser               => C4::Context->preference("OpacBrowser"),
Lines 424-430 sub get_template_and_user { Link Here
424
            OpacNavRight              => "" . C4::Context->preference("OpacNavRight"),
427
            OpacNavRight              => "" . C4::Context->preference("OpacNavRight"),
425
            OpacNavBottom             => "" . C4::Context->preference("OpacNavBottom"),
428
            OpacNavBottom             => "" . C4::Context->preference("OpacNavBottom"),
426
            OpacPasswordChange        => C4::Context->preference("OpacPasswordChange"),
429
            OpacPasswordChange        => C4::Context->preference("OpacPasswordChange"),
427
            OPACPatronDetails        => C4::Context->preference("OPACPatronDetails"),
430
            OPACPatronDetails         => C4::Context->preference("OPACPatronDetails"),
428
            OPACPrivacy               => C4::Context->preference("OPACPrivacy"),
431
            OPACPrivacy               => C4::Context->preference("OPACPrivacy"),
429
            OPACFinesTab              => C4::Context->preference("OPACFinesTab"),
432
            OPACFinesTab              => C4::Context->preference("OPACFinesTab"),
430
            OpacTopissue              => C4::Context->preference("OpacTopissue"),
433
            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 6399-6404 if ( CheckVersion($DBversion) ) { Link Here
6399
    SetVersion($DBversion);
6399
    SetVersion($DBversion);
6400
}
6400
}
6401
6401
6402
$DBversion = "3.11.00.XXX";
6403
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
6404
    $dbh->do(q{
6405
        ALTER TABLE branchcategories ADD show_in_pulldown BOOLEAN NOT NULL DEFAULT '0',
6406
        ADD INDEX ( show_in_pulldown )
6407
    });
6408
    print "Upgrade to $DBversion done (Bug 9257 - Add "groups" to normal search pulldown)\n";
6409
    SetVersion ($DBversion);
6410
}
6402
6411
6403
=head1 FUNCTIONS
6412
=head1 FUNCTIONS
6404
6413
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt (+8 lines)
Lines 346-351 tinyMCE.init({ Link Here
346
            [% END %]
346
            [% END %]
347
            </select>
347
            </select>
348
		</li>
348
		</li>
349
        <li>
350
            <label for="show_in_pulldown">Show in search pulldown: </label>
351
            [% IF ( show_in_pulldown ) %]
352
                <input type="checkbox" name="show_in_pulldown" id="show_in_pulldown" checked="checked"/>
353
            [% ELSE %]
354
                <input type="checkbox" name="show_in_pulldown" id="show_in_pulldown" />
355
            [% END %]
356
        </li>
349
		</ol>
357
		</ol>
350
    </fieldset>
358
    </fieldset>
351
	<fieldset class="action"><input type="submit" value="Update" /></fieldset>
359
	<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 77-87 Link Here
77
        <input type="text" title="Type search term" id = "transl1" name="q" class="left" style="width: 35%; font-size: 111%;"/><div id="translControl"></div>
77
        <input type="text" title="Type search term" id = "transl1" name="q" class="left" style="width: 35%; font-size: 111%;"/><div id="translControl"></div>
78
[% END %]
78
[% END %]
79
   [% IF ( OpacAddMastheadLibraryPulldown ) %]
79
   [% IF ( OpacAddMastheadLibraryPulldown ) %]
80
      <select name="limit" id="select_library" class="left">
80
      <select name="branch_group_limit" id="select_library" class="left">
81
         <option value="">All libraries</option>
81
         <option value="">All libraries</option>
82
         [% FOREACH BranchesLoo IN BranchesLoop %]
82
         <optgroup label="Libraries">
83
            [% IF ( BranchesLoo.selected ) %]<option selected="selected" value="branch:[% BranchesLoo.value %]">[% BranchesLoo.branchname %]</option>
83
             [% FOREACH BranchesLoo IN BranchesLoop %]
84
            [% ELSE %]<option value="branch:[% BranchesLoo.value %]">[% BranchesLoo.branchname %]</option>[% END %]
84
                [% IF ( BranchesLoo.selected ) %]<option selected="selected" value="branch:[% BranchesLoo.value %]">[% BranchesLoo.branchname %]</option>
85
                [% ELSE %]<option value="branch:[% BranchesLoo.value %]">[% BranchesLoo.branchname %]</option>[% END %]
86
             [% END %]
87
         </optgroup>
88
         [% IF BranchCategoriesLoop %]
89
             <optgroup label="Groups">
90
                 [% FOREACH bc IN BranchCategoriesLoop %]
91
                     [% IF ( bc.selected ) %]
92
                         <option selected="selected" value="multibranchlimit-[% bc.categorycode %]">[% bc.categoryname %]</option>
93
                     [% ELSE %]
94
                         <option value="multibranchlimit-[% bc.categorycode %]">[% bc.categoryname %]</option>
95
                     [% END %]
96
                 [% END %]
97
             </optgroup>
85
         [% END %]
98
         [% END %]
86
      </select>
99
      </select>
87
   [% ELSE %]
100
   [% 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