mirror of
https://gitlab.com/TheGamecraft/c-cms.git
synced 2026-04-21 02:39:10 -04:00
Finalisation de Google Drive
This commit is contained in:
@@ -141,7 +141,7 @@ class ConfigController extends Controller
|
||||
public function editfilesConfig()
|
||||
{
|
||||
$configList = [
|
||||
'cadet_list'
|
||||
'cadet_list',
|
||||
];
|
||||
|
||||
$configListEncrypt = [
|
||||
@@ -151,6 +151,19 @@ class ConfigController extends Controller
|
||||
'GOOGLE_DRIVE_FOLDER_ID'
|
||||
];
|
||||
|
||||
if (\request('is_active') == 'on')
|
||||
{
|
||||
$config = \App\Config::find('is_Google_Drive_enabled');
|
||||
$config->data = ['true'];
|
||||
$config->save();
|
||||
}
|
||||
else
|
||||
{
|
||||
$config = \App\Config::find('is_Google_Drive_enabled');
|
||||
$config->data = ['false'];
|
||||
$config->save();
|
||||
}
|
||||
|
||||
|
||||
foreach ($configList as $configName)
|
||||
{
|
||||
|
||||
@@ -254,10 +254,21 @@ class GoogleDriveController extends Controller
|
||||
public function checkFileSystem()
|
||||
{
|
||||
$error = [];
|
||||
if(\App\Config::getData('is_Google_Drive_enabled'))
|
||||
if(\App\Config::getData('is_Google_Drive_enabled') == "true")
|
||||
{
|
||||
$structure = $this->getFileStructure();
|
||||
$this->checkStructure($structure,'/','/',$error);
|
||||
if ($this->checkConfig())
|
||||
{
|
||||
$structure = $this->getFileStructure();
|
||||
$this->checkStructure($structure,'/','/',$error);
|
||||
}
|
||||
else
|
||||
{
|
||||
$error = ['Il y a un probleme avec vos configurations'];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$error = ['Google Drive n\'est pas actif'];
|
||||
}
|
||||
return $error;
|
||||
}
|
||||
@@ -329,4 +340,24 @@ class GoogleDriveController extends Controller
|
||||
return $dir;
|
||||
}
|
||||
|
||||
public function checkConfig()
|
||||
{
|
||||
$configNull = (\Crypt::decryptString(\App\Config::getData('GOOGLE_DRIVE_CLIENT_ID')) != "" && \Crypt::decryptString(\App\Config::getData('GOOGLE_DRIVE_CLIENT_SECRET')) != "" && \Crypt::decryptString(\App\Config::getData('GOOGLE_DRIVE_REFRESH_TOKEN')) != "" && \Crypt::decryptString(\App\Config::getData('GOOGLE_DRIVE_FOLDER_ID')) != "");
|
||||
$configOk = true;
|
||||
|
||||
if ($configNull)
|
||||
{
|
||||
try {
|
||||
$contents = collect(Storage::cloud()->listContents("/", false));
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
$configOk = false;
|
||||
}
|
||||
}
|
||||
|
||||
return $configNull && $configOk;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user