+# 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";
+
+# Admin
+$tabsysprefs{singleBranchMode} = "Admin";
+$tabsysprefs{staffClientBaseURL} = "Admin";
+$tabsysprefs{Version} = "Admin";
+$tabsysprefs{OpacMaintenance} = "Admin";
+$tabsysprefs{FrameworksLoaded} = "Admin";
+$tabsysprefs{libraryAddress} = "Admin";
+$tabsysprefs{delimiter} = "Admin";
+$tabsysprefs{IndependantBranches} = "Admin";
+$tabsysprefs{insecure} = "Admin";
+$tabsysprefs{KohaAdmin} = "Admin";
+$tabsysprefs{KohaAdminEmailAddress} = "Admin";
+$tabsysprefs{MIME} = "Admin";
+$tabsysprefs{timeout} = "Admin";
+$tabsysprefs{Intranet_includes} = "Admin";
+$tabsysprefs{AutoLocation} = "Admin";
+$tabsysprefs{DebugLevel} = "Admin";
+$tabsysprefs{SessionStorage} = "Admin";
+$tabsysprefs{noItemTypeImages} = "Admin";
+$tabsysprefs{OPACBaseURL} = "Admin";
+$tabsysprefs{GranularPermissions} = "Admin";
+
+# Authorities
+$tabsysprefs{authoritysep} = "Authorities";
+$tabsysprefs{AuthDisplayHierarchy} = "Authorities";
+$tabsysprefs{dontmerge} = "Authorities";
+$tabsysprefs{BiblioAddsAuthorities} = "Authorities";
+
+# Cataloguing
+$tabsysprefs{advancedMARCEditor} = "Cataloguing";
+$tabsysprefs{autoBarcode} = "Cataloguing";
+$tabsysprefs{hide_marc} = "Cataloguing";
+$tabsysprefs{IntranetBiblioDefaultView} = "Cataloguing";
+$tabsysprefs{ISBD} = "Cataloguing";
+$tabsysprefs{itemcallnumber} = "Cataloguing";
+$tabsysprefs{LabelMARCView} = "Cataloguing";
+$tabsysprefs{marc} = "Cataloguing";
+$tabsysprefs{marcflavour} = "Cataloguing";
+$tabsysprefs{MARCOrgCode} = "Cataloguing";
+$tabsysprefs{z3950AuthorAuthFields} = "Cataloguing";
+$tabsysprefs{z3950NormalizeAuthor} = "Cataloguing";
+$tabsysprefs{Stemming} = "Cataloguing";
+$tabsysprefs{WeightFields} = "Cataloguing";
+$tabsysprefs{NoZebra} = "Cataloguing";
+$tabsysprefs{NoZebraIndexes} = "Cataloguing";
+$tabsysprefs{ReceiveBackIssues} = "Cataloguing";
+$tabsysprefs{DefaultClassificationSource} = "Cataloguing";
+$tabsysprefs{RoutingSerials} = "Cataloguing";
+$tabsysprefs{'item-level_itypes'} = "Cataloguing";
+$tabsysprefs{OpacSuppression} = "Cataloguing";
+
+# Circulation
+$tabsysprefs{maxoutstanding} = "Circulation";
+$tabsysprefs{maxreserves} = "Circulation";
+$tabsysprefs{noissuescharge} = "Circulation";
+$tabsysprefs{IssuingInProcess} = "Circulation";
+$tabsysprefs{patronimages} = "Circulation";
+$tabsysprefs{printcirculationslips} = "Circulation";
+$tabsysprefs{ReturnBeforeExpiry} = "Circulation";
+$tabsysprefs{SpecifyDueDate} = "Circulation";
+$tabsysprefs{AutomaticItemReturn} = "Circulation";
+$tabsysprefs{ReservesMaxPickUpDelay} = "Circulation";
+$tabsysprefs{TransfersMaxDaysWarning} = "Circulation";
+$tabsysprefs{useDaysMode} = "Circulation";
+$tabsysprefs{ReservesNeedReturns} = "Circulation";
+$tabsysprefs{CircAutocompl} = "Circulation";
+$tabsysprefs{AllowRenewalLimitOverride} = "Circulation";
+$tabsysprefs{canreservefromotherbranches} = "Circulation";
+$tabsysprefs{finesMode} = "Circulation";
+$tabsysprefs{emailLibrarianWhenHoldIsPlaced} = "Circulation";
+$tabsysprefs{globalDueDate} = "Circulation";
+$tabsysprefs{holdCancelLength} = "Circulation";
+$tabsysprefs{itemBarcodeInputFilter} = "Circulation";
+$tabsysprefs{WebBasedSelfCheck} = "Circulation";
+$tabsysprefs{CircControl} = "Circulation";
+$tabsysprefs{finesCalendar} = "Circulation";
+$tabsysprefs{previousIssuesDefaultSortOrder} = "Circulation";
+$tabsysprefs{todaysIssuesDefaultSortOrder} = "Circulation";
+$tabsysprefs{HomeOrHoldingBranch} = "Circulation";
+$tabsysprefs{RandomizeHoldsQueueWeight} = "Circulation";
+$tabsysprefs{StaticHoldsQueueWeight} = "Circulation";
+$tabsysprefs{AllowOnShelfHolds} = "Circulation";
+$tabsysprefs{AllowHoldsOnDamagedItems} = "Circulation";
+$tabsysprefs{UseBranchTransferLimits} = "Circulation";
+$tabsysprefs{AllowHoldPolicyOverride} = "Circulation";
+$tabsysprefs{BranchTransferLimitsType} = "Circulation";
+
+# Staff Client
+$tabsysprefs{TemplateEncoding} = "StaffClient";
+$tabsysprefs{template} = "StaffClient";
+$tabsysprefs{intranetstylesheet} = "StaffClient";
+$tabsysprefs{IntranetNav} = "StaffClient";
+$tabsysprefs{intranetcolorstylesheet} = "StaffClient";
+$tabsysprefs{intranetuserjs} = "StaffClient";
+$tabsysprefs{yuipath} = "StaffClient";
+$tabsysprefs{IntranetmainUserblock} = "StaffClient";
+
+# Patrons
+$tabsysprefs{autoMemberNum} = "Patrons";
+$tabsysprefs{checkdigit} = "Patrons";
+$tabsysprefs{intranetreadinghistory} = "Patrons";
+$tabsysprefs{NotifyBorrowerDeparture} = "Patrons";
+$tabsysprefs{memberofinstitution} = "Patrons";
+$tabsysprefs{ReadingHistory} = "Patrons";
+$tabsysprefs{BorrowerMandatoryField} = "Patrons";
+$tabsysprefs{borrowerRelationship} = "Patrons";
+$tabsysprefs{BorrowersTitles} = "Patrons";
+$tabsysprefs{patronimages} = "Patrons";
+$tabsysprefs{MinPasswordLength} = "Patrons";
+$tabsysprefs{uppercasesurnames} = "Patrons";
+$tabsysprefs{NoReturnSetLost} = "Patrons";
+$tabsysprefs{MaxFine} = "Patrons";
+$tabsysprefs{NotifyBorrowerDeparture} = "Patrons";
+$tabsysprefs{AddPatronLists} = "Patrons";
+$tabsysprefs{PatronsPerPage} = "Patrons";
+$tabsysprefs{ExtendedPatronAttributes} = "Patrons";
+$tabsysprefs{AutoEmailOpacUser} = "Patrons";
+$tabsysprefs{AutoEmailPrimaryAddress} = "Patrons";
+$tabsysprefs{EnhancedMessagingPreferences} = "Patrons";
+$tabsysprefs{'SMSSendDriver'} = 'Patrons';
+
+# I18N/L10N
+$tabsysprefs{dateformat} = "I18N/L10N";
+$tabsysprefs{opaclanguages} = "I18N/L10N";
+$tabsysprefs{opaclanguagesdisplay} = "I18N/L10N";
+$tabsysprefs{language} = "I18N/L10N";
+
+# Searching
+$tabsysprefs{defaultSortField} = "Searching";
+$tabsysprefs{defaultSortOrder} = "Searching";
+$tabsysprefs{numSearchResults} = "Searching";
+$tabsysprefs{OPACdefaultSortField} = "Searching";
+$tabsysprefs{OPACdefaultSortOrder} = "Searching";
+$tabsysprefs{OPACItemsResultsDisplay} = "Searching";
+$tabsysprefs{OPACnumSearchResults} = "Searching";
+$tabsysprefs{QueryFuzzy} = "Searching";
+$tabsysprefs{QueryStemming} = "Searching";
+$tabsysprefs{QueryWeightFields} = "Searching";
+$tabsysprefs{expandedSearchOption} = "Searching";
+$tabsysprefs{sortbynonfiling} = "Searching";
+$tabsysprefs{QueryAutoTruncate} = "Searching";
+$tabsysprefs{QueryRemoveStopwords} = "Searching";
+$tabsysprefs{AdvancedSearchTypes} = "Searching";
+
+# 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';
+
+# Syndetics
+$tabsysprefs{SyndeticsClientCode} = 'EnhancedContent';
+$tabsysprefs{SyndeticsEnabled} = 'EnhancedContent';
+$tabsysprefs{SyndeticsCoverImages} = 'EnhancedContent';
+$tabsysprefs{SyndeticsTOC} = 'EnhancedContent';
+$tabsysprefs{SyndeticsSummary} = 'EnhancedContent';
+$tabsysprefs{SyndeticsEditions} = 'EnhancedContent';
+$tabsysprefs{SyndeticsExcerpt} = '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';
+$tabsysprefs{AuthorisedValueImages} = "EnhancedContent";
+
+# OPAC
+$tabsysprefs{BiblioDefaultView} = "OPAC";
+$tabsysprefs{LibraryName} = "OPAC";
+$tabsysprefs{opaccolorstylesheet} = "OPAC";
+$tabsysprefs{opaccredits} = "OPAC";
+$tabsysprefs{opaclayoutstylesheet} = "OPAC";
+$tabsysprefs{OpacNav} = "OPAC";
+$tabsysprefs{opacsmallimage} = "OPAC";
+$tabsysprefs{opacstylesheet} = "OPAC";
+$tabsysprefs{opacthemes} = "OPAC";
+$tabsysprefs{opacuserjs} = "OPAC";
+$tabsysprefs{SubscriptionHistory} = "OPAC";
+$tabsysprefs{opacheader} = "OPAC";
+$tabsysprefs{noOPACUserLogin} = "OPAC";
+$tabsysprefs{hideBiblioNumber} = "OPAC";
+$tabsysprefs{OPACDisplayExtendedSubInfo} = "OPAC";
+$tabsysprefs{OpacMainUserBlock} = "OPAC";
+$tabsysprefs{OPACSubscriptionDisplay} = "OPAC";
+$tabsysprefs{OPACURLOpenInNewWindow} = "OPAC";
+$tabsysprefs{OPACUserCSS} = "OPAC";
+$tabsysprefs{OPACHighlightedWords} = "OPAC";
+$tabsysprefs{OPACViewOthersSuggestions} = "OPAC";
+$tabsysprefs{URLLinkText} = "OPAC";
+$tabsysprefs{OPACShelfBrowser} = "OPAC";
+$tabsysprefs{OPACDisplayRequestPriority} = "OPAC";
+
+# OPAC
+$tabsysprefs{SearchMyLibraryFirst} = "OPAC";
+$tabsysprefs{hidelostitems} = "OPAC";
+$tabsysprefs{opacbookbag} = "OPAC";
+$tabsysprefs{OpacPasswordChange} = "OPAC";
+$tabsysprefs{opacreadinghistory} = "OPAC";
+$tabsysprefs{virtualshelves} = "OPAC";
+$tabsysprefs{RequestOnOpac} = "OPAC";
+$tabsysprefs{reviewson} = "OPAC";
+$tabsysprefs{OpacTopissues} = "OPAC";
+$tabsysprefs{OpacAuthorities} = "OPAC";
+$tabsysprefs{OpacCloud} = "OPAC";
+$tabsysprefs{opacuserlogin} = "OPAC";
+$tabsysprefs{AnonSuggestions} = "OPAC";
+$tabsysprefs{suggestion} = "OPAC";
+$tabsysprefs{OpacTopissue} = "OPAC";
+$tabsysprefs{OpacBrowser} = "OPAC";
+$tabsysprefs{kohaspsuggest} = "OPAC";
+$tabsysprefs{OpacRenewalAllowed} = "OPAC";
+$tabsysprefs{OPACItemHolds} = "OPAC";
+$tabsysprefs{OPACGroupResults} = "OPAC";
+$tabsysprefs{XSLTDetailsDisplay} = "OPAC";
+$tabsysprefs{XSLTResultsDisplay} = "OPAC";
+
+# 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";
+$tabsysprefs{'OAI-PMH:archiveID'} = "OAI-PMH";
+$tabsysprefs{'OAI-PMH:MaxCount'} = "OAI-PMH";
+$tabsysprefs{'OAI-PMH:Set'} = "OAI-PMH";
+$tabsysprefs{'OAI-PMH:Subset'} = "OAI-PMH";
+
+sub StringSearch {
+ my ( $searchstring, $type ) = @_;
+ my $dbh = C4::Context->dbh;
+ $searchstring =~ s/\'/\\\'/g;
+ my @data = split( ' ', $searchstring );
+ my $count = @data;
+ my @results;
+ my $cnt = 0;
+ my $sth;