bug 2235: fix various data-corrupting bugs in MARC editor
[koha_fer] / admin / systempreferences.pl
index 6a1ed4d..db96845 100755 (executable)
@@ -47,19 +47,29 @@ use C4::Context;
 use C4::Koha;
 use C4::Languages qw(getTranslatedLanguages);
 use C4::ClassSource;
+use C4::Log;
 use C4::Output;
-use C4::Context;
 
 # use Smart::Comments;
 
 
 # FIXME, shouldnt we store this stuff in the systempreferences table? 
 
+# FIXME: This uses hash in a backwards way.  What we really want is:
+#              $tabsysprefs{key} = $array_ref;
+#                              like
+#              $tabsysprefs{Cataloguing} = [qw(autoBarcode ISBD marc ...)];
+#
+#      Because some things *should* be on more than one tab.
+#      And the tabname is the unique part (the key).
+
 my %tabsysprefs;
 # Acquisitions
     $tabsysprefs{acquisitions}="Acquisitions";
     $tabsysprefs{gist}="Acquisitions";
     $tabsysprefs{emailPurchaseSuggestions}="Acquisitions";
+       $tabsysprefs{RenewSerialAddsSuggestion}="Acquisitions";
+    $tabsysprefs{serialsadditems}="Acquisitions";
 
 # Admin
     $tabsysprefs{singleBranchMode}="Admin";
@@ -81,6 +91,7 @@ my %tabsysprefs;
     $tabsysprefs{SessionStorage}="Admin";
     $tabsysprefs{noItemTypeImages}="Admin";
     $tabsysprefs{OPACBaseURL}="Admin";
+    $tabsysprefs{GranularPermissions}="Admin";
 
 # Authorities
     $tabsysprefs{authoritysep}="Authorities";
@@ -97,7 +108,6 @@ my %tabsysprefs;
     $tabsysprefs{LabelMARCView}="Cataloguing";
     $tabsysprefs{marc}="Cataloguing";
     $tabsysprefs{marcflavour}="Cataloguing";
-    $tabsysprefs{serialsadditems}="Cataloguing";
     $tabsysprefs{MARCOrgCode}="Cataloguing";
     $tabsysprefs{z3950AuthorAuthFields}="Cataloguing";
     $tabsysprefs{z3950NormalizeAuthor}="Cataloguing";
@@ -138,6 +148,8 @@ my %tabsysprefs;
     $tabsysprefs{previousIssuesDefaultSortOrder}="Circulation";
     $tabsysprefs{todaysIssuesDefaultSortOrder}="Circulation";
     $tabsysprefs{HomeOrHoldingBranch}="Circulation";
+       $tabsysprefs{RandomizeHoldsQueueWeight}="Circulation";
+       $tabsysprefs{StaticHoldsQueueWeight}="Circulation";
 
 # Staff Client
     $tabsysprefs{TemplateEncoding}="StaffClient";
@@ -165,16 +177,11 @@ my %tabsysprefs;
     $tabsysprefs{NoReturnSetLost}="Patrons";
     $tabsysprefs{MaxFine}="Patrons";
     $tabsysprefs{NotifyBorrowerDeparture}="Patrons";
+    $tabsysprefs{AddPatronLists}="Patrons";
     $tabsysprefs{PatronsPerPage}="Patrons";
-
-# FRBR
-    $tabsysprefs{FRBRizeEditions}="FRBR";
-    $tabsysprefs{XISBN}="FRBR";
-    $tabsysprefs{OCLCAffiliateID}="FRBR";
-    $tabsysprefs{XISBNDailyLimit}="FRBR";
-    $tabsysprefs{PINESISBN}="FRBR";
-    $tabsysprefs{ThingISBN}="FRBR";
-    $tabsysprefs{OPACFRBRizeEditions}="FRBR";
+    $tabsysprefs{ExtendedPatronAttributes}="Patrons";
+    $tabsysprefs{AutoEmailOpacUser}="Patrons";
+    $tabsysprefs{AutoEmailPrimaryAddress}="Patrons";
 
 # I18N/L10N
     $tabsysprefs{dateformat}="I18N/L10N";
