"Fossies" - the Fresh Open Source Software Archive

Member "otrs-5.0.40/Kernel/System/Console/Command/Admin/Role/Add.pm" (12 Dec 2019, 1493 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 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::Console::Command::Admin::Role::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 role.');
   24     $Self->AddOption(
   25         Name        => 'name',
   26         Description => 'Name of the new role.',
   27         Required    => 1,
   28         HasValue    => 1,
   29         ValueRegex  => qr/.*/smx,
   30     );
   31     $Self->AddOption(
   32         Name        => 'comment',
   33         Description => 'Comment for the new role.',
   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>Adding a new role...</yellow>\n");
   46 
   47     my $RID = $Kernel::OM->Get('Kernel::System::Group')->RoleAdd(
   48         Name    => $Self->GetOption('name'),
   49         Comment => $Self->GetOption('comment') || '',
   50         ValidID => 1,
   51         UserID  => 1,
   52     );
   53 
   54     if ($RID) {
   55         $Self->Print("<green>Done</green>\n");
   56         return $Self->ExitCodeOk();
   57     }
   58 
   59     $Self->PrintError("Can't add role");
   60     return $Self->ExitCodeError();
   61 }
   62 
   63 1;