mirror of
https://gitlab.com/TheGamecraft/c-cms.git
synced 2026-04-23 19:39:10 -04:00
3.2.5
This commit is contained in:
@@ -24,4 +24,9 @@ class Config extends Model
|
||||
{
|
||||
return $this->morphMany('App\Log', 'logable');
|
||||
}
|
||||
|
||||
public static function find($name)
|
||||
{
|
||||
return Config::where('name',$name)->first();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,4 +25,9 @@ class Course extends Model
|
||||
{
|
||||
return $this->morphMany('App\Log', 'logable');
|
||||
}
|
||||
|
||||
public function use_course()
|
||||
{
|
||||
return $this->name == "" && $this->ocom == "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,4 +59,74 @@ class Event extends Model
|
||||
}
|
||||
return $events;
|
||||
}
|
||||
|
||||
public static function checkForError()
|
||||
{
|
||||
$events = Event::all();
|
||||
|
||||
$warning = [];
|
||||
$danger = [];
|
||||
|
||||
foreach ($events as $event)
|
||||
{
|
||||
if($event->date_begin == null)
|
||||
{
|
||||
array_push($warning,'Évènement ID:'.$event->id.' - "date_begin", Incorrect');
|
||||
}
|
||||
if($event->date_end == null)
|
||||
{
|
||||
array_push($warning,'Évènement ID:'.$event->id.' - "date_end", Incorrect');
|
||||
}
|
||||
if($event->type == null || $event->type == "" || !\App\EventType::all()->has($event->type))
|
||||
{
|
||||
$event->type = 1;
|
||||
//$event->save();
|
||||
array_push($warning,'Évènement ID:'.$event->id.' - "type", Incorrect... Réinitialisé à la valeur par défaut');
|
||||
clog('error','danger','Évènement ID:'.$event->id.' - "type", Incorrect... Réinitialisé à la valeur par défaut');
|
||||
}
|
||||
if($event->is_mandatory == null && $event->is_mandatory != 0)
|
||||
{
|
||||
array_push($warning,'Évènement ID:'.$event->id.' - "is_mandatory", Incorrect... Réinitialisé à la valeur par défaut');
|
||||
clog('error','danger','Évènement ID:'.$event->id.' - "is_mandatory", Incorrect... Réinitialisé à la valeur par défaut');
|
||||
}
|
||||
if($event->use_weekly_msg == null && $event->use_weekly_msg != 0)
|
||||
{
|
||||
array_push($warning,'Évènement ID:'.$event->id.' - "use_weekly_msg", Incorrect... Réinitialisé à la valeur par défaut');
|
||||
clog('error','danger','Évènement ID:'.$event->id.' - "use_weekly_msg", Incorrect... Réinitialisé à la valeur par défaut');
|
||||
}
|
||||
if($event->use_schedule == null && $event->use_schedule != 0)
|
||||
{
|
||||
array_push($warning,'Évènement ID:'.$event->id.' - "use_schedule", Incorrect... Réinitialisé à la valeur par défaut');
|
||||
clog('error','danger','Évènement ID:'.$event->id.' - "use_schedule", Incorrect... Réinitialisé à la valeur par défaut');
|
||||
}
|
||||
if($event->schedule == null)
|
||||
{
|
||||
$event->schedule = '{"periodes":[{"name":"Periode 1","begin_time":"19:00","end_time":"20:10"},{"name":"Periode 2","begin_time":"20:30","end_time":"21:20"}],"niveaux":[{"name":"Niveau 1"},{"name":"Niveau 2"},{"name":"Niveau 3"}]}';
|
||||
$event->save();
|
||||
array_push($warning,'Évènement ID:'.$event->id.' - "schedule", Incorrect... Réinitialisé à la valeur par défaut');
|
||||
clog('error','danger','Évènement ID:'.$event->id.' - "schedule", Incorrect... Réinitialisé à la valeur par défaut');
|
||||
}
|
||||
if($event->location == null || $event->location == "")
|
||||
{
|
||||
array_push($warning,'Évènement ID:'.$event->id.' - "location", Incorrect... Réinitialisé à la valeur par défaut');
|
||||
clog('error','danger','Évènement ID:'.$event->id.' - "location", Incorrect... Réinitialisé à la valeur par défaut');
|
||||
}
|
||||
if($event->calendar_color == null || $event->calendar_color == "")
|
||||
{
|
||||
$event->calendar_color = '#A4A4A4';
|
||||
$event->save();
|
||||
array_push($warning,'Évènement ID:'.$event->id.' - "calendar_color", Incorrect... Réinitialisé à la valeur par défaut');
|
||||
clog('error','danger','Évènement ID:'.$event->id.' - "calendar_color", Incorrect... Réinitialisé à la valeur par défaut');
|
||||
}
|
||||
if($event->calendar_icon == null || $event->calendar_icon == "")
|
||||
{
|
||||
$event->calendar_icon = 'fas fa-book';
|
||||
$event->save();
|
||||
array_push($warning,'Évènement ID:'.$event->id.' - "calendar_icon", Incorrect... Réinitialisé à la valeur par défaut');
|
||||
clog('error','danger','Évènement ID:'.$event->id.' - "calendar_icon", Incorrect... Réinitialisé à la valeur par défaut');
|
||||
}
|
||||
}
|
||||
|
||||
return [$warning,$danger];
|
||||
}
|
||||
}
|
||||
|
||||
39
app/GoogleDriveFile.php
Normal file
39
app/GoogleDriveFile.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class GoogleDriveFile extends Model
|
||||
{
|
||||
public static function icon($extension)
|
||||
{
|
||||
$icon = "fas fa-file";
|
||||
switch ($extension)
|
||||
{
|
||||
case 'pdf':
|
||||
$icon = 'fas fa-file-pdf text-pdf';
|
||||
break;
|
||||
case 'php':
|
||||
$icon = 'fas fa-file-code text-code';
|
||||
break;
|
||||
case 'pptx':
|
||||
$icon = 'fas fa-file-powerpoint text-powerpoint';
|
||||
break;
|
||||
case 'docx':
|
||||
case 'odt':
|
||||
$icon = 'fas fa-file-word text-word';
|
||||
break;
|
||||
case 'ods':
|
||||
case 'xlsx':
|
||||
$icon = 'fas fa-file-excel text-excel';
|
||||
break;
|
||||
case 'png':
|
||||
case 'PNG':
|
||||
case 'jpg':
|
||||
$icon = 'fas fa-file-image text-image';
|
||||
break;
|
||||
}
|
||||
return $icon;
|
||||
}
|
||||
}
|
||||
@@ -36,4 +36,10 @@ class AdminController extends Controller
|
||||
return view('admin.update');
|
||||
}
|
||||
|
||||
public function status()
|
||||
{
|
||||
$alerts = \App\Event::checkForError();
|
||||
return view('admin.status.index',['alerts' => $alerts]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -137,13 +137,33 @@ class ConfigController extends Controller
|
||||
|
||||
public function editfilesConfig()
|
||||
{
|
||||
$config = \App\Config::all()->where('name','cadet_list')->first();
|
||||
$configList = [
|
||||
'cadet_list'
|
||||
];
|
||||
|
||||
$config->data = [\request('cadet_list')];
|
||||
$configListEncrypt = [
|
||||
'GOOGLE_DRIVE_CLIENT_ID',
|
||||
'GOOGLE_DRIVE_CLIENT_SECRET',
|
||||
'GOOGLE_DRIVE_REFRESH_TOKEN',
|
||||
'GOOGLE_DRIVE_FOLDER_ID'
|
||||
];
|
||||
|
||||
$config->save();
|
||||
|
||||
clog('edit','success','a modifié la configuration');
|
||||
foreach ($configList as $configName)
|
||||
{
|
||||
$config = \App\Config::find($configName);
|
||||
$config->data = [\request($configName)];
|
||||
$config->save();
|
||||
}
|
||||
|
||||
foreach ($configListEncrypt as $configName)
|
||||
{
|
||||
$config = \App\Config::find($configName);
|
||||
$config->data = [\Crypt::encryptString(\request($configName))];
|
||||
$config->save();
|
||||
}
|
||||
|
||||
clog('edit','success','a modifié la configuration des fichiers');
|
||||
return redirect('/admin/config/files')->with('success','Modification sauvegarder avec succès !');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,6 +38,8 @@ class EventController extends Controller
|
||||
{
|
||||
$event = new Event();
|
||||
|
||||
|
||||
|
||||
$event->name = request('name');
|
||||
$event->date_begin = request('begin_time');
|
||||
$event->date_end = request('end_time');
|
||||
@@ -51,7 +53,7 @@ class EventController extends Controller
|
||||
$event->is_mandatory = 0;
|
||||
}
|
||||
|
||||
$event->desc = '';
|
||||
$event->desc = \request('admin_desc');
|
||||
|
||||
if(\request("use_weekly_msg"))
|
||||
{
|
||||
@@ -95,10 +97,10 @@ class EventController extends Controller
|
||||
]);
|
||||
$nbPeriode++;
|
||||
}
|
||||
|
||||
$event->schedule = [
|
||||
'periodes' => $periodes,
|
||||
'niveaux' => $niveaux
|
||||
'niveaux' => $niveaux,
|
||||
'courses' => []
|
||||
];
|
||||
|
||||
$event->save();
|
||||
@@ -106,7 +108,7 @@ class EventController extends Controller
|
||||
if ($event->use_schedule) {
|
||||
for ($l=1; $l < $nbLevel; $l++) {
|
||||
for ($p=1; $p < $nbPeriode; $p++) {
|
||||
|
||||
|
||||
$course = new \App\Course();
|
||||
|
||||
$users = \App\User::all();
|
||||
@@ -119,16 +121,26 @@ class EventController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
$course->name = request('name_n'.$l.'_p'.$p);
|
||||
$course->user_id = $instructor;
|
||||
$course->ocom = request('ocom_n'.$l.'_p'.$p);
|
||||
$course->location = request('location_n'.$l.'_p'.$p);
|
||||
$course->periode = $p;
|
||||
$course->level = $l;
|
||||
|
||||
$course->comment = "";
|
||||
$course->event_id = $event->id;
|
||||
|
||||
if(\request("use_course_n".$l."_p".$p) == 'on')
|
||||
{
|
||||
$course->name = request('name_n'.$l.'_p'.$p);
|
||||
$course->ocom = request('ocom_n'.$l.'_p'.$p);
|
||||
$course->comment = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
$course->name = "";
|
||||
$course->ocom = "";
|
||||
$course->comment = request('desc_n'.$l.'_p'.$p);
|
||||
}
|
||||
|
||||
$course->save();
|
||||
}
|
||||
}
|
||||
@@ -253,4 +265,9 @@ class EventController extends Controller
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function checkEvent()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
117
app/Http/Controllers/GoogleDriveController.php
Normal file
117
app/Http/Controllers/GoogleDriveController.php
Normal file
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class GoogleDriveController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @param string $dir
|
||||
* @param bool $recursive
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index($dir = '/',$recursive = true)
|
||||
{
|
||||
$contents = collect(Storage::cloud()->listContents($dir, $recursive));
|
||||
|
||||
return $contents->where('type', '=', 'file'); // files
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return bool
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$path = Storage::cloud()->makeDirectory('Test Dir');
|
||||
dd($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param $filename
|
||||
* @return \Illuminate\Http\Response
|
||||
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
|
||||
*/
|
||||
public function show()
|
||||
{
|
||||
$filename = \request('file');
|
||||
$recursive = false; // Get subdirectories also?
|
||||
$contents = collect(Storage::cloud()->listContents('/1nEe35-GvLX598RketTI-UoaOxIMNxfka', true));
|
||||
|
||||
$file = $contents
|
||||
->where('type', '=', 'file')
|
||||
->where('filename', '=', pathinfo($filename, PATHINFO_FILENAME))
|
||||
->where('extension', '=', pathinfo($filename, PATHINFO_EXTENSION))
|
||||
->first(); // there can be duplicate file names!
|
||||
|
||||
//return $file; // array with file info
|
||||
|
||||
$rawData = Storage::cloud()->get($file['path']);
|
||||
|
||||
return response($rawData, 200)
|
||||
->header('ContentType', $file['mimetype'])
|
||||
->header('Content-Disposition', "attachment; filename='$filename'");
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function list()
|
||||
{
|
||||
$dir = '/';
|
||||
$recursive = false; // Get subdirectories also?
|
||||
$contents = collect(Storage::cloud()->listContents($dir, $recursive));
|
||||
|
||||
return view('admin.files.Google Drive.index',['directories' => $contents->where('type', '=', 'dir'), 'files' => $contents->where('type', '=', 'file')]);
|
||||
//return $contents->where('type', '=', 'file'); // files
|
||||
}
|
||||
}
|
||||
@@ -272,6 +272,36 @@ class Permission extends Model
|
||||
'icon' => 'fa-eye',
|
||||
'valeur' => 0
|
||||
],
|
||||
],
|
||||
'file' => [
|
||||
'file_see' => [
|
||||
'ckey' => 'file_see',
|
||||
'communName' => 'Voir les fichiers',
|
||||
'desc' => 'L\'utilisateur peut-il consulter les fichiers',
|
||||
'icon' => 'fa-eye',
|
||||
'valeur' => 0
|
||||
],
|
||||
'file_add' => [
|
||||
'ckey' => 'file_add',
|
||||
'communName' => 'Ajouter un fichier',
|
||||
'desc' => 'L\'utilisateur peut-il ajouter un fichier',
|
||||
'icon' => 'fa-eye',
|
||||
'valeur' => 0
|
||||
],
|
||||
'file_edit' => [
|
||||
'ckey' => 'file_edit',
|
||||
'communName' => 'Modifier un fichier',
|
||||
'desc' => 'L\'utilisateur peut-il modifier un fichier',
|
||||
'icon' => 'fa-eye',
|
||||
'valeur' => 0
|
||||
],
|
||||
'file_delete' => [
|
||||
'ckey' => 'file_delete',
|
||||
'communName' => 'Supprimer un fichier',
|
||||
'desc' => 'L\'utilisateur peut-il supprimer un fichier',
|
||||
'icon' => 'fa-eye',
|
||||
'valeur' => 0
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
|
||||
44
app/Providers/GoogleDriveServiceProvider.php
Normal file
44
app/Providers/GoogleDriveServiceProvider.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Hypweb\Flysystem\GoogleDrive\GoogleDriveAdapter;
|
||||
|
||||
class GoogleDriveServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Register services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Bootstrap services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
\Storage::extend('google', function($app, $config) {
|
||||
$client = new \Google_Client();
|
||||
$client->setClientId(\Crypt::decryptString(\App\Config::getData('GOOGLE_DRIVE_CLIENT_ID')));
|
||||
$client->setClientSecret(\Crypt::decryptString(\App\Config::getData('GOOGLE_DRIVE_CLIENT_SECRET')));
|
||||
$client->refreshToken(\Crypt::decryptString(\App\Config::getData('GOOGLE_DRIVE_REFRESH_TOKEN')));
|
||||
$service = new \Google_Service_Drive($client);
|
||||
|
||||
$options = [];
|
||||
if(isset($config['teamDriveId'])) {
|
||||
$options['teamDriveId'] = $config['teamDriveId'];
|
||||
}
|
||||
|
||||
$adapter = new GoogleDriveAdapter($service, \Crypt::decryptString(\App\Config::getData('GOOGLE_DRIVE_FOLDER_ID')), $options);
|
||||
|
||||
return new \League\Flysystem\Filesystem($adapter);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user