diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 1142609..46a36d1 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -2,8 +2,13 @@
-
+
+
+
+
+
+
@@ -28,81 +33,34 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
+
+
-
-
+
+
-
-
-
+
+
+
+
+
-
+
-
-
+
+
@@ -110,11 +68,21 @@
-
-
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
@@ -143,33 +111,31 @@
-
-
-
-
-
+
+
+
+
+
+
true
-
-
-
@@ -210,10 +176,9 @@
-
-
-
+
+
@@ -255,8 +220,11 @@
+
+
+
@@ -363,7 +331,6 @@
-
@@ -482,55 +449,61 @@
1445434194207
-
+
+ 1445435646344
+
+
+ 1445435646344
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -552,20 +525,14 @@
-
+
+
-
-
-
-
-
-
-
@@ -646,13 +613,6 @@
-
-
-
-
-
-
-
@@ -667,13 +627,6 @@
-
-
-
-
-
-
-
@@ -688,13 +641,6 @@
-
-
-
-
-
-
-
@@ -812,13 +758,6 @@
-
-
-
-
-
-
-
@@ -835,43 +774,48 @@
-
+
-
+
+
+
+
+
+
+
+
-
+
-
-
+
+
-
-
+
+
-
+
-
-
-
-
-
+
+
+
-
+
@@ -880,77 +824,105 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/models/Film.php b/app/models/Film.php
index 422e6d9..364467e 100644
--- a/app/models/Film.php
+++ b/app/models/Film.php
@@ -28,12 +28,13 @@ class Film extends Eloquent {
return $query
->addSelect(DB::raw('film_films.*, COUNT(case when film_votes.stimme IS TRUE then 1 end) as upvotes'))
->leftJoin('votes', 'votes.film', '=', 'films.id')
+ ->leftJoin('users', 'users.id', '=', 'votes.user')
->whereNull('gesehen')
->where('films.id', "!=", is_object($nextfilm) ? $nextfilm->id : 0)
+ ->where('users.settings', 'NOT LIKE', '%disabled":true%')
->groupBy('films.id')
->orderBy('upvotes', 'DESC')
- ->orderBy('vorgeschlagen', 'ASC')
- ->take(5);
+ ->orderBy('vorgeschlagen', 'ASC');
}
public function getVotes() {
diff --git a/app/models/User.php b/app/models/User.php
index 79e3d8d..a83e17a 100644
--- a/app/models/User.php
+++ b/app/models/User.php
@@ -61,7 +61,7 @@ class User extends Eloquent implements UserInterface, RemindableInterface {
public function getSetting($key, $false = false) {
$settings = json_decode($this->settings);
- if(!is_null($settings))
+ if(!is_null($settings) && property_exists($settings, $key))
return $settings->$key;
else
return $false;
diff --git a/app/routes.php b/app/routes.php
index 1d4b16a..625fe82 100644
--- a/app/routes.php
+++ b/app/routes.php
@@ -16,7 +16,9 @@ Route::get('/', function()
{
$gesehen = Film::zuletztGesehen()->get();
$vorgeschlagen = Film::neuesteVorschlage()->get();
- $mg = Film::meistgewunschteVorschlage()->get();
+ $mg = Film::meistgewunschteVorschlage()->take(5)->get();
+ //$x = DB::getQueryLog();
+ //dd(end($x));
$news = News::aktuell()->get();
$nextfilm = Dumbo::find(1)->film;
@@ -160,15 +162,7 @@ Route::get('logout', array('as' => 'logout', 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,
- 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'))
- ->leftJoin('votes', 'votes.film', '=', 'films.id')
- ->whereNull('films.gesehen')
- ->groupBy('id')
- ->orderBy('vcount', 'DESC')->orderBy('vorgeschlagen', 'ASC')
- ->paginate(25);
+ $filme = Film::meistgewunschteVorschlage()->paginate(25);
return View::make('suggest')
->with('filme', $filme)
@@ -377,6 +371,7 @@ Route::get('users', array('before' => 'auth', function() {
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.');
+ /** @var User $u */
$u = User::findOrFail($id);
switch($operation) {
case 'mkadm':
@@ -393,6 +388,16 @@ Route::get('users/{operation}/{id}', array('before' => 'auth', function($operati
$msg = $u->name . " wurde gelöscht.";
$u->delete();
break;
+ case 'inact':
+ $msg = $u->name. " ist inaktiv.";
+ $u->setSetting("disabled", true);
+ $u->save();
+ break;
+ case 'act':
+ $msg = $u->name. " ist aktiv.";
+ $u->setSetting("disabled", false);
+ $u->save();
+ break;
}
return Redirect::to('users')->with('message', $msg);
@@ -500,16 +505,16 @@ Route::get('stats', function() {
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')->raw('ORDER BY COUNT(*) DESC')->take(3)->get(),
+ 'vals' => Comment::addselect(DB::raw('film_comments.*, ROUND(AVG(`bewertung`),1) as count, COUNT(*) as no'))
+ ->where('bewertung', '!=', 0)->groupBy('user')->orderBy('count', 'DESC')->orderBy('no', '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')->raw('ORDER BY COUNT(*) ASC')->take(3)->get(),
+ 'vals' => Comment::addselect(DB::raw('film_comments.*, ROUND(AVG(`bewertung`),1) as count, COUNT(*) as no'))
+ ->where('bewertung', '!=', 0)->groupBy('user')->orderBy('count', 'ASC')->orderBy('no', 'ASC')->take(3)->get(),
'prop' => 'autor',
'type' => 'User'
),
diff --git a/app/views/index.blade.php b/app/views/index.blade.php
index d93504c..eebcddf 100644
--- a/app/views/index.blade.php
+++ b/app/views/index.blade.php
@@ -3,17 +3,23 @@
@section('content')
+ @if(is_object($nextfilm))
Nächster Film

-
{{is_object($nextfilm) ? $nextfilm->name . " (" . $nextfilm->besitzer->name . ")" : "Steht nicht fest"}}
- @if(is_object($nextfilm)) {{ link_to_route('film', "Filmdetails", array($nextfilm->id), array('class' => 'btn btn-info btn-xs'))}}
- @endif
- @if(is_object($nextfilm) && !is_null(Auth::user()) && Auth::user()->admin)
id) }}' class='btn btn-success btn-xs'>Gesehen
+
+ {{ $nextfilm->name }}
+
+
{{$nextfilm->besitzer->name}}
+
+
+ {{ link_to_route('film', "Filmdetails", array($nextfilm->id), array('class' => 'btn btn-info btn-xs'))}}
+ @if(!is_null(Auth::user()) && Auth::user()->admin)
id) }}' class='btn btn-success btn-xs'>Gesehen
@endif
+ @endif
Meistgewünschter Film
@@ -102,11 +108,6 @@
-
-
Dumbo
-
Suchst du noch oder guckst du schon?
-
-
Letzte Kommentare
diff --git a/app/views/settings.blade.php b/app/views/settings.blade.php
index ea90a75..a1fd817 100644
--- a/app/views/settings.blade.php
+++ b/app/views/settings.blade.php
@@ -6,7 +6,7 @@
diff --git a/app/views/users.blade.php b/app/views/users.blade.php
index 9857a4c..48660b0 100644
--- a/app/views/users.blade.php
+++ b/app/views/users.blade.php
@@ -25,11 +25,16 @@
@if($user->admin)
@if($user->name != "Daniel")
-
Rechte entziehen
+
Rechte entziehen
@else
—
@endif
@else
+ @if(!$user->getSetting("disabled"))
+
id) }}">Deaktivieren
+ @else
+
id) }}">Aktivieren
+ @endif
Zum Admin machen
Löschen
@endif