"Fossies" - the Fresh Open Source Software Archive

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