abort(401);
}
+ $links = request('links', '[]');
+ $rulers = request('rulers', '[]');
+
LinksData::saveLinksInFile($fluidbook_id,
backpack_user()->id,
request('message'),
- json_decode(request('links', '[]'), true),
- json_decode(request('rulers', '[]'), true),
+ is_array($links) ? $links : json_decode($links, true),
+ is_array($rulers) ? $rulers : json_decode($rulers, true),
);
$fb = FluidbookPublication::withoutGlobalScopes()->find($fluidbook_id);
/* Reset
*
*/
- if(!cache()->has('queue_editor'.$fluidbookId)) {
+ if (!cache()->has('queue_editor' . $fluidbookId)) {
$entries = [["token" => $token, "date" => now()]];
- cache(['queue_editor'.$fluidbookId => $entries]);
+ cache(['queue_editor' . $fluidbookId => $entries]);
} else {
- $queueEditor = cache()->get('queue_editor'.$fluidbookId); // on récupère la liste des onglets
- $connexion = array_filter($queueEditor, function($n) use($token) { return $n["token"] === $token; });
+ $queueEditor = cache()->get('queue_editor' . $fluidbookId); // on récupère la liste des onglets
+ $connexion = array_filter($queueEditor, function ($n) use ($token) {
+ return $n["token"] === $token;
+ });
$key = key($connexion);
if ((int)$unload === 1 && $key) {
unset($queueEditor[$key]); // on supprime l'onglet de la liste au chargement ou à sa fermeture
}
- if(!$key) {
+ if (!$key) {
$queueEditor[] = ["token" => $token, "date" => now()];
} else {
$queueEditor[$key]["token"] = $token;
}
// on supprime les connexions afk
- $queueEditor = array_filter($queueEditor, function($n) {
- return strtotime($n["date"]) > strtotime(now())-10;
+ $queueEditor = array_filter($queueEditor, function ($n) {
+ return strtotime($n["date"]) > strtotime(now()) - 10;
});
- cache(['queue_editor'.$fluidbookId => $queueEditor]);
+ cache(['queue_editor' . $fluidbookId => $queueEditor]);
}
- $connexionExist = cache()->get('connexion'.$fluidbookId);
- $queueEditor = cache()->get('queue_editor'.$fluidbookId);
+ $connexionExist = cache()->get('connexion' . $fluidbookId);
+ $queueEditor = cache()->get('queue_editor' . $fluidbookId);
// réinitialiser la connexion courante quand on clique sur "déconnecter l'utilisateur"
- if($request->clear) {
+ if ($request->clear) {
$queueEditorCurrent = $queueEditor[$key];
unset($queueEditor[$key]);
$queueEditor = array_merge([$queueEditorCurrent], $queueEditor);
/*cache()->forget('queue_editor'.$fluidbookId);*/
/*cache()->forget('connexion'.$fluidbookId);*/
- if(cache()->has('queue_editor'.$fluidbookId)) {
+ if (cache()->has('queue_editor' . $fluidbookId)) {
if (sizeof(cache()->get('queue_editor' . $fluidbookId)) === 1) {
cache(['connexion' . $fluidbookId => ['id' => $userId, 'token' => $token, 'f_id' => $fluidbookId]]);
return json_encode(["queueEditor" => $queueEditor, "status" => "available", $connexionExist]);
}
}
- if($connexionExist && $fluidbookId === $connexionExist['f_id']) {
+ if ($connexionExist && $fluidbookId === $connexionExist['f_id']) {
$user = User::withoutGlobalScopes()->find($connexionExist['id']);
- $user = $user->firstname.' '.$user->lastname;
+ $user = $user->firstname . ' ' . $user->lastname;
- if(current($queueEditor)["token"] !== $token) {
- return json_encode(["queueEditor"=>$queueEditor,"token"=>$token,"status"=>"unavailable","infos_connection"=>array_merge(["user" => $user],$connexionExist)]);
+ if (current($queueEditor)["token"] !== $token) {
+ return json_encode(["queueEditor" => $queueEditor, "token" => $token, "status" => "unavailable", "infos_connection" => array_merge(["user" => $user], $connexionExist)]);
} else {
- return json_encode(["queueEditor"=>$queueEditor,"status"=>"available",$connexionExist]);
+ return json_encode(["queueEditor" => $queueEditor, "status" => "available", $connexionExist]);
}
} else {
- cache(['connexion'.$fluidbookId => ['id' => $userId, 'token' => $token,'f_id' => $fluidbookId] ]);
- return json_encode(["queueEditor"=>$queueEditor,"status"=>"available",cache()->get('connexion'.$fluidbookId)]);
+ cache(['connexion' . $fluidbookId => ['id' => $userId, 'token' => $token, 'f_id' => $fluidbookId]]);
+ return json_encode(["queueEditor" => $queueEditor, "status" => "available", cache()->get('connexion' . $fluidbookId)]);
}
}