mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-20 08:52:15 +00:00
Frontend upload restrict consolidation
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
namespace App\Users\Restrictions\Engines;
|
||||
|
||||
use App\Users\Models\User;
|
||||
use App\Users\Restrictions\RestrictionsEngine;
|
||||
use Domain\Teams\Actions\CheckMaxTeamMembersLimitAction;
|
||||
|
||||
class DefaultRestrictionsEngine implements RestrictionsEngine
|
||||
{
|
||||
public function canUpload(User $user, int $fileSize = 0): bool
|
||||
{
|
||||
// 1. If storage limitations is set to false, then allow upload
|
||||
if (! get_settings('storage_limitation')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Get used storage percentage
|
||||
$usedPercentage = get_storage_percentage(
|
||||
used: $user->usedCapacity + $fileSize,
|
||||
maxAmount: $user->limitations->max_storage_amount,
|
||||
);
|
||||
|
||||
// 2. Check if storage usage exceed predefined capacity
|
||||
return ! ($usedPercentage >= 100);
|
||||
}
|
||||
|
||||
public function canDownload(User $user): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function canCreateFolder(User $user): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function canCreateTeamFolder(User $user): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function canInviteTeamMembers(User $user, array $newInvites = []): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function canVisitShared(User $user): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user