diff --git a/src/app/resource/controllers/LinkController.php b/src/app/resource/controllers/LinkController.php index d863615f12fe59f6b04d04fb5a2998468077a3d2..2a67f44a109596c15323787f243565795d28d631 100644 --- a/src/app/resource/controllers/LinkController.php +++ b/src/app/resource/controllers/LinkController.php @@ -18,6 +18,7 @@ use Contact\controllers\ContactController; use Contact\models\ContactModel; use Entity\models\EntityModel; use Entity\models\ListInstanceModel; +use Group\controllers\PrivilegeController; use History\controllers\HistoryController; use Resource\models\ResModel; use Resource\models\ResourceContactModel; @@ -99,6 +100,10 @@ class LinkController public function linkResources(Request $request, Response $response, array $args) { + if (!PrivilegeController::hasPrivilege(['privilegeId' => 'add_links', 'userId' => $GLOBALS['id']])) { + return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']); + } + if (!Validator::intVal()->validate($args['resId']) || !ResController::hasRightByResId(['resId' => [$args['resId']], 'userId' => $GLOBALS['id']])) { return $response->withStatus(403)->withJson(['errors' => 'Resource out of perimeter']); } @@ -163,6 +168,10 @@ class LinkController public function unlinkResources(Request $request, Response $response, array $args) { + if (!PrivilegeController::hasPrivilege(['privilegeId' => 'add_links', 'userId' => $GLOBALS['id']])) { + return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']); + } + if (!Validator::intVal()->validate($args['resId']) || !ResController::hasRightByResId(['resId' => [$args['resId']], 'userId' => $GLOBALS['id']])) { return $response->withStatus(403)->withJson(['errors' => 'Resource out of perimeter']); } diff --git a/src/frontend/app/linkedResource/linked-resource-list.component.html b/src/frontend/app/linkedResource/linked-resource-list.component.html index 0727d29341582c93188e5321761227b2be8b1814..99603bd7aa77cd110a593f4474a5909062a94a09 100644 --- a/src/frontend/app/linkedResource/linked-resource-list.component.html +++ b/src/frontend/app/linkedResource/linked-resource-list.component.html @@ -59,7 +59,7 @@ [class.undefined]="row.subject == lang.undefined" title="{{row.subject}}">{{row.subject | shorten: 150: '...'}}</span> <span class="main-info-data"> - <button mat-icon-button color="warn" [title]="lang.unlink" + <button *ngIf="privilegeService.hasCurrentUserPrivilege('add_links')" mat-icon-button color="warn" [title]="lang.unlink" (click)="$event.stopPropagation();unlinkResource(row)"> <mat-icon class="fa fa-unlink fa-2x" aria-hidden="true"></mat-icon> </button> @@ -70,7 +70,7 @@ <mat-row *matRowDef="let row; columns: displayedColumns;" (mouseenter)="viewThumbnail(row);" (mouseleave)="closeThumbnail();"></mat-row> </mat-table> - <button mat-fab class="linkRes" color="primary" [title]="lang.linkResource" (click)="openSearchResourceModal()"> + <button *ngIf="privilegeService.hasCurrentUserPrivilege('add_links')" mat-fab class="linkRes" color="primary" [title]="lang.linkResource" (click)="openSearchResourceModal()"> <mat-icon class="fa fa-link" style="height:auto;"></mat-icon> </button> </ng-template> \ No newline at end of file diff --git a/src/frontend/app/linkedResource/linked-resource-list.component.ts b/src/frontend/app/linkedResource/linked-resource-list.component.ts index 4275c7831ec49d4cfa1249bcfe36c42e4efd5549..a6dc9fcf5a39297e5d357ab2a1fe1ddd27a52d3e 100644 --- a/src/frontend/app/linkedResource/linked-resource-list.component.ts +++ b/src/frontend/app/linkedResource/linked-resource-list.component.ts @@ -13,6 +13,7 @@ import { MatDialog } from '@angular/material'; import { LinkResourceModalComponent } from './linkResourceModal/link-resource-modal.component'; import { FunctionsService } from '../../service/functions.service'; import { ContactsListModalComponent } from '../contact/list/modal/contacts-list-modal.component'; +import { PrivilegeService } from '../../service/privileges.service'; declare function $j(selector: any): any; @@ -44,7 +45,8 @@ export class LinkedResourceListComponent implements OnInit { private notify: NotificationService, public appService: AppService, public dialog: MatDialog, - public functions: FunctionsService + public functions: FunctionsService, + private privilegeService: PrivilegeService ) { } ngOnInit(): void { diff --git a/src/frontend/lang/lang-en.ts b/src/frontend/lang/lang-en.ts index e30c9d81abee7edae2496b47f4450ba13255265c..5a0101ec4b1a93a944390f9e0c195ab4e5b7d76e 100755 --- a/src/frontend/lang/lang-en.ts +++ b/src/frontend/lang/lang-en.ts @@ -1181,6 +1181,7 @@ export const LANG_EN = { "viewFullHistoryDesc" : "Read the full events history linked to the utilisation of Maarch.", "editResource" : "Edit a document", "editResourceDesc" : "Edit a document. Il will also depend on status setting (Index modification)", + "addLinks" : "Add links", "deleteDocumentInDetail" : "Delete a document in detail page", "manageTagsInApplication" : "Create tags", "manageTagsInApplicationDesc" : "Create tags while indexing, processing and in details", diff --git a/src/frontend/lang/lang-fr.ts b/src/frontend/lang/lang-fr.ts index 7ca8df863fe7021f1f4a0a6c3b6ed2f4bede75b1..9608c0b2cb26eb98f3f58b28b1dc882e5c012b99 100755 --- a/src/frontend/lang/lang-fr.ts +++ b/src/frontend/lang/lang-fr.ts @@ -1219,6 +1219,7 @@ export const LANG_FR = { "viewFullHistoryDesc" : "Consulter l'historique complet des événements relatifs à l'utilisation de la GED Maarch.", "editResource" : "Modifier les données d'un courrier", "editResourceDesc" : "Modifier les données d'un courrier. Cela dépendra aussi du paramétrage du statut (Modification des index)", + "addLinks" : "Ajouter des liaisons à un courrier", "deleteDocumentInDetail" : "Supprimer un document dans la fiche détaillée", "manageTagsInApplication" : "Créer des mots-clés depuis les pages d'actions", "manageTagsInApplicationDesc" : "Créer des mots-clés depuis l'indexation, le traitement et la fiche détaillée", diff --git a/src/frontend/lang/lang-nl.ts b/src/frontend/lang/lang-nl.ts index 5f4b6da211db1dc98af156f9bf0458ffa190263a..b33e8dc549296a8a96663f19e8983be86057d473 100755 --- a/src/frontend/lang/lang-nl.ts +++ b/src/frontend/lang/lang-nl.ts @@ -1207,6 +1207,7 @@ export const LANG_NL = { "viewFullHistoryDesc" : "De volledige geschiedenis van de evenementen over het gebruik van GED Maarch raadplegen.", "editResource" : "Een document in de gedetailleerde", "editResourceDesc" : "Een document in de gedetailleerde. Dat zal ook van de instelling van de status afhangen (Wijziging van de indexen)", + "addLinks" : "Add links", //_TO_TRANSLATE "deleteDocumentInDetail" : "Een document in de gedetailleerde fiche verwijderen", "manageTagsInApplication" : "Create tags", //_TO_TRANSLATE "manageTagsInApplicationDesc" : "Create tags while indexing, processing and in details", //_TO_TRANSLATE diff --git a/src/frontend/service/privileges.service.ts b/src/frontend/service/privileges.service.ts index 86c8f03637158884d395b69df86c403e962c16ba..d1e5d49a5b18184429a78d5a647e236ce2c106fd 100644 --- a/src/frontend/service/privileges.service.ts +++ b/src/frontend/service/privileges.service.ts @@ -308,6 +308,12 @@ export class PrivilegeService { "comment": this.lang.editResourceDesc, "unit": 'application' }, + { + "id": "add_links", + "label": this.lang.addLinks, + "comment": this.lang.addLinks, + "unit": 'application' + }, { "id": "delete_document_in_detail", "label": this.lang.deleteDocumentInDetail,