Merge branch 'arcadia_link'
This commit is contained in:
commit
6532fc2fda
24 changed files with 607 additions and 42 deletions
75
app/Console/Commands/ArcadiaLink.php
Normal file
75
app/Console/Commands/ArcadiaLink.php
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Media;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class ArcadiaLink extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'arcadialink:process';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->info('Démarrage du traitement');
|
||||
$files = Storage::disk('arcadia_link_r')->files();
|
||||
$bar = $this->output->createProgressBar(count($files)-1);
|
||||
$bar->start();
|
||||
|
||||
foreach ($files as $filename) {
|
||||
if($filename == ".gitignore" || $filename == ".gitkeep") continue;
|
||||
|
||||
// ---- Récupération du contenu
|
||||
$files = Storage::disk('arcadia_link_r')->get($filename);
|
||||
$fileContent = simplexml_load_string($files, null, LIBXML_NOCDATA);
|
||||
|
||||
$media = Media::find($fileContent->code_DAM);
|
||||
$media->arcadia_id = $fileContent->codeArcadia;
|
||||
$media->version = $fileContent->version;
|
||||
$media->isLocked = 0;
|
||||
$media->save();
|
||||
|
||||
// ---- Index dans Elasticsearch
|
||||
$media = Media::find($media->id);
|
||||
$esExist = Media::searchByQuery(array('match' => array('arcadia_id' => "$media->arcadia_id")));
|
||||
if ($esExist)
|
||||
$media->removeFromIndex();
|
||||
$media->addToIndex();
|
||||
|
||||
//Storage::disk('arcadia_link_r')->delete($filename);
|
||||
$bar->advance();
|
||||
}
|
||||
|
||||
$bar->finish();
|
||||
$this->line("");
|
||||
$this->info('Fin du traitement');
|
||||
}
|
||||
}
|
||||
|
|
@ -238,6 +238,9 @@ class DossierController extends Controller
|
|||
$response['draggable'] = false;
|
||||
}
|
||||
|
||||
// Envoi du role
|
||||
$response['role'] = Auth::user()->role;
|
||||
|
||||
return json_encode($response);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Traits\ArcadiaLink;
|
||||
use Elasticquent\ElasticquentTrait;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Http\Request;
|
||||
|
|
@ -531,7 +532,6 @@ class MediaController extends Controller
|
|||
} else {
|
||||
$response['draggable'] = false;
|
||||
}
|
||||
$response['role'] = Auth::user()->role;
|
||||
$response['isDepot'] = $isDepot;
|
||||
|
||||
return json_encode($response);
|
||||
|
|
@ -576,6 +576,16 @@ class MediaController extends Controller
|
|||
$historique->description = "Média déplacé à la racine";
|
||||
}
|
||||
$media->save();
|
||||
|
||||
// Elasticsearch
|
||||
$id = $media->id;
|
||||
$media = Media::find($id);
|
||||
$media->removeFromIndex();
|
||||
$media->addToIndex();
|
||||
|
||||
// Lien Arcadia
|
||||
ArcadiaLink::update($media);
|
||||
|
||||
$historique->save();
|
||||
}
|
||||
}
|
||||
|
|
@ -594,7 +604,12 @@ class MediaController extends Controller
|
|||
$user_id = Auth::user()->id;
|
||||
$deleteMedias = $request->input('medias');
|
||||
|
||||
$medias = Media::whereIn('id', $deleteMedias)->whereNull('arcadia_id')->get();
|
||||
if (Auth::user()->hasRole(config('roles.const.ADMIN'))){
|
||||
$medias = Media::whereIn('id', $deleteMedias)->get();
|
||||
}else{
|
||||
$medias = Media::whereIn('id', $deleteMedias)->whereNull('arcadia_id')->get();
|
||||
}
|
||||
|
||||
foreach ($medias as $media) {
|
||||
$deletedMediasList[] = $media->id;
|
||||
|
||||
|
|
@ -606,12 +621,41 @@ class MediaController extends Controller
|
|||
$historique->description = "Le média a été supprimé";
|
||||
$historique->save();
|
||||
|
||||
// Elasticsearch
|
||||
$media->removeFromIndex();
|
||||
|
||||
$media->delete();
|
||||
|
||||
// Lien Arcadia
|
||||
ArcadiaLink::delete($media);
|
||||
}
|
||||
|
||||
return json_encode($deletedMediasList);
|
||||
}
|
||||
|
||||
/**
|
||||
* Récupération d'un média
|
||||
*/
|
||||
|
||||
public function recoverMedia(Request $request)
|
||||
{
|
||||
$arcadia_id = $request->arcadia_id;
|
||||
$media = Media::onlyTrashed()->where('arcadia_id', '=', $arcadia_id)->first();
|
||||
$media->restore();
|
||||
$media->isLocked = 1;
|
||||
$media->save();
|
||||
|
||||
// Elasticsearch
|
||||
$id = $media->id;
|
||||
$media = Media::find($id);
|
||||
$media->addToIndex();
|
||||
|
||||
// Lien Arcadia
|
||||
ArcadiaLink::reactivate($media);
|
||||
|
||||
return json_encode(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtenir toutes les informations d'un média
|
||||
*
|
||||
|
|
@ -669,7 +713,6 @@ class MediaController extends Controller
|
|||
{
|
||||
Auth::user()->authorizeRoles([config('roles.const.ADMIN'), config('roles.const.REDACTEUR'), config('roles.const.CONTRIBUTEUR')]);
|
||||
$user_id = Auth::user()->id;
|
||||
$response = array();
|
||||
$mediaUpdate = (object)$request->input('media');
|
||||
|
||||
$media = Media::where('id', $mediaUpdate->id)->first();
|
||||
|
|
@ -746,9 +789,14 @@ class MediaController extends Controller
|
|||
}
|
||||
|
||||
// ---- Index dans Elasticsearch
|
||||
$id = $media->id;
|
||||
$media = Media::find($id);
|
||||
$media->removeFromIndex();
|
||||
$media->addToIndex();
|
||||
|
||||
// Lien Arcadia
|
||||
ArcadiaLink::update($media);
|
||||
|
||||
// ---- Historique des actions
|
||||
$historique = new historique();
|
||||
$historique->user_id = $user_id;
|
||||
|
|
@ -759,7 +807,7 @@ class MediaController extends Controller
|
|||
|
||||
}
|
||||
|
||||
$response = true;
|
||||
$response = array('status' => true, 'sujet_id' => $media->sujet_id);
|
||||
return json_encode($response);
|
||||
}
|
||||
|
||||
|
|
@ -793,6 +841,15 @@ class MediaController extends Controller
|
|||
// ---- Sauvegarde de la nouvelle étiquette
|
||||
$media->etiquette_id = $etiquette_id;
|
||||
$media->save();
|
||||
|
||||
// ---- Index dans Elasticsearch
|
||||
$id = $media->id;
|
||||
$media = Media::find($id);
|
||||
$media->removeFromIndex();
|
||||
$media->addToIndex();
|
||||
|
||||
// Lien Arcadia
|
||||
ArcadiaLink::update($media);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -847,6 +904,12 @@ class MediaController extends Controller
|
|||
$media->taille = $this->formatBytes($this->get_file_size($mediaPath));
|
||||
$media->save();
|
||||
|
||||
// ---- Index dans Elasticsearch
|
||||
$id = $media->id;
|
||||
$media = Media::find($id);
|
||||
$media->removeFromIndex();
|
||||
$media->addToIndex();
|
||||
|
||||
$historique = new historique();
|
||||
$historique->user_id = Auth::user()->id;;
|
||||
$historique->media_id = $media->id;
|
||||
|
|
@ -859,6 +922,9 @@ class MediaController extends Controller
|
|||
// ---- Creation des vignettes en lien avec le sujet du média
|
||||
$this->create_thumb($media);
|
||||
$response = $media;
|
||||
|
||||
// Lien Arcadia
|
||||
ArcadiaLink::update($media);
|
||||
}
|
||||
|
||||
return json_encode($response);
|
||||
|
|
@ -873,28 +939,24 @@ class MediaController extends Controller
|
|||
Auth::user()->authorizeRoles([config('roles.const.ADMIN')]);
|
||||
$response = false;
|
||||
$media_id = $request->input('media_id');
|
||||
$arcadia_id = $request->input('arcadia_id');
|
||||
|
||||
$historique = new historique();
|
||||
$historique->user_id = Auth::user()->id;
|
||||
$historique->media_id = $media_id;
|
||||
$historique->type = "Modification";
|
||||
|
||||
if ($arcadia_id == "" || $arcadia_id == 0) {
|
||||
$arcadia_id = NULL;
|
||||
$historique->description = "Suppression de la référence Arcadia";
|
||||
} else {
|
||||
$historique->description = "Ajout de la référence Arcadia " . $arcadia_id;
|
||||
$media = Media::where('arcadia_id', $arcadia_id)->first();
|
||||
if ($media) return json_encode($response);
|
||||
}
|
||||
$historique->description = "Ajout de la liaison Arcadia";
|
||||
|
||||
$media = Media::where('id', $media_id)->first();
|
||||
if ($media) {
|
||||
$media->arcadia_id = $arcadia_id;
|
||||
$media->isLocked = 1;
|
||||
$media->save();
|
||||
|
||||
// Lien Arcadia
|
||||
ArcadiaLink::create($media);
|
||||
|
||||
// ---- Index dans Elasticsearch
|
||||
$id = $media->id;
|
||||
$media = Media::find($id);
|
||||
$media->removeFromIndex();
|
||||
$media->addToIndex();
|
||||
|
||||
|
|
@ -1030,8 +1092,13 @@ class MediaController extends Controller
|
|||
$media->largeur_mm = "";
|
||||
$media->hauteur_mm = "";
|
||||
}
|
||||
|
||||
$media->isDefault = 1;
|
||||
$media->save();
|
||||
|
||||
$id = $media->id;
|
||||
$media = Media::find($id);
|
||||
|
||||
// ---- Index dans Elasticsearch
|
||||
$media = Media::where('id', $media->id)->first();
|
||||
$media->addToIFndex();
|
||||
|
|
@ -1056,7 +1123,6 @@ class MediaController extends Controller
|
|||
$historique->description = "Média ajouté";
|
||||
$historique->save();
|
||||
|
||||
|
||||
return json_encode($response);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
27
app/Http/Controllers/RecoveryController.php
Normal file
27
app/Http/Controllers/RecoveryController.php
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Media;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class RecoveryController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
Auth::user()->authorizeRoles(config('roles.const.ADMIN'));
|
||||
|
||||
return view('recovery.index');
|
||||
}
|
||||
|
||||
public function checkArcadiaId(Request $request)
|
||||
{
|
||||
$response = false;
|
||||
$arcadia_id = $request->id;
|
||||
$media = Media::onlyTrashed()->where('arcadia_id', '=', $arcadia_id)->first();
|
||||
if ($media)
|
||||
$response = true;
|
||||
return json_encode($response);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Traits\ArcadiaLink;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Http\Request;
|
||||
|
|
@ -115,6 +116,10 @@ class UploadController extends Controller {
|
|||
$filepath = preg_quote($media->folder.$media->uid, '/');
|
||||
$matchingFiles = preg_grep('/^'.$filepath.'/', $filesfF);
|
||||
Storage::delete($matchingFiles);
|
||||
|
||||
$media->isDefault = 0;
|
||||
$media->save();
|
||||
|
||||
}else{
|
||||
// On déplace le fichier dans le répertoire des médias
|
||||
Storage::move("uploads/".$filename, $destinationPath.$filename);
|
||||
|
|
@ -200,6 +205,8 @@ class UploadController extends Controller {
|
|||
break;
|
||||
}
|
||||
|
||||
$id = $media->id;
|
||||
$media = Media::find($id);
|
||||
// ---- Index dans Elasticsearch
|
||||
$media = Media::where('id', $media->id)->first();
|
||||
$media->addToIndex();
|
||||
|
|
|
|||
175
app/Http/Traits/ArcadiaLink.php
Normal file
175
app/Http/Traits/ArcadiaLink.php
Normal file
|
|
@ -0,0 +1,175 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Traits;
|
||||
|
||||
use App\Models\Format;
|
||||
use App\Scopes\SystemScope;
|
||||
use DOMDocument;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
trait ArcadiaLink {
|
||||
|
||||
public static function create($media)
|
||||
{
|
||||
self::convert(self::getXML($media, "C"), $media);
|
||||
}
|
||||
|
||||
public static function update($media)
|
||||
{
|
||||
if ($media->arcadia_id === NULL)
|
||||
return;
|
||||
self::convert(self::getXML($media, "M"), $media);
|
||||
}
|
||||
|
||||
public static function delete($media)
|
||||
{
|
||||
if ($media->arcadia_id === NULL)
|
||||
return;
|
||||
$dom = new DOMDocument('1.0','UTF-8');
|
||||
$dom->formatOutput = true;
|
||||
$root = $dom->createElement('MEDIA_VISUEL');
|
||||
$dom->appendChild($root);
|
||||
$root->appendChild($dom->createElement('codeArcadia'))->appendChild($dom->createCDATASection( "$media->arcadia_id"));
|
||||
$root->appendChild($dom->createElement('code_DAM'))->appendChild($dom->createCDATASection( "$media->id"));
|
||||
$root->appendChild( $dom->createElement('TypeMouvement'))->appendChild($dom->createCDATASection( "S"));
|
||||
$xml = $dom->saveXML();
|
||||
|
||||
self::convert($xml, $media);
|
||||
}
|
||||
|
||||
public static function reactivate($media)
|
||||
{
|
||||
if ($media->arcadia_id === NULL)
|
||||
return;
|
||||
$dom = new DOMDocument('1.0','UTF-8');
|
||||
$dom->formatOutput = true;
|
||||
$root = $dom->createElement('MEDIA_VISUEL');
|
||||
$dom->appendChild($root);
|
||||
$root->appendChild($dom->createElement('codeArcadia'))->appendChild($dom->createCDATASection( "$media->arcadia_id"));
|
||||
$root->appendChild($dom->createElement('code_DAM'))->appendChild($dom->createCDATASection( "$media->id"));
|
||||
$root->appendChild( $dom->createElement('TypeMouvement'))->appendChild($dom->createCDATASection( "R"));
|
||||
$xml = $dom->saveXML();
|
||||
|
||||
self::convert($xml, $media);
|
||||
}
|
||||
|
||||
private static function convert($xml, $media)
|
||||
{
|
||||
$uid = sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0x0fff) | 0x4000, mt_rand(0, 0x3fff) | 0x8000, mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff));
|
||||
Storage::disk('arcadia_link_s')->put("$uid.xml", $xml);
|
||||
self::compress($media->folder, $media->uid, $media->extension, $uid);
|
||||
}
|
||||
|
||||
private static function compress($folder, $name, $extension, $uid)
|
||||
{
|
||||
try {
|
||||
$zip_file = storage_path('arcadia_link/send') ."/$uid.zip";
|
||||
$zip = new \ZipArchive();
|
||||
$zip->open($zip_file, \ZipArchive::CREATE | \ZipArchive::OVERWRITE);
|
||||
$zip->addFile(storage_path('arcadia_link/send') . "/$uid.xml", 'media.xml');
|
||||
$zip->addFile(public_path() . "/$folder$name.$extension", "$name.$extension");
|
||||
$zip->close();
|
||||
unset($zip);
|
||||
unlink(storage_path('arcadia_link/send') . "/$uid.xml");
|
||||
|
||||
/* Pour faire la meme chose en .tar (CDC Initial)
|
||||
$a = new \PharData( storage_path('arcadia_link/send') ."/$uid.tmp");
|
||||
|
||||
// ADD FILES TO archive.tar FILE
|
||||
$a->addFile(storage_path('arcadia_link/send') . "/$uid.xml", 'media.xml');
|
||||
$a->addFile(public_path() . "/$folder$name.$extension", "$name.$extension");
|
||||
|
||||
// COMPRESS archive.tar FILE. COMPRESSED FILE WILL BE archive.tar.gz
|
||||
$a->compress(\Phar::NONE);
|
||||
|
||||
// NOTE THAT BOTH FILES WILL EXISTS. SO IF YOU WANT YOU CAN UNLINK archive.tar
|
||||
unset($a);
|
||||
unlink(storage_path('arcadia_link/send') . "/$uid.tmp");
|
||||
unlink(storage_path('arcadia_link/send') . "/$uid.xml");
|
||||
*/
|
||||
} catch (Exception $e) {
|
||||
//echo "Exception : " . $e;
|
||||
// TODO : Envoi mail Log
|
||||
Log::emergency("Erreur création .zip : $e (Traits/ArcadiaLink)");
|
||||
}
|
||||
}
|
||||
|
||||
private static function getXML($media, $mouvement)
|
||||
{
|
||||
$refKey = self::getRefKey($media);
|
||||
$formats = self::getFormats();
|
||||
|
||||
$dom = new DOMDocument('1.0','UTF-8');
|
||||
$dom->formatOutput = true;
|
||||
|
||||
$root = $dom->createElement('MEDIA_VISUEL');
|
||||
$dom->appendChild($root);
|
||||
|
||||
$root->appendChild($dom->createElement('codeArcadia'))->appendChild($dom->createCDATASection( "$media->arcadia_id"));
|
||||
$root->appendChild($dom->createElement('code_DAM'))->appendChild($dom->createCDATASection( "$media->id"));
|
||||
$root->appendChild( $dom->createElement('TypeMouvement'))->appendChild($dom->createCDATASection( "$mouvement"));
|
||||
|
||||
$cleRef = $root->appendChild( $dom->createElement('cle_Referentiel'));
|
||||
|
||||
foreach ($refKey as $k) {
|
||||
$cleRef->appendChild( $dom->createElement('id'))->appendChild($dom->createCDATASection( "$k->id"));
|
||||
}
|
||||
|
||||
$root->appendChild( $dom->createElement('libExtension'))->appendChild($dom->createCDATASection( "$media->extension"));
|
||||
$root->appendChild( $dom->createElement('nbPxLargeur'))->appendChild($dom->createCDATASection( "$media->largeur"));
|
||||
$root->appendChild( $dom->createElement('largeurMm'))->appendChild($dom->createCDATASection( "$media->largeur_mm"));
|
||||
$root->appendChild( $dom->createElement('nbPxHauteur'))->appendChild($dom->createCDATASection( "$media->hauteur"));
|
||||
$root->appendChild( $dom->createElement('hauteurMm'))->appendChild($dom->createCDATASection( "$media->hauteur_mm"));
|
||||
$root->appendChild( $dom->createElement('pppLargeur'))->appendChild($dom->createCDATASection( "$media->resolution"));
|
||||
$root->appendChild( $dom->createElement('version'))->appendChild($dom->createCDATASection( "$media->version"));
|
||||
$root->appendChild( $dom->createElement('codeTypeMedia'))->appendChild($dom->createCDATASection( "$media->typemedia_id"));
|
||||
$root->appendChild( $dom->createElement('codeTypeVue'))->appendChild($dom->createCDATASection( "$media->typevue_id"));
|
||||
$root->appendChild( $dom->createElement('commentaire'))->appendChild($dom->createCDATASection( "$media->commentaire"));
|
||||
$root->appendChild( $dom->createElement('codeSujet'))->appendChild($dom->createCDATASection( "$media->sujet_id"));
|
||||
$root->appendChild( $dom->createElement('langue'))->appendChild($dom->createCDATASection( "$media->langue_id"));
|
||||
$root->appendChild( $dom->createElement('copyright'))->appendChild($dom->createCDATASection( "$media->copyright_id"));
|
||||
$root->appendChild( $dom->createElement('codeVariante'))->appendChild($dom->createCDATASection( "$media->variante_id"));
|
||||
$root->appendChild( $dom->createElement('dateCreation'))->appendChild($dom->createCDATASection( "$media->created_at"));
|
||||
$root->appendChild( $dom->createElement('dateModification'))->appendChild($dom->createCDATASection( "$media->updated_at"));
|
||||
$root->appendChild( $dom->createElement('datePublication'))->appendChild($dom->createCDATASection( "$media->published_at"));
|
||||
$root->appendChild( $dom->createElement('libelle'))->appendChild($dom->createCDATASection( "$media->libelle"));
|
||||
$root->appendChild( $dom->createElement('NomFichier'))->appendChild($dom->createCDATASection( "$media->uid.$media->extension"));
|
||||
|
||||
$mediaFormat = $root->appendChild( $dom->createElement('formats'));
|
||||
|
||||
foreach ($formats as $k) {
|
||||
$format = $mediaFormat->appendChild( $dom->createElement('format'));
|
||||
$format->appendChild( $dom->createElement('id'))->appendChild($dom->createCDATASection( $k['id']));
|
||||
$format->appendChild( $dom->createElement('libelle'))->appendChild($dom->createCDATASection( $k['libelle']));
|
||||
$format->appendChild( $dom->createElement('extension'))->appendChild($dom->createCDATASection("$media->extension"));
|
||||
$format->appendChild( $dom->createElement('largeur'))->appendChild($dom->createCDATASection( $k['largeur']));
|
||||
$format->appendChild( $dom->createElement('hauteur'))->appendChild($dom->createCDATASection( $k['hauteur']));
|
||||
$format->appendChild( $dom->createElement('lien'))->appendChild($dom->createCDATASection(env('APP_URL') . "/$media->folder$media->uid" . "_" . $k['libelle'] . ".$media->extension"));
|
||||
}
|
||||
|
||||
return $dom->saveXML();
|
||||
}
|
||||
|
||||
private static function getRefKey($media)
|
||||
{
|
||||
switch ($media->sujet_id){
|
||||
case 1:
|
||||
return $media->articles()->get();
|
||||
break;
|
||||
case 2:
|
||||
return $media->marques()->get();
|
||||
break;
|
||||
case 4:
|
||||
return $media->societes()->get();
|
||||
break;
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
private static function getFormats()
|
||||
{
|
||||
return Format::withoutGlobalScope(SystemScope::class)->where('system', '=', '1')->get();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
<?php
|
||||
namespace App\Http\Traits;
|
||||
use Elasticquent\ElasticquentTrait;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
trait ElasticTrait {
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ trait MediaTools {
|
|||
$formats = $media->sujet->formats;
|
||||
|
||||
$mediaPath = public_path()."/".$media->folder.$media->uid.".".$media->extension;
|
||||
$im = new \imagick($mediaPath);
|
||||
$im = new \Imagick($mediaPath);
|
||||
$im->setImageBackgroundColor('#ffffff');
|
||||
$im->setImageAlphaChannel(\Imagick::ALPHACHANNEL_REMOVE);
|
||||
$im->mergeImageLayers(\Imagick::LAYERMETHOD_FLATTEN);
|
||||
|
|
@ -44,7 +44,7 @@ trait MediaTools {
|
|||
|
||||
public function create_sys_thumb($media) {
|
||||
$mediaPath = public_path()."/".$media->folder.$media->uid.".".$media->extension;
|
||||
$im = new \imagick();
|
||||
$im = new \Imagick();
|
||||
$im->readImage($mediaPath);
|
||||
|
||||
if(in_array($media->extension, array("pdf", "ai", "psd")) ){
|
||||
|
|
|
|||
|
|
@ -60,6 +60,15 @@ return [
|
|||
'root' => storage_path('export_arcadia'),
|
||||
],
|
||||
|
||||
'arcadia_link_s' => [
|
||||
'driver' => 'local',
|
||||
'root' => storage_path('arcadia_link/send'),
|
||||
],
|
||||
'arcadia_link_r' => [
|
||||
'driver' => 'local',
|
||||
'root' => storage_path('arcadia_link/receive'),
|
||||
],
|
||||
|
||||
's3' => [
|
||||
'driver' => 's3',
|
||||
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||
|
|
|
|||
2
public/js/app.js
vendored
2
public/js/app.js
vendored
File diff suppressed because one or more lines are too long
64
resources/js/admin.js
vendored
64
resources/js/admin.js
vendored
|
|
@ -110,6 +110,70 @@ $(document).ready(function() {
|
|||
});
|
||||
});
|
||||
|
||||
// Rechercher ID Arcadia pour réactivation
|
||||
$("#recovery-form").submit(function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
$.ajaxSetup({
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
|
||||
}
|
||||
});
|
||||
|
||||
const id = $("input[name='arcadia_id']").val();
|
||||
|
||||
$.ajax({
|
||||
url: '/check-arcadia-id',
|
||||
method: 'POST',
|
||||
dataType : 'json',
|
||||
data: {
|
||||
id: id,
|
||||
},
|
||||
success: function(result){
|
||||
if (result === false){
|
||||
$.fancyMessage({
|
||||
title : "Attention",
|
||||
message : "Aucun média supprimé avec cet ID Arcadia.",
|
||||
type : "error",
|
||||
});
|
||||
}else{
|
||||
$.fancyConfirm({
|
||||
title : "Attention",
|
||||
message : "Êtes-vous sûr de vouloir lancer le traitement ?",
|
||||
okButton : 'Oui',
|
||||
noButton : 'Non',
|
||||
callback : function (value) {
|
||||
if (value) {
|
||||
$.ajax({
|
||||
url: '/ajax/recover-media',
|
||||
method: 'POST',
|
||||
dataType : 'json',
|
||||
data: {
|
||||
arcadia_id: id,
|
||||
},
|
||||
success: function(result){
|
||||
$.fancyMessage({
|
||||
title : "Information",
|
||||
message : "La demande de récupération a été faite.",
|
||||
type : "info",
|
||||
});
|
||||
},
|
||||
error: function(jqXHR, textStatus, errorThrown) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
error: function(jqXHR, textStatus, errorThrown) {
|
||||
|
||||
}
|
||||
});
|
||||
$("input[name='arcadia_id']").val('');
|
||||
});
|
||||
|
||||
initSelector(".selector_marques");
|
||||
initSelector(".selector_sujets");
|
||||
});
|
||||
|
|
|
|||
108
resources/js/media.js
vendored
108
resources/js/media.js
vendored
|
|
@ -576,7 +576,6 @@ $(document).ready(function() {
|
|||
typemedia: $(this).attr('data-typemedia'),
|
||||
ext: $(this).attr('data-ext'),
|
||||
}, drPlugin, viewer);
|
||||
|
||||
});
|
||||
|
||||
$("#CloseListUploadedFiles").on('click', function (e) {
|
||||
|
|
@ -652,38 +651,36 @@ $(document).ready(function() {
|
|||
// ---- Bouton Arcadia
|
||||
$('.tab_edit .btn-arcadia-link').on('click', function(event){
|
||||
event.preventDefault();
|
||||
var arcadia_id = $("#arcadia_id").val();
|
||||
arcadia_id = prompt("Indiquez le code Arcadia de ce média", arcadia_id);
|
||||
|
||||
// Si la saisie est vide on affiche le message d'erreur et on n'execute pas l'ajax
|
||||
if (arcadia_id === "") {
|
||||
$.fancybox.close();
|
||||
$.fancyMessage({
|
||||
title: "Lier un média à Arcadia",
|
||||
message: "Le code Arcadia est vide.",
|
||||
type: "error"
|
||||
});
|
||||
return;
|
||||
}else if (arcadia_id === null) {
|
||||
if ($(window).data('CurrentIsDefault') === 1){
|
||||
$.fancyMessage({title : "Lier un média à Arcadia", message : "Ce média ne peut pas être lié car il possède un visuel par défaut.", type : "error"});
|
||||
return;
|
||||
}
|
||||
|
||||
var result = confirm("Etes-vous sur de vouloir lancer le traitement ?");
|
||||
if (result != true)
|
||||
return;
|
||||
|
||||
$.ajax({
|
||||
url: '/ajax/set-id-arcadia',
|
||||
method: 'POST',
|
||||
dataType : 'json',
|
||||
data: {
|
||||
arcadia_id: arcadia_id,
|
||||
media_id : $(window).data('current_edit_media'),
|
||||
},
|
||||
success: function(result){
|
||||
if(result == true){
|
||||
$.fancybox.close();
|
||||
$.fancyMessage({title : "Lier un média à Arcadia", message : "Le code Arcadia a bien été ajouté au média", type : "info"});
|
||||
$("#arcadia_id").val(arcadia_id);
|
||||
$.fancyMessage({title : "Lier un média à Arcadia", message : "La demande à été effectuée, votre média est temporairement bloqué.", type : "info"});
|
||||
|
||||
$(".btn_tab_edit_save").attr('disabled', true);
|
||||
$(".btn_tab_edit_delete").attr('disabled', true);
|
||||
$(".is-locked").show();
|
||||
$(".btn-arcadia-link").hide();
|
||||
|
||||
}else{
|
||||
$.fancybox.close();
|
||||
$.fancyMessage({title : "Lier un média à Arcadia", message : "Ce code a déjà été attribué à un autre média. Ajout impossible.", type : "error"});
|
||||
$.fancyMessage({title : "Lier un média à Arcadia", message : "Une erreur est survenue. Traitement impossible.", type : "error"});
|
||||
}
|
||||
},
|
||||
error: function(jqXHR, textStatus, errorThrown) {
|
||||
|
|
@ -780,6 +777,59 @@ $(document).ready(function() {
|
|||
removeMedias(medias);
|
||||
});
|
||||
|
||||
// Suppression d'un média
|
||||
$(".btn_tab_edit_delete").on("click", function (event) {
|
||||
event.preventDefault();
|
||||
|
||||
if ($(".tab_edit #arcadia_id").val().length) {
|
||||
var r = confirm("Etes-vous sûr de vouloir supprimer ce média ? (Lié à Arcadia)");
|
||||
} else {
|
||||
var r = confirm("Etes-vous sûr de vouloir supprimer ce média ?");
|
||||
}
|
||||
|
||||
if (r == true) {
|
||||
var medias = [$(window).data('current_edit_media')];
|
||||
$.ajax({
|
||||
url: '/ajax/remove-media',
|
||||
method: 'POST',
|
||||
dataType : 'json',
|
||||
data: {
|
||||
medias: medias
|
||||
},
|
||||
success: function(result){
|
||||
$.each(result, function (index, value) {
|
||||
$(".media_container .imageItem[data-id='"+value+"']").remove();
|
||||
});
|
||||
|
||||
// ---- MAJ du nb de média dans le dossier
|
||||
var currentFolder = $(window).data('currentFolder');
|
||||
if(currentFolder == 0 || currentFolder == ""){
|
||||
var count = $(".folder_container .root_folder .count");
|
||||
}else{
|
||||
var count = $(".folder_container .dd3-item[data-id='"+currentFolder+"'] > .dd3-content .count");
|
||||
}
|
||||
count.html(parseInt(count.html())-result.length);
|
||||
|
||||
if(result.length != medias.length){
|
||||
$.fancybox.close();
|
||||
if(medias.length == 1){
|
||||
$.fancyMessage({title : "Attention", message : "Ce média est lié à Arcadia. Suppression refusée. ", type : "error"});
|
||||
}else{
|
||||
$.fancyMessage({title : "Attention", message : "Votre sélection contient des médias liés à Arcadia. Ces médias ne seront pas supprimés.", type : "info"});
|
||||
}
|
||||
}else{
|
||||
$(".form_media_close").trigger('click');
|
||||
$.fancyMessage({title : "Suppression de média", message : "Le média a été supprimé.", type : "info"});
|
||||
}
|
||||
},
|
||||
error: function(jqXHR, textStatus, errorThrown) {
|
||||
$.fancybox.close();
|
||||
$.fancyMessage({title : "Attention", message : "Erreur lors de la suppression du média, merci d'actualiser la page.", type : "error"});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// ---- Popup pour Appliquer une étiquette à un média en masse
|
||||
$('.action_tag_media').on('click',function(event){
|
||||
event.preventDefault();
|
||||
|
|
@ -951,6 +1001,9 @@ $(document).ready(function() {
|
|||
},
|
||||
success: function(result){
|
||||
$.fancyMessage({title : "Sauvegarde d'un média", message : "Les données ont bien été enregistrées", type : "info"});
|
||||
// On replace l'offset pour recharger
|
||||
$(window).data('offset', $(window).data('offset')-$(window).data('limit'));
|
||||
loadMedia(result.sujet_id);
|
||||
},
|
||||
error: function(jqXHR, textStatus, errorThrown) {
|
||||
$.fancyMessage({title : "Sauvegarde d'un média", message : "Erreur lors de l'enregistrement. Merci d'actualiser la page.", type : "error"});
|
||||
|
|
@ -1261,6 +1314,16 @@ function initFolderManager(sujetId){
|
|||
var output = '';
|
||||
var draggable = result.draggable;
|
||||
|
||||
// init du role du user
|
||||
$(window).data('CurrentUserRole', result.role);
|
||||
|
||||
// Si l'utilisateur est lecteur alors on enleve la possibilite d'upload
|
||||
if (result.role === 2){
|
||||
$(".form_media_replace").hide();
|
||||
}else{
|
||||
$(".form_media_replace").show();
|
||||
}
|
||||
|
||||
// initialisation de la liste type vues
|
||||
var typevues = result.typevues;
|
||||
$("#typevues").find('option').remove();
|
||||
|
|
@ -1482,7 +1545,7 @@ window.loadMedia = function(sujet_id, saveSearch = 0){
|
|||
output += '<li class="menu-option editItem"><i class="fas fa-edit"></i> Editer</li>';
|
||||
output += '<li class="menu-option downloadItem"><i class="fas fa-file-download"></i> Télécharger</li>';
|
||||
output += '<li class="menu-option addBasket"><i class="fas fa-shopping-basket"></i> Ajouter au panier</li>';
|
||||
if(result.role != 2 ){
|
||||
if($(window).data('CurrentUserRole') != 2 ){
|
||||
output += '<li class="menu-option deleteItem"><i class="fas fa-trash-alt"></i> Supprimer</li>';
|
||||
//output += '<li class="menu-option tagItem"><i class="fas fa-tags"></i> Etiquette</li>';
|
||||
}
|
||||
|
|
@ -1509,12 +1572,19 @@ window.loadMedia = function(sujet_id, saveSearch = 0){
|
|||
// ---- Supression de médias
|
||||
function removeMedias(medias){
|
||||
|
||||
// Si Admin
|
||||
if ($(window).data('CurrentUserRole') === 1){
|
||||
var msg = "Êtes-vous sûr de vouloir supprimer "+medias.length+" média(s) ? <br> ATTENTION DES MEDIAS PEUVENT ETRE LIES AVEC ARCADIA !";
|
||||
}else{
|
||||
var msg = "Êtes-vous sûr de vouloir supprimer "+medias.length+" média(s) ?";
|
||||
}
|
||||
|
||||
if(medias.length == 0){
|
||||
$.fancyMessage({title : "Supprimer un média", message : "Veuillez sélectionner les médias à supprimer.", type : "info"});
|
||||
}else{
|
||||
$.fancyConfirm({
|
||||
title : "Suppression de média",
|
||||
message : "Êtes-vous sûr de vouloir supprimer "+medias.length+" média(s) ?",
|
||||
message : msg,
|
||||
okButton : 'Supprimer',
|
||||
noButton : 'Annuler',
|
||||
callback : function (value) {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
<div class="side_menu">
|
||||
<a href="{{ route('user.index') }}"><span>Gestion des utilisateurs</span><i class="fas fa-users-cog"></i></a>
|
||||
<a class="active" href="{{ route('dossier.index') }}"><span>Gestion des dossiers</span><i class="fas fa-folders"></i></a>
|
||||
<a href="{{ route('recovery.index') }}"><span>Récupération des médias</span><i class="fas fa-undo-alt"></i></a>
|
||||
</div>
|
||||
<div class="main_content">
|
||||
@if ($errors->any())
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
<div class="side_menu">
|
||||
<a href="{{ route('user.index') }}"><span>Gestion des utilisateurs</span><i class="fas fa-users-cog"></i></a>
|
||||
<a class="active" href="{{ route('dossier.index') }}"><span>Gestion des dossiers</span><i class="fas fa-folders"></i></a>
|
||||
<a href="{{ route('recovery.index') }}"><span>Récupération des médias</span><i class="fas fa-undo-alt"></i></a>
|
||||
</div>
|
||||
<div class="main_content">
|
||||
@if ($errors->any())
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
<div class="side_menu">
|
||||
<a href="{{ route('user.index') }}"><span>Gestion des utilisateurs</span><i class="fas fa-users-cog"></i></a>
|
||||
<a class="active" href="{{ route('dossier.index') }}"><span>Gestion des dossiers</span><i class="fas fa-folders"></i></a>
|
||||
<a href="{{ route('recovery.index') }}"><span>Récupération des médias</span><i class="fas fa-undo-alt"></i></a>
|
||||
</div>
|
||||
<div class="main_content">
|
||||
<div class="heading">
|
||||
|
|
|
|||
|
|
@ -21,11 +21,12 @@
|
|||
<h3>Informations générales</h3>
|
||||
<form class="form_edit_media" action="#" method="post">
|
||||
<div class="row arcadia_fields">
|
||||
<label for="arcadia_id">Code Arcadia</label>
|
||||
<label for="arcadia_id">Arcadia</label>
|
||||
<input type="text" name="arcadia_id" id="arcadia_id" readonly><br>
|
||||
<div class="">
|
||||
<input type="number" value="" id="arcadia_id" name="arcadia_id" readonly >
|
||||
@if (Auth::user()->hasRole(config('roles.const.ADMIN')))
|
||||
<button class="btn btn-square ml-10 btn-arcadia-link" type="button" name="button"><i class="far fa-link"></i> Lien avec Arcadia</button>
|
||||
<button class="btn btn-square ml-10 btn-arcadia-link" type="button" name="button"><i class="far fa-link"></i> Lier avec Arcadia</button>
|
||||
<span class="is-locked" style="display: none;">En attente de liaison Arcadia</span>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -221,6 +222,9 @@
|
|||
</div>
|
||||
<div class="button_bar">
|
||||
<a href="#" class="btn btn-black mr-10 btn_tab_edit_cancel">Fermer</a>
|
||||
@if (Auth::user()->hasRole([config('roles.const.ADMIN'), config('roles.const.REDACTEUR')]))
|
||||
<button class="btn btn-red btn_tab_edit_delete" type="button" name="button">Supprimer</button>
|
||||
@endif
|
||||
@if (Auth::user()->hasRole([config('roles.const.CONTRIBUTEUR'), config('roles.const.ADMIN'), config('roles.const.REDACTEUR')]))
|
||||
<button class="btn btn_tab_edit_save" type="button" name="button">Sauvegarder</button>
|
||||
@endif
|
||||
|
|
|
|||
54
resources/views/recovery/index.blade.php
Normal file
54
resources/views/recovery/index.blade.php
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
@extends('layouts.app')
|
||||
@include('layouts.header')
|
||||
@section('content')
|
||||
<main class="user_index template_2col">
|
||||
<div class="side_menu">
|
||||
<a href="{{ route('user.index') }}"><span>Gestion des utilisateurs</span><i
|
||||
class="fas fa-users-cog"></i></a>
|
||||
<a href="{{ route('dossier.index') }}"><span>Gestion des dossiers</span><i class="fas fa-folders"></i></a>
|
||||
<a class="active" href="{{ route('recovery.index') }}"><span>Récupération des médias</span><i
|
||||
class="fas fa-undo-alt"></i></a>
|
||||
</div>
|
||||
<div class="main_content">
|
||||
@if ($errors->any())
|
||||
<div class="alert alert-danger">
|
||||
<i class="fas fa-times"></i>
|
||||
<ul>
|
||||
@foreach ($errors->all() as $error)
|
||||
<li>{{ __($error) }}</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</div>
|
||||
@endif
|
||||
@if (session()->has('error'))
|
||||
<div class="alert alert-danger">
|
||||
<i class="fas fa-times"></i>
|
||||
<ul>
|
||||
<li>{{ Session::get('error') }}</li>
|
||||
</ul>
|
||||
</div>
|
||||
@endif
|
||||
@if (session()->has('message'))
|
||||
<div class="alert alert-ok">
|
||||
<i class="fas fa-check"></i>
|
||||
<ul>
|
||||
<li>{{ Session::get('message') }}</li>
|
||||
</ul>
|
||||
</div>
|
||||
@endif
|
||||
<div class="heading">
|
||||
<h1>Récupération des médias</h1>
|
||||
</div>
|
||||
<form id="recovery-form" class="dataform">
|
||||
@csrf
|
||||
<div class="form-field">
|
||||
{!! Form::label('arcadia_id', 'ID Arcadia *') !!}
|
||||
{!! Form::text('arcadia_id') !!}
|
||||
</div>
|
||||
<div class="button-row">
|
||||
{!! Form::submit('Rechercher', [ 'class' => 'btn']) !!}
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</main>
|
||||
@endsection
|
||||
|
|
@ -5,6 +5,7 @@
|
|||
<div class="side_menu">
|
||||
<a class="active" href="{{ route('user.index') }}"><span>Gestion des utilisateurs</span><i class="fas fa-users-cog"></i></a>
|
||||
<a href="{{ route('dossier.index') }}"><span>Gestion des dossiers</span><i class="fas fa-folders"></i></a>
|
||||
<a href="{{ route('recovery.index') }}"><span>Récupération des médias</span><i class="fas fa-undo-alt"></i></a>
|
||||
</div>
|
||||
<div class="main_content">
|
||||
@if ($errors->any())
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
<div class="side_menu">
|
||||
<a class="active" href="{{ route('user.index') }}"><span>Gestion des utilisateurs</span><i class="fas fa-users-cog"></i></a>
|
||||
<a href="{{ route('dossier.index') }}"><span>Gestion des dossiers</span><i class="fas fa-folders"></i></a>
|
||||
<a href="{{ route('recovery.index') }}"><span>Récupération des médias</span><i class="fas fa-undo-alt"></i></a>
|
||||
</div>
|
||||
<div class="main_content">
|
||||
@if ($errors->any())
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
<div class="side_menu">
|
||||
<a class="active" href="{{ route('user.index') }}"><span>Gestion des utilisateurs</span><i class="fas fa-users-cog"></i></a>
|
||||
<a href="{{ route('dossier.index') }}"><span>Gestion des dossiers</span><i class="fas fa-folders"></i></a>
|
||||
<a href="{{ route('recovery.index') }}"><span>Récupération des médias</span><i class="fas fa-undo-alt"></i></a>
|
||||
</div>
|
||||
<div class="main_content">
|
||||
<div class="heading">
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ Route::group(['middleware' => ['auth']], function(){
|
|||
Route::post('/ajax/load-media', 'MediaController@loadMedia');
|
||||
Route::post('/ajax/move-media', 'MediaController@moveMedia');
|
||||
Route::post('/ajax/remove-media', 'MediaController@removeMedia');
|
||||
Route::post('/ajax/recover-media', 'MediaController@recoverMedia');
|
||||
Route::post('/ajax/get-media', 'MediaController@getOneMedia');
|
||||
Route::post('/ajax/save-media', 'MediaController@saveMedia');
|
||||
Route::post('/ajax/apply-sticker', 'MediaController@applySticker');
|
||||
|
|
@ -58,6 +59,8 @@ Route::group(['middleware' => ['auth']], function(){
|
|||
Route::resource('user', 'UserController');
|
||||
Route::post('/check-matricule', 'UserController@checkMatricule');
|
||||
Route::resource('dossier', 'DossierController');
|
||||
Route::get('/recovery', 'RecoveryController@index')->name('recovery.index');
|
||||
Route::post('/check-arcadia-id', 'RecoveryController@checkArcadiaId');
|
||||
});
|
||||
|
||||
Auth::routes([
|
||||
|
|
|
|||
1
storage/arcadia_link/.gitkeep
Normal file
1
storage/arcadia_link/.gitkeep
Normal file
|
|
@ -0,0 +1 @@
|
|||
gitkeep
|
||||
1
storage/arcadia_link/receive/.gitkeep
Normal file
1
storage/arcadia_link/receive/.gitkeep
Normal file
|
|
@ -0,0 +1 @@
|
|||
gitkeep
|
||||
1
storage/arcadia_link/send/.gitkeep
Normal file
1
storage/arcadia_link/send/.gitkeep
Normal file
|
|
@ -0,0 +1 @@
|
|||
gitkeep
|
||||
Loading…
Add table
Reference in a new issue