"Fossies" - the Fresh Open Source Software Archive

Member "otrs-5.0.40/Kernel/System/DynamicField/Driver/ProcessManagement/ActivityID.pm" (12 Dec 2019, 5558 Bytes) of package /linux/www/otrs-5.0.40.tar.bz2:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "ActivityID.pm" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: rel-6_0_25_vs_rel-6_0_26.

    1 # --
    2 # Copyright (C) 2001-2019 OTRS AG, https://otrs.com/
    3 # --
    4 # This software comes with ABSOLUTELY NO WARRANTY. For details, see
    5 # the enclosed file COPYING for license information (GPL). If you
    6 # did not receive this file, see https://www.gnu.org/licenses/gpl-3.0.txt.
    7 # --
    8 
    9 package Kernel::System::DynamicField::Driver::ProcessManagement::ActivityID;
   10 
   11 use strict;
   12 use warnings;
   13 
   14 use Kernel::System::VariableCheck qw(:all);
   15 
   16 use base qw(Kernel::System::DynamicField::Driver::BaseText);
   17 
   18 our @ObjectDependencies = (
   19     'Kernel::Config',
   20     'Kernel::System::DynamicFieldValue',
   21     'Kernel::System::Main',
   22     'Kernel::System::ProcessManagement::Activity',
   23     'Kernel::System::Ticket::ColumnFilter',
   24 );
   25 
   26 =head1 NAME
   27 
   28 Kernel::System::DynamicField::Driver::Text
   29 
   30 =head1 SYNOPSIS
   31 
   32 DynamicFields Text Driver delegate
   33 
   34 =head1 PUBLIC INTERFACE
   35 
   36 This module implements the public interface of L<Kernel::System::DynamicField::Backend>.
   37 Please look there for a detailed reference of the functions.
   38 
   39 =over 4
   40 
   41 =item new()
   42 
   43 usually, you want to create an instance of this
   44 by using Kernel::System::DynamicField::Backend->new();
   45 
   46 =cut
   47 
   48 sub new {
   49     my ( $Type, %Param ) = @_;
   50 
   51     # allocate new hash for object
   52     my $Self = {};
   53     bless( $Self, $Type );
   54 
   55     # set field behaviors
   56     $Self->{Behaviors} = {
   57         'IsACLReducible'               => 0,
   58         'IsNotificationEventCondition' => 1,
   59         'IsSortable'                   => 1,
   60         'IsFiltrable'                  => 1,
   61         'IsStatsCondition'             => 1,
   62         'IsCustomerInterfaceCapable'   => 1,
   63     };
   64 
   65     # get the Dynamic Field Backend custom extensions
   66     my $DynamicFieldDriverExtensions
   67         = $Kernel::OM->Get('Kernel::Config')->Get('DynamicFields::Extension::Driver::Text');
   68 
   69     EXTENSION:
   70     for my $ExtensionKey ( sort keys %{$DynamicFieldDriverExtensions} ) {
   71 
   72         # skip invalid extensions
   73         next EXTENSION if !IsHashRefWithData( $DynamicFieldDriverExtensions->{$ExtensionKey} );
   74 
   75         # create a extension config shortcut
   76         my $Extension = $DynamicFieldDriverExtensions->{$ExtensionKey};
   77 
   78         # check if extension has a new module
   79         if ( $Extension->{Module} ) {
   80 
   81             # check if module can be loaded
   82             if (
   83                 !$Kernel::OM->Get('Kernel::System::Main')->RequireBaseClass( $Extension->{Module} )
   84                 )
   85             {
   86                 die "Can't load dynamic fields backend module"
   87                     . " $Extension->{Module}! $@";
   88             }
   89         }
   90 
   91         # check if extension contains more behaviors
   92         if ( IsHashRefWithData( $Extension->{Behaviors} ) ) {
   93 
   94             %{ $Self->{Behaviors} } = (
   95                 %{ $Self->{Behaviors} },
   96                 %{ $Extension->{Behaviors} }
   97             );
   98         }
   99     }
  100 
  101     return $Self;
  102 }
  103 
  104 sub DisplayValueRender {
  105     my ( $Self, %Param ) = @_;
  106 
  107     # set HTMLOuput as default if not specified
  108     if ( !defined $Param{HTMLOutput} ) {
  109         $Param{HTMLOutput} = 1;
  110     }
  111 
  112     # get raw Title and Value strings from field value
  113     # convert the ActivityEntityID to the Activity name
  114     my $Activity;
  115     if ( $Param{Value} ) {
  116         $Activity = $Kernel::OM->Get('Kernel::System::ProcessManagement::Activity')->ActivityGet(
  117             ActivityEntityID => $Param{Value},
  118             Interface        => 'all',
  119         );
  120     }
  121     my $Value = $Activity->{Name} // '';
  122     my $Title = $Value;
  123 
  124     # HTMLOuput transformations
  125     if ( $Param{HTMLOutput} ) {
  126         $Value = $Param{LayoutObject}->Ascii2Html(
  127             Text => $Value,
  128             Max  => $Param{ValueMaxChars} || '',
  129         );
  130 
  131         $Title = $Param{LayoutObject}->Ascii2Html(
  132             Text => $Title,
  133             Max  => $Param{TitleMaxChars} || '',
  134         );
  135     }
  136     else {
  137         if ( $Param{ValueMaxChars} && length($Value) > $Param{ValueMaxChars} ) {
  138             $Value = substr( $Value, 0, $Param{ValueMaxChars} ) . '...';
  139         }
  140         if ( $Param{TitleMaxChars} && length($Title) > $Param{TitleMaxChars} ) {
  141             $Title = substr( $Title, 0, $Param{TitleMaxChars} ) . '...';
  142         }
  143     }
  144 
  145     # set field link form config
  146     my $Link = $Param{DynamicFieldConfig}->{Config}->{Link} || '';
  147 
  148     # create return structure
  149     my $Data = {
  150         Value => $Value,
  151         Title => $Title,
  152         Link  => $Link,
  153     };
  154 
  155     return $Data;
  156 }
  157 
  158 sub ColumnFilterValuesGet {
  159     my ( $Self, %Param ) = @_;
  160 
  161     # take config from field config
  162     my $FieldConfig = $Param{DynamicFieldConfig}->{Config};
  163 
  164     # set PossibleValues
  165     my $SelectionData = $Kernel::OM->Get('Kernel::System::ProcessManagement::Activity')->ActivityList();
  166 
  167     # get column filter values from database
  168     my $ColumnFilterValues = $Kernel::OM->Get('Kernel::System::Ticket::ColumnFilter')->DynamicFieldFilterValuesGet(
  169         TicketIDs => $Param{TicketIDs},
  170         FieldID   => $Param{DynamicFieldConfig}->{ID},
  171         ValueType => 'Text',
  172     );
  173 
  174     # get the display value if still exist in dynamic field configuration
  175     for my $Key ( sort keys %{$ColumnFilterValues} ) {
  176         if ( $SelectionData->{$Key} ) {
  177             $ColumnFilterValues->{$Key} = $SelectionData->{$Key};
  178         }
  179     }
  180 
  181     return $ColumnFilterValues;
  182 }
  183 
  184 1;
  185 
  186 =back
  187 
  188 =head1 TERMS AND CONDITIONS
  189 
  190 This software is part of the OTRS project (L<https://otrs.org/>).
  191 
  192 This software comes with ABSOLUTELY NO WARRANTY. For details, see
  193 the enclosed file COPYING for license information (GPL). If you
  194 did not receive this file, see L<https://www.gnu.org/licenses/gpl-3.0.txt>.
  195 
  196 =cut