From 53594885286620afd8b96bf1b77fa8c54a5ac4c3 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 27 Sep 2017 14:30:20 -0300 Subject: [PATCH] Bug 12227: Remove the demo functionality This is a legacy mode that did not really work. Test plan: Play with frameworks and sysprefs and confirm the changes (add/del/update) are taken into account. Signed-off-by: Alex Buckley Signed-off-by: Kyle M Hall Signed-off-by: Jonathan Druart --- C4/Auth.pm | 14 ---- C4/InstallAuth.pm | 10 --- admin/auth_subfields_structure.pl | 8 +-- admin/auth_tag_structure.pl | 54 +++++++------- admin/marc_subfields_structure.pl | 112 ++++++++++++++---------------- admin/marctagstructure.pl | 76 ++++++++++---------- admin/preferences.pl | 12 ++-- admin/systempreferences.pl | 5 +- 8 files changed, 123 insertions(+), 168 deletions(-) diff --git a/C4/Auth.pm b/C4/Auth.pm index bf1457e1ed..67bdd7e751 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -1887,15 +1887,6 @@ sub checkpw_internal { return 1, $cardnumber, $userid; } } - if ( $userid && $userid eq 'demo' - && "$password" eq 'demo' - && C4::Context->config('demo') ) - { - - # DEMO => the demo user is allowed to do everything (if demo set to 1 in koha.conf - # some features won't be effective : modify systempref, modify MARC structure, - return 2; - } return 0; } @@ -2052,11 +2043,6 @@ sub haspermission { # Super User Account from /etc/koha.conf $flags->{'superlibrarian'} = 1; } - elsif ( $userid eq 'demo' && C4::Context->config('demo') ) { - - # Demo user that can do "anything" (demo=1 in /etc/koha.conf) - $flags->{'superlibrarian'} = 1; - } return $flags if $flags->{superlibrarian}; diff --git a/C4/InstallAuth.pm b/C4/InstallAuth.pm index 9c6795f829..92d5d9820a 100644 --- a/C4/InstallAuth.pm +++ b/C4/InstallAuth.pm @@ -419,16 +419,6 @@ sub checkpw { ); return 2; } - if ( $userid - && $userid eq 'demo' - && "$password" eq 'demo' - && C4::Context->config('demo') ) - { - -# DEMO => the demo user is allowed to do everything (if demo set to 1 in koha.conf -# some features won't be effective : modify systempref, modify MARC structure, - return 2; - } return 0; } diff --git a/admin/auth_subfields_structure.pl b/admin/auth_subfields_structure.pl index 37249e6826..14408594f3 100755 --- a/admin/auth_subfields_structure.pl +++ b/admin/auth_subfields_structure.pl @@ -224,7 +224,6 @@ if ($op eq 'add_form') { my $hidden = $ohidden[$i]; #collate from 3 hiddens; my $isurl = $input->param("isurl$i")?1:0; if ($liblibrarian) { - unless (C4::Context->config('demo') or C4::Context->config('demo') eq 1) { if (auth_subfield_structure_exists($authtypecode, $tagfield, $tagsubfield)) { $sth_update->execute( $authtypecode, @@ -269,7 +268,6 @@ if ($op eq 'add_form') { $defaultvalue, ); } - } } } print $input->redirect("/cgi-bin/koha/admin/auth_subfields_structure.pl?tagfield=$tagfield&authtypecode=$authtypecode"); @@ -293,10 +291,8 @@ if ($op eq 'add_form') { ################## DELETE_CONFIRMED ################################## # called by delete_confirm, used to effectively confirm deletion of data in DB } elsif ($op eq 'delete_confirmed') { - unless (C4::Context->config('demo') or C4::Context->config('demo') eq 1) { - my $sth=$dbh->prepare("delete from auth_subfield_structure where tagfield=? and tagsubfield=? and authtypecode=?"); - $sth->execute($tagfield,$tagsubfield,$authtypecode); - } + my $sth=$dbh->prepare("delete from auth_subfield_structure where tagfield=? and tagsubfield=? and authtypecode=?"); + $sth->execute($tagfield,$tagsubfield,$authtypecode); print $input->redirect("/cgi-bin/koha/admin/auth_subfields_structure.pl?tagfield=$tagfield&authtypecode=$authtypecode"); exit; # END $OP eq DELETE_CONFIRMED diff --git a/admin/auth_tag_structure.pl b/admin/auth_tag_structure.pl index ddf163acbc..c2b07621e6 100755 --- a/admin/auth_tag_structure.pl +++ b/admin/auth_tag_structure.pl @@ -117,31 +117,29 @@ if ($op eq 'add_form') { my $repeatable = $input->param('repeatable') ? 1 : 0; my $mandatory = $input->param('mandatory') ? 1 : 0; my $authorised_value = $input->param('authorised_value'); - unless (C4::Context->config('demo') eq 1) { - if ($input->param('modif')) { - $sth=$dbh->prepare("UPDATE auth_tag_structure SET tagfield=?, liblibrarian=?, libopac=?, repeatable=?, mandatory=?, authorised_value=? WHERE authtypecode=? AND tagfield=?"); - $sth->execute( - $tagfield, - $liblibrarian, - $libopac, - $repeatable, - $mandatory, - $authorised_value, - $authtypecode, - $tagfield, - ); - } else { - $sth=$dbh->prepare("INSERT INTO auth_tag_structure (tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value,authtypecode) VALUES (?,?,?,?,?,?,?)"); - $sth->execute( - $tagfield, - $liblibrarian, - $libopac, - $repeatable, - $mandatory, - $authorised_value, - $authtypecode - ); - } + if ($input->param('modif')) { + $sth=$dbh->prepare("UPDATE auth_tag_structure SET tagfield=?, liblibrarian=?, libopac=?, repeatable=?, mandatory=?, authorised_value=? WHERE authtypecode=? AND tagfield=?"); + $sth->execute( + $tagfield, + $liblibrarian, + $libopac, + $repeatable, + $mandatory, + $authorised_value, + $authtypecode, + $tagfield, + ); + } else { + $sth=$dbh->prepare("INSERT INTO auth_tag_structure (tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value,authtypecode) VALUES (?,?,?,?,?,?,?)"); + $sth->execute( + $tagfield, + $liblibrarian, + $libopac, + $repeatable, + $mandatory, + $authorised_value, + $authtypecode + ); } print $input->redirect("/cgi-bin/koha/admin/auth_tag_structure.pl?searchfield=$tagfield&authtypecode=$authtypecode"); exit; @@ -160,10 +158,8 @@ if ($op eq 'add_form') { ################## DELETE_CONFIRMED ################################## # called by delete_confirm, used to effectively confirm deletion of data in DB } elsif ($op eq 'delete_confirmed') { - unless (C4::Context->config('demo') eq 1) { - $dbh->do(q|delete from auth_tag_structure where tagfield=? and authtypecode=?|, undef, $searchfield, $authtypecode); - $dbh->do(q|delete from auth_subfield_structure where tagfield=? and authtypecode=?|, undef, $searchfield, $authtypecode); - } + $dbh->do(q|delete from auth_tag_structure where tagfield=? and authtypecode=?|, undef, $searchfield, $authtypecode); + $dbh->do(q|delete from auth_subfield_structure where tagfield=? and authtypecode=?|, undef, $searchfield, $authtypecode); my $tagfield = $input->param('tagfield'); print $input->redirect("/cgi-bin/koha/admin/auth_tag_structure.pl?searchfield=$tagfield&authtypecode=$authtypecode"); exit; diff --git a/admin/marc_subfields_structure.pl b/admin/marc_subfields_structure.pl index 9b478fa661..eeef468398 100755 --- a/admin/marc_subfields_structure.pl +++ b/admin/marc_subfields_structure.pl @@ -281,61 +281,58 @@ elsif ( $op eq 'add_validate' ) { my $maxlength = $maxlength[$i] ? $maxlength[$i] : 9999; if (defined($liblibrarian) && $liblibrarian ne "") { - my $is_demo = C4::Context->config('demo') || ''; - if ( $is_demo ne '1' ) { - if (marc_subfield_structure_exists($tagfield, $tagsubfield, $frameworkcode)) { - $sth_update->execute( + if (marc_subfield_structure_exists($tagfield, $tagsubfield, $frameworkcode)) { + $sth_update->execute( + $tagfield, + $tagsubfield, + $liblibrarian, + $libopac, + $repeatable, + $mandatory, + $kohafield, + $tab, + $seealso, + $authorised_value, + $authtypecode, + $value_builder, + $hidden, + $isurl, + $frameworkcode, + $link, + $defaultvalue, + $maxlength, + ( $tagfield, $tagsubfield, - $liblibrarian, - $libopac, - $repeatable, - $mandatory, - $kohafield, - $tab, - $seealso, - $authorised_value, - $authtypecode, - $value_builder, - $hidden, - $isurl, $frameworkcode, - $link, - $defaultvalue, - $maxlength, - ( - $tagfield, - $tagsubfield, - $frameworkcode, - ), - ); - } else { - if( $frameworkcode ne q{} ) { - # BZ 19096: Overwrite kohafield from Default when adding a new record - my $rec = Koha::MarcSubfieldStructures->find( q{}, $tagfield, $tagsubfield ); - $kohafield = $rec->kohafield if $rec; - } - $sth_insert->execute( - $tagfield, - $tagsubfield, - $liblibrarian, - $libopac, - $repeatable, - $mandatory, - $kohafield, - $tab, - $seealso, - $authorised_value, - $authtypecode, - $value_builder, - $hidden, - $isurl, - $frameworkcode, - $link, - $defaultvalue, - $maxlength, - ); + ) + ); + } else { + if( $frameworkcode ne q{} ) { + # BZ 19096: Overwrite kohafield from Default when adding a new record + my $rec = Koha::MarcSubfieldStructures->find( q{}, $tagfield, $tagsubfield ); + $kohafield = $rec->kohafield if $rec; } + $sth_insert->execute( + $tagfield, + $tagsubfield, + $liblibrarian, + $libopac, + $repeatable, + $mandatory, + $kohafield, + $tab, + $seealso, + $authorised_value, + $authtypecode, + $value_builder, + $hidden, + $isurl, + $frameworkcode, + $link, + $defaultvalue, + $maxlength, + ); } } } @@ -378,15 +375,12 @@ elsif ( $op eq 'delete_confirm' ) { } elsif ( $op eq 'delete_confirmed' ) { my $dbh = C4::Context->dbh; - my $is_demo = C4::Context->config('demo') || ''; - if ( $is_demo ne '1' ) { - my $sth = - $dbh->prepare( + my $sth = + $dbh->prepare( "delete from marc_subfield_structure where tagfield=? and tagsubfield=? and frameworkcode=?" - ); - $sth->execute( $tagfield, $tagsubfield, $frameworkcode ); - $sth->finish; - } + ); + $sth->execute( $tagfield, $tagsubfield, $frameworkcode ); + $sth->finish; $cache->clear_from_cache("MarcStructure-0-$frameworkcode"); $cache->clear_from_cache("MarcStructure-1-$frameworkcode"); $cache->clear_from_cache("default_value_for_mod_marc-"); diff --git a/admin/marctagstructure.pl b/admin/marctagstructure.pl index 97f96f1933..e7d6b74398 100755 --- a/admin/marctagstructure.pl +++ b/admin/marctagstructure.pl @@ -121,37 +121,35 @@ if ($op eq 'add_form') { my $repeatable = $input->param('repeatable') ? 1 : 0; my $mandatory = $input->param('mandatory') ? 1 : 0; my $authorised_value = $input->param('authorised_value'); - unless (C4::Context->config('demo')) { - if ($input->param('modif')) { - $sth = $dbh->prepare( - "UPDATE marc_tag_structure SET liblibrarian=? ,libopac=? ,repeatable=? ,mandatory=? ,authorised_value=? WHERE frameworkcode=? AND tagfield=?" - ); - $sth->execute( $liblibrarian, - $libopac, - $repeatable, - $mandatory, - $authorised_value, - $frameworkcode, - $tagfield - ); - } else { - $sth = $dbh->prepare( - "INSERT INTO marc_tag_structure (tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value,frameworkcode) values (?,?,?,?,?,?,?)" - ); - $sth->execute($tagfield, - $liblibrarian, - $libopac, - $repeatable, - $mandatory, - $authorised_value, - $frameworkcode - ); - } - $cache->clear_from_cache("MarcStructure-0-$frameworkcode"); - $cache->clear_from_cache("MarcStructure-1-$frameworkcode"); - $cache->clear_from_cache("default_value_for_mod_marc-"); - $cache->clear_from_cache("MarcSubfieldStructure-$frameworkcode"); + if ($input->param('modif')) { + $sth = $dbh->prepare( + "UPDATE marc_tag_structure SET liblibrarian=? ,libopac=? ,repeatable=? ,mandatory=? ,authorised_value=? WHERE frameworkcode=? AND tagfield=?" + ); + $sth->execute( $liblibrarian, + $libopac, + $repeatable, + $mandatory, + $authorised_value, + $frameworkcode, + $tagfield + ); + } else { + $sth = $dbh->prepare( + "INSERT INTO marc_tag_structure (tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value,frameworkcode) values (?,?,?,?,?,?,?)" + ); + $sth->execute($tagfield, + $liblibrarian, + $libopac, + $repeatable, + $mandatory, + $authorised_value, + $frameworkcode + ); } + $cache->clear_from_cache("MarcStructure-0-$frameworkcode"); + $cache->clear_from_cache("MarcStructure-1-$frameworkcode"); + $cache->clear_from_cache("default_value_for_mod_marc-"); + $cache->clear_from_cache("MarcSubfieldStructure-$frameworkcode"); print $input->redirect("/cgi-bin/koha/admin/marctagstructure.pl?searchfield=$tagfield&frameworkcode=$frameworkcode"); exit; # END $OP eq ADD_VALIDATE @@ -170,16 +168,14 @@ if ($op eq 'add_form') { ################## DELETE_CONFIRMED ################################## # called by delete_confirm, used to effectively confirm deletion of data in DB } elsif ($op eq 'delete_confirmed') { - unless (C4::Context->config('demo')) { - my $sth1 = $dbh->prepare("DELETE FROM marc_tag_structure WHERE tagfield=? AND frameworkcode=?"); - my $sth2 = $dbh->prepare("DELETE FROM marc_subfield_structure WHERE tagfield=? AND frameworkcode=?"); - $sth1->execute($searchfield, $frameworkcode); - $sth2->execute($searchfield, $frameworkcode); - $cache->clear_from_cache("MarcStructure-0-$frameworkcode"); - $cache->clear_from_cache("MarcStructure-1-$frameworkcode"); - $cache->clear_from_cache("default_value_for_mod_marc-"); - $cache->clear_from_cache("MarcSubfieldStructure-$frameworkcode"); - } + my $sth1 = $dbh->prepare("DELETE FROM marc_tag_structure WHERE tagfield=? AND frameworkcode=?"); + my $sth2 = $dbh->prepare("DELETE FROM marc_subfield_structure WHERE tagfield=? AND frameworkcode=?"); + $sth1->execute($searchfield, $frameworkcode); + $sth2->execute($searchfield, $frameworkcode); + $cache->clear_from_cache("MarcStructure-0-$frameworkcode"); + $cache->clear_from_cache("MarcStructure-1-$frameworkcode"); + $cache->clear_from_cache("default_value_for_mod_marc-"); + $cache->clear_from_cache("MarcSubfieldStructure-$frameworkcode"); $template->param( searchfield => $searchfield, frameworkcode => $frameworkcode, diff --git a/admin/preferences.pl b/admin/preferences.pl index 032789fb82..1e12b1e9a0 100755 --- a/admin/preferences.pl +++ b/admin/preferences.pl @@ -314,16 +314,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 ); diff --git a/admin/systempreferences.pl b/admin/systempreferences.pl index 67e063895b..511d726b5c 100755 --- a/admin/systempreferences.pl +++ b/admin/systempreferences.pl @@ -276,7 +276,7 @@ if ( $op eq 'update_and_reedit' ) { } } my $variable = $input->param('variable'); - C4::Context->set_preference($variable, $value) unless C4::Context->config('demo'); + C4::Context->set_preference($variable, $value); } ################## ADD_FORM ################################## @@ -335,8 +335,7 @@ if ( $op eq 'add_form' ) { $value = encode_base64($value); } - C4::Context->set_preference( $variable, $value, $expl, $type, $options ) - unless C4::Context->config('demo'); + C4::Context->set_preference( $variable, $value, $expl, $type, $options ); print $input->redirect("/cgi-bin/koha/admin/systempreferences.pl?tab="); exit; ################## DELETE_CONFIRM ################################## -- 2.39.5