@@ -199,14 +206,36 @@ my %tabsysprefs;
     $tabsysprefs{QueryAutoTruncate}="Searching";
     $tabsysprefs{QueryRemoveStopwords}="Searching";
 
-# Amazon.com
-    $tabsysprefs{AmazonContent}="Amazon";
-    $tabsysprefs{AWSAccessKeyID}="Amazon";
-    $tabsysprefs{AmazonLocale}="Amazon";
-    $tabsysprefs{AmazonAssocTag}="Amazon";
-    $tabsysprefs{AmazonSimilarItems}="Amazon";
-    $tabsysprefs{OPACAmazonContent}="Amazon";
-    $tabsysprefs{OPACAmazonSimilarItems}="Amazon";
+# EnhancedContent
+   $tabsysprefs{AmazonContent}="EnhancedContent";
+   $tabsysprefs{AWSAccessKeyID}="EnhancedContent";
+   $tabsysprefs{AmazonLocale}="EnhancedContent";
+   $tabsysprefs{AmazonAssocTag}="EnhancedContent";
+   $tabsysprefs{AmazonSimilarItems}="EnhancedContent";
+   $tabsysprefs{OPACAmazonContent}="EnhancedContent";
+   $tabsysprefs{OPACAmazonSimilarItems}="EnhancedContent";
+# Baker & Taylor 
+   $tabsysprefs{BakerTaylorBookstoreURL} = 'EnhancedContent';
+   $tabsysprefs{BakerTaylorEnabled}      = 'EnhancedContent';
+   $tabsysprefs{BakerTaylorPassword}     = 'EnhancedContent';
+   $tabsysprefs{BakerTaylorUsername}     = 'EnhancedContent';
+# FRBR    
+   $tabsysprefs{FRBRizeEditions}="EnhancedContent";
+   $tabsysprefs{XISBN}="EnhancedContent";
+   $tabsysprefs{OCLCAffiliateID}="EnhancedContent";
+   $tabsysprefs{XISBNDailyLimit}="EnhancedContent";
+   $tabsysprefs{PINESISBN}="EnhancedContent";
+   $tabsysprefs{ThingISBN}="EnhancedContent";
+   $tabsysprefs{OPACFRBRizeEditions}="EnhancedContent";
+# Tags
+   $tabsysprefs{TagsEnabled}            = 'EnhancedContent';
+   $tabsysprefs{TagsExternalDictionary} = 'EnhancedContent';
+   $tabsysprefs{TagsInputOnDetail}      = 'EnhancedContent';
+   $tabsysprefs{TagsInputOnList}        = 'EnhancedContent';
+   $tabsysprefs{TagsShowOnDetail}       = 'EnhancedContent';
+   $tabsysprefs{TagsShowOnList}         = 'EnhancedContent';
+   $tabsysprefs{TagsModeration}         = 'EnhancedContent';
+   $tabsysprefs{GoogleJackets}                         = 'EnhancedContent';
 
 # OPAC
     $tabsysprefs{BiblioDefaultView}="OPAC";
@@ -224,7 +253,6 @@ my %tabsysprefs;
     $tabsysprefs{opacheader}="OPAC";
 
     $tabsysprefs{hideBiblioNumber}="OPAC";
-    $tabsysprefs{noOPACUserLogin}="OPAC";
     $tabsysprefs{OPACDisplayExtendedSubInfo}="OPAC";
     $tabsysprefs{OpacMainUserBlock}="OPAC";
     $tabsysprefs{OPACSubscriptionDisplay}="OPAC";
@@ -256,15 +284,16 @@ my %tabsysprefs;
     $tabsysprefs{OpacBrowser}="OPAC";
     $tabsysprefs{kohaspsuggest} = "OPAC";
     $tabsysprefs{OpacRenewalAllowed} = "OPAC";
+    $tabsysprefs{OPACItemHolds} = "OPAC";
 
 # LOGFeatures
