Passed
Branch feature/babel (9a8402)
by John
03:52
created
app/Http/Controllers/AccountController.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
         $accountModel=new AccountModel();
29 29
         $info=$accountModel->detail(Auth::user()->id);
30 30
         $feed=$accountModel->feed(Auth::user()->id);
31
-        $extraInfo = $accountModel->getExtraInfo(Auth::user()->id,100);
31
+        $extraInfo=$accountModel->getExtraInfo(Auth::user()->id, 100);
32 32
         return view("account.dashboard", [
33 33
             'page_title'=>"DashBoard",
34 34
             'site_title'=>"NOJ",
@@ -45,10 +45,10 @@  discard block
 block discarded – undo
45 45
     {
46 46
         $accountModel=new AccountModel();
47 47
         $info=$accountModel->detail(Auth::user()->id);
48
-        if(!empty(session('last_email_send'))){
49
-            $email_cooldown = 300 - (time() - session('last_email_send'));
48
+        if (!empty(session('last_email_send'))) {
49
+            $email_cooldown=300-(time()-session('last_email_send'));
50 50
         }
51
-        $extraInfo = $accountModel->getExtraInfo(Auth::user()->id,100);
51
+        $extraInfo=$accountModel->getExtraInfo(Auth::user()->id, 100);
52 52
         return view("account.dashboard", [
53 53
             'page_title'=>"Settings",
54 54
             'site_title'=>"NOJ",
Please login to merge, or discard this patch.
app/Http/Controllers/UserController.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@
 block discarded – undo
28 28
         $accountModel=new AccountModel();
29 29
         $info=$accountModel->detail($uid);
30 30
         $feed=$accountModel->feed($uid);
31
-        $extraInfo = $accountModel->getExtraInfo($uid,0);
31
+        $extraInfo=$accountModel->getExtraInfo($uid, 0);
32 32
         return view("account.dashboard", [
33 33
             'page_title'=>$info["name"],
34 34
             'site_title'=>"NOJ",
Please login to merge, or discard this patch.
app/Models/AccountModel.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -25,8 +25,8 @@  discard block
 block discarded – undo
25 25
     public function feed($uid=null)
26 26
     {
27 27
         $ret=[];
28
-        $solution=DB::table("problem_solution")->join("problem","problem.pid","=","problem_solution.pid")->where(["uid"=>$uid,"audit"=>1])->select("problem.pid as pid","pcode","title","problem_solution.created_at as created_at")->orderBy("problem_solution.created_at","DESC")->get()->all();
29
-        foreach($solution as &$s){
28
+        $solution=DB::table("problem_solution")->join("problem", "problem.pid", "=", "problem_solution.pid")->where(["uid"=>$uid, "audit"=>1])->select("problem.pid as pid", "pcode", "title", "problem_solution.created_at as created_at")->orderBy("problem_solution.created_at", "DESC")->get()->all();
29
+        foreach ($solution as &$s) {
30 30
             $s["type"]="event";
31 31
             $s["color"]="wemd-orange";
32 32
             $s["icon"]="comment-check-outline";
@@ -92,14 +92,14 @@  discard block
 block discarded – undo
92 92
         ])->join("problem", "problem.pid", "=", "submission.pid")->select('pcode')->distinct()->get()->all();
93 93
         $ret["solvedCount"]=count($ret["solved"]);
94 94
         // Casual
95
-        $ret["rank"]=Cache::tags(['rank',$ret["id"]])->get("rank", "N/A");
96
-        $ret["rankTitle"]=Cache::tags(['rank',$ret["id"]])->get("title");
95
+        $ret["rank"]=Cache::tags(['rank', $ret["id"]])->get("rank", "N/A");
96
+        $ret["rankTitle"]=Cache::tags(['rank', $ret["id"]])->get("title");
97 97
         $ret["rankTitleColor"]=RankModel::getColor($ret["rankTitle"]);
98 98
         // Professional
99 99
         $ret["professionalTitle"]=RankModel::getProfessionalTitle($ret["professional_rate"]);
100 100
         $ret["professionalTitleColor"]=RankModel::getProfessionalColor($ret["professionalTitle"]);
101 101
         // Administration Group
102
-        $ret["admin"]=$uid==1?1:0;
102
+        $ret["admin"]=$uid==1 ? 1 : 0;
103 103
         if (Cache::tags(['bing', 'pic'])->get(date("Y-m-d"))==null) {
104 104
             $bing=new BingPhoto([
105 105
                 'locale' => 'zh-CN',
@@ -111,9 +111,9 @@  discard block
 block discarded – undo
111 111
         return $ret;
112 112
     }
113 113
 
114
-    public function getExtraInfo($uid,$secret_level = 0){
115
-        $ret = DB::table('users_extra')->where('uid',$uid)->get()->all();
116
-        $key_meaning = [
114
+    public function getExtraInfo($uid, $secret_level=0) {
115
+        $ret=DB::table('users_extra')->where('uid', $uid)->get()->all();
116
+        $key_meaning=[
117 117
             0 => 'gender',
118 118
             1 => 'contact',
119 119
             2 => 'school',
@@ -121,20 +121,20 @@  discard block
 block discarded – undo
121 121
             4 => 'location',
122 122
             5 => 'editor_left_width',
123 123
         ];
124
-        $result = [];
125
-        if(!empty($ret)){
124
+        $result=[];
125
+        if (!empty($ret)) {
126 126
             foreach ($ret as $value) {
127
-                if(empty($value['secret_level']) || $value['secret_level'] <= $secret_level){
128
-                    $key_name = $key_meaning[$value['key']] ?? 'unknown';
129
-                    $result[$key_name] = $value['value'];
127
+                if (empty($value['secret_level']) || $value['secret_level']<=$secret_level) {
128
+                    $key_name=$key_meaning[$value['key']] ?? 'unknown';
129
+                    $result[$key_name]=$value['value'];
130 130
                 }
131 131
             }
132 132
         }
133 133
         return $result;
134 134
     }
135 135
 
136
-    public function setExtraInfo($uid,$key_name,$value = null,$secret_level = -1){
137
-        $key_value = [
136
+    public function setExtraInfo($uid, $key_name, $value=null, $secret_level=-1) {
137
+        $key_value=[
138 138
             'gender'                    => 0,
139 139
             'contact'                   => 1,
140 140
             'school'                    => 2,
@@ -143,31 +143,31 @@  discard block
 block discarded – undo
143 143
             'editor_left_width'         => 5,
144 144
             //TODO...
145 145
         ];
146
-        $key = $key_value[$key_name];
147
-        $ret = DB::table('users_extra')->where('uid',$uid)->where('key',$key)->first();
148
-        if(!empty($ret)){
146
+        $key=$key_value[$key_name];
147
+        $ret=DB::table('users_extra')->where('uid', $uid)->where('key', $key)->first();
148
+        if (!empty($ret)) {
149 149
             unset($ret['id']);
150
-            if(!is_null($value)){
151
-                $ret['value'] = $value;
150
+            if (!is_null($value)) {
151
+                $ret['value']=$value;
152 152
             }
153
-            if($secret_level != -1){
154
-                $ret['secret_level'] = $secret_level;
153
+            if ($secret_level!=-1) {
154
+                $ret['secret_level']=$secret_level;
155 155
             }
156
-            DB::table('users_extra')->where('uid',$uid)->where('key',$key)->update($ret);
157
-        }else{
156
+            DB::table('users_extra')->where('uid', $uid)->where('key', $key)->update($ret);
157
+        } else {
158 158
             return DB::table('users_extra')->insertGetId(
159 159
                 [
160 160
                     'uid' => $uid,
161 161
                     'key' => $key,
162 162
                     'value' => $value,
163
-                    'secret_level' => $secret_level == -1 ? 0 : $secret_level,
163
+                    'secret_level' => $secret_level==-1 ? 0 : $secret_level,
164 164
                 ]
165 165
             );
166 166
         }
167 167
     }
168 168
 
169
-    public function unsetExtraInfoIfExist($uid,$key_name){
170
-        $key_value = [
169
+    public function unsetExtraInfoIfExist($uid, $key_name) {
170
+        $key_value=[
171 171
             'gender'                    => 0,
172 172
             'contact'                   => 1,
173 173
             'school'                    => 2,
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
             'editor_left_width'         => 5,
177 177
             //TODO...
178 178
         ];
179
-        $key = $key_value[$key_name];
180
-        $ret = DB::table('users_extra')->where('uid',$uid)->where('key',$key)->delete();
179
+        $key=$key_value[$key_name];
180
+        $ret=DB::table('users_extra')->where('uid', $uid)->where('key', $key)->delete();
181 181
     }
182 182
 }
Please login to merge, or discard this patch.
app/Http/Controllers/Ajax/AccountController.php 1 patch
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 class AccountController extends Controller
17 17
 {
18 18
 
19
-    public function updateAvatar(Request $request){
19
+    public function updateAvatar(Request $request) {
20 20
         $isValid=$request->file('avatar')->isValid();
21 21
         if ($isValid) {
22 22
             $extension=$request->file('avatar')->extension();
@@ -43,13 +43,13 @@  discard block
 block discarded – undo
43 43
         }
44 44
     }
45 45
 
46
-    public function changeBasicInfo(Request $request){
46
+    public function changeBasicInfo(Request $request) {
47 47
         // if(!$request->has('username')){
48 48
         //     return ResponseModel::err(1003);
49 49
         // }
50 50
         // $username = $request->input('username');
51
-        $describes = $request->input('describes');
52
-        if(strlen($describes) > 255){
51
+        $describes=$request->input('describes');
52
+        if (strlen($describes)>255) {
53 53
             return ResponseModel::err(1006);
54 54
         }
55 55
         // $old_username=Auth::user()->name;
@@ -58,79 +58,79 @@  discard block
 block discarded – undo
58 58
         // }
59 59
         $user=Auth::user();
60 60
         // $user->name = $username;
61
-        $user->describes = $describes;
61
+        $user->describes=$describes;
62 62
         $user->save();
63 63
         return ResponseModel::success();
64 64
     }
65 65
 
66
-    public function changePassword(Request $request){
67
-        if(!$request->has('old_password') || !$request->has('new_password') || !$request->has('confirm_password')){
66
+    public function changePassword(Request $request) {
67
+        if (!$request->has('old_password') || !$request->has('new_password') || !$request->has('confirm_password')) {
68 68
             return ResponseModel::err(1003);
69 69
         }
70
-        $old_password = $request->input('old_password');
71
-        $new_password = $request->input('new_password');
72
-        $confirm_password = $request->input('confirm_password');
73
-        if($new_password != $confirm_password){
70
+        $old_password=$request->input('old_password');
71
+        $new_password=$request->input('new_password');
72
+        $confirm_password=$request->input('confirm_password');
73
+        if ($new_password!=$confirm_password) {
74 74
             return ResponseModel::err(2004);
75 75
         }
76
-        if(strlen($new_password) < 8 || strlen($old_password) < 8){
76
+        if (strlen($new_password)<8 || strlen($old_password)<8) {
77 77
             return ResponseModel::err(1006);
78 78
         }
79
-        $user = Auth::user();
80
-        if(!Hash::check($old_password, $user->password)){
79
+        $user=Auth::user();
80
+        if (!Hash::check($old_password, $user->password)) {
81 81
             return ResponseModel::err(2005);
82 82
         }
83
-        $user->password = Hash::make($new_password);
83
+        $user->password=Hash::make($new_password);
84 84
         $user->save();
85 85
         return ResponseModel::success();
86 86
     }
87 87
 
88
-    public function checkEmailCooldown(Request $request){
89
-        $last_send = $request->session()->get('last_email_send');
90
-        if(empty($last_send) || time() - $last_send >= 300){
91
-            $request->session()->put('last_email_send',time());
92
-            return ResponseModel::success(200,null,0);
93
-        }else{
94
-            $cooldown =  300 - (time() - $last_send);
95
-            return ResponseModel::success(200,null,$cooldown);
88
+    public function checkEmailCooldown(Request $request) {
89
+        $last_send=$request->session()->get('last_email_send');
90
+        if (empty($last_send) || time()-$last_send>=300) {
91
+            $request->session()->put('last_email_send', time());
92
+            return ResponseModel::success(200, null, 0);
93
+        } else {
94
+            $cooldown=300-(time()-$last_send);
95
+            return ResponseModel::success(200, null, $cooldown);
96 96
         }
97 97
     }
98 98
 
99
-    public function changeExtraInfo(Request $request){
100
-        $input = $request->input();
101
-        $allow_change = ['gender','contact','school','country','location'];
102
-        foreach($input as $key => $value){
103
-            if(!in_array($key,$allow_change)){
99
+    public function changeExtraInfo(Request $request) {
100
+        $input=$request->input();
101
+        $allow_change=['gender', 'contact', 'school', 'country', 'location'];
102
+        foreach ($input as $key => $value) {
103
+            if (!in_array($key, $allow_change)) {
104 104
                 return ResponseModel::error(1007);
105 105
             }
106 106
         }
107
-        $account_model = new AccountModel();
108
-        $user_id = Auth::user()->id;
107
+        $account_model=new AccountModel();
108
+        $user_id=Auth::user()->id;
109 109
         foreach ($input as $key => $value) {
110
-            if(strlen($value) != 0){
111
-                $account_model->setExtraInfo($user_id,$key,$value,0);
112
-            }else{
113
-                $account_model->unsetExtraInfoIfExist($user_id,$key);
110
+            if (strlen($value)!=0) {
111
+                $account_model->setExtraInfo($user_id, $key, $value, 0);
112
+            } else {
113
+                $account_model->unsetExtraInfoIfExist($user_id, $key);
114 114
             }
115 115
         }
116 116
         return ResponseModel::success();
117 117
     }
118 118
 
119
-    public function saveEditorWidth(Request $request){
120
-        $input = $request->input();
121
-        $allow_change = ['editor_left_width'];
122
-        foreach($input as $key => $value){
123
-            if(!in_array($key,$allow_change)){
119
+    public function saveEditorWidth(Request $request) {
120
+        $input=$request->input();
121
+        $allow_change=['editor_left_width'];
122
+        foreach ($input as $key => $value) {
123
+            if (!in_array($key, $allow_change)) {
124 124
                 return ResponseModel::error(1007);
125 125
             }
126 126
         }
127
-        $account_model = new AccountModel();
128
-        $user_id = Auth::user()->id;
127
+        $account_model=new AccountModel();
128
+        $user_id=Auth::user()->id;
129 129
         foreach ($input as $key => $value) {
130
-            if(strlen($value) != 0){
131
-                $account_model->setExtraInfo($user_id,$key,$value,0);
132
-            }else{
133
-                $account_model->unsetExtraInfoIfExist($user_id,$key);
130
+            if (strlen($value)!=0) {
131
+                $account_model->setExtraInfo($user_id, $key, $value, 0);
132
+            } else {
133
+                $account_model->unsetExtraInfoIfExist($user_id, $key);
134 134
             }
135 135
         }
136 136
         return ResponseModel::success();
Please login to merge, or discard this patch.
app/Http/Controllers/ProblemController.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -131,7 +131,7 @@
 block discarded – undo
131 131
             ];
132 132
         }
133 133
 
134
-        $editor_left_width = $account->getExtraInfo(Auth::user()->id)['editor_left_width'] ?? '40';
134
+        $editor_left_width=$account->getExtraInfo(Auth::user()->id)['editor_left_width'] ?? '40';
135 135
 
136 136
         return is_null($prob_detail) ?  redirect("/problem") : view('problem.editor', [
137 137
                                             'page_title'=>$prob_detail["title"],
Please login to merge, or discard this patch.
app/Http/Controllers/ContestController.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
     public function index()
23 23
     {
24 24
         $contestModel=new ContestModel();
25
-        $return_list=$contestModel->list(Auth::check()?Auth::user()->id:0);
25
+        $return_list=$contestModel->list(Auth::check() ?Auth::user()->id : 0);
26 26
         $featured=$contestModel->featured();
27 27
         return view('contest.index', [
28 28
             'page_title'=>"Contest",
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
             ];
158 158
         }
159 159
 
160
-        $editor_left_width = $accountModel->getExtraInfo(Auth::user()->id)['editor_left_width'] ?? '40';
160
+        $editor_left_width=$accountModel->getExtraInfo(Auth::user()->id)['editor_left_width'] ?? '40';
161 161
 
162 162
         return view('contest.board.editor', [
163 163
             'page_title'=>"Problem Detail",
Please login to merge, or discard this patch.
app/Http/Controllers/MainController.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -56,11 +56,11 @@
 block discarded – undo
56 56
     public function oldRedirect(Request $request)
57 57
     {
58 58
         $all_data=$request->all();
59
-        $method=isset($all_data["method"])?$all_data["method"]:null;
60
-        $id=isset($all_data["id"])?$all_data["id"]:null;
61
-        if($method=="showdetail" && !is_null($id)){
59
+        $method=isset($all_data["method"]) ? $all_data["method"] : null;
60
+        $id=isset($all_data["id"]) ? $all_data["id"] : null;
61
+        if ($method=="showdetail" && !is_null($id)) {
62 62
             $problemModel=new ProblemModel();
63
-            return ($problemModel->existPCode("NOJ$id"))?Redirect::route('problem_detail', ['pcode' => "NOJ$id"]):Redirect::route('problem_index');
63
+            return ($problemModel->existPCode("NOJ$id")) ?Redirect::route('problem_detail', ['pcode' => "NOJ$id"]) : Redirect::route('problem_index');
64 64
         }
65 65
         return Redirect::route('home');
66 66
     }
Please login to merge, or discard this patch.
app/Console/Commands/upgrade.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -11,14 +11,14 @@  discard block
 block discarded – undo
11 11
      *
12 12
      * @var string
13 13
      */
14
-    protected $signature = 'upgrade';
14
+    protected $signature='upgrade';
15 15
 
16 16
     /**
17 17
      * The console command description.
18 18
      *
19 19
      * @var string
20 20
      */
21
-    protected $description = 'Upgrade to the Latest of NOJ';
21
+    protected $description='Upgrade to the Latest of NOJ';
22 22
 
23 23
     /**
24 24
      * Create a new command instance.
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
      */
38 38
     public function handle()
39 39
     {
40
-        $bar = $this->output->createProgressBar(8);
40
+        $bar=$this->output->createProgressBar(8);
41 41
         $bar->setFormat("%current%/%max% [%bar%] %percent:3s%%\n<info>%message%</info>");
42 42
 
43 43
         $bar->setMessage("Enable Maintenance Mode.");
Please login to merge, or discard this patch.
app/Models/GroupModel.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -78,13 +78,13 @@  discard block
 block discarded – undo
78 78
 
79 79
     public function changeGroupName($gid, $GroupName)
80 80
     {
81
-        return DB::table("group")->where('gid',$gid)->update([
81
+        return DB::table("group")->where('gid', $gid)->update([
82 82
             "name"=>$GroupName
83 83
         ]);
84 84
     }
85 85
 
86
-    public function changeJoinPolicy($gid, $JoinPolicy){
87
-        return DB::table("group")->where('gid',$gid)->update([
86
+    public function changeJoinPolicy($gid, $JoinPolicy) {
87
+        return DB::table("group")->where('gid', $gid)->update([
88 88
             "join_policy"=>$JoinPolicy
89 89
         ]);
90 90
     }
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
     public function details($gcode)
93 93
     {
94 94
         $basic_info=DB::table($this->tableName)->where(["gcode"=>$gcode])->first();
95
-        if(empty($basic_info)) return [];
95
+        if (empty($basic_info)) return [];
96 96
         $basic_info["members"]=$this->countGroupMembers($basic_info["gid"]);
97 97
         $basic_info["tags"]=$this->getGroupTags($basic_info["gid"]);
98 98
         $basic_info["create_time_foramt"]=date_format(date_create($basic_info["create_time"]), 'M jS, Y');
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
         foreach ($user_list as &$u) {
134 134
             $u["role_parsed"]=$this->role[$u["role"]];
135 135
             $u["role_color"]=$this->role_color[$u["role"]];
136
-            if(is_null($u["sub_group"])) $u["sub_group"]="None";
136
+            if (is_null($u["sub_group"])) $u["sub_group"]="None";
137 137
         }
138 138
         return $user_list;
139 139
     }
Please login to merge, or discard this patch.