filesysteme

This commit is contained in:
Mathieu Lagacé
2020-09-12 10:13:21 -04:00
parent ae00c9e7e0
commit b3f471e6e9
21 changed files with 952 additions and 1221 deletions

View File

@@ -0,0 +1,58 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Contracts\Filesystem\Cloud;
class initDrive extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'drive:init';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Initialize drive';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
\Storage::cloud()->createDir('Systeme');
\Storage::cloud()->createDir('Systeme/Fichier');
\Storage::cloud()->createDir('Systeme/Fichier/PlanDeCours');
\Storage::cloud()->createDir('Systeme/Fichier/MessageDeLaSemaine');
\Storage::cloud()->createDir('Prive');
\Storage::cloud()->createDir('Prive/Cadet');
\Storage::cloud()->createDir('Prive/ETAMAS');
\Storage::cloud()->createDir('Prive/Officier');
\Storage::cloud()->createDir('Prive/Staff');
\Storage::cloud()->createDir('Prive/Staff/Guide');
\Storage::cloud()->createDir('Prive/Staff/Instruction');
\Storage::cloud()->createDir('Publique');
\Storage::cloud()->createDir('Publique/Fichier');
\Storage::cloud()->createDir('Publique/Image');
return "Drive is initialized";
}
}

View File

@@ -41,12 +41,21 @@ class FilesController extends Controller
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
* @param string $id
* @return void
*/
public function show($id)
public function show($path)
{
//
$file_rules = \DB::table('acl_rules')->where('path','=',$path)->get()->all();
if ($file_rules != []) {
dd($file_rules);
}
dd(dirname($path));
$path_rules = \DB::table('acl_rules')->where('path','=',dirname($path))->get()->all();
if ($path_rules != []) {
}
return abort(404);
}
/**

View File

@@ -0,0 +1,72 @@
<?php
namespace App\Services;
use Alexusmai\LaravelFileManager\Services\ACLService\ACLRepository;
/**
* Class DBACLRepository
*
* @package Alexusmai\LaravelFileManager\Services\ACLService
*/
class DBACLRepository implements ACLRepository
{
/**
* Get user ID
*
* @return mixed
*/
public function getUserID()
{
return \Auth::id();
}
public function getUserRank()
{
return \Auth::user()->rank_id;
}
public function getUserJobs()
{
return \Auth::user()->job_id;
}
/**
* Get ACL rules list for user
*
* @return array
*/
public function getRules(): array
{
$rules = \DB::table('acl_rules')
->where('user_id', $this->getUserID())
->get(['disk', 'path', 'access'])
->map(function ($item) {
return get_object_vars($item);
})
->all();
$rank_rules = \DB::table('acl_rules')
->where('rank_id', $this->getUserRank())
->get(['disk', 'path', 'access'])
->map(function ($item) {
return get_object_vars($item);
})
->all();
$job_rules = \DB::table('acl_rules')
->where('job_id', $this->getUserJobs())
->get(['disk', 'path', 'access'])
->map(function ($item) {
return get_object_vars($item);
})
->all();
$all_rules = \DB::table('acl_rules')
->where('user_id', '=','*')
->get(['disk', 'path', 'access'])
->map(function ($item) {
return get_object_vars($item);
})
->all();
$rules = array_merge($rules,$rank_rules,$job_rules,$all_rules);
return $rules;
}
}