Bugzilla – Attachment 67617 Details for
Bug 12227
Remove demo user functionality
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 12227: Remove the demo functionality
Bug-12227-Remove-the-demo-functionality.patch (text/plain), 18.49 KB, created by
Alex Buckley
on 2017-10-04 21:06:30 UTC
(
hide
)
Description:
Bug 12227: Remove the demo functionality
Filename:
MIME Type:
Creator:
Alex Buckley
Created:
2017-10-04 21:06:30 UTC
Size:
18.49 KB
patch
obsolete
>From 5bc665e03eb6161369c5dd9aded27c60bdbc2d0f Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >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 <alexbuckley@catalyst.net.nz> >--- > 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 | 104 ++++++++++++++++++-------------------- > admin/marctagstructure.pl | 76 +++++++++++++--------------- > admin/preferences.pl | 12 ++--- > admin/systempreferences.pl | 5 +- > 8 files changed, 119 insertions(+), 164 deletions(-) > >diff --git a/C4/Auth.pm b/C4/Auth.pm >index d22e935..27e62e9 100644 >--- a/C4/Auth.pm >+++ b/C4/Auth.pm >@@ -1886,15 +1886,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; > } > >@@ -2051,11 +2042,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 9c6795f..92d5d98 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 37249e6..1440859 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 ddf163a..c2b0762 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 077a58b..bdd1ceb 100755 >--- a/admin/marc_subfields_structure.pl >+++ b/admin/marc_subfields_structure.pl >@@ -281,56 +281,53 @@ 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 { >- $sth_insert->execute( >- $tagfield, >- $tagsubfield, >- $liblibrarian, >- $libopac, >- $repeatable, >- $mandatory, >- $kohafield, >- $tab, >- $seealso, >- $authorised_value, >- $authtypecode, >- $value_builder, >- $hidden, >- $isurl, >- $frameworkcode, >- $link, >- $defaultvalue, >- $maxlength, >- ); >- } >+ ), >+ ); >+ } else { >+ $sth_insert->execute( >+ $tagfield, >+ $tagsubfield, >+ $liblibrarian, >+ $libopac, >+ $repeatable, >+ $mandatory, >+ $kohafield, >+ $tab, >+ $seealso, >+ $authorised_value, >+ $authtypecode, >+ $value_builder, >+ $hidden, >+ $isurl, >+ $frameworkcode, >+ $link, >+ $defaultvalue, >+ $maxlength, >+ ); > } > } > } >@@ -373,15 +370,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-$frameworkcode"); >diff --git a/admin/marctagstructure.pl b/admin/marctagstructure.pl >index 4800b34..5a23a5a 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-$frameworkcode"); >- $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-$frameworkcode"); >+ $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-$frameworkcode"); >- $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-$frameworkcode"); >+ $cache->clear_from_cache("MarcSubfieldStructure-$frameworkcode"); > $template->param( > searchfield => $searchfield, > frameworkcode => $frameworkcode, >diff --git a/admin/preferences.pl b/admin/preferences.pl >index 032789f..1e12b1e 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 67e0638..511d726 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.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 12227
:
67407
|
67617
|
68837