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

patches php 81 #35

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
16 changes: 8 additions & 8 deletions controllers/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -723,19 +723,19 @@ public function actionSearch($q, $limit = '')
foreach ($query->all() as $item) {

// check read permissions or is folder
if (!$fileSystem->grantAccess($item['path'],
Filefly::ACCESS_READ) || $fileSystem->get($item['path'])->isDir()) {
continue;
}

try {
$item['id'] = $item['path'];
$item['mime'] = '';
$result[] = $item;
if (!$fileSystem->grantAccess($item['path'],
Filefly::ACCESS_READ) || $fileSystem->get($item['path'])->isDir()) {
continue;
}
} catch (FileNotFoundException $e) {
\Yii::warning($e->getMessage(), __METHOD__);
continue;
}

$item['id'] = $item['path'];
$item['mime'] = '';
$result[] = $item;
}

return $this->asJson($result);
Expand Down
2 changes: 1 addition & 1 deletion messages/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"compression_failed": "Compression failed",
"archive_opening_failed": "Could not open archive, it is either corrupted or unsupported",
"extraction_failed": "Extraction failed",
"upload_failed": "Upload filed",
"upload_failed": "Upload failed",
"recycling_failed": "An error occured during the filesystem recycling",
"permission_edit_denied" : "You are not allowed to edit this file",
"permission_upload_denied" : "You are not allowed to upload files to this directory",
Expand Down
2 changes: 1 addition & 1 deletion messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"compression_failed": "Compression failed",
"archive_opening_failed": "Could not open archive, it is either corrupted or unsupported",
"extraction_failed": "Extraction failed",
"upload_failed": "Upload filed",
"upload_failed": "Upload failed",
"recycling_failed": "An error occured during the filesystem recycling",
"permission_edit_denied" : "You are not allowed to edit this file",
"permission_upload_denied" : "You are not allowed to upload files to this directory",
Expand Down
18 changes: 16 additions & 2 deletions models/FileflyHashmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,22 @@ public static function accessColumnAttributes()
*/
public static function accessDefaults()
{
$currentModule = Yii::$app->controller->module->id;
return \Yii::$app->getModule($currentModule)->defaultPermissions;
$currentModule = isset(Yii::$app->loadedModules[Module::class]) ? Yii::$app->loadedModules[Module::class] : null;

if (isset($currentModule->defaultPermissions))
return $currentModule->defaultPermissions;

$currentModule = Yii::$app->getModule(Yii::$app->controller->module->id);

if (isset($currentModule->defaultPermissions))
return $currentModule->defaultPermissions;

$currentModule = Yii::$app->getModule(Module::NAME);

if (isset($currentModule->defaultPermissions))
return $currentModule->defaultPermissions;

return Module::getInstance()->defaultPermissions;
}

/**
Expand Down
4 changes: 4 additions & 0 deletions plugins/AccessPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ public function setFilesystem(FilesystemInterface $filesystem)
*/
protected function normalize($path)
{
if(empty($path)) {
return $path;
}

return '/' . ltrim($path, '/');
}
}
16 changes: 10 additions & 6 deletions plugins/SetAccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function handle($oldItemPath = null, $newItemPath = null)
->where(
[
'component' => $this->component,
'path' => $oldItemPath,
'path' => $oldItemPath,
]
)
->one();
Expand All @@ -68,12 +68,12 @@ public function handle($oldItemPath = null, $newItemPath = null)
$defaultPermissions = FileflyHashmap::accessDefaults();
$newHash = new FileflyHashmap(
[
'component' => $this->component,
'type' => $type,
'path' => $oldItemPath,
'size' => $size,
'component' => $this->component,
'type' => $type,
'path' => $oldItemPath,
'size' => $size,
'access_owner' => \Yii::$app->user->id,
Module::ACCESS_READ => $defaultPermissions[Module::ACCESS_READ],
Module::ACCESS_READ => $defaultPermissions[Module::ACCESS_READ],
Module::ACCESS_UPDATE => $defaultPermissions[Module::ACCESS_UPDATE],
Module::ACCESS_DELETE => $defaultPermissions[Module::ACCESS_DELETE],
]
Expand All @@ -97,6 +97,10 @@ public function handle($oldItemPath = null, $newItemPath = null)
*/
private function updateRecursive($oldItemPath, $newItemPath)
{
if (empty($newItemPath)) {
return true;
}

$find = $oldItemPath . '%';

$items = FileflyHashmap::find()
Expand Down