Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #2930: Introduced lightadmin functionality. #2931

Merged
merged 1 commit into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 78 additions & 1 deletion Kernel/Modules/AdminAttachment.pm
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ sub new {
my $Self = {%Param};
bless( $Self, $Type );

if ( !$Param{AccessRw} && $Param{AccessRo} ) {
$Self->{LightAdmin} = 1;
}

return $Self;
}

Expand All @@ -51,6 +55,25 @@ sub Run {

my $Output = $LayoutObject->Header();
$Output .= $LayoutObject->NavigationBar();

# check permission for all linked templates.
if ( $Self->{LightAdmin} ) {
$Data{Permission} = $StdAttachmentObject->StdAttachmentStandardTemplatePermission(
ID => $ID,
UserID => $Self->{UserID},
Default => 'ro',
);
if ( !$Data{Permission} ) {
%Data = ();
}
elsif ( $Data{Permission} eq 'ro' ) {
$Output .= $LayoutObject->Notify(
Priority => 'Notice',
Data => $LayoutObject->{LanguageObject}->Translate('No permission to edit this attachment.'),
);
}
}

$Self->_Edit(
Action => 'Change',
%Data,
Expand Down Expand Up @@ -89,6 +112,18 @@ sub Run {
}
}

if ( $Self->{LightAdmin} ) {
my $Permission = $StdAttachmentObject->StdAttachmentStandardTemplatePermission(
ID => $GetParam{ID},
UserID => $Self->{UserID},
);

# No permission to change the attachment.
if ( $Permission ne 'rw' ) {
$Errors{NoPermission} = 1;
}
}

# if no errors occurred
if ( !%Errors ) {

Expand Down Expand Up @@ -231,7 +266,25 @@ sub Run {
# challenge token check for write action
$LayoutObject->ChallengeTokenCheck();

my $ID = $ParamObject->GetParam( Param => 'ID' );
my $ID = $ParamObject->GetParam( Param => 'ID' );

if ( $Self->{LightAdmin} ) {
my $Permission = $StdAttachmentObject->StdAttachmentStandardTemplatePermission(
ID => $ID,
UserID => $Self->{UserID},
);

# No permission to delete the attachment.
if ( $Permission ne 'rw' ) {
return $LayoutObject->Attachment(
ContentType => 'text/html',
Content => 0,
Type => 'inline',
NoCache => 1,
);
}
}

my $Delete = $StdAttachmentObject->StdAttachmentDelete(
ID => $ID,
);
Expand All @@ -257,6 +310,20 @@ sub Run {
my %Data = $StdAttachmentObject->StdAttachmentGet(
ID => $ID,
);

if ( $Self->{LightAdmin} ) {
my $Permission = $StdAttachmentObject->StdAttachmentStandardTemplatePermission(
ID => $ID,
UserID => $Self->{UserID},
Default => 'ro',
);

# No permission to download the attachment.
if ( !$Permission ) {
%Data = ();
}
}

if ( !%Data ) {
return $LayoutObject->ErrorScreen();
}
Expand Down Expand Up @@ -361,11 +428,21 @@ sub _Overview {

# get valid list
my %ValidList = $Kernel::OM->Get('Kernel::System::Valid')->ValidList();
ID:
for my $ID ( sort { $List{$a} cmp $List{$b} } keys %List ) {
my %Data = $StdAttachmentObject->StdAttachmentGet(
ID => $ID,
);

# check permission for all linked templates.
if ( $Self->{LightAdmin} ) {
$Data{Permission} = $StdAttachmentObject->StdAttachmentStandardTemplatePermission(
ID => $ID,
UserID => $Self->{UserID},
);
next ID if !$Data{Permission};
}

$LayoutObject->Block(
Name => 'OverviewResultRow',
Data => {
Expand Down
Loading
Loading