|
@@ -11,209 +11,210 @@
|
|
|
|
|
|
|
|
*/
|
|
*/
|
|
|
|
|
|
-define('TMDB_API_KEY', 'b187f8d9c5e72b1faecb741d5d04239a');
|
|
|
|
|
|
|
|
Route::get('/', function()
|
|
Route::get('/', function()
|
|
{
|
|
{
|
|
- $gesehen = Film::zuletztGesehen()->get();
|
|
|
|
- $vorgeschlagen = Film::neuesteVorschlage()->get();
|
|
|
|
|
|
+ $gesehen = Film::zuletztGesehen()->get();
|
|
|
|
+ $vorgeschlagen = Film::neuesteVorschlage()->get();
|
|
$mg = Film::meistgewunschteVorschlage()->get();
|
|
$mg = Film::meistgewunschteVorschlage()->get();
|
|
|
|
|
|
- $news = News::aktuell()->get();
|
|
|
|
- $nextfilm = Dumbo::find(1)->film;
|
|
|
|
|
|
+ $news = News::aktuell()->get();
|
|
|
|
+ $nextfilm = Dumbo::find(1)->film;
|
|
|
|
|
|
- $tmdb = new TMDb(TMDB_API_KEY, 'de', TRUE);
|
|
|
|
|
|
+ $tmdb = new TMDb(Config::get('constants.tvdb.apikey'), 'de', TRUE);
|
|
foreach(array("top" => $mg[0], "neu" => $vorgeschlagen[0], "alt" => $gesehen[0]) as $key => $val) {
|
|
foreach(array("top" => $mg[0], "neu" => $vorgeschlagen[0], "alt" => $gesehen[0]) as $key => $val) {
|
|
$tmovie = $tmdb->getMovie($val->tvdbid);
|
|
$tmovie = $tmdb->getMovie($val->tvdbid);
|
|
$images[$key] = $tmdb->getImageUrl($tmovie['poster_path'], TMDb::IMAGE_POSTER, 'w342');
|
|
$images[$key] = $tmdb->getImageUrl($tmovie['poster_path'], TMDb::IMAGE_POSTER, 'w342');
|
|
}
|
|
}
|
|
|
|
|
|
- if(is_object($nextfilm)) {
|
|
|
|
- $tmovie = $tmdb->getMovie($nextfilm->tvdbid);
|
|
|
|
- $images["next"] = $tmdb->getImageUrl($tmovie['poster_path'], TMDb::IMAGE_POSTER, 'w342');
|
|
|
|
- } else {
|
|
|
|
- $images["next"] = "img/no-poster-w92.jpg";
|
|
|
|
- }
|
|
|
|
|
|
+ if(is_object($nextfilm)) {
|
|
|
|
+ $tmovie = $tmdb->getMovie($nextfilm->tvdbid);
|
|
|
|
+ $images["next"] = $tmdb->getImageUrl($tmovie['poster_path'], TMDb::IMAGE_POSTER, 'w342');
|
|
|
|
+ } else {
|
|
|
|
+ $images["next"] = "img/no-poster-w92.jpg";
|
|
|
|
+ }
|
|
|
|
|
|
- $kommentare = Comment::neueste()->get();
|
|
|
|
|
|
+ $kommentare = Comment::neueste()->get();
|
|
|
|
|
|
$labels = array("", "danger", "danger", "warning", "warning", "info", "info", "primary", "primary", "success", "success");
|
|
$labels = array("", "danger", "danger", "warning", "warning", "info", "info", "primary", "primary", "success", "success");
|
|
|
|
|
|
return View::make('index')
|
|
return View::make('index')
|
|
- ->with('gesehen', $gesehen)
|
|
|
|
- ->with('vorgeschlagen', $vorgeschlagen)
|
|
|
|
|
|
+ ->with('gesehen', $gesehen)
|
|
|
|
+ ->with('vorgeschlagen', $vorgeschlagen)
|
|
->with('meistgw', $mg)
|
|
->with('meistgw', $mg)
|
|
- ->with('images', $images)
|
|
|
|
- ->with('news', $news)
|
|
|
|
- ->with('kommentare', $kommentare)
|
|
|
|
|
|
+ ->with('images', $images)
|
|
|
|
+ ->with('news', $news)
|
|
|
|
+ ->with('kommentare', $kommentare)
|
|
->with('labels', $labels)
|
|
->with('labels', $labels)
|
|
- ->with('nextfilm', $nextfilm);
|
|
|
|
|
|
+ ->with('nextfilm', $nextfilm);
|
|
});
|
|
});
|
|
|
|
|
|
Route::get('film/{id}', array('as' => 'film', function($id) {
|
|
Route::get('film/{id}', array('as' => 'film', function($id) {
|
|
- $film = Film::findOrFail($id);
|
|
|
|
-
|
|
|
|
- $tmdb = new TMDb('b187f8d9c5e72b1faecb741d5d04239a', 'de', TRUE);
|
|
|
|
- $tmovie = $tmdb->getMovie($film->tvdbid);
|
|
|
|
- $tcast = $tmdb->getMovieCast($film->tvdbid);
|
|
|
|
- $ttrail = $tmdb->getMovieTrailers($film->tvdbid);
|
|
|
|
- $image = $tmdb->getImageUrl($tmovie['poster_path'], TMDb::IMAGE_POSTER, 'w342');
|
|
|
|
-
|
|
|
|
- $votes = $film->votes()->count();
|
|
|
|
- $vposi = $film->votes()->where('stimme', true)->count();
|
|
|
|
-
|
|
|
|
- $pv = array();
|
|
|
|
- foreach($film->votes()->where('stimme', true)->get() as $v) {
|
|
|
|
- $pv[] = $v->voter;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- $nv = array();
|
|
|
|
- foreach($film->votes()->where('stimme', false)->get() as $v) {
|
|
|
|
- $nv[] = $v->voter;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if(!is_null(Auth::user()) && $film->votes()->where('user', Auth::user()->id)->count() > 0) {
|
|
|
|
- $uvote[0] = true;
|
|
|
|
- $uvote[1] = $film->votes()->where('user', Auth::user()->id)->first()->stimme;
|
|
|
|
- } else {
|
|
|
|
- $uvote[0] = false;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- $comments = $film->comments()->orderBy('id', 'DESC')->get();
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- $labels = array("", "danger", "danger", "warning", "warning", "info", "info", "primary", "primary", "success", "success");
|
|
|
|
-
|
|
|
|
- return View::make('film')
|
|
|
|
- ->with('film', $film)
|
|
|
|
- ->with('tfilm', $tmovie)
|
|
|
|
- ->with('poster', $image)
|
|
|
|
- ->with('comments', $comments)
|
|
|
|
- ->with('cast', $tcast)
|
|
|
|
- ->with('trail', $ttrail)
|
|
|
|
- ->with('votes', $votes)
|
|
|
|
- ->with('uvote', $uvote)
|
|
|
|
- ->with('pv', $pv)
|
|
|
|
- ->with('nv', $nv)
|
|
|
|
- ->with('vposi', $vposi)
|
|
|
|
- ->with('labels', $labels)
|
|
|
|
- ->with('tmdb', $tmdb);
|
|
|
|
|
|
+ $film = Film::findOrFail($id);
|
|
|
|
+
|
|
|
|
+ $tmdb = new TMDb('b187f8d9c5e72b1faecb741d5d04239a', 'de', TRUE);
|
|
|
|
+ $tmovie = $tmdb->getMovie($film->tvdbid);
|
|
|
|
+ $tcast = $tmdb->getMovieCast($film->tvdbid);
|
|
|
|
+ $ttrail = $tmdb->getMovieTrailers($film->tvdbid);
|
|
|
|
+ $image = $tmdb->getImageUrl($tmovie['poster_path'], TMDb::IMAGE_POSTER, 'w342');
|
|
|
|
+
|
|
|
|
+ $votes = $film->votes()->count();
|
|
|
|
+ $vposi = $film->votes()->where('stimme', true)->count();
|
|
|
|
+
|
|
|
|
+ $pv = array();
|
|
|
|
+ foreach($film->votes()->where('stimme', true)->get() as $v) {
|
|
|
|
+ $pv[] = $v->voter;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $nv = array();
|
|
|
|
+ foreach($film->votes()->where('stimme', false)->get() as $v) {
|
|
|
|
+ $nv[] = $v->voter;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(!is_null(Auth::user()) && $film->votes()->where('user', Auth::user()->id)->count() > 0) {
|
|
|
|
+ $uvote[0] = true;
|
|
|
|
+ $uvote[1] = $film->votes()->where('user', Auth::user()->id)->first()->stimme;
|
|
|
|
+ } else {
|
|
|
|
+ $uvote[0] = false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ $comments = $film->comments()->orderBy('id', 'DESC')->get();
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ $labels = array("", "danger", "danger", "warning", "warning", "info", "info", "primary", "primary", "success", "success");
|
|
|
|
+
|
|
|
|
+ return View::make('film')
|
|
|
|
+ ->with('film', $film)
|
|
|
|
+ ->with('tfilm', $tmovie)
|
|
|
|
+ ->with('poster', $image)
|
|
|
|
+ ->with('comments', $comments)
|
|
|
|
+ ->with('cast', $tcast)
|
|
|
|
+ ->with('trail', $ttrail)
|
|
|
|
+ ->with('votes', $votes)
|
|
|
|
+ ->with('uvote', $uvote)
|
|
|
|
+ ->with('pv', $pv)
|
|
|
|
+ ->with('nv', $nv)
|
|
|
|
+ ->with('vposi', $vposi)
|
|
|
|
+ ->with('labels', $labels)
|
|
|
|
+ ->with('tmdb', $tmdb);
|
|
}));
|
|
}));
|
|
|
|
|
|
Route::get('vote/{stimme}/{user}/{film}', function($stimme, $user, $film) {
|
|
Route::get('vote/{stimme}/{user}/{film}', function($stimme, $user, $film) {
|
|
- $v = Vote::where('user', $user)->where('film', $film)->first();
|
|
|
|
|
|
+ $v = Vote::where('user', $user)->where('film', $film)->first();
|
|
|
|
|
|
- if(!is_null($v)) {
|
|
|
|
- $v->stimme = $stimme == "yes" ? true : false;
|
|
|
|
- } else {
|
|
|
|
- $v = new Vote();
|
|
|
|
- $v->user = $user;
|
|
|
|
- $v->film = $film;
|
|
|
|
- $v->stimme = $stimme == "yes" ? true : false;
|
|
|
|
- }
|
|
|
|
|
|
+ if(!is_null($v)) {
|
|
|
|
+ $v->stimme = $stimme == "yes" ? true : false;
|
|
|
|
+ } else {
|
|
|
|
+ $v = new Vote();
|
|
|
|
+ $v->user = $user;
|
|
|
|
+ $v->film = $film;
|
|
|
|
+ $v->stimme = $stimme == "yes" ? true : false;
|
|
|
|
+ }
|
|
|
|
|
|
- $v->save();
|
|
|
|
|
|
+ $v->save();
|
|
|
|
|
|
- return Redirect::to('film/' . $film);
|
|
|
|
|
|
+ return Redirect::to('film/' . $film);
|
|
});
|
|
});
|
|
|
|
|
|
Route::post('comment', array('as' => 'comment', function() {
|
|
Route::post('comment', array('as' => 'comment', function() {
|
|
- $c = new Comment();
|
|
|
|
- $c->film = Input::get('film');
|
|
|
|
- $c->user = Input::get('user');
|
|
|
|
- $c->text = Input::get('text');
|
|
|
|
- $c->bewertung = !is_null(Input::get('rate')) ? Input::get('rate') : 0;
|
|
|
|
- $c->save();
|
|
|
|
- return Redirect::to('film/' . Input::get('film'));
|
|
|
|
|
|
+ $c = new Comment();
|
|
|
|
+ $c->film = Input::get('film');
|
|
|
|
+ $c->user = Input::get('user');
|
|
|
|
+ $c->text = Input::get('text');
|
|
|
|
+ $c->bewertung = !is_null(Input::get('rate')) ? Input::get('rate') : 0;
|
|
|
|
+ $c->save();
|
|
|
|
+ return Redirect::to('film/' . Input::get('film'));
|
|
}));
|
|
}));
|
|
|
|
|
|
Route::post('comment/edit', array('as'=> 'modcomment', function () {
|
|
Route::post('comment/edit', array('as'=> 'modcomment', function () {
|
|
- $c = Comment::findOrFail(Input::get('id'));
|
|
|
|
- $c->text = Input::get('text');
|
|
|
|
- $c->bewertung = Input::get('rate');
|
|
|
|
- $c->save();
|
|
|
|
- return Redirect::to('film/' . $c->film);
|
|
|
|
|
|
+ $c = Comment::findOrFail(Input::get('id'));
|
|
|
|
+ $c->text = Input::get('text');
|
|
|
|
+ $c->bewertung = Input::get('rate');
|
|
|
|
+ $c->save();
|
|
|
|
+ return Redirect::to('film/' . $c->film);
|
|
}));
|
|
}));
|
|
|
|
|
|
Route::get('login', array('as' => 'login', function() {
|
|
Route::get('login', array('as' => 'login', function() {
|
|
- return View::make('login');
|
|
|
|
|
|
+ return View::make('login');
|
|
}));
|
|
}));
|
|
|
|
|
|
Route::post('login', function() {
|
|
Route::post('login', function() {
|
|
- $userdata = array(
|
|
|
|
- 'name' => Input::get('user'),
|
|
|
|
- 'password' => Input::get('password'));
|
|
|
|
- if(Auth::attempt($userdata, true)) {
|
|
|
|
- return Redirect::intended('/');
|
|
|
|
- } else {
|
|
|
|
- echo "Login gescheitert.";
|
|
|
|
- var_dump($userdata);
|
|
|
|
- return Redirect::to('login')
|
|
|
|
- ->with('login_errors', true);
|
|
|
|
- }
|
|
|
|
|
|
+ $userdata = array(
|
|
|
|
+ 'name' => Input::get('user'),
|
|
|
|
+ 'password' => Input::get('password'));
|
|
|
|
+ if(Auth::attempt($userdata, true)) {
|
|
|
|
+ return Redirect::intended('/');
|
|
|
|
+ } else {
|
|
|
|
+ echo "Login gescheitert.";
|
|
|
|
+ var_dump($userdata);
|
|
|
|
+ return Redirect::to('login')
|
|
|
|
+ ->with('login_errors', true);
|
|
|
|
+ }
|
|
});
|
|
});
|
|
|
|
|
|
Route::get('logout', array('as' => 'logout', function() {
|
|
Route::get('logout', array('as' => 'logout', function() {
|
|
- Auth::logout();
|
|
|
|
- return Redirect::to('/');
|
|
|
|
|
|
+ Auth::logout();
|
|
|
|
+ return Redirect::to('/');
|
|
}));
|
|
}));
|
|
|
|
|
|
Route::get('beliebt', function() {
|
|
Route::get('beliebt', function() {
|
|
-
|
|
|
|
- $filme = DB::table(DB::raw('film_films'))
|
|
|
|
- ->select(DB::raw('film_films.*, COUNT(case when film_votes.stimme IS TRUE then 1 end) as upvotes,
|
|
|
|
|
|
+
|
|
|
|
+ $filme = DB::table(DB::raw('film_films'))
|
|
|
|
+ ->select(DB::raw('film_films.*, COUNT(case when film_votes.stimme IS TRUE then 1 end) as upvotes,
|
|
COUNT(case when film_votes.stimme IS FALSE then 1 end) as downvotes,
|
|
COUNT(case when film_votes.stimme IS FALSE then 1 end) as downvotes,
|
|
COUNT(case when film_votes.stimme IS TRUE then 1 end) as vcount'))
|
|
COUNT(case when film_votes.stimme IS TRUE then 1 end) as vcount'))
|
|
- ->leftJoin('votes', 'votes.film', '=', 'films.id')
|
|
|
|
- ->whereNull('films.gesehen')
|
|
|
|
- ->groupBy('id')
|
|
|
|
- ->orderBy('vcount', 'DESC')->orderBy('vorgeschlagen', 'ASC')
|
|
|
|
- ->paginate(25);
|
|
|
|
|
|
+ ->leftJoin('votes', 'votes.film', '=', 'films.id')
|
|
|
|
+ ->whereNull('films.gesehen')
|
|
|
|
+ ->groupBy('id')
|
|
|
|
+ ->orderBy('vcount', 'DESC')->orderBy('vorgeschlagen', 'ASC')
|
|
|
|
+ ->paginate(25);
|
|
|
|
|
|
- return View::make('suggest')
|
|
|
|
- ->with('filme', $filme)
|
|
|
|
- ->with('titel', 'Vorschläge nach Wertung');
|
|
|
|
|
|
+ return View::make('suggest')
|
|
|
|
+ ->with('filme', $filme)
|
|
|
|
+ ->with('titel', 'Vorschläge nach Wertung');
|
|
|
|
|
|
});
|
|
});
|
|
|
|
|
|
Route::get('vorgeschlagen', function() {
|
|
Route::get('vorgeschlagen', function() {
|
|
|
|
|
|
- $filme = DB::table(DB::raw('film_films'))
|
|
|
|
- ->select(DB::raw('film_films.*, COUNT(case when film_votes.stimme IS TRUE then 1 end) as upvotes,
|
|
|
|
|
|
+ $filme = DB::table(DB::raw('film_films'))
|
|
|
|
+ ->select(DB::raw('film_films.*, COUNT(case when film_votes.stimme IS TRUE then 1 end) as upvotes,
|
|
COUNT(case when film_votes.stimme IS FALSE then 1 end) as downvotes,
|
|
COUNT(case when film_votes.stimme IS FALSE then 1 end) as downvotes,
|
|
COUNT(case when film_votes.stimme IS TRUE then 1 end) as vcount'))
|
|
COUNT(case when film_votes.stimme IS TRUE then 1 end) as vcount'))
|
|
- ->leftJoin('votes', 'votes.film', '=', 'films.id')
|
|
|
|
- ->whereNull('films.gesehen')
|
|
|
|
- ->groupBy('id')
|
|
|
|
- ->orderBy('vorgeschlagen', 'DESC')
|
|
|
|
- ->paginate(25);
|
|
|
|
|
|
+ ->leftJoin('votes', 'votes.film', '=', 'films.id')
|
|
|
|
+ ->whereNull('films.gesehen')
|
|
|
|
+ ->groupBy('id')
|
|
|
|
+ ->orderBy('vorgeschlagen', 'DESC')
|
|
|
|
+ ->paginate(25);
|
|
|
|
|
|
- return View::make('suggest')
|
|
|
|
- ->with('filme', $filme)
|
|
|
|
- ->with('titel', 'Vorschläge nach Datum');
|
|
|
|
|
|
+ return View::make('suggest')
|
|
|
|
+ ->with('filme', $filme)
|
|
|
|
+ ->with('titel', 'Vorschläge nach Datum');
|
|
|
|
|
|
});
|
|
});
|
|
|
|
|
|
Route::get('gesehen/{field?}/{order?}', function($field = "gesehen", $order = "desc") {
|
|
Route::get('gesehen/{field?}/{order?}', function($field = "gesehen", $order = "desc") {
|
|
- $filme = Film::whereNotNull('gesehen')->orderBy($field, $order)->paginate(25);
|
|
|
|
|
|
+ $filme = Film::whereNotNull('gesehen')->orderBy($field, $order)->paginate(25);
|
|
|
|
+ $labels = array("", "danger", "danger", "warning", "warning", "info", "info", "primary", "primary", "success", "success");
|
|
|
|
|
|
- return View::make('seen')
|
|
|
|
- ->with('filme', $filme);
|
|
|
|
|
|
+ return View::make('seen')
|
|
|
|
+ ->with('labels', $labels)
|
|
|
|
+ ->with('filme', $filme);
|
|
|
|
|
|
})->where(array('field' => '[a-z]+', 'order' => 'asc|desc'));
|
|
})->where(array('field' => '[a-z]+', 'order' => 'asc|desc'));
|
|
|
|
|
|
Route::get('neu', array('before' => 'auth', function() {
|
|
Route::get('neu', array('before' => 'auth', function() {
|
|
|
|
|
|
- return View::make('new');
|
|
|
|
|
|
+ return View::make('new');
|
|
|
|
|
|
}));
|
|
}));
|
|
|
|
|
|
Route::post('neu', array('before' => 'auth', function() {
|
|
Route::post('neu', array('before' => 'auth', function() {
|
|
- $tmdb = new TMDb('b187f8d9c5e72b1faecb741d5d04239a', 'de', TRUE);
|
|
|
|
- $r = $tmdb->searchMovie(Input::get('search'));
|
|
|
|
|
|
+ $tmdb = new TMDb('b187f8d9c5e72b1faecb741d5d04239a', 'de', TRUE);
|
|
|
|
+ $r = $tmdb->searchMovie(Input::get('search'));
|
|
|
|
|
|
- return View::make('new')->with('result', $r)->with('tmdb', $tmdb);
|
|
|
|
|
|
+ return View::make('new')->with('result', $r)->with('tmdb', $tmdb);
|
|
}));
|
|
}));
|
|
|
|
|
|
Route::get('vorschlag/{id}', array('before' => 'auth', function($id) {
|
|
Route::get('vorschlag/{id}', array('before' => 'auth', function($id) {
|
|
@@ -236,94 +237,94 @@ Route::get('vorschlag/{id}', array('before' => 'auth', function($id) {
|
|
}));
|
|
}));
|
|
|
|
|
|
Route::get('mark-read/{id}', array('before' => 'auth', function($id) {
|
|
Route::get('mark-read/{id}', array('before' => 'auth', function($id) {
|
|
- $film = Film::findOrFail($id);
|
|
|
|
- $film->gesehen = \Carbon\Carbon::today();
|
|
|
|
- $film->save();
|
|
|
|
- if(Dumbo::find(1)->nextfilm == $film->id) {
|
|
|
|
- $system = Dumbo::findOrFail(1);
|
|
|
|
- $system->nextfilm = 0;
|
|
|
|
- $system->save();
|
|
|
|
- }
|
|
|
|
- return Redirect::to('film/' . $film->id);
|
|
|
|
|
|
+ $film = Film::findOrFail($id);
|
|
|
|
+ $film->gesehen = \Carbon\Carbon::today();
|
|
|
|
+ $film->save();
|
|
|
|
+ if(Dumbo::find(1)->nextfilm == $film->id) {
|
|
|
|
+ $system = Dumbo::findOrFail(1);
|
|
|
|
+ $system->nextfilm = 0;
|
|
|
|
+ $system->save();
|
|
|
|
+ }
|
|
|
|
+ return Redirect::to('film/' . $film->id);
|
|
}));
|
|
}));
|
|
|
|
|
|
Route::get('view-next/{id}', array('before' => 'auth', function($id) {
|
|
Route::get('view-next/{id}', array('before' => 'auth', function($id) {
|
|
- $system = Dumbo::findOrFail(1);
|
|
|
|
- $system->nextfilm = $id;
|
|
|
|
- $system->save();
|
|
|
|
- return Redirect::to('film/' . $id);
|
|
|
|
|
|
+ $system = Dumbo::findOrFail(1);
|
|
|
|
+ $system->nextfilm = $id;
|
|
|
|
+ $system->save();
|
|
|
|
+ return Redirect::to('film/' . $id);
|
|
}));
|
|
}));
|
|
|
|
|
|
Route::get('register', function() {
|
|
Route::get('register', function() {
|
|
- return View::make('register');
|
|
|
|
|
|
+ return View::make('register');
|
|
});
|
|
});
|
|
|
|
|
|
Route::post('register', function() {
|
|
Route::post('register', function() {
|
|
- $vrules = array(
|
|
|
|
- 'name' => 'required|unique:users',
|
|
|
|
- 'email' => 'required|email',
|
|
|
|
- 'password' => 'required|confirmed',
|
|
|
|
- 'fire' => array('required', 'regex:/^Kreis$/i')
|
|
|
|
- );
|
|
|
|
-
|
|
|
|
- $vfields = array(
|
|
|
|
- 'name' => Input::get('user'),
|
|
|
|
- 'email' => Input::get('email'),
|
|
|
|
- 'password' => Input::get('password'),
|
|
|
|
- 'password_confirmation' => Input::get('pw-confirm'),
|
|
|
|
- 'fire' => Input::get('fire')
|
|
|
|
- );
|
|
|
|
-
|
|
|
|
- $val = Validator::make($vfields, $vrules);
|
|
|
|
-
|
|
|
|
- if($val->fails()) {
|
|
|
|
- return View::make('register')->with('errors', $val->messages());
|
|
|
|
- } else {
|
|
|
|
- $u = new User();
|
|
|
|
- $u->name = Input::get('user');
|
|
|
|
- $u->email = Input::get('email');
|
|
|
|
- $u->password = Hash::make(Input::get('password'));
|
|
|
|
- $u->save();
|
|
|
|
- return Redirect::to('/')->with('message', 'Registriert!');
|
|
|
|
- }
|
|
|
|
|
|
+ $vrules = array(
|
|
|
|
+ 'name' => 'required|unique:users',
|
|
|
|
+ 'email' => 'required|email',
|
|
|
|
+ 'password' => 'required|confirmed',
|
|
|
|
+ 'fire' => array('required', 'regex:/^Kreis$/i')
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ $vfields = array(
|
|
|
|
+ 'name' => Input::get('user'),
|
|
|
|
+ 'email' => Input::get('email'),
|
|
|
|
+ 'password' => Input::get('password'),
|
|
|
|
+ 'password_confirmation' => Input::get('pw-confirm'),
|
|
|
|
+ 'fire' => Input::get('fire')
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ $val = Validator::make($vfields, $vrules);
|
|
|
|
+
|
|
|
|
+ if($val->fails()) {
|
|
|
|
+ return View::make('register')->with('errors', $val->messages());
|
|
|
|
+ } else {
|
|
|
|
+ $u = new User();
|
|
|
|
+ $u->name = Input::get('user');
|
|
|
|
+ $u->email = Input::get('email');
|
|
|
|
+ $u->password = Hash::make(Input::get('password'));
|
|
|
|
+ $u->save();
|
|
|
|
+ return Redirect::to('/')->with('message', 'Registriert!');
|
|
|
|
+ }
|
|
});
|
|
});
|
|
|
|
|
|
Route::get('settings', array('before' => 'auth', function() {
|
|
Route::get('settings', array('before' => 'auth', function() {
|
|
- return View::make('settings');
|
|
|
|
|
|
+ return View::make('settings');
|
|
}));
|
|
}));
|
|
|
|
|
|
Route::post('settings/{mode}', array('before' => 'auth', function($mode) {
|
|
Route::post('settings/{mode}', array('before' => 'auth', function($mode) {
|
|
- Validator::extend('pass', function($attribute, $value, $parameters) {
|
|
|
|
- return Hash::check($value, Auth::user()->password);
|
|
|
|
- });
|
|
|
|
- if($mode == 'password') {
|
|
|
|
- var_dump(Hash::check(Input::get('oldpw'), Auth::user()->password));
|
|
|
|
- $vfields = array('oldpw' => Input::get('oldpw'), 'newpw' => Input::get('newpw'), 'newpw_confirmation' => Input::get('newpw2'));
|
|
|
|
- $vrules = array( 'oldpw' => 'required|pass', 'newpw' => 'required|confirmed' );
|
|
|
|
- $val = Validator::make($vfields, $vrules);
|
|
|
|
- if($val->passes()) {
|
|
|
|
- $u = Auth::user();
|
|
|
|
- $u->password = Hash::make(Input::get('newpw'));
|
|
|
|
- $u->save();
|
|
|
|
- return View::make('settings')->with('message', 'Passwort geändert.');
|
|
|
|
- } else {
|
|
|
|
- return View::make('settings')->with('errors', $val->messages());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if($mode == 'email') {
|
|
|
|
- $vfields = array('pw' => Input::get('pw'), 'email' => Input::get('email'), 'email_confirmation' => Input::get('email2'));
|
|
|
|
- $vrules = array('pw' => 'required|pass', 'email' => 'required|confirmed');
|
|
|
|
- $val = Validator::make($vfields, $vrules);
|
|
|
|
- if($val->passes()) {
|
|
|
|
- $u = Auth::user();
|
|
|
|
- $u->email = Input::get('email');
|
|
|
|
- $u->save();
|
|
|
|
- return View::make('settings')->with('message', 'Email geändert.');
|
|
|
|
- } else {
|
|
|
|
- return View::make('settings')->with('errors', $val->messages());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ Validator::extend('pass', function($attribute, $value, $parameters) {
|
|
|
|
+ return Hash::check($value, Auth::user()->password);
|
|
|
|
+ });
|
|
|
|
+ if($mode == 'password') {
|
|
|
|
+ var_dump(Hash::check(Input::get('oldpw'), Auth::user()->password));
|
|
|
|
+ $vfields = array('oldpw' => Input::get('oldpw'), 'newpw' => Input::get('newpw'), 'newpw_confirmation' => Input::get('newpw2'));
|
|
|
|
+ $vrules = array( 'oldpw' => 'required|pass', 'newpw' => 'required|confirmed' );
|
|
|
|
+ $val = Validator::make($vfields, $vrules);
|
|
|
|
+ if($val->passes()) {
|
|
|
|
+ $u = Auth::user();
|
|
|
|
+ $u->password = Hash::make(Input::get('newpw'));
|
|
|
|
+ $u->save();
|
|
|
|
+ return View::make('settings')->with('message', 'Passwort geändert.');
|
|
|
|
+ } else {
|
|
|
|
+ return View::make('settings')->with('errors', $val->messages());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if($mode == 'email') {
|
|
|
|
+ $vfields = array('pw' => Input::get('pw'), 'email' => Input::get('email'), 'email_confirmation' => Input::get('email2'));
|
|
|
|
+ $vrules = array('pw' => 'required|pass', 'email' => 'required|confirmed');
|
|
|
|
+ $val = Validator::make($vfields, $vrules);
|
|
|
|
+ if($val->passes()) {
|
|
|
|
+ $u = Auth::user();
|
|
|
|
+ $u->email = Input::get('email');
|
|
|
|
+ $u->save();
|
|
|
|
+ return View::make('settings')->with('message', 'Email geändert.');
|
|
|
|
+ } else {
|
|
|
|
+ return View::make('settings')->with('errors', $val->messages());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
if($mode == 'avatar-reset') {
|
|
if($mode == 'avatar-reset') {
|
|
/** @var User $u */
|
|
/** @var User $u */
|
|
@@ -365,81 +366,81 @@ Route::post('settings/{mode}', array('before' => 'auth', function($mode) {
|
|
}));
|
|
}));
|
|
|
|
|
|
Route::get('users', array('before' => 'auth', function() {
|
|
Route::get('users', array('before' => 'auth', function() {
|
|
- if(Auth::user()->admin) {
|
|
|
|
- $u = User::orderBy('name')->paginate();
|
|
|
|
|
|
+ if(Auth::user()->admin) {
|
|
|
|
+ $u = User::orderBy('name')->paginate();
|
|
|
|
|
|
- return View::make('users')->with('users', $u);
|
|
|
|
- } else {
|
|
|
|
- App::abort(401, 'Diese Seite ist nicht für Dich.');
|
|
|
|
- }
|
|
|
|
|
|
+ return View::make('users')->with('users', $u);
|
|
|
|
+ } else {
|
|
|
|
+ App::abort(401, 'Diese Seite ist nicht für Dich.');
|
|
|
|
+ }
|
|
}));
|
|
}));
|
|
|
|
|
|
Route::get('users/{operation}/{id}', array('before' => 'auth', function($operation, $id) {
|
|
Route::get('users/{operation}/{id}', array('before' => 'auth', function($operation, $id) {
|
|
- if(!Auth::user()->admin) App::abort(401, 'Diese Seite ist nicht für Dich.');
|
|
|
|
- $u = User::findOrFail($id);
|
|
|
|
- switch($operation) {
|
|
|
|
- case 'mkadm':
|
|
|
|
- $u->admin = true;
|
|
|
|
- $u->save();
|
|
|
|
- $msg = $u->name . " ist jetzt ein Admin.";
|
|
|
|
- break;
|
|
|
|
- case 'rmadm':
|
|
|
|
- $u->admin = false;
|
|
|
|
- $u->save();
|
|
|
|
- $msg = $u->name . " ist kein Admin mehr.";
|
|
|
|
- break;
|
|
|
|
- case 'rmusr':
|
|
|
|
- $msg = $u->name . " wurde gelöscht.";
|
|
|
|
- $u->delete();
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return Redirect::to('users')->with('message', $msg);
|
|
|
|
|
|
+ if(!Auth::user()->admin) App::abort(401, 'Diese Seite ist nicht für Dich.');
|
|
|
|
+ $u = User::findOrFail($id);
|
|
|
|
+ switch($operation) {
|
|
|
|
+ case 'mkadm':
|
|
|
|
+ $u->admin = true;
|
|
|
|
+ $u->save();
|
|
|
|
+ $msg = $u->name . " ist jetzt ein Admin.";
|
|
|
|
+ break;
|
|
|
|
+ case 'rmadm':
|
|
|
|
+ $u->admin = false;
|
|
|
|
+ $u->save();
|
|
|
|
+ $msg = $u->name . " ist kein Admin mehr.";
|
|
|
|
+ break;
|
|
|
|
+ case 'rmusr':
|
|
|
|
+ $msg = $u->name . " wurde gelöscht.";
|
|
|
|
+ $u->delete();
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return Redirect::to('users')->with('message', $msg);
|
|
}));
|
|
}));
|
|
|
|
|
|
|
|
|
|
Route::get('news', array('before' => 'auth', function() {
|
|
Route::get('news', array('before' => 'auth', function() {
|
|
- return View::make('news');
|
|
|
|
|
|
+ return View::make('news');
|
|
}));
|
|
}));
|
|
|
|
|
|
Route::post('news', array('before' => 'auth', function() {
|
|
Route::post('news', array('before' => 'auth', function() {
|
|
- $vrules = array(
|
|
|
|
- 'headline' => 'required',
|
|
|
|
- 'body' => 'required'
|
|
|
|
- );
|
|
|
|
-
|
|
|
|
- $vfields = array(
|
|
|
|
- 'headline' => Input::get('headline'),
|
|
|
|
- 'body' => Input::get('body')
|
|
|
|
- );
|
|
|
|
-
|
|
|
|
- $val = Validator::make($vfields, $vrules);
|
|
|
|
-
|
|
|
|
- if($val->fails()) {
|
|
|
|
- return View::make('news')->with('errors', $val->messages());
|
|
|
|
- } else {
|
|
|
|
- $n = new News();
|
|
|
|
- $n->author = Auth::user()->id;
|
|
|
|
- $n->headline = Input::get('headline');
|
|
|
|
- $n->body = Input::get('body');
|
|
|
|
- $n->save();
|
|
|
|
- return Redirect::to('/')->with('message', 'News erstellt!');
|
|
|
|
- }
|
|
|
|
|
|
+ $vrules = array(
|
|
|
|
+ 'headline' => 'required',
|
|
|
|
+ 'body' => 'required'
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ $vfields = array(
|
|
|
|
+ 'headline' => Input::get('headline'),
|
|
|
|
+ 'body' => Input::get('body')
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ $val = Validator::make($vfields, $vrules);
|
|
|
|
+
|
|
|
|
+ if($val->fails()) {
|
|
|
|
+ return View::make('news')->with('errors', $val->messages());
|
|
|
|
+ } else {
|
|
|
|
+ $n = new News();
|
|
|
|
+ $n->author = Auth::user()->id;
|
|
|
|
+ $n->headline = Input::get('headline');
|
|
|
|
+ $n->body = Input::get('body');
|
|
|
|
+ $n->save();
|
|
|
|
+ return Redirect::to('/')->with('message', 'News erstellt!');
|
|
|
|
+ }
|
|
}));
|
|
}));
|
|
|
|
|
|
Route::get('passwort-vergessen', function() {
|
|
Route::get('passwort-vergessen', function() {
|
|
- return View::make('pwform');
|
|
|
|
|
|
+ return View::make('pwform');
|
|
});
|
|
});
|
|
|
|
|
|
Route::post('passwort-vergessen', function() {
|
|
Route::post('passwort-vergessen', function() {
|
|
- $credentials = array('email' => Input::get('email'));
|
|
|
|
- return Password::remind($credentials, function($message, $user) {
|
|
|
|
- $message->subject('Passwort für Dumbo zurücksetzen.');
|
|
|
|
- });
|
|
|
|
|
|
+ $credentials = array('email' => Input::get('email'));
|
|
|
|
+ return Password::remind($credentials, function($message, $user) {
|
|
|
|
+ $message->subject('Passwort für Dumbo zurücksetzen.');
|
|
|
|
+ });
|
|
});
|
|
});
|
|
|
|
|
|
Route::get('passwort-reset/{token}', function($token) {
|
|
Route::get('passwort-reset/{token}', function($token) {
|
|
- return View::make('pwreset')->with('token', $token);
|
|
|
|
|
|
+ return View::make('pwreset')->with('token', $token);
|
|
});
|
|
});
|
|
|
|
|
|
Route::post('passwort-reset', function() {
|
|
Route::post('passwort-reset', function() {
|
|
@@ -456,4 +457,106 @@ Route::post('passwort-reset', function() {
|
|
|
|
|
|
return Redirect::to('/');
|
|
return Redirect::to('/');
|
|
});
|
|
});
|
|
|
|
+});
|
|
|
|
+
|
|
|
|
+Route::get('stats', function() {
|
|
|
|
+ $stats = [
|
|
|
|
+ array(
|
|
|
|
+ 'name' => 'Meiste Vorschläge',
|
|
|
|
+ 'entr' => array('Vorschlag', 'Vorschläge'),
|
|
|
|
+ 'vals' => Film::addSelect(DB::raw("film_films.*, COUNT(`id`) as count"))
|
|
|
|
+ ->groupBy('user')->orderBy('count', 'DESC')->take(3)->get(),
|
|
|
|
+ 'prop' => 'besitzer',
|
|
|
|
+ 'type' => 'User'
|
|
|
|
+ ),
|
|
|
|
+
|
|
|
|
+ array(
|
|
|
|
+ 'name' => 'Meiste angenommene Vorschläge',
|
|
|
|
+ 'entr' => array('Vorschlag', 'Vorschläge'),
|
|
|
|
+ 'vals' => Film::addSelect(DB::raw("film_films.*, COUNT(`id`) as count"))
|
|
|
|
+ ->whereNotNull('gesehen')->groupBy('user')->orderBy('count', 'DESC')->take(3)->get(),
|
|
|
|
+ 'prop' => 'besitzer',
|
|
|
|
+ 'type' => 'User'
|
|
|
|
+ ),
|
|
|
|
+
|
|
|
|
+ array(
|
|
|
|
+ 'name' => 'Meiste Kommentare',
|
|
|
|
+ 'entr' => array('Kommentar', 'Kommentare'),
|
|
|
|
+ 'vals' => Comment::addselect(DB::raw('film_comments.*, COUNT(`id`) as count'))
|
|
|
|
+ ->where('text', '!=', '')->groupBy('user')->orderBy('count', 'DESC')->take(3)->get(),
|
|
|
|
+ 'prop' => 'autor',
|
|
|
|
+ 'type' => 'User'
|
|
|
|
+ ),
|
|
|
|
+
|
|
|
|
+ array(
|
|
|
|
+ 'name' => 'Meiste Bewertungen',
|
|
|
|
+ 'entr' => array('Bewertung', 'Bewertungen'),
|
|
|
|
+ 'vals' => Comment::addselect(DB::raw('film_comments.*, COUNT(`id`) as count'))
|
|
|
|
+ ->where('bewertung', '!=', 0)->groupBy('user')->orderBy('count', 'DESC')->take(3)->get(),
|
|
|
|
+ 'prop' => 'autor',
|
|
|
|
+ 'type' => 'User'
|
|
|
|
+ ),
|
|
|
|
+
|
|
|
|
+ array(
|
|
|
|
+ 'name' => 'Bewertet am besten',
|
|
|
|
+ 'entr' => array('', ''),
|
|
|
|
+ 'vals' => Comment::addselect(DB::raw('film_comments.*, ROUND(AVG(`bewertung`),1) as count'))
|
|
|
|
+ ->where('bewertung', '!=', 0)->groupBy('user')->orderBy('count', 'DESC')->take(3)->get(),
|
|
|
|
+ 'prop' => 'autor',
|
|
|
|
+ 'type' => 'User'
|
|
|
|
+ ),
|
|
|
|
+ array(
|
|
|
|
+ 'name' => 'Bewertet am schlechtesten',
|
|
|
|
+ 'entr' => array('', ''),
|
|
|
|
+ 'vals' => Comment::addselect(DB::raw('film_comments.*, ROUND(AVG(`bewertung`),1) as count'))
|
|
|
|
+ ->where('bewertung', '!=', 0)->groupBy('user')->orderBy('count', 'ASC')->take(3)->get(),
|
|
|
|
+ 'prop' => 'autor',
|
|
|
|
+ 'type' => 'User'
|
|
|
|
+ ),
|
|
|
|
+ array(
|
|
|
|
+ 'name' => 'Meiste Filme wider Willen gesehen',
|
|
|
|
+ 'entr' => array('Film', 'Filme'),
|
|
|
|
+ 'vals' => Vote::addSelect(DB::raw('film_films.*, film_votes.*, COUNT(*) as count'))
|
|
|
|
+ ->leftJoin('films', 'films.id', '=', 'votes.film')->whereNotNull('gesehen')
|
|
|
|
+ ->whereRaw('stimme IS FALSE')->groupBy('votes.user')->orderBy('count', 'DESC')
|
|
|
|
+ ->take(3)->get(),
|
|
|
|
+ 'prop' => 'voter',
|
|
|
|
+ 'type' => 'User'
|
|
|
|
+ ),
|
|
|
|
+ array(
|
|
|
|
+ 'name' => 'Unbeliebtester Film',
|
|
|
|
+ 'entr' => array('Stimme', 'Stimmen'),
|
|
|
|
+ 'prop' => 'oFilm',
|
|
|
|
+ 'type' => 'Film',
|
|
|
|
+ 'vals' => Vote::addSelect(DB::raw('film_votes.*, film_films.*, COUNT(*) as count'))
|
|
|
|
+ ->leftJoin('films', 'films.id', '=', 'votes.film')
|
|
|
|
+ ->whereRaw('stimme IS FALSE')->groupBy('film')->orderBy('count', 'DESC')
|
|
|
|
+ ->take(3)->get()
|
|
|
|
+ ),
|
|
|
|
+ array(
|
|
|
|
+ 'name' => 'Schlechtbewertetster Film',
|
|
|
|
+ 'entr' => array('', ''),
|
|
|
|
+ 'prop' => 'objekt',
|
|
|
|
+ 'type' => 'Film',
|
|
|
|
+ 'vals' => Comment::addSelect(DB::raw('film_comments.*, film_films.*, ROUND(AVG(`bewertung`),1) as count'))
|
|
|
|
+ ->leftJoin('films', 'films.id', '=', 'comments.film')->whereNotNull('gesehen')
|
|
|
|
+ ->where('bewertung', '>', 0)->groupBy('film')->orderBy('count', 'ASC')
|
|
|
|
+ ->take(3)->get()
|
|
|
|
+ ),
|
|
|
|
+ array(
|
|
|
|
+ 'name' => 'Bestbewertetster Film',
|
|
|
|
+ 'entr' => array('', ''),
|
|
|
|
+ 'prop' => 'objekt',
|
|
|
|
+ 'type' => 'Film',
|
|
|
|
+ 'vals' => Comment::addSelect(DB::raw('film_comments.*, film_films.*, ROUND(AVG(`bewertung`),1) as count'))
|
|
|
|
+ ->leftJoin('films', 'films.id', '=', 'comments.film')->whereNotNull('gesehen')
|
|
|
|
+ ->where('bewertung', '>', 0)->groupBy('film')->orderBy('count', 'DESC')
|
|
|
|
+ ->take(3)->get()
|
|
|
|
+ ),
|
|
|
|
+ ];
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+// dd(DB::getQueryLog());
|
|
|
|
+
|
|
|
|
+ return View::make('stats')->with('stats', $stats);
|
|
});
|
|
});
|