@@ -, +, @@
- 1 to use/not use the validation workflow
- 1 to set the validation framework code
- 1 to set the users with access to the validation framework
- if validation off shows all
- if validation on and framework code is different than validation framework code, shows the framework code
- if validation on and framework code equal to validation framework code and the user have permissions, shows the framework code
- if validation on and framework code equal to validation framework code and the user doesn't have permissions, don't shows the framework code
- prevent any user to use the validation framework (if validation on) when putting the code in the browser URL
- if validation on always set suppress = 1 in framework different than the validating one
---
cataloguing/addbiblio.pl | 25 ++++++++++++++++++--
cataloguing/addbooks.pl | 16 ++++++++++++-
installer/data/mysql/sysprefs.sql | 3 +++
installer/data/mysql/updatedatabase.pl | 8 +++++++
.../en/modules/admin/preferences/cataloguing.pref | 18 ++++++++++++++
5 files changed, 67 insertions(+), 3 deletions(-)
--- a/cataloguing/addbiblio.pl
+++ a/cataloguing/addbiblio.pl
@@ -22,8 +22,9 @@
use strict;
#use warnings; FIXME - Bug 2505
use CGI q(-utf8);
+use CGI::Session;
use C4::Output;
-use C4::Auth;
+use C4::Auth qw/:DEFAULT get_session/;
use C4::Biblio;
use C4::Search;
use C4::AuthoritiesMarc;
@@ -709,6 +710,16 @@ my $fa_branch = $input->param('branch');
my $fa_stickyduedate = $input->param('stickyduedate');
my $fa_duedatespec = $input->param('duedatespec');
+# getting userID
+my $sessionID = $input->cookie("CGISESSID") ;
+my $session = get_session($sessionID);
+my $userid = $session->param('id');
+
+# getting validation variables
+my $validation = C4::Context->preference('CatalogingValidation');
+my $validationframework = C4::Context->preference('CatalogingValidationFramework');
+my %validationusers = map { $_ => 1 } split(/,/,C4::Context->preference('CatalogingValidationUsers'));
+
my $userflags = 'edit_catalogue';
my $changed_framework = $input->param('changed_framework');
@@ -730,6 +741,10 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
}
);
+# Clear the framework code if validation is on and the framework code is equal to validation framework but the user is not authorized to use it
+# Avoid users to user validation framework adding the code to the URL
+$frameworkcode = '' if ($validation && ($frameworkcode eq $validationframework && !$validationusers{$userid}));
+
if ($frameworkcode eq 'FA'){
# We need to grab and set some variables in the template for use on the additems screen
$template->param(
@@ -759,7 +774,11 @@ foreach my $thisframeworkcode ( keys %$frameworks ) {
if ($frameworkcode eq $thisframeworkcode){
$row{'selected'} = 1;
}
- push @frameworkcodeloop, \%row;
+ # Add the framework code if validation is off.
+ # Add the framework code if validation is on, the framework code is equal to validation framework and the user is not authorized to use it
+ if (!$validation || ($validation && ($thisframeworkcode ne $validationframework || ($thisframeworkcode eq $validationframework && $validationusers{$userid})))) {
+ push @frameworkcodeloop, \%row;
+ }
}
$template->param( frameworkcodeloop => \@frameworkcodeloop,
breedingid => $breedingid );
@@ -855,6 +874,8 @@ if ( $op eq "addbiblio" ) {
ModBiblio( $record, $biblionumber, $frameworkcode );
}
else {
+ # force 942$n = 1 when validation is on and isn't validation framework
+ $record->field('942')->update('n' => '1') if ($validation && ($frameworkcode ne $validationframework));
( $biblionumber, $oldbibitemnum ) = AddBiblio( $record, $frameworkcode );
}
if ($redirect eq "items" || ($mode ne "popup" && !$is_a_modif && $redirect ne "view" && $redirect ne "just_save")){
--- a/cataloguing/addbooks.pl
+++ a/cataloguing/addbooks.pl
@@ -27,7 +27,8 @@
use strict;
use warnings;
use CGI qw ( -utf8 );
-use C4::Auth;
+use CGI::Session;
+use C4::Auth qw/:DEFAULT get_session/;
use C4::Biblio;
use C4::Breeding;
use C4::Output;
@@ -36,6 +37,16 @@ use C4::Search;
my $input = new CGI;
+# getting userID
+my $sessionID = $input->cookie("CGISESSID");
+my $session = get_session($sessionID);
+my $userid = $session->param('id');
+
+# getting validation variables
+my $validation = C4::Context->preference('CatalogingValidation');
+my $validationframework = C4::Context->preference('CatalogingValidationFramework');
+my %validationusers = map { $_ => 1 } split(/,/,C4::Context->preference('CatalogingValidationUsers'));
+
my $success = $input->param('biblioitem');
my $query = $input->param('q');
my @value = $input->param('value');
@@ -58,6 +69,9 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
my $frameworks = getframeworks;
my @frameworkcodeloop;
foreach my $thisframeworkcode ( sort { uc($frameworks->{$a}->{'frameworktext'}) cmp uc($frameworks->{$b}->{'frameworktext'}) } keys %{$frameworks} ) {
+ # Add the framework code if validation is off.
+ # Add the framework code if validation is on, the framework code is equal to validation framework and the user is not authorized to use it
+ if (!$validation || ($validation && ($thisframeworkcode ne $validationframework || ($thisframeworkcode eq $validationframework && $validationusers{$userid})))) {
push @frameworkcodeloop, {
value => $thisframeworkcode,
frameworktext => $frameworks->{$thisframeworkcode}->{'frameworktext'},
--- a/installer/data/mysql/sysprefs.sql
+++ a/installer/data/mysql/sysprefs.sql
@@ -87,6 +87,9 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `
('casServerUrl','https://localhost:8443/cas','','URL of the cas server','Free'),
('CatalogModuleRelink','0',NULL,'If OFF the linker will never replace the authids that are set in the cataloging module.','YesNo'),
('CataloguingLog','1',NULL,'If ON, log edit/create/delete actions on bibliographic data. WARNING: this feature is very resource consuming.','YesNo'),
+('CatalogingValidation','0',NULL,'Active cataloging validation','YesNo');
+('CatalogingValidationFramework','',NULL,'Cataloging validation framework','long');
+('CatalogingValidationUsers','',NULL,'Cataloging validation users','long');
('checkdigit','none','none|katipo','If ON, enable checks on patron cardnumber: none or \"Katipo\" style checks','Choice'),
('CircAutocompl','1',NULL,'If ON, autocompletion is enabled for the Circulation input','YesNo'),
('CircAutoPrintQuickSlip','qslip',NULL,'Choose what should happen when an empty barcode field is submitted in circulation: Display a print quick slip window, Display a print slip window or Clear the screen.','Choice'),
--- a/installer/data/mysql/updatedatabase.pl
+++ a/installer/data/mysql/updatedatabase.pl
@@ -6697,6 +6697,14 @@ if ( CheckVersion($DBversion) ) {
");
print "Upgrade to $DBversion done (Bug 7804: Added plugin system.)\n";
+}
+
+$DBversion = '3.11.00.XXX';
+if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
+ $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('CatalogingValidation', '0','Active cataloging validation',NULL,'YesNo');");
+ $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('CatalogingValidationFramework','','Cataloging validation framework',NULL,'long');");
+ $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('CatalogingValidationUsers', '','Cataloging validation users',NULL,'long');");
+ print "Upgrade to $DBversion done (Bug 9163 - Cataloguing validation workflow)\n";
SetVersion($DBversion);
}
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref
@@ -247,3 +247,21 @@ Cataloging:
- "All values of repeating tags and subfields will be printed with the given RIS tag."
- "
"
- "Use of TY ( record type ) as a key will replace the default TY with the field value of your choosing."
+ Validation:
+ -
+ - pref: CatalogingValidation
+ choices:
+ yes: Use
+ no: "Don't use"
+ - "cataloging validation. This allows some users to use a special MARC framework (only visible to them) to validate and put the record online in OPAC.
"
+ - "NOTE:
- All MARC frameworks except the validation framework (set in CatalogingValidationFramework) needs to have the suppress subfield hidden.
- The validation framework needs to have suppress subfield visible.
- The system preference OPACSuppresion needs to be on.
- The users with access to the validation framework are set in CatalogingValidationUsers."
+ -
+ - "Code of the validation framework:"
+ - pref: CatalogingValidationFramework
+ class: long
+ - "
NOTE:
- CatalogingValidation needs to be on.
- The framework needs to be created in the MARC frameworks administration panel.
- The framework needs to have suppress subfield visible."
+ -
+ - "The following users (list comma separated) will have access to validation framework:"
+ - pref: CatalogingValidationUsers
+ class: long
+ - "
NOTE:
- CatalogingValidation needs to be on."
--