-    $tabsysprefs{CataloguingLog}  = "LOGFeatures";
-    $tabsysprefs{BorrowersLog}    = "LOGFeatures";
-    $tabsysprefs{SubscriptionLog} = "LOGFeatures";
-    $tabsysprefs{IssueLog}        = "LOGFeatures";
-    $tabsysprefs{ReturnLog}       = "LOGFeatures";
-    $tabsysprefs{LetterLog}       = "LOGFeatures";
-    $tabsysprefs{FinesLog}        = "LOGFeatures";
+    $tabsysprefs{CataloguingLog}  = "Logs";
+    $tabsysprefs{BorrowersLog}    = "Logs";
+    $tabsysprefs{SubscriptionLog} = "Logs";
+    $tabsysprefs{IssueLog}        = "Logs";
+    $tabsysprefs{ReturnLog}       = "Logs";
+    $tabsysprefs{LetterLog}       = "Logs";
+    $tabsysprefs{FinesLog}        = "Logs";
     
 # OAI-PMH variables
    $tabsysprefs{'OAI-PMH'}           = "OAI-PMH";
@@ -273,7 +302,6 @@ my %tabsysprefs;
    $tabsysprefs{'OAI-PMH:Set'}       = "OAI-PMH";
    $tabsysprefs{'OAI-PMH:Subset'}    = "OAI-PMH";
 
-
 sub StringSearch  {
     my ($searchstring,$type)=@_;
     my $dbh = C4::Context->dbh;
@@ -333,8 +361,9 @@ sub StringSearch  {
 }
 
 my $input = new CGI;
-my $searchfield=$input->param('searchfield');
-my $offset=$input->param('offset');
+my $searchfield = $input->param('searchfield');
+my $Tvalue = $input->param('Tvalue');
+my $offset = $input->param('offset');
 my $script_name="/cgi-bin/koha/admin/systempreferences.pl";
 
 my ($template, $borrowernumber, $cookie)
@@ -400,12 +429,16 @@ if ($op eq 'update_and_reedit') {
             my $sth=$dbh->prepare("update systempreferences set value=?,explanation=?,type=?,options=? where variable=?");
             $sth->execute($value, $input->param('explanation'), $input->param('variable'), $input->param('preftype'), $input->param('prefoptions'));
             $sth->finish;
+                       warn "logaction !! mod ";
+                       logaction('SYSTEMPREFERENCE','MODIFY',undef, $input->param('variable') . " | " . $value );
         }
     } else {
         unless (C4::Context->config('demo') eq 1) {
             my $sth=$dbh->prepare("insert into systempreferences (variable,value,explanation) values (?,?,?,?,?)");
             $sth->execute($input->param('variable'), $input->param('value'), $input->param('explanation'), $input->param('preftype'), $input->param('prefoptions'));
             $sth->finish;
+                       warn "logaction !! add ";
+                       logaction('SYSTEMPREFERENCE','ADD',undef, $input->param('variable') . " | " . $input->param('value') );
         }
     }
     $sth->finish;
@@ -538,12 +571,14 @@ if ($op eq 'add_form') {
             my $sth=$dbh->prepare("update systempreferences set value=?,explanation=?,type=?,options=? where variable=?");
             $sth->execute($value, $input->param('explanation'), $input->param('preftype'), $input->param('prefoptions'), $input->param('variable'));
             $sth->finish;
+                       logaction('SYSTEMPREFERENCE','MODIFY',undef, $input->param('variable') . " | " . $value );
         }
     } else {
         unless (C4::Context->config('demo') eq 1) {
             my $sth=$dbh->prepare("insert into systempreferences (variable,value,explanation,type,options) values (?,?,?,?,?)");
             $sth->execute($input->param('variable'), $value, $input->param('explanation'), $input->param('preftype'), $input->param('prefoptions'));
             $sth->finish;
+                       logaction('SYSTEMPREFERENCE','ADD',undef, $input->param('variable') . " | " . $value );
         }
     }
     $sth->finish;
@@ -568,6 +603,8 @@ if ($op eq 'add_form') {
     my $dbh = C4::Context->dbh;
     my $sth=$dbh->prepare("delete from systempreferences where variable=?");
     $sth->execute($searchfield);
+       my $logstring =  $searchfield . " | " . $Tvalue ;
+       logaction('SYSTEMPREFERENCE','DELETE',undef,$logstring);
     $sth->finish;
 
                                                     # END $OP eq DELETE_CONFIRMED