Merge pull request #4985 from tsiegleauq/more-mediafile-permission

Add more permission checks to file manager
This commit is contained in:
Emanuel Schütze 2019-09-06 12:16:37 +02:00 committed by GitHub
commit 84bb091e0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 15 deletions

View File

@ -172,26 +172,28 @@
<!-- Menu for single files in the list --> <!-- Menu for single files in the list -->
<mat-menu #singleMediafileMenu="matMenu"> <mat-menu #singleMediafileMenu="matMenu">
<ng-template matMenuContent let-mediafile="mediafile"> <ng-template matMenuContent let-mediafile="mediafile">
<!-- Exclusive for images --> <div *osPerms="'core.can_manage_logos_and_fonts'">
<div *ngIf="mediafile.isImage() && canEdit"> <!-- Exclusive for images -->
<div *ngFor="let action of logoActions"> <div *ngIf="mediafile.isImage()">
<ng-container <div *ngFor="let action of logoActions">
*ngTemplateOutlet="manageButton; context: { mediafile: mediafile, action: action }" <ng-container
></ng-container> *ngTemplateOutlet="manageButton; context: { mediafile: mediafile, action: action }"
></ng-container>
</div>
</div> </div>
</div>
<!-- Exclusive for fonts --> <!-- Exclusive for fonts -->
<div *ngIf="mediafile.isFont() && canEdit"> <div *ngIf="mediafile.isFont()">
<div *ngFor="let action of fontActions"> <div *ngFor="let action of fontActions">
<ng-container <ng-container
*ngTemplateOutlet="manageButton; context: { mediafile: mediafile, action: action }" *ngTemplateOutlet="manageButton; context: { mediafile: mediafile, action: action }"
></ng-container> ></ng-container>
</div>
</div> </div>
<mat-divider *ngIf="mediafile.isFont() || mediafile.isImage()"></mat-divider>
</div> </div>
<!-- Edit and delete for all images --> <!-- Edit and delete for all images -->
<mat-divider *ngIf="mediafile.isFont() || mediafile.isImage()"></mat-divider>
<os-projector-button <os-projector-button
*ngIf="mediafile.isProjectable()" *ngIf="mediafile.isProjectable()"
[object]="mediafile" [object]="mediafile"

View File

@ -81,6 +81,7 @@ export class MediafileListComponent extends BaseListViewComponent<ViewMediafile>
return ( return (
this.operator.hasPerms('core.can_manage_projector') || this.operator.hasPerms('core.can_manage_projector') ||
this.operator.hasPerms('agenda.can_see_list_of_speakers') || this.operator.hasPerms('agenda.can_see_list_of_speakers') ||
this.operator.hasPerms('core.can_manage_logos_and_fonts') ||
this.canEdit this.canEdit
); );
} }
@ -253,6 +254,8 @@ export class MediafileListComponent extends BaseListViewComponent<ViewMediafile>
return ( return (
this.operator.hasPerms('agenda.can_see_list_of_speakers') || this.operator.hasPerms('agenda.can_see_list_of_speakers') ||
(file.isProjectable() && this.operator.hasPerms('core.can_manage_projector')) || (file.isProjectable() && this.operator.hasPerms('core.can_manage_projector')) ||
(file.isFont() && this.operator.hasPerms('core.can_manage_logos_and_fonts')) ||
(file.isImage() && this.operator.hasPerms('core.can_manage_logos_and_fonts')) ||
this.canEdit this.canEdit
); );
} }
@ -433,7 +436,9 @@ export class MediafileListComponent extends BaseListViewComponent<ViewMediafile>
public onManageButton(event: any, file: ViewMediafile, action: string): void { public onManageButton(event: any, file: ViewMediafile, action: string): void {
// prohibits automatic closing // prohibits automatic closing
event.stopPropagation(); event.stopPropagation();
this.mediaManage.setAs(file, action); this.mediaManage.setAs(file, action).then(() => {
this.cd.markForCheck();
});
} }
public createNewFolder(templateRef: TemplateRef<string>): void { public createNewFolder(templateRef: TemplateRef<string>): void {