Skip to content
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
18 changes: 9 additions & 9 deletions controllers/EditController.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,24 @@ public function actionFolder($id = null)
{
$folder = FileSystemItem::getItemById($id);

if ($folder && !$folder->content->canEdit()) {
throw new HttpException(403);
}

if ($folder && $folder->content->container->id !== $this->contentContainer->id) {
throw new HttpException(404);
}

$post = Yii::$app->request->post();

// create new folder if no folder was found or folder is not editable.
if (!$folder || !($folder instanceof Folder) || !$folder->isEditableFolder()) {
if (!($folder instanceof Folder) || !$folder->isEditableFolder()) {
$this->getCurrentFolder()->resolveConflictsBeforeCreate($post['Folder']['title'] ?? null);
$folder = $this->getCurrentFolder()->newFolder();
$folder->content->container = $this->contentContainer;
$folder->hidden = $this->module->getContentHiddenDefault($this->contentContainer);
}

if (!($folder instanceof Folder) || $folder->content->container->id !== $this->contentContainer->id) {
throw new HttpException(404);
}

if (!$folder->content->canEdit()) {
throw new HttpException(403);
}

if ($folder->load($post) && $folder->save()) {
$this->view->saved();
return $this->htmlRedirect($folder->createUrl('/cfiles/browse/index'));
Expand Down
3 changes: 3 additions & 0 deletions controllers/ZipController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
use humhub\modules\cfiles\actions\UploadZipAction;
use humhub\modules\cfiles\libs\ZIPCreator;
use humhub\modules\cfiles\models\FileSystemItem;
use humhub\modules\cfiles\permissions\WriteAccess;
use Yii;
use yii\web\BadRequestHttpException;

/**
* ZipController
Expand All @@ -27,6 +29,7 @@ protected function getAccessRules()
{
return [
['checkZipSupport'],
['permission' => [WriteAccess::class], 'actions' => ['upload']],
];
}

Expand Down
5 changes: 3 additions & 2 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
Changelog
=========

0.16.11 - Unreleased
-------------------------
0.16.11 - November 24, 2025
---------------------------
- Enh #264: Update download and upload actions
- Fix #267: Include only accessible folders and files in a downloading zip archive

0.16.10 - August 1, 2025
Expand Down
4 changes: 2 additions & 2 deletions models/FileSystemItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -334,11 +334,11 @@ public function canEdit(): bool
return true;
}

if (Yii::$app->user->isGuest || $this->isNewRecord) {
if (Yii::$app->user->isGuest) {
return false;
}

return $this->content->created_by === Yii::$app->user->id &&
return ($this->isNewRecord || $this->content->created_by === Yii::$app->user->id) &&
$this->content->container->permissionManager->can(WriteAccess::class);
}

Expand Down
Loading