Created
January 14, 2013 13:54
-
-
Save Sigmus/4530193 to your computer and use it in GitHub Desktop.
Permission
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Permission | |
{ | |
public static function action($action) | |
{ | |
return self::$action(); | |
} | |
private static function ask() | |
{ | |
list($count_limit_day,$count_did_today) = self::query('Question','questions'); | |
if($count_limit_day - $count_did_today > 0) { | |
return true; | |
} | |
else { | |
return false; | |
} | |
} | |
private static function answer() | |
{ | |
list($count_limit_day,$count_did_today) = self::query('Answer','answers'); | |
if($count_limit_day - $count_did_today > 0) { | |
return true; | |
} | |
else { | |
return false; | |
} | |
} | |
private static function vote() | |
{ | |
list($count_limit_day,$count_did_today) = self::query('Vote','votes'); | |
if($count_limit_day - $count_did_today > 0) { | |
return true; | |
} | |
else { | |
return false; | |
} | |
} | |
private static function choose_best_answer() | |
{ | |
//list($count_limit_day,$count_did_today) = self::query('Vote','votes'); | |
//$count_did_today = Answer::where('choosed', '=', '1')->where('created_at', '>', date('Y-m-d') . ' 00:00:00')->where('created_at', '<', date('Y-m-d') . ' 23:59:59')->question_id; | |
//$count_did_todayA = $count_did_today-> | |
$count_limit_day = Permissionslevel::where('level', '=', Session::get('ULVL'))->first()->best_answers; | |
if($count_limit_day - $count_did_today > 0) { | |
return true; | |
} | |
else { | |
return false; | |
} | |
} | |
private static function denounce() | |
{ | |
list($count_limit_day,$count_did_today) = self::query('Denounce','denounces'); | |
if($count_limit_day - $count_did_today > 0) { | |
return true; | |
} | |
else { | |
return false; | |
} | |
} | |
private static function query($model,$field) | |
{ | |
$count_did_today = $model::where('user_id', '=', Session::get('UID'))->where('created_at', '>', date('Y-m-d') . ' 00:00:00')->where('created_at', '<', date('Y-m-d') . ' 23:59:59')->count(); | |
$count_limit_day = Permissionslevel::where('level', '=', Session::get('ULVL'))->first()->$field; | |
return array($count_limit_day,$count_did_today); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment