Bug 21890: Allow restricting password resets by patron category
[srvgit] / admin / preferences.pl
index 032789f..92c5bbe 100755 (executable)
@@ -35,7 +35,6 @@ use YAML::Syck qw();
 use List::MoreUtils qw(any);
 $YAML::Syck::ImplicitTyping = 1;
 $YAML::Syck::ImplicitUnicode = 1;
-our $lang;
 
 # use Smart::Comments;
 #
@@ -62,7 +61,9 @@ sub _get_chunk {
 
     my $name = $options{'pref'};
     my $chunk = { name => $name, value => $value, type => $options{'type'} || 'input', class => $options{'class'} };
-
+    if( $options{'syntax'} ){
+        $chunk->{'syntax'} = $options{'syntax'};
+    }
     if ( $options{'class'} && $options{'class'} eq 'password' ) {
         $chunk->{'input_type'} = 'password';
     } elsif ( $options{'class'} && $options{'class'} eq 'date' ) {
@@ -81,7 +82,7 @@ sub _get_chunk {
             $interface = 'intranet';
             $theme     = C4::Context->preference('template');
         }
-        $chunk->{'languages'} = getTranslatedLanguages( $interface, $theme, $lang, $current_languages );
+        $chunk->{'languages'} = getTranslatedLanguages( $interface, $theme, undef, $current_languages );
         $chunk->{'type'} = 'languages';
     } elsif ( $options{ 'choices' } ) {
         if ( $options{'choices'} && ref( $options{ 'choices' } ) eq '' ) {
@@ -229,7 +230,8 @@ sub SearchPrefs {
     our @terms = split( /\s+/, $searchfield );
 
     foreach my $tab_name ( keys %tab_files ) {
-        my $data = GetTab( $input, $tab_name );
+        # Force list context to remove 'uninitialized value in goto' warn coming from YAML::Syck; note that the other GetTab call is in list context too. The actual cause however is the null value for the pref OpacRenewalBranch in opac.pref
+        my ($data) = GetTab( $input, $tab_name );
         my $title = ( keys( %$data ) )[0];
         my $tab = $data->{ $title };
         $tab = { '' => $tab } if ( ref( $tab ) eq 'ARRAY' );
@@ -300,12 +302,11 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
         query           => $input,
         type            => "intranet",
         authnotrequired => 0,
-        flagsrequired   => { parameters => 'parameters_remaining_permissions' },
+        flagsrequired   => { parameters => 'manage_sysprefs' },
         debug           => 1,
     }
 );
 
-$lang = $template->param( 'lang' );
 my $op = $input->param( 'op' ) || '';
 my $tab = $input->param( 'tab' );
 $tab ||= 'acquisitions'; # Ideally this should be "local-use" but preferences.pl
@@ -314,16 +315,14 @@ $tab ||= 'acquisitions'; # Ideally this should be "local-use" but preferences.pl
 my $highlighted;
 
 if ( $op eq 'save' ) {
-    unless ( C4::Context->config( 'demo' ) ) {
-        foreach my $param ( $input->param() ) {
-            my ( $pref ) = ( $param =~ /pref_(.*)/ );
+    foreach my $param ( $input->param() ) {
+        my ( $pref ) = ( $param =~ /pref_(.*)/ );
 
-            next if ( !defined( $pref ) );
+        next if ( !defined( $pref ) );
 
-            my $value = join( ',', $input->param( $param ) );
+        my $value = join( ',', $input->param( $param ) );
 
-            C4::Context->set_preference( $pref, $value );
-        }
+        C4::Context->set_preference( $pref, $value );
     }
 
     print $input->redirect( '/cgi-bin/koha/admin/preferences.pl?tab=' . $tab );