"Fossies" - the Fresh Open Source Software Archive

Member "otrs-5.0.40/Kernel/System/Console/Command/Admin/TicketType/Add.pm" (12 Dec 2019, 1307 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 "Add.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::Console::Command::Admin::TicketType::Add;
   10 
   11 use strict;
   12 use warnings;
   13 
   14 use base qw(Kernel::System::Console::BaseCommand);
   15 
   16 our @ObjectDependencies = (
   17     'Kernel::System::Type',
   18 );
   19 
   20 sub Configure {
   21     my ( $Self, %Param ) = @_;
   22 
   23     $Self->Description('Add new ticket type.');
   24     $Self->AddOption(
   25         Name        => 'name',
   26         Description => "Name of the new ticket type.",
   27         Required    => 1,
   28         HasValue    => 1,
   29         ValueRegex  => qr/.*/smx,
   30     );
   31 
   32     return;
   33 }
   34 
   35 sub Run {
   36     my ( $Self, %Param ) = @_;
   37 
   38     $Self->Print("<yellow>Adding a new ticket type...</yellow>\n");
   39 
   40     # add ticket type
   41     if (
   42         !$Kernel::OM->Get('Kernel::System::Type')->TypeAdd(
   43             UserID  => 1,
   44             ValidID => 1,
   45             Name    => $Self->GetOption('name'),
   46         )
   47         )
   48     {
   49         $Self->PrintError("Can't add ticket type.");
   50         return $Self->ExitCodeError();
   51     }
   52 
   53     $Self->Print("<green>Done.</green>\n");
   54     return $Self->ExitCodeOk();
   55 }
   56 
   57 1;