Skip to content

Commit

Permalink
Improve permission inheritance
Browse files Browse the repository at this point in the history
  • Loading branch information
Eseperio committed Oct 25, 2023
1 parent 81f7660 commit d1d7cee
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 36 deletions.
8 changes: 7 additions & 1 deletion src/actions/RemoveACL.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,21 @@ public function run()
$permModel = Yii::createObject(InodePermissionsForm::class);
$permModel->scenario = AccessControl::SCENARIO_DELETE;
$permModel->setAttributes(Yii::$app->request->post(), false);
$all = Yii::$app->request->post('all', false);
if ($permModel->validate()) {
try {
$realModel = AccessControl::find()->where([
'user_id' => $permModel->user_id,
'role' => $permModel->role,
'inode_id' => $permModel->inode_id
])->one();
if (!empty($realModel))

if (!empty($realModel)) {
if($all){
$realModel->removeSiblingsRecursive();
}
$realModel->delete();
}
} catch (\Throwable $e) {
throw $e;
}
Expand Down
7 changes: 5 additions & 2 deletions src/messages/es/filescatalog.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
'An error ocurred when trying to delete' => 'Ocurrió un error al intentar eliminar',
'An error ocurred while uploading the file/s' => 'Ocurrió un error al cargar el/los archivo/s',
'Apply to all children? This cannot be undone' => '¿Aplicar a todo el contenido de forma recursiva? Esto no se puede deshacer',
'Apply to children' => 'Aplicar a hijos',
'Apply to children' => 'Aplicar a descendientes',
'Author Name' => 'Nombre del autor',
'Back' => 'Atrás',
'Bulk access control' => 'Control de acceso en masa',
Expand Down Expand Up @@ -58,6 +58,7 @@
'Directories does not accept versioning' => 'Los directorios no permiten versiones',
'Directory' => 'Directorio',
'Download' => 'Descargar',
'Error saving file content: ' => 'Error al guardar el contenido del archivo: ',
'Everyone' => 'Todos',
'Expires At' => 'Fecha de caducidad',
'Extension' => 'Extensión',
Expand Down Expand Up @@ -103,6 +104,7 @@
'Read, Write and Delete' => 'Leer, escribir y borrar',
'Real path' => 'Ruta real',
'Recipient' => 'Destinatario',
'Remove here and in all descendants' => 'Quitar aquí y en todos los descendientes',
'Rename' => 'Renombrar',
'Role' => 'Rol',
'Root node can not be deleted' => 'El nodo principal no puede ser eliminado',
Expand Down Expand Up @@ -154,5 +156,6 @@
'or' => 'ó',
'tomorrow' => 'mañana',
'{user} has shared the file {filename} with you' => '{user} ha compartido el archivo {filename} contigo',
'Shared with {qty}' => '@@Compartido con {qty}@@',
'Remove' => 'Quitar',
'Shared with {qty}' => 'Compartido con {qty}',
];
81 changes: 48 additions & 33 deletions src/views/default/partials/_acl.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,42 +123,57 @@
}
?>
</div>
<div class="col-sm-3">
<div class="col-sm-2">
<?= CrudStatus::widget(['model' => $item]) ?>
</div>
<div class="col-sm-3">
<?= Html::a(Yii::t('filescatalog', 'Apply to children'), ['inherit-acl'],
[
'class' => 'pull-right',
'data' => [
'method' => 'post',
'confirm' => Yii::t('filescatalog', 'Apply to all children? This cannot be undone'),
'params' => [
'inode_id' => $item->inode_id,
'role' => $item->role,
'user_id' => $item->user_id
]
],
]) ?>
</div>
<div class="col-sm-3">
<?= Html::a(Yii::t('filescatalog', 'Delete'), [
'remove-acl',
], [
'class' => 'pull-right',
'data' => [
'method' => 'post',
'confirm' => Yii::t('filescatalog', 'Confirm deletion'),
'params' => [
'inode_id' => $item->inode_id,
'role' => $item->role,
'user_id' => $item->user_id
]
],
]) ?>

<div class="col-sm-6">
<ul>
<li>
<?= Html::a(Yii::t('filescatalog', 'Apply to children'), ['inherit-acl'],
[
'data' => [
'method' => 'post',
'confirm' => Yii::t('filescatalog', 'Apply to all children? This cannot be undone'),
'params' => [
'inode_id' => $item->inode_id,
'role' => $item->role,
'user_id' => $item->user_id
]
],
]) ?>
</li>
<li> <?= Html::a(Yii::t('filescatalog', 'Remove'), [
'remove-acl',
], [
'data' => [
'method' => 'post',
'confirm' => Yii::t('filescatalog', 'Confirm deletion'),
'params' => [
'inode_id' => $item->inode_id,
'role' => $item->role,
'user_id' => $item->user_id
]
],
]) ?></li>
<li>
<?= Html::a(Yii::t('filescatalog', 'Remove here and in all descendants'), [
'remove-acl',
], [
'data' => [
'method' => 'post',
'confirm' => Yii::t('filescatalog', 'Confirm deletion'),
'params' => [
'inode_id' => $item->inode_id,
'role' => $item->role,
'user_id' => $item->user_id,
'all' => true
]
],
]) ?>
</li>
</ul>
</div>
</
>
</li>
<?php endforeach; ?>
</ul>
Expand Down

0 comments on commit d1d7cee

Please sign in to comment.