|
@@ -31,6 +31,23 @@ Route::get('film/{id}', array('as' => 'film', function($id) {
|
|
|
|
|
|
$votes = $film->votes()->count();
|
|
|
$vposi = $film->votes()->where('stimme', true)->count();
|
|
|
+ $pv = "";
|
|
|
+ foreach($film->votes()->where('stimme', true)->get() as $v) {
|
|
|
+ $pv .= $v->voter->name . "<br> ";
|
|
|
+ }
|
|
|
+
|
|
|
+ $nv = "";
|
|
|
+ foreach($film->votes()->where('stimme', false)->get() as $v) {
|
|
|
+ $nv = $v->voter->name . "<br> ";
|
|
|
+ }
|
|
|
+
|
|
|
+ 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();
|
|
|
|
|
@@ -42,18 +59,54 @@ Route::get('film/{id}', array('as' => 'film', function($id) {
|
|
|
->with('cast', $tcast)
|
|
|
->with('trail', $ttrail)
|
|
|
->with('votes', $votes)
|
|
|
+ ->with('uvote', $uvote)
|
|
|
+ ->with('pv', $pv)
|
|
|
+ ->with('nv', $nv)
|
|
|
->with('vposi', $vposi)
|
|
|
->with('tmdb', $tmdb);
|
|
|
}));
|
|
|
|
|
|
+Route::get('vote/{stimme}/{user}/{film}', function($stimme, $user, $film) {
|
|
|
+ $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->stimmer = $stimme == "yes" ? true : false;
|
|
|
+ }
|
|
|
+
|
|
|
+ $v->save();
|
|
|
+
|
|
|
+ return Redirect::to('film/' . $film);
|
|
|
+});
|
|
|
+
|
|
|
+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->save();
|
|
|
+ return Redirect::to('film/' . Input::get('film'));
|
|
|
+}));
|
|
|
+
|
|
|
+Route::post('comment/edit', array('as'=> 'modcomment', function () {
|
|
|
+ $c = Comment::findOrFail(Input::get('id'));
|
|
|
+ $c->text = Input::get('text');
|
|
|
+ $c->save();
|
|
|
+ return Redirect::to('film/' . $c->film);
|
|
|
+}));
|
|
|
+
|
|
|
Route::get('login', array('as' => 'login', function() {
|
|
|
return View::make('login');
|
|
|
}));
|
|
|
|
|
|
Route::post('login', function() {
|
|
|
$userdata = array(
|
|
|
- 'name' => Input::get('iSpieler'),
|
|
|
- 'password' => Input::get('iPassword'));
|
|
|
+ 'name' => Input::get('user'),
|
|
|
+ 'password' => Input::get('password'));
|
|
|
if(Auth::attempt($userdata)) {
|
|
|
return Redirect::intended('/');
|
|
|
} else {
|
|
@@ -67,4 +120,157 @@ Route::post('login', function() {
|
|
|
Route::get('logout', array('as' => 'logout', function() {
|
|
|
Auth::logout();
|
|
|
return Redirect::to('/');
|
|
|
+}));
|
|
|
+
|
|
|
+Route::get('vorgeschlagen/{field?}/{order?}', function($field = "vorgeschlagen", $order = "desc") {
|
|
|
+ $filme = Film::whereNull('gesehen')->orderBy($field, $order)->paginate();
|
|
|
+
|
|
|
+ return View::make('suggest')
|
|
|
+ ->with('filme', $filme);
|
|
|
+
|
|
|
+})->where(array('field' => '[a-z]+', 'order' => 'asc|desc'));
|
|
|
+
|
|
|
+Route::get('gesehen/{field?}/{order?}', function($field = "gesehen", $order = "desc") {
|
|
|
+ $filme = Film::whereNotNull('gesehen')->orderBy($field, $order)->paginate();
|
|
|
+
|
|
|
+ return View::make('seen')
|
|
|
+ ->with('filme', $filme);
|
|
|
+
|
|
|
+})->where(array('field' => '[a-z]+', 'order' => 'asc|desc'));
|
|
|
+
|
|
|
+Route::get('neu', array('before' => 'auth', function() {
|
|
|
+
|
|
|
+ return View::make('new');
|
|
|
+
|
|
|
+}));
|
|
|
+
|
|
|
+Route::post('neu', array('before' => 'auth', function() {
|
|
|
+ $tmdb = new TMDb('b187f8d9c5e72b1faecb741d5d04239a', 'de', TRUE);
|
|
|
+ $r = $tmdb->searchMovie(Input::get('search'));
|
|
|
+
|
|
|
+ return View::make('new')->with('result', $r)->with('tmdb', $tmdb);
|
|
|
+}));
|
|
|
+
|
|
|
+Route::get('vorschlag/{id}', array('before' => 'auth', function($id) {
|
|
|
+ $tmdb = new TMDb('b187f8d9c5e72b1faecb741d5d04239a', 'de', TRUE);
|
|
|
+ $f = $tmdb->getMovie($id);
|
|
|
+ $film = new Film();
|
|
|
+ $film ->name = $f['title'];
|
|
|
+ $film->tvdbid = $id;
|
|
|
+ $film->vorgeschlagen = \Carbon\Carbon::today();
|
|
|
+ $film->user = Auth::user()->id;
|
|
|
+ $film->save();
|
|
|
+ return Redirect::to('film/' . $film->id);
|
|
|
+}));
|
|
|
+
|
|
|
+Route::get('mark-read/{id}', array('before' => 'auth', function($id) {
|
|
|
+ $film = Film::findOrFail($id);
|
|
|
+ $film->gesehen = \Carbon\Carbon::today();
|
|
|
+ $film->save();
|
|
|
+ return Redirect::to('film/' . $film->id);
|
|
|
+}));
|
|
|
+
|
|
|
+Route::get('register', function() {
|
|
|
+ return View::make('register');
|
|
|
+});
|
|
|
+
|
|
|
+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!');
|
|
|
+ }
|
|
|
+});
|
|
|
+
|
|
|
+Route::get('settings', array('before' => 'auth', function() {
|
|
|
+ return View::make('settings');
|
|
|
+}));
|
|
|
+
|
|
|
+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());
|
|
|
+ }
|
|
|
+ }
|
|
|
+}));
|
|
|
+
|
|
|
+Route::get('users', array('before' => 'auth', function() {
|
|
|
+ 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.');
|
|
|
+ }
|
|
|
+}));
|
|
|
+
|
|
|
+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);
|
|
|
}));
|