Hi all!
Tired of visiting the search page just for executing a search already saved? There's help:
I wrote a patch to implement a dropdown box in AgentNavigationBar containing the search profiles of the agent logged in. It works like the upmost dropdown box on the search page. In fact, it uses the functionality of Kernel/Modules/AgentUtilities, too.
It mainly consists of a new module Kernel/Output/HTML/SearchProfiler.pm alongside it's .dtl and some changes in Modules/Agent.pm and Kernel/Output/HTML/Standard/AgentNavigationBar.dtl. A new Config.pm option 'SearchProfiler' must be set to '1' to let this work, it defaults to '0' in Defaults.pm.
The patch prefetches functionality from OTRS 2.0, ie. it incorporates one function from Kernel/System/SearchProfile.pm. An upgrade to 2.0 won't break OTRS, but render no search profiles. So, it must (and will) be rewritten by the time 2.0 becomes released.
Find the patch attached and under: http://wiki.robertkehl.de/index.pl?PatchSearchProfiler
With kind regards,
Robert Kehl
--- Kernel/Output/HTML/Standard/SearchProfiler.dtl.orig 1970-01-01 01:00:00.000000000 +0100 +++ Kernel/Output/HTML/Standard/SearchProfiler.dtl 2004-11-02 23:31:16.000000000 +0100 @@ -0,0 +1,22 @@ +# -- +# SearchProfiler.dtl - provides HTML form for a search profile box +# Copyright (C) 2004 Dipl.-Ing. Robert Kehl, http://roknet.de/, GPL2 applies. +# -- +# $Id: $ +# -- +# This software comes with ABSOLUTELY NO WARRANTY. For details, see +# the enclosed file COPYING for license information (GPL). If you +# did not receive this file, see http://www.gnu.org/licenses/gpl.txt. +# -- +<!-- start search profile form --> +<table border="0" cellspacing="1" cellpadding="3"><tr align="left"><td> + <form action="$Env{"CGIHandle"}" method="get"> + <input type="hidden" name="Action" value="AgentUtilities"> + <input type="hidden" name="Subaction" value="LoadProfile"> + <input type="hidden" name="SearchTemplate" value="1"> +$Data{"SearchProfilesList"} +# <input class="button" name="SearchTemplate" type="submit" value="$Text{"Search"}"> + <input type="hidden" name="OnChangeSubmit" value="1"> + </form> +</td></tr></table> +<!-- end search profile form --> --- Kernel/Output/HTML/SearchProfiler.pm.orig 1970-01-01 01:00:00.000000000 +0100 +++ Kernel/Output/HTML/SearchProfiler.pm 2004-11-02 23:39:19.000000000 +0100 @@ -0,0 +1,122 @@ +# -- +# Kernel/Output/HTML/SearchProfiler.pm - Creates an easy-to-use HTML form +# with the search profiles of the user as an inline object. +# Copyright (C) 2004 Dipl.-Ing. Robert Kehl, http://roknet.de +# -- +# $Id: $ +# -- +# This software comes with ABSOLUTELY NO WARRANTY. For details, see +# the enclosed file COPYING for license information (GPL). If you +# did not receive this file, see http://www.gnu.org/licenses/gpl.txt. +# -- +# Note: This module must be rewritten for OTRS 2.0, it targets the 1.3 release. +# -- + +package Kernel::Output::HTML::SearchProfiler; + +use strict; + +use vars qw($VERSION); +$VERSION = '$Revision: 1.0 $'; +$VERSION =~ s/^\$.*:\W(.*)\W.+?$/$1/; + +# -- +sub new { + my $Type = shift; + my %Param = @_; + + # make my $Self + my $Self = {}; + bless ($Self, $Type); + + # get parameters + foreach (keys %Param) { + $Self->{$_} = $Param{$_}; + } + + # the DB object isn't available and safe to create + my $DBObject = Kernel::System::DB->new( + ConfigObject => $Self->{ConfigObject}, + LogObject => $Self->{LogObject}, + ); + $Self->{DBObject} = $DBObject; + + # check needed objects + foreach (qw(ConfigObject LogObject DBObject LayoutObject)) { + die "Got no $_" if (!$Self->{$_}); + } + + return $Self; +} + +sub GetSearchProfilesList { + my $Self = shift; + my %Param = @_; + my $Output; + + # get common objects + foreach (keys %Param) { + $Self->{$_} = $Param{$_}; + } + + # check needed objects + foreach (qw(UserLogin TemplateFile)) { + die "Got no $_" if (!$Self->{$_}); + } + + # read search profiles of user + my %SearchProfiles = $Self->SearchProfileList( + UserLogin => "$Self->{UserLogin}", + ); + + # build option string + my $SearchProfilesList = $Self->{LayoutObject}->OptionStrgHashRef( + Data => { '', " - $Self->{Title}", %SearchProfiles }, + Name => 'Profile', + OnChangeSubmit => "$Self->{OnChangeSubmit}", + ); + + # create output from given TemplateFile + $Output .= $Self->{LayoutObject}->Output( + TemplateFile => $Self->{TemplateFile}, + Data => { SearchProfilesList => $SearchProfilesList } + ); + + return $Output; +} + +# prefetched from 2.0 +sub SearchProfileList { + my $Self = shift; + my %Param = @_; + # check needed stuff + foreach (qw(UserLogin)) { + if (!defined($Param{$_})) { + $Self->{LogObject}->Log(Priority => 'error', Message => "Need $_!"); + return; + } + } + # db quote + foreach (keys %Param) { + $Param{$_} = $Self->{DBObject}->Quote($Param{$_}); + } + # sql + my $SQL = "SELECT profile_name ". + " FROM ". + " search_profile ". + " WHERE ". + " login = '$Param{UserLogin}'"; + my %Result = (); + if ($Self->{DBObject}->Prepare(SQL => $SQL)) { + while (my @Data = $Self->{DBObject}->FetchrowArray()) { + $Result{$Data[0]} = $Data[0]; + } + return %Result; + } + else { + return; + } +} + +# -- +1; --- Kernel/Output/HTML/Agent.pm.orig 2004-11-02 21:23:42.000000000 +0100 +++ Kernel/Output/HTML/Agent.pm 2004-11-02 23:33:58.000000000 +0100 @@ -77,6 +77,18 @@ $Param{Reminder}).'</a>', ); } + # SearchProfiler + my $SearchProfilerObject = Kernel::Output::HTML::SearchProfiler->new( + ConfigObject => $Self->{ConfigObject}, + LogObject => $Self->{LogObject}, + LayoutObject => $Self->{LayoutObject}, + ); + $Param{SearchProfilesStrg} = $SearchProfilerObject->GetSearchProfilesList( + Title => $Self->{ParamObject}->GetParam(Param => 'Profile') || '', + OnChangeSubmit => $Self->{ParamObject}->GetParam(Param => 'OnChangeSubmit') || '1', + UserLogin => $Self->{UserLogin}, + TemplateFile => 'SearchProfiler', + ); # create & return output return $Self->Output(TemplateFile => 'AgentNavigationBar', Data => \%Param).$Output; } --- Kernel/Output/HTML/Standard/AgentNavigationBar.dtl.orig 2004-11-02 23:12:22.000000000 +0100 +++ Kernel/Output/HTML/Standard/AgentNavigationBar.dtl 2004-11-02 23:17:58.000000000 +0100 @@ -17,6 +17,8 @@ <dtl if ($Env{"UserIsGroup[stats]"} eq "Yes") { $Data{"StatsLink"} = "<td valign="top" align="center" class="nav"><div title="$Text{"Stats-Area"}"><a href="$Env{"Baselink"}Action=SystemStats" onmouseover="window.status='$Text{"Stats-Area"}'; return true;" onmouseout="window.status='';" class="navitem"><img border="0" src="$Env{"Images"}stats.png" alt="$Text{"Stats-Area"}"><br>$Text{"Stats-Area"}</a></div></td>"; }> # check if bulk feature is aktiv <dtl if ($Config{"FrontendBulkFeature"} eq "1") { $Data{"BulkLink"} = "<td valign="top" align="center" class="nav"><div title="$Text{"Bulk Actions on Tickets"}"><a href="" onclick="BulkSubmit(); return false;" onmouseover="window.status='$Text{"Bulk Action"}'; return true;" onmouseout="window.status='';" class="navitem"><img border="0" src="$Env{"Images"}misc.png" alt="$Text{"Bulk Action"}"><br>$Text{"Bulk Action"}</a></div></td>"; }> +# check if the SearchProfiler should be shown +<dtl if ($Config{"SearchProfiler"} eq "1") { $Data{"SearchProfiler"} = "<td valign="top" align="center" class="nav">$Data{"SearchProfilesStrg"}</td>"; }> <!-- start NavigationBar --> <table border="0" width="100%" cellspacing="0" cellpadding="3"> @@ -50,6 +52,7 @@ $Data{"StatsLink"} $Data{"FAQLink"} $Data{"AdminLink"} + $Data{"SearchProfiler"} </tr> </table> </td> --- Kernel/Config/Defaults.pm.orig 2004-11-02 23:54:19.000000000 +0100 +++ Kernel/Config/Defaults.pm 2004-11-03 00:32:02.000000000 +0100 @@ -426,6 +426,10 @@ # 3 => 0, # }; + # SearchProfiler + # (a dropdown in AgentNavigationBar containing the agent's search profiles) + $Self->{SearchProfiler} = 0; + # --------------------------------------------------- # # AgentStatusView (shows all open tickets) # # --------------------------------------------------- #
_______________________________________________ OTRS mailing list: dev - Webpage: http://otrs.org/ Archive: http://lists.otrs.org/pipermail/dev To unsubscribe: http://lists.otrs.org/cgi-bin/listinfo/dev
