Closed anilone closed 5 years ago
Hi, thank you.
/**
* Get disk list
* @return array
*/
public function getDiskList(): array
{
if (\Request::route()->getName() === 'name1') {
return [
['disk1'],
];
} elseif(\Request::route()->getName() === 'name2') {
return [
['disk2'],
];
}
return ['disk1', 'disk2'];
}
/**
* ACL strategy
*
* blacklist - Allow everything(access - 2 - r/w) that is not forbidden by the ACL rules list
*
* whitelist - Deny anything(access - 0 - deny), that not allowed by the ACL rules list
*/
'aclStrategy' => 'blacklist',
Example:
public function getRules(): array
{
return [
['disk' => 'Cloud', 'path' => 'Finance Control/*/Bills', 'access' => 2],
['disk' => 'Cloud', 'path' => 'Finance Control/*/Bills/*', 'access' => 2],
['disk' => 'Cloud', 'path' => 'Finance Control/*/Day Book', 'access' => 2],
['disk' => 'Cloud', 'path' => 'Finance Control/*/Day Book/*', 'access' => 2],
['disk' => 'Cloud', 'path' => 'Finance Control/*/Tax Invoice', 'access' => 2],
['disk' => 'Cloud', 'path' => 'Finance Control/*/Tax Invoice/*', 'access' => 2],
['disk' => 'Cloud', 'path' => 'Finance Control/*/Vouchers', 'access' => 2],
['disk' => 'Cloud', 'path' => 'Finance Control/*/Vouchers/*', 'access' => 2],
['disk' => 'Cloud', 'path' => '*', 'access' => 1],
];
}
It would be better to open for r/w only the contents of these folders (Bills, Day Book, ..)
public function getRules(): array
{
return [
['disk' => 'Cloud', 'path' => 'Finance Control/*/Bills/*', 'access' => 2],
['disk' => 'Cloud', 'path' => 'Finance Control/*/Day Book/*', 'access' => 2],
['disk' => 'Cloud', 'path' => 'Finance Control/*/Tax Invoice/*', 'access' => 2],
['disk' => 'Cloud', 'path' => 'Finance Control/*/Vouchers/*', 'access' => 2],
['disk' => 'Cloud', 'path' => '*', 'access' => 1],
];
}
Rules are reading from up to down!
Hi , Thanks a bunch for the help !
My 2nd issue have solved perfectly , but 1st issue still persist.
I have created a TestConfigRepository and implemented the if condition as you suggested above
my Disk Drives are 'Finance Control' & 'Finance Tracker'
public function getDiskList(): array { if (\Request::route()->getName() === 'cloud.financetracker') { return [ 'Finance Tracker', ]; } elseif(\Request::route()->getName() === 'cloud.financecontrol') { return [ 'Finance Control', ]; }
}
It seems like not entering into the if conditions, \Request::route()->getName() is not working in this repository. I have tried this to get route name in Middleware for deleting purpose and is working fine.
i already tried 'use Illuminate\Http\Request;'
if the Disk drive is given outside the If condition it works .
Screen shot of the error is given below
is there any solution for this ?
Hi, I find out the reason for not entering into the if conditions.
public function getDiskList(): array { if (\Request::route()->getName() === 'cloud.financetracker') { return [ 'Finance Tracker', ]; } elseif(\Request::route()->getName() === 'cloud.financecontrol') { return [ 'Finance Control', ]; }
\Request::route()->getName() returns 'fm.initialize' which i think is a file manager route , need the route of entire web page instead. is there any way ?
Hi, yes. it's my mistake.. FM doesn't know anything about page url where he is working. It means that you can't change disk list for the selected url. I have no easy solution without changing the code ..
Hi, At last i found a solution for this problem. I set my route name in the session from my controller .
example: session(['myRoute' =>'cloud.financetracker']);
Now we can easily recognize the current route name of web page and use it in TestConfigRepository
if (session('myRoute') === 'cloud.financetracker') {
return [
'Finance Tracker'
];
} elseif(session('myRoute') === 'cloud.financecontrol') {
return [
'Finance Control'
];
}
we can also use this method for Delete and Upload middleware for FM.
Thanks a lot , All the best !
@anilone your solution is the only solution that worked for me after 2 days of trying to set configuration in different middlewares and controllers. Thank you. Great solution
Hi! Well done for your awesome work!
ACL rules has working fine with me for your test example codes,but for my project i have two issues and stuck with it. will mention the issues below, please help !
Issue No 1. I have 2 Disk drives and i am using file manager-laravel in two balde views with two routes. how can i restrict showing only one disk drive for a particular route.
Issue No 2. I need to give R/W permission to Some Sub folders with particular name , for their parent Folders give Read Only permission. as my folders are creating dynamically with random names i can't name it in ACL rule list,but the last sub folder names are always same.
for example , I have a main folder naming 'CLT 01' ,Under this Folder there is another folder 'FY-2014-2015', under this folder another 12 folders will be added which are months from April-2014 to March-2015 . Inside Every month folder, there are 4 sub folders. Need to Give R/W permission for the last Four sub folders only and all other folders should be Read only.
screen shot of the folder structure is shown below
Thanks for your help!