"Fossies" - the Fresh Open Source Software Archive

Member "otrs-5.0.40/Kernel/System/ProcessManagement/Activity.pm" (12 Dec 2019, 5258 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 "Activity.pm" see the Fossies "Dox" file reference documentation.

    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::ProcessManagement::Activity;
   10 
   11 use strict;
   12 use warnings;
   13 
   14 use Kernel::System::VariableCheck qw(:all);
   15 
   16 our @ObjectDependencies = (
   17     'Kernel::Config',
   18     'Kernel::System::Log',
   19 );
   20 
   21 =head1 NAME
   22 
   23 Kernel::System::ProcessManagement::Activity - Activities lib
   24 
   25 =head1 SYNOPSIS
   26 
   27 All Process Management Activity functions.
   28 
   29 =head1 PUBLIC INTERFACE
   30 
   31 =over 4
   32 
   33 =cut
   34 
   35 =item new()
   36 
   37 create an object. Do not use it directly, instead use:
   38 
   39     use Kernel::System::ObjectManager;
   40     local $Kernel::OM = Kernel::System::ObjectManager->new();
   41     my $ActivityObject = $Kernel::OM->Get('Kernel::System::ProcessManagement::Activity');
   42 
   43 =cut
   44 
   45 sub new {
   46     my ( $Type, %Param ) = @_;
   47 
   48     # allocate new hash for object
   49     my $Self = {};
   50     bless( $Self, $Type );
   51 
   52     return $Self;
   53 }
   54 
   55 =item ActivityGet()
   56 
   57     Get Activity info
   58     Returned activity dialogs are limited to given interface
   59 
   60     my $Activity = $ActivityObject->ActivityGet(
   61         ActivityEntityID => 'A1',
   62         Interface        => ['AgentInterface'],   # ['AgentInterface'] or ['CustomerInterface'] or ['AgentInterface', 'CustomerInterface'] or 'all'
   63     );
   64 
   65     Returns:
   66 
   67     $Activity = {
   68           'Name'           => 'Activity 3'
   69           'CreateTime'     => '08-02-2012 13:37:00',
   70           'ChangeBy'       => '2',
   71           'ChangeTime'     => '09-02-2012 13:37:00',
   72           'CreateBy'       => '3',
   73           'ActivityDialog' => {
   74               '1' => 'AD5',
   75               '3' => 'AD7',
   76               '2' => 'AD6',
   77             },
   78         };
   79 
   80 =cut
   81 
   82 sub ActivityGet {
   83     my ( $Self, %Param ) = @_;
   84 
   85     for my $Needed (qw(ActivityEntityID Interface)) {
   86         if ( !defined $Param{$Needed} ) {
   87             $Kernel::OM->Get('Kernel::System::Log')->Log(
   88                 Priority => 'error',
   89                 Message  => "Need $Needed!"
   90             );
   91             return;
   92         }
   93     }
   94 
   95     # get config object
   96     my $ConfigObject = $Kernel::OM->Get('Kernel::Config');
   97 
   98     my $Activity = $ConfigObject->Get('Process::Activity');
   99 
  100     if ( !IsHashRefWithData($Activity) ) {
  101         $Kernel::OM->Get('Kernel::System::Log')->Log(
  102             Priority => 'error',
  103             Message  => 'Need Activity config!'
  104         );
  105         return;
  106     }
  107 
  108     my $ActivityEntity = $Activity->{ $Param{ActivityEntityID} };
  109 
  110     if ( !IsHashRefWithData($ActivityEntity) ) {
  111         $Kernel::OM->Get('Kernel::System::Log')->Log(
  112             Priority => 'error',
  113             Message  => "No data for Activity '$Param{ActivityEntityID}' found!"
  114         );
  115         return;
  116     }
  117 
  118     # limit activity dialogs by interface
  119     return $ActivityEntity if ref $Param{Interface} ne 'ARRAY' && $Param{Interface} eq 'all';
  120     if ( ref $Param{Interface} ne 'ARRAY' && $Param{Interface} ne 'all' ) {
  121         $Param{Interface} = [ $Param{Interface} ];
  122     }
  123 
  124     # get activity dialogs
  125     my $ActivityDialogs = $ConfigObject->Get('Process::ActivityDialog');
  126 
  127     if ( IsHashRefWithData( $ActivityEntity->{ActivityDialog} ) ) {
  128 
  129         # filter activity dialogs
  130         ACTIVITYDIALOG:
  131         for my $ActivityDialogID ( sort keys %{ $ActivityEntity->{ActivityDialog} } ) {
  132             my $ActivityDialog = $ActivityEntity->{ActivityDialog}->{$ActivityDialogID};
  133             if ( IsHashRefWithData($ActivityDialog) ) {
  134                 $ActivityDialog = $ActivityDialog->{ActivityDialogEntityID};
  135             }
  136             for my $Interface ( @{ $Param{Interface} } ) {
  137 
  138                 # keep activity dialog if interface is included in activity dialog configuration
  139                 if (
  140                     grep { $_ eq $Interface } @{ $ActivityDialogs->{$ActivityDialog}->{Interface} }
  141                     )
  142                 {
  143                     next ACTIVITYDIALOG;
  144                 }
  145             }
  146 
  147             # remove activity dialog if no match could be found
  148             delete $ActivityEntity->{ActivityDialog}->{$ActivityDialogID};
  149         }
  150     }
  151 
  152     return $ActivityEntity;
  153 }
  154 
  155 =item ActivityList()
  156 
  157     Get a list of all Activities
  158 
  159     my $Activities = $ActivityObject->ActivityList();
  160 
  161     Returns:
  162 
  163     $ActivityList = {
  164         'A1' => 'Activity 1',
  165         'A2' => 'Activity 2',
  166         'A3' => '',
  167     };
  168 
  169 =cut
  170 
  171 sub ActivityList {
  172     my ( $Self, %Param ) = @_;
  173 
  174     my $Activities = $Kernel::OM->Get('Kernel::Config')->Get('Process::Activity');
  175 
  176     if ( !IsHashRefWithData($Activities) ) {
  177         $Kernel::OM->Get('Kernel::System::Log')->Log(
  178             Priority => 'error',
  179             Message  => 'Need Activity config!'
  180         );
  181         return;
  182     }
  183 
  184     my %ActivityList = map { $_ => $Activities->{$_}{Name} || '' } keys %{$Activities};
  185 
  186     return \%ActivityList;
  187 }
  188 
  189 1;
  190 
  191 =back
  192 
  193 =head1 TERMS AND CONDITIONS
  194 
  195 This software is part of the OTRS project (L<https://otrs.org/>).
  196 
  197 This software comes with ABSOLUTELY NO WARRANTY. For details, see
  198 the enclosed file COPYING for license information (GPL). If you
  199 did not receive this file, see L<https://www.gnu.org/licenses/gpl-3.0.txt>.
  200 
  201 =cut