X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FController%2FTopQuickSearch.pm;h=4d0aa9492bec0302260a6db9d30d8e62e7f67e02;hb=d6fed9b55a11dca1cfd9cd6f43940a945533d318;hp=b72174928d54241ff655b3b9efc4032ea0f40a84;hpb=4e070acf473ae9992a3561594cce55123be0a7ec;p=kivitendo-erp.git diff --git a/SL/Controller/TopQuickSearch.pm b/SL/Controller/TopQuickSearch.pm index b72174928..4d0aa9492 100644 --- a/SL/Controller/TopQuickSearch.pm +++ b/SL/Controller/TopQuickSearch.pm @@ -6,6 +6,7 @@ use parent qw(SL::Controller::Base); use SL::ClientJS; use SL::JSON; use SL::Locale::String qw(t8); +use SL::Helper::UserPreferences; use Rose::Object::MakeMethods::Generic ( 'scalar --get_set_init' => [ qw(module js) ], @@ -16,8 +17,18 @@ my @available_modules = ( 'SL::Controller::TopQuickSearch::Part', 'SL::Controller::TopQuickSearch::Service', 'SL::Controller::TopQuickSearch::Assembly', + 'SL::Controller::TopQuickSearch::Assortment', 'SL::Controller::TopQuickSearch::Contact', + 'SL::Controller::TopQuickSearch::SalesQuotation', + 'SL::Controller::TopQuickSearch::SalesOrder', + 'SL::Controller::TopQuickSearch::SalesDeliveryOrder', + 'SL::Controller::TopQuickSearch::RequestForQuotation', + 'SL::Controller::TopQuickSearch::PurchaseOrder', + 'SL::Controller::TopQuickSearch::PurchaseDeliveryOrder', 'SL::Controller::TopQuickSearch::GLTransaction', + 'SL::Controller::TopQuickSearch::Customer', + 'SL::Controller::TopQuickSearch::Vendor', + 'SL::Controller::TopQuickSearch::PhoneNumber', ); my %modules_by_name; @@ -58,9 +69,18 @@ sub available_modules { } sub enabled_modules { - my %enabled_names = map { - $_ => 1 - } @{ $::instance_conf->get_quick_search_modules }; + my $user_prefs = SL::Helper::UserPreferences->new( + namespace => 'TopQuickSearch', + ); + + my @quick_search_modules; + if (my $prefs_val = $user_prefs->get('quick_search_modules')) { + @quick_search_modules = split ',', $prefs_val; + } else { + @quick_search_modules = @{ $::instance_conf->get_quick_search_modules }; + } + + my %enabled_names = map { $_ => 1 } @quick_search_modules; grep { $enabled_names{$_->name} @@ -69,7 +89,7 @@ sub enabled_modules { sub active_modules { grep { - $::auth->assert($_->auth, 1) + !$_->auth || $::auth->assert($_->auth, 1) } $_[0]->enabled_modules } @@ -82,7 +102,7 @@ sub init_module { die 'Unknown module ' . $::form->{module} unless my $class = $modules_by_name{$::form->{module}}; - $::auth->assert($class->auth); + $::auth->assert($class->auth) if $class->auth; return $class->new; } @@ -115,13 +135,14 @@ SL::Controller::TopQuickSearch - Framework for pluggable quicksearch fields in t =head1 SYNOPSIS -use SL::Controller::TopQuickSearch; -my $search = SL::Controller::TopQuickSearch->new; + use SL::Controller::TopQuickSearch; + my $search = SL::Controller::TopQuickSearch->new; + $::request->layout->add_javascripts('kivi.QuickSearch.js'); -# in layout -[%- FOREACH module = search.available_modules %] - -[%- END %] + # in template + [%- FOREACH module = search.enabled_modules %] + + [%- END %] =head1 DESCRIPTION @@ -167,6 +188,10 @@ redirect should occur. Each search must check rights and must not present a backdoor into data that the user should not see. +=item * + +By design the search must not try to guess C. + =back =head1 INTERFACE @@ -175,7 +200,7 @@ The full interface is described in L =head1 TODO - - toggling with cofiguration doesn't work yet + * user configuration =head1 BUGS