X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FController%2FTopQuickSearch.pm;h=8b470803142dc4482c4d7478850c6730081110a0;hb=2fe6237c8b09d2f5a83145673c15be84bdfadf8a;hp=1134b6a14903e609e2edd35e94ab8c15c50a20bd;hpb=2bccc0a27d0c6917ab219aeb60efcbc9ae043205;p=kivitendo-erp.git
diff --git a/SL/Controller/TopQuickSearch.pm b/SL/Controller/TopQuickSearch.pm
index 1134b6a14..8b4708031 100644
--- a/SL/Controller/TopQuickSearch.pm
+++ b/SL/Controller/TopQuickSearch.pm
@@ -6,18 +6,26 @@ 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) ],
);
-my @available_modules = qw(
- SL::Controller::TopQuickSearch::Article
- SL::Controller::TopQuickSearch::Part
- SL::Controller::TopQuickSearch::Service
- SL::Controller::TopQuickSearch::Assembly
- SL::Controller::TopQuickSearch::Contact
- SL::Controller::TopQuickSearch::GLTransaction
+my @available_modules = (
+ 'SL::Controller::TopQuickSearch::Article',
+ '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::RequestForQuotation',
+ 'SL::Controller::TopQuickSearch::PurchaseOrder',
+ 'SL::Controller::TopQuickSearch::GLTransaction',
+ 'SL::Controller::TopQuickSearch::Customer',
+ 'SL::Controller::TopQuickSearch::Vendor',
);
my %modules_by_name;
@@ -57,10 +65,34 @@ sub available_modules {
map { $_->new } @available_modules;
}
+sub enabled_modules {
+ my $user_prefs = SL::Helper::UserPreferences->new(
+ namespace => 'TopQuickSearch',
+ );
+
+ my %enabled_names;
+ if ($user_prefs) {
+ my $prefs_val = $user_prefs->get('quick_search_modules');
+ my @quick_search_modules = split ',', $prefs_val;
+
+ %enabled_names = map {
+ $_ => 1
+ } @quick_search_modules ;
+ } else {
+ %enabled_names = map {
+ $_ => 1
+ } @{ $::instance_conf->get_quick_search_modules };
+ }
+
+ grep {
+ $enabled_names{$_->name}
+ } $_[0]->available_modules
+}
+
sub active_modules {
grep {
$::auth->assert($_->auth, 1)
- } $_[0]->available_modules
+ } $_[0]->enabled_modules
}
sub init_module {
@@ -68,13 +100,9 @@ sub init_module {
$self->require_modules;
- die t8('Need module') unless $::form->{module};
+ die 'Need module' unless $::form->{module};
- $::lxdebug->dump(0, "modules", \%modules_by_name);
-
- die t8('Unknown module #1', $::form->{module}) unless my $class = $modules_by_name{$::form->{module}};
-
- $::lxdebug->dump(0, "auth:", $class->auth);
+ die 'Unknown module ' . $::form->{module} unless my $class = $modules_by_name{$::form->{module}};
$::auth->assert($class->auth);
@@ -109,21 +137,22 @@ 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
This controller provides abstraction for different search plugins, and ensures
that all follow a common useability scheme.
-Modules should be configurable, but currently are not. Diabling modules can be
-done by removing them from available_modules.
+Modules should be configurable per user, but currently are not. Disabling
+modules can be done by removing them from available_modules or in client_config.
=head1 BEHAVIOUR REQUIREMENTS
@@ -161,26 +190,19 @@ redirect should occur.
Each search must check rights and must not present a backdoor into data that
the user should not see.
-=back
+=item *
-=head1 INTERFACE
+By design the search must not try to guess C.
-Plugins need to provide:
+=back
- - name
- - localized description for config
- - localized description for textfield
- - autocomplete callback
- - redirect callback
+=head1 INTERFACE
-the frontend will only generate urls of the forms:
- action=TopQuickSearch/autocomplete&module=&term=
- action=TopQuickSearch/search&module=&term=
+The full interface is described in L
=head1 TODO
- - filter available searches with auth
- - toggling with cofiguration doesn't work yet
+ * user configuration
=head1 BUGS