Refactoring Complet
Voir facebook pour l'installation de la nouvelle BDD.
This commit is contained in:
51
SRC/app/Http/Controllers/APIController.php
Normal file
51
SRC/app/Http/Controllers/APIController.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php namespace App\Http\Controllers;
|
||||
|
||||
use App\Oeuvre;
|
||||
use App\Auteur;
|
||||
use App\Referent;
|
||||
use Response;
|
||||
use Input;
|
||||
|
||||
class APIController extends Controller {
|
||||
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function refByName($reg = "") {
|
||||
|
||||
if(!empty($reg))
|
||||
$res = User::referents()->name($reg)->get();
|
||||
else
|
||||
$res = User::referents()->get();
|
||||
return Response::json($res->toArray());
|
||||
}
|
||||
|
||||
public function searchOeuvres() {
|
||||
/*$auteurs = (Input::get('auteur', array()))?Input::get('auteur', array()): [];
|
||||
$designations = (Input::get('designation', array()))? Input::get('designation', array()): [];
|
||||
$domaines = (Input::get('domaine', array()))? Input::get('domaine', array()): [];
|
||||
$matieres = (Input::get('matiere', array()))? Input::get('matiere', array()): [];
|
||||
$techniques = (Input::get('technique', array()))?Input::get('technique', array()): [];
|
||||
$debut = (Input::get('debut'))? Input::get('debut'): '';
|
||||
$fin = (Input::get('fin'))?Input::get('fin'): '';
|
||||
*/
|
||||
//::whereIn('technique_id', $techniques)
|
||||
//$res = Oeuvre::paginate(15);
|
||||
//$listeoeuvres = Oeuvre::where('auteur_id', '=', Input::get('auteur'))->simplePaginate(1);
|
||||
|
||||
$listeoeuvres = Oeuvre::simplePaginate(5);
|
||||
|
||||
|
||||
return view('backend/ref_listeoeuvres',['oeuvres' => $listeoeuvres]);
|
||||
|
||||
//return Response::json($res->toArray());
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
<?php namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Referent;
|
||||
use Input;
|
||||
use Auth;
|
||||
use Session;
|
||||
@ -27,9 +27,8 @@ class AdminController extends Controller {
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$me = User::current();
|
||||
$user = User::all();
|
||||
return view('admin', ['nameRoute' => 'Admin', 'users' => $user, 'me' => $me]);
|
||||
$user = Referent::all();
|
||||
return view('backend/admin_home', ['nameRoute' => 'Admin', 'users' => $user]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -39,47 +38,16 @@ class AdminController extends Controller {
|
||||
*/
|
||||
public function addUser()
|
||||
{
|
||||
$user = new User;
|
||||
$user = new Referent;
|
||||
|
||||
$user->firstname = Input::get('firstname');
|
||||
$user->nom = Input::get('nom');
|
||||
$user->email = Input::get('email');
|
||||
$user->droits = (Input::get('isadmin'))?1:0;
|
||||
$user->school = Input::get('city');
|
||||
$user->lastname = Input::get('lastname');
|
||||
$user->image = "pictures/user_picture/default.jpg";
|
||||
$user->etablissement = Input::get('etablissement');
|
||||
$user->prenom = Input::get('prenom');
|
||||
$user->image = "imgs/avatar/default.jpg";
|
||||
$user->save();
|
||||
|
||||
Password:: sendResetLink(Input::only('email'));
|
||||
return redirect('/admin')->with('message_add', 'User ajouté avec succès');
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* updateUser an user in database.
|
||||
*
|
||||
*
|
||||
*/
|
||||
public function updateUser()
|
||||
{
|
||||
|
||||
$idUser = Input::get('idUser');
|
||||
$user = User::find($idUser);
|
||||
|
||||
if (Request::hasFile('file'))
|
||||
{
|
||||
Request::file('file')->move("./pictures/user_picture/", $idUser);
|
||||
$user->image = "pictures/user_picture/".$idUser;
|
||||
}
|
||||
|
||||
$user->firstname = Input::get('firstname');
|
||||
$user->email = Input::get('email');
|
||||
$user->school = Input::get('city');
|
||||
$user->lastname = Input::get('lastname');
|
||||
|
||||
|
||||
$user->save();
|
||||
return redirect('/admin')->with('message_update', 'User mis à jour avec succès');
|
||||
Password::sendResetLink(Input::only('email'));
|
||||
return redirect('/admin')->with('message_add', 'Le référent a été ajouté.');
|
||||
}
|
||||
|
||||
|
||||
@ -87,29 +55,23 @@ class AdminController extends Controller {
|
||||
* Delete an user
|
||||
*
|
||||
*/
|
||||
public function deleteUser()
|
||||
public function deleteUser($idUser)
|
||||
{
|
||||
$idUser = Input::get('idUser');
|
||||
$user = User::find($idUser);
|
||||
$user = Referent::find($idUser);
|
||||
$user->delete();
|
||||
return redirect('/admin')->with('message_delete', 'User supprimé avec succès');
|
||||
return redirect('/admin')->with('message_delete', 'Le référent a été supprimé.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Log as one user
|
||||
*
|
||||
*/
|
||||
public function logAs()
|
||||
public function logAs($idUser)
|
||||
{
|
||||
// Saving idUser in Session
|
||||
$me = Auth::user()->id;
|
||||
Session::put('admin', $me);
|
||||
|
||||
// logout from Auth
|
||||
Auth::logout();
|
||||
|
||||
// Log as referent
|
||||
$idUser = Input::get('idUser');
|
||||
Auth::loginUsingId($idUser);
|
||||
|
||||
// Redirect referent route
|
||||
|
@ -1,30 +0,0 @@
|
||||
<?php namespace App\Http\Controllers\Auth;
|
||||
|
||||
use Illuminate\Routing\Controller;
|
||||
use Auth;
|
||||
|
||||
class AuthController extends Controller {
|
||||
/**
|
||||
* Handle an authentication attempt.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function authenticate()
|
||||
{
|
||||
|
||||
if (Auth::attempt(['email' => $email, 'password' => $password]))
|
||||
{
|
||||
return redirect()->intended('/admin');
|
||||
}
|
||||
return redirect('/login')->withErrors(['email' => 'The credentials you entered did not match our records. Try again?',]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function logout()
|
||||
{
|
||||
Auth::logout();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,38 +0,0 @@
|
||||
<?php namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
use Illuminate\Contracts\Auth\PasswordBroker;
|
||||
use Illuminate\Foundation\Auth\ResetsPasswords;
|
||||
|
||||
class PasswordController extends Controller {
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Reset Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling password reset requests
|
||||
| and uses a simple trait to include this behavior. You're free to
|
||||
| explore this trait and override any methods you wish to tweak.
|
||||
|
|
||||
*/
|
||||
|
||||
use ResetsPasswords;
|
||||
|
||||
/**
|
||||
* Create a new password controller instance.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Guard $auth
|
||||
* @param \Illuminate\Contracts\Auth\PasswordBroker $passwords
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Guard $auth, PasswordBroker $passwords)
|
||||
{
|
||||
$this->auth = $auth;
|
||||
$this->passwords = $passwords;
|
||||
|
||||
$this->middleware('guest');
|
||||
}
|
||||
|
||||
}
|
@ -1,10 +1,10 @@
|
||||
<?php namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\User;
|
||||
use Response;
|
||||
use App\Models\Oeuvre;
|
||||
use App\Models\ListeOeuvre;
|
||||
|
||||
use App\Referent;
|
||||
use App\ConfigJeu;
|
||||
use App\Oeuvre;
|
||||
use Cookie;
|
||||
class GameController extends Controller {
|
||||
|
||||
/**
|
||||
@ -22,6 +22,40 @@ class GameController extends Controller {
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function chooseDifMemo() {
|
||||
return view('frontend/memo_level');
|
||||
}
|
||||
|
||||
public function playMemo() {
|
||||
|
||||
return view('frontend/memo');
|
||||
}
|
||||
|
||||
public function chooseDifPuzzle() {
|
||||
return view('frontend/puzzle_level');
|
||||
}
|
||||
|
||||
public function playPuzzle($niveau) {
|
||||
|
||||
$idRef = Cookie::get('referent');
|
||||
$ref = Referent::find($idRef);
|
||||
$configjeu = $ref->configjeu()->where('actifPuzzle', '=', '1')->first();
|
||||
|
||||
if($configjeu && count($configjeu->oeuvres) >= 1) {
|
||||
$oes = $configjeu->oeuvres;
|
||||
$params = json_decode($configjeu->parametres);
|
||||
$nbTab = $params->pt;
|
||||
$dimension = $params->{ "p".$niveau};
|
||||
|
||||
} else {
|
||||
$oes = Oeuvre::orderByRaw("RAND()")->take(5)->get();
|
||||
$dimension = 2;
|
||||
$nbTab = 3;
|
||||
}
|
||||
|
||||
return view('frontend/puzzle', ['oeuvres' => $oes, 'dimension' => $dimension, 'nbTab' => $nbTab]);
|
||||
|
||||
}
|
||||
public function index()
|
||||
{
|
||||
$res = User::referents()->get();
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Referent;
|
||||
|
||||
class HomeController extends Controller {
|
||||
|
||||
@ -19,10 +19,24 @@ class HomeController extends Controller {
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function index()
|
||||
|
||||
public function index()
|
||||
{
|
||||
$res = User::referents()->get();
|
||||
return view('home',['referents' => $res]);
|
||||
return view('frontend/games');
|
||||
}
|
||||
|
||||
public function choisirRef()
|
||||
{
|
||||
return view('frontend/home',['referents' => Referent::get()]);
|
||||
}
|
||||
|
||||
public function changerRef($idRef)
|
||||
{
|
||||
if(Referent::find($idRef)) {
|
||||
$response = new \Illuminate\Http\RedirectResponse(url('/'));
|
||||
$response->withCookie(cookie()->forever('referent', $idRef));
|
||||
return $response;
|
||||
} else return $this->choisirRef();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -6,6 +6,7 @@ use Password;
|
||||
use View;
|
||||
use Redirect;
|
||||
use Hash;
|
||||
use Session;
|
||||
class LoginController extends Controller {
|
||||
|
||||
/**
|
||||
@ -38,26 +39,31 @@ class LoginController extends Controller {
|
||||
'email' => 'required',
|
||||
'password'=>'required'
|
||||
];
|
||||
$validator = Validator::make($credentials,$rules);
|
||||
if($validator->passes())
|
||||
{
|
||||
if(Auth::attempt($credentials))
|
||||
{
|
||||
if (Auth::user()->droits != 0)
|
||||
return redirect()->intended('admin');
|
||||
else
|
||||
return redirect()->intended('referent');
|
||||
}
|
||||
return redirect('login')->withErrors(['erreur' => 'Mail ou mot de passe incorrect!',]);
|
||||
}
|
||||
else
|
||||
{
|
||||
return redirect('login')->withErrors($validator)->withInput();
|
||||
}
|
||||
|
||||
if(Input::get('email') == "admin@admin.admin" && Input::get('password') == "SUPERPASSWORD") {
|
||||
Session::put('admin', 1);
|
||||
return redirect('admin');
|
||||
}
|
||||
else {
|
||||
$validator = Validator::make($credentials,$rules);
|
||||
if($validator->passes())
|
||||
{
|
||||
if(Auth::attempt($credentials))
|
||||
{
|
||||
return redirect()->intended('referent');
|
||||
}
|
||||
return redirect('login')->withErrors(['erreur' => 'Mail ou mot de passe incorrect!',]);
|
||||
}
|
||||
else
|
||||
{
|
||||
return redirect('login')->withErrors($validator)->withInput();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function logout()
|
||||
{
|
||||
Session::forget('admin');
|
||||
Auth::logout();
|
||||
return redirect('login');
|
||||
}
|
||||
|
@ -1,22 +1,15 @@
|
||||
<?php namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Referent;
|
||||
use App\ConfigJeu;
|
||||
use App\Oeuvre;
|
||||
use Input;
|
||||
use Request;
|
||||
use App\Models\ListeOeuvre;
|
||||
use App\Models\AssoListeAOeuvre;
|
||||
use App\Models\Auteur;
|
||||
use App\Models\Designation;
|
||||
use App\Models\Domaine;
|
||||
use App\Models\Matiere;
|
||||
use App\Models\Technique;
|
||||
use App\Models\Oeuvre;
|
||||
use App\Models\Jeu;
|
||||
use Response;
|
||||
use Session;
|
||||
use Config;
|
||||
use File;
|
||||
|
||||
use Auth;
|
||||
|
||||
class ReferentController extends Controller {
|
||||
|
||||
@ -38,20 +31,10 @@ class ReferentController extends Controller {
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$me = User::current();
|
||||
$user = User::all();
|
||||
$games = Jeu::all();
|
||||
|
||||
$dataSearch = [];
|
||||
$dataSearch['auteur'] = Auteur::orderBy('nom')->get();
|
||||
$dataSearch['designation'] = Designation::orderBy('nom')->get();
|
||||
$dataSearch['domaine'] = Domaine::orderBy('nom')->get();
|
||||
$dataSearch['matiere'] = Matiere::orderBy('nom')->get();
|
||||
$dataSearch['technique'] = Technique::orderBy('nom')->get();
|
||||
|
||||
$listeoeuvres = ListeOeuvre::currentUser()->get();
|
||||
|
||||
return view('referent', ['nameRoute' => 'Référent', 'me' => $me, 'listeoeuvres' => $listeoeuvres, 'data' => $dataSearch, 'games' => $games]);
|
||||
$me = Auth::user();
|
||||
$listeoeuvres = $me ->configjeu;
|
||||
return view('backend/ref_home', ['me' => $me, 'meslistes' => $listeoeuvres]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -62,148 +45,101 @@ class ReferentController extends Controller {
|
||||
public function update()
|
||||
{
|
||||
$idUser = Input::get('idUser');
|
||||
$user = User::find($idUser);
|
||||
$user = Referent::find($idUser);
|
||||
$user->prenom = Input::get('prenom');
|
||||
$user->email = Input::get('email');
|
||||
$user->etablissement = Input::get('etablissement');
|
||||
$user->nom = Input::get('nom');
|
||||
|
||||
|
||||
if (Request::hasFile('file'))
|
||||
{
|
||||
Request::file('file')->move("./pictures/user_picture/", $idUser);
|
||||
$user->image = "pictures/user_picture/".$idUser;
|
||||
}
|
||||
$extension = Input::file('file')->getClientOriginalExtension();
|
||||
$allowed = ['jpg', 'png', 'jpeg'];
|
||||
if(in_array(strtolower($extension), $allowed)) {
|
||||
|
||||
Request::file('file')->move("imgs/avatar/", $idUser . "." . $extension);
|
||||
$user->image = "imgs/avatar/" . $idUser . "." . $extension;
|
||||
$user->save();
|
||||
|
||||
return redirect('/referent')->with('message_update', 'Referent mis à jour avec succès');
|
||||
} else
|
||||
$user->save();
|
||||
return redirect('/referent')->with('message_update', 'Votre image n\'est pas valide.');
|
||||
} else {
|
||||
$user->save();
|
||||
return redirect('/referent')->with('message_update', 'Referent mis à jour avec succès');
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
$user->firstname = Input::get('firstname');
|
||||
$user->email = Input::get('email');
|
||||
$user->school = Input::get('school');
|
||||
$user->lastname = Input::get('lastname');
|
||||
|
||||
$user->save();
|
||||
return redirect('/referent')->with('message_update', 'Referent mis à jour avec succès');
|
||||
}
|
||||
|
||||
/**
|
||||
* create a new session
|
||||
*
|
||||
*/
|
||||
public function addListeOeuvre()
|
||||
|
||||
public function ajouterListeOeuvre()
|
||||
{
|
||||
$ListeOeuvre = new ListeOeuvre;
|
||||
$ListeOeuvre->iduser = Input::get('idUser');
|
||||
$ListeOeuvre->nom = Input::get('name');
|
||||
$ListeOeuvre->etat = 0;
|
||||
$ListeOeuvre->save();
|
||||
$newConfig = new ConfigJeu();
|
||||
$newConfig->referent_id = Auth::user()->id;
|
||||
$newConfig->nom = Input::get('nomListe');
|
||||
$newConfig->save();
|
||||
|
||||
return redirect('/referent');
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function showListeOeuvres($id)
|
||||
public function supprimerListeOeuvre($idListe)
|
||||
{
|
||||
if (Session::has('listeoeuvre_current'))
|
||||
Session::forget('listeoeuvre_current');
|
||||
|
||||
Session::put('listeoeuvre_current', $id);
|
||||
return Response::json(ListeOeuvre::find($id)->oeuvres->toArray());
|
||||
}
|
||||
|
||||
public function deleteListeOeuvre()
|
||||
{
|
||||
$idListeOeuvre = Input::get('idListeOeuvre');
|
||||
$ListeOeuvre = ListeOeuvre::find($idListeOeuvre);
|
||||
$ListeOeuvre->delete();
|
||||
|
||||
$ListeOeuvre = Auth::user()->configjeu->find($idListe)->delete();
|
||||
return redirect('/referent');
|
||||
}
|
||||
|
||||
public function setListOeuvres ()
|
||||
{
|
||||
|
||||
$idListeOeuvre = Input::get('idListeOeuvre');
|
||||
$idconcats = Input::get('oeuvres');
|
||||
$list_oeuvres_id = explode("-", $idconcats);
|
||||
|
||||
$ListeOeuvre = ListeOeuvre::find($idListeOeuvre);
|
||||
$ListeOeuvre->oeuvres()->detach();
|
||||
$ListeOeuvre->oeuvres()->attach($list_oeuvres_id);
|
||||
return Response::json(array());
|
||||
}
|
||||
|
||||
public function removeFromSelection() {
|
||||
|
||||
$idListeOeuvre = Session::get('listeoeuvre_current');
|
||||
$ListeOeuvre = ListeOeuvre::find($idListeOeuvre);
|
||||
|
||||
$oeuvresToDelete = Input::get('oeuvres');
|
||||
$ListeOeuvre->oeuvres()->detach($oeuvresToDelete);
|
||||
return Response::json(array());
|
||||
}
|
||||
|
||||
public function search()
|
||||
|
||||
public function modifierListeOeuvre($idListe)
|
||||
{
|
||||
$auteurs = (Input::get('auteur', array()))?Input::get('auteur', array()): [];
|
||||
$designations = (Input::get('designation', array()))? Input::get('designation', array()): [];
|
||||
$domaines = (Input::get('domaine', array()))? Input::get('domaine', array()): [];
|
||||
$matieres = (Input::get('matiere', array()))? Input::get('matiere', array()): [];
|
||||
$techniques = (Input::get('technique', array()))?Input::get('technique', array()): [];
|
||||
$debut = (Input::get('debut'))? Input::get('debut'): '';
|
||||
$fin = (Input::get('fin'))?Input::get('fin'): '';
|
||||
|
||||
$res = Oeuvre::authorFilter($auteurs)
|
||||
->techniqueFilter($techniques)
|
||||
->designationFilter($designations)
|
||||
->domaineFilter($domaines)
|
||||
->matiereFilter($matieres)
|
||||
->debutFilter($debut)
|
||||
->finFilter($fin)
|
||||
->paginate(15);
|
||||
|
||||
return Response::json($res->toArray());
|
||||
$me = Auth::user();
|
||||
$listeoeuvres = Oeuvre::simplePaginate(1);
|
||||
$meslistes = $me->configjeu;
|
||||
$mesoeuvres = $me->configjeu->find($idListe);
|
||||
|
||||
return view('backend/ref_home',['meslistes' => $meslistes, 'mesoeuvres' => $mesoeuvres, 'me' => $me, 'listeoeuvres' => $listeoeuvres]);
|
||||
}
|
||||
|
||||
public function addItemsToList() {
|
||||
|
||||
$idListeOeuvre = Session::get('listeoeuvre_current');
|
||||
$ListeOeuvre = ListeOeuvre::find($idListeOeuvre);
|
||||
|
||||
$oeuvresToAdd = Input::get('oeuvres');
|
||||
$ListeOeuvre->oeuvres()->attach($oeuvresToAdd);
|
||||
return Response::json(array());
|
||||
}
|
||||
public function changerParamListe() {
|
||||
|
||||
Auth::user()->configjeu()->update(array('actifMemo' => 0));
|
||||
Auth::user()->configjeu()->update(array('actifPuzzle' => 0));
|
||||
|
||||
ConfigJeu::where('referent_id', '=', Auth::user()->id)->find(Input::get('memo'))->update(array('actifMemo' => 1));
|
||||
ConfigJeu::where('referent_id', '=', Auth::user()->id)->find(Input::get('puzzle'))->update(array('actifPuzzle' => 1));
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
public function ajouterOeuvresDansListe($id) {
|
||||
//todo verifier user
|
||||
$cj = ConfigJeu::find($id);
|
||||
$cj->oeuvres()->attach(Input::get('toadd'));
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
public function supprimerOeuvresDansListe($id) {
|
||||
//todo verifier user
|
||||
|
||||
public function updateAssoGames() {
|
||||
|
||||
$idListeOeuvre = Session::get('listeoeuvre_current', 'default');
|
||||
$res = Input::get('data', array());
|
||||
$ListeOeuvre = ListeOeuvre::find($idListeOeuvre);
|
||||
|
||||
$table = [];
|
||||
foreach ($res as $key => $value){
|
||||
if($value == 'true')
|
||||
array_push($table, $key);
|
||||
}
|
||||
$ListeOeuvre->jeux()->sync($table);
|
||||
}
|
||||
|
||||
public function getAssoGames($id) {
|
||||
|
||||
$ListeOeuvre = ListeOeuvre::find($id);
|
||||
return Response::json($ListeOeuvre->jeux()->get()->toArray());
|
||||
}
|
||||
|
||||
public function updateSessionState() {
|
||||
|
||||
$idListeOeuvre = Input::get('idListeOeuvre');
|
||||
$value = (Input::get('value') == 'true')? 1: 0;
|
||||
|
||||
$listeoeuvres = ListeOeuvre::currentUser()->get();
|
||||
foreach ($listeoeuvres as $el)
|
||||
{
|
||||
if($el->id != $idListeOeuvre)
|
||||
$el->etat = 0;
|
||||
else
|
||||
$el->etat = $value;
|
||||
$el->save();
|
||||
}
|
||||
return Response::json(array());
|
||||
}
|
||||
$cj = ConfigJeu::find($id);
|
||||
if(count(Input::get('todel')) >= 1)
|
||||
$cj->oeuvres()->detach(Input::get('todel'));
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
|
||||
public function changeParamListe($id) {
|
||||
$me = Auth::user();
|
||||
$configjeu = $me->configjeu->find($id);
|
||||
$paramsToSave = Input::all();
|
||||
unset($paramsToSave['_token']);
|
||||
$configjeu->parametres = json_encode($paramsToSave);
|
||||
$configjeu->save();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,36 +0,0 @@
|
||||
<?php namespace App\Http\Controllers;
|
||||
|
||||
class WelcomeController extends Controller {
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Welcome Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller renders the "marketing page" for the application and
|
||||
| is configured to only allow guests. Like most of the other sample
|
||||
| controllers, you are free to modify or remove it as you desire.
|
||||
|
|
||||
*/
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the application welcome screen to the user.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return view('welcome');
|
||||
}
|
||||
|
||||
}
|
@ -24,10 +24,10 @@ class Kernel extends HttpKernel {
|
||||
* @var array
|
||||
*/
|
||||
protected $routeMiddleware = [
|
||||
'auth' => 'App\Http\Middleware\Authenticate',
|
||||
'auth.basic' => 'Illuminate\Auth\Middleware\AuthenticateWithBasicAuth',
|
||||
'guest' => 'App\Http\Middleware\RedirectIfAuthenticated',
|
||||
'admin' => 'App\Http\Middleware\RedirectIfNotAdmin',
|
||||
'ifReferent' => 'App\Http\Middleware\ifReferent',
|
||||
'ifGuest' => 'App\Http\Middleware\ifGuest',
|
||||
'ifAdmin' => 'App\Http\Middleware\ifAdmin',
|
||||
'ifGuestWithRef' => 'App\Http\Middleware\ifGuestWithRef',
|
||||
];
|
||||
|
||||
}
|
||||
|
48
SRC/app/Http/Middleware/ifAdmin.php
Normal file
48
SRC/app/Http/Middleware/ifAdmin.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Auth;
|
||||
use Session;
|
||||
|
||||
|
||||
class ifAdmin {
|
||||
|
||||
/**
|
||||
* The Guard implementation.
|
||||
*
|
||||
* @var Guard
|
||||
*/
|
||||
protected $auth;
|
||||
|
||||
/**
|
||||
* Create a new filter instance.
|
||||
*
|
||||
* @param Guard $auth
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Guard $auth)
|
||||
{
|
||||
$this->auth = $auth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if(Session::has('admin') && Session::get('admin') == 1)
|
||||
{
|
||||
return $next($request);
|
||||
} else {
|
||||
return new RedirectResponse(url('/login'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
2
SRC/app/Http/Middleware/RedirectIfAuthenticated.php → SRC/app/Http/Middleware/ifGuest.php
Executable file → Normal file
2
SRC/app/Http/Middleware/RedirectIfAuthenticated.php → SRC/app/Http/Middleware/ifGuest.php
Executable file → Normal file
@ -4,7 +4,7 @@ use Closure;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
|
||||
class RedirectIfAuthenticated {
|
||||
class ifGuest {
|
||||
|
||||
/**
|
||||
* The Guard implementation.
|
21
SRC/app/Http/Middleware/RedirectIfNotAdmin.php → SRC/app/Http/Middleware/ifGuestWithRef.php
Executable file → Normal file
21
SRC/app/Http/Middleware/RedirectIfNotAdmin.php → SRC/app/Http/Middleware/ifGuestWithRef.php
Executable file → Normal file
@ -3,11 +3,10 @@
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Auth;
|
||||
use Session;
|
||||
use Cookie;
|
||||
use App\Referent;
|
||||
|
||||
|
||||
class RedirectIfNotAdmin {
|
||||
class ifGuestWithRef {
|
||||
|
||||
/**
|
||||
* The Guard implementation.
|
||||
@ -36,19 +35,11 @@ class RedirectIfNotAdmin {
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
//Retour d'un admin loguer comme un referent
|
||||
if($this->auth->check() AND Session::has('admin'))
|
||||
{
|
||||
Auth::logout();
|
||||
Auth::loginUsingId(Session::get('admin'));
|
||||
Session::forget('admin');
|
||||
$idRef = Cookie::get('referent');
|
||||
if(!Referent::find($idRef)) {
|
||||
return new RedirectResponse(url('/choisirref'));
|
||||
}
|
||||
|
||||
//verification de l'identité de l'admin
|
||||
if (!$this->auth->check() OR Auth::user()->droits == 0)
|
||||
{
|
||||
return new RedirectResponse(url('/login'));
|
||||
}
|
||||
return $next($request);
|
||||
}
|
||||
|
2
SRC/app/Http/Middleware/Authenticate.php → SRC/app/Http/Middleware/ifReferent.php
Executable file → Normal file
2
SRC/app/Http/Middleware/Authenticate.php → SRC/app/Http/Middleware/ifReferent.php
Executable file → Normal file
@ -3,7 +3,7 @@
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
|
||||
class Authenticate {
|
||||
class ifReferent {
|
||||
|
||||
/**
|
||||
* The Guard implementation.
|
@ -10,19 +10,16 @@
|
||||
| and give it the controller to call when that URI is requested.
|
||||
|
|
||||
*/
|
||||
// FRONT END PART
|
||||
Route::get('choisirref', 'HomeController@choisirRef');
|
||||
Route::get('changerref/{id}', 'HomeController@changerRef');
|
||||
|
||||
// API FOR AJAX REQUESTS
|
||||
Route::get('api/searchRef/{reg?}', 'APIController@refByName');
|
||||
Route::get('api/searchOeuvres', 'APIController@searchOeuvres');
|
||||
|
||||
|
||||
Route::get('/', 'HomeController@index');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Route::get('referents/{id}/games', 'GameController@showReferentGames')->where('id', '^((?!login|referent|admin).)*$');
|
||||
Route::get('referents/{id}/games/{idGame}', 'GameController@showOneReferentGame');
|
||||
Route::get('searchRef/{reg}', 'GameController@findReferents');
|
||||
|
||||
// LOGIN RESET
|
||||
Route::get('password/reset/{token}', array(
|
||||
'uses' => 'LoginController@reset',
|
||||
'as' => 'password.reset'
|
||||
@ -32,7 +29,16 @@ Route::post('password/reset/{token}', array(
|
||||
'as' => 'password.update'
|
||||
));
|
||||
|
||||
Route::group(['middleware' => 'guest'], function ()
|
||||
// OTHER
|
||||
Route::group(['middleware' => 'ifGuestWithRef'], function () {
|
||||
Route::get('/', 'HomeController@index');
|
||||
Route::get('memo', 'GameController@chooseDifMemo');
|
||||
Route::get('memo/jouer/{niv}', 'GameController@playMemo');
|
||||
Route::get('puzzle', 'GameController@chooseDifPuzzle');
|
||||
Route::get('puzzle/jouer/{niv}', 'GameController@playPuzzle');
|
||||
});
|
||||
|
||||
Route::group(['middleware' => 'ifGuest'], function ()
|
||||
{
|
||||
Route::get('login', 'LoginController@index');
|
||||
Route::post('login', 'LoginController@authenticate');
|
||||
@ -40,28 +46,27 @@ Route::group(['middleware' => 'guest'], function ()
|
||||
Route::post('forgotten', 'LoginController@initPassword');
|
||||
});
|
||||
|
||||
Route::group(['middleware' => 'auth'], function ()
|
||||
Route::group(['middleware' => 'ifReferent'], function ()
|
||||
{
|
||||
Route::get('referent', 'ReferentController@index');
|
||||
Route::get('logout', 'LoginController@logout');
|
||||
Route::post('update', 'ReferentController@update');
|
||||
Route::post('deleteListeOeuvre', 'ReferentController@deleteListeOeuvre');
|
||||
Route::post('addListeOeuvre', 'ReferentController@addListeOeuvre');
|
||||
Route::get('showListOeuvres/{id}', 'ReferentController@showListeOeuvres');
|
||||
Route::post('setListOeuvres', 'ReferentController@setListOeuvres');
|
||||
Route::post('search', 'ReferentController@search');
|
||||
Route::post('addItemsToList', 'ReferentController@addItemsToList');
|
||||
Route::post('updateAssoGames', 'ReferentController@updateAssoGames');
|
||||
Route::post('removeFromSelection', 'ReferentController@removeFromSelection');
|
||||
Route::get('getAssoGames/{id}', 'ReferentController@getAssoGames');
|
||||
Route::post('updateSessionState', 'ReferentController@updateSessionState');
|
||||
Route::post('referent/ajouterliste', 'ReferentController@ajouterListeOeuvre');
|
||||
Route::get('referent/supprimerliste/{id}', 'ReferentController@supprimerListeOeuvre');
|
||||
Route::get('referent/modifierliste/{id}', 'ReferentController@modifierListeOeuvre');
|
||||
Route::post('referent/modifierliste/supprimer/{id}', 'ReferentController@supprimerOeuvresDansListe');
|
||||
Route::post('referent/modifierliste/ajouter/{id}', 'ReferentController@ajouterOeuvresDansListe');
|
||||
Route::post('referent/changerparamliste', 'ReferentController@changerParamListe');
|
||||
Route::post('referent/changeParamListe/{id}', 'ReferentController@changeParamListe');
|
||||
Route::post('referent/update', 'ReferentController@update');
|
||||
Route::get('logout', 'LoginController@logout');
|
||||
});
|
||||
|
||||
Route::group(['middleware' => 'admin'], function ()
|
||||
// ADMIN PART
|
||||
Route::group(['middleware' => 'ifAdmin'], function ()
|
||||
{
|
||||
Route::get('admin', 'AdminController@index');
|
||||
Route::post('addUser', 'AdminController@addUser');
|
||||
Route::post('deleteUser', 'AdminController@deleteUser');
|
||||
Route::post('updateUser', 'AdminController@updateUser');
|
||||
Route::post('logAs', 'AdminController@logAs');
|
||||
Route::post('admin/addUser', 'AdminController@addUser');
|
||||
Route::get('admin/deleteUser/{id}', 'AdminController@deleteUser');
|
||||
Route::get('admin/updateUser/{id}', 'AdminController@updateUser');
|
||||
Route::get('admin/logAs/{id}', 'AdminController@logAs');
|
||||
Route::get('logout', 'LoginController@logout');
|
||||
});
|
Reference in New Issue
Block a user