Passed
Pull Request — master (#257)
by
unknown
05:15
created
app/Http/Controllers/Contest/IndexController.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
         $filter["rated"]=isset($all_data["rated"]) ? $all_data["rated"] : null;
28 28
         $filter["anticheated"]=isset($all_data["anticheated"]) ? $all_data["anticheated"] : null;
29 29
         $filter["practice"]=isset($all_data["practice"]) ? $all_data["practice"] : null;
30
-        $return_list=$contestModel->list($filter,Auth::check()?Auth::user()->id:0);
30
+        $return_list=$contestModel->list($filter, Auth::check() ?Auth::user()->id : 0);
31 31
         $featured=$contestModel->featured();
32 32
         if (is_null($return_list)) {
33 33
             if (isset($all_data["page"]) && $all_data["page"]>1) {
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
         $contestModel=new ContestModel();
67 67
         $groupModel=new GroupModel();
68 68
         $clearance=Auth::check() ? $contestModel->judgeClearance($cid, Auth::user()->id) : 0;
69
-        $basic = $contestModel->basic($cid);
69
+        $basic=$contestModel->basic($cid);
70 70
         if (Auth::check()) {
71 71
             $contest_detail=$contestModel->detail($cid, Auth::user()->id);
72 72
             $registration=$contestModel->registration($cid, Auth::user()->id);
Please login to merge, or discard this patch.
app/Http/Controllers/Contest/BoardController.php 1 patch
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -34,10 +34,10 @@  discard block
 block discarded – undo
34 34
         $contestModel=new ContestModel();
35 35
         $clearance=$contestModel->judgeClearance($cid, Auth::user()->id);
36 36
         $basicInfo=$contestModel->basic($cid);
37
-        if (!$clearance || time() < strtotime($basicInfo['begin_time'])) {
38
-            if($clearance == 3){
37
+        if (!$clearance || time()<strtotime($basicInfo['begin_time'])) {
38
+            if ($clearance==3) {
39 39
                 return Redirect::route('contest.admin', ['cid' => $cid]);
40
-            }else{
40
+            } else {
41 41
                 return Redirect::route('contest.detail', ['cid' => $cid]);
42 42
             }
43 43
         }
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
         if ($remainingTime<=0) {
51 51
             $remainingTime=0;
52 52
         }
53
-        if($basicInfo['public'] && !$basicInfo['audit_status']){
53
+        if ($basicInfo['public'] && !$basicInfo['audit_status']) {
54 54
             return Redirect::route('contest.detail', ['cid' => $cid]);
55 55
         }
56 56
         return view('contest.board.challenge', [
@@ -83,15 +83,15 @@  discard block
 block discarded – undo
83 83
         $accountModel=new AccountModel();
84 84
         $clearance=$contestModel->judgeClearance($cid, Auth::user()->id);
85 85
         $basicInfo=$contestModel->basic($cid);
86
-        if (!$clearance || time() < strtotime($basicInfo['begin_time'])) {
87
-            if($clearance == 3){
86
+        if (!$clearance || time()<strtotime($basicInfo['begin_time'])) {
87
+            if ($clearance==3) {
88 88
                 return Redirect::route('contest.admin', ['cid' => $cid]);
89
-            }else{
89
+            } else {
90 90
                 return Redirect::route('contest.detail', ['cid' => $cid]);
91 91
             }
92 92
         }
93 93
         $basicInfo=$contestModel->basic($cid);
94
-        if($basicInfo['public'] && !$basicInfo['audit_status']){
94
+        if ($basicInfo['public'] && !$basicInfo['audit_status']) {
95 95
             return Redirect::route('contest.detail', ['cid' => $cid]);
96 96
         }
97 97
         $contest_name=$contestModel->contestName($cid);
@@ -122,8 +122,8 @@  discard block
 block discarded – undo
122 122
             ];
123 123
         }
124 124
 
125
-        $editor_left_width = $accountModel->getExtra(Auth::user()->id, 'editor_left_width');
126
-        if(empty($editor_left_width)) $editor_left_width='40';
125
+        $editor_left_width=$accountModel->getExtra(Auth::user()->id, 'editor_left_width');
126
+        if (empty($editor_left_width)) $editor_left_width='40';
127 127
 
128 128
         return view('contest.board.editor', [
129 129
             'page_title'=>"Problem Detail",
@@ -157,15 +157,15 @@  discard block
 block discarded – undo
157 157
         $contestModel=new ContestModel();
158 158
         $clearance=$contestModel->judgeClearance($cid, Auth::user()->id);
159 159
         $basicInfo=$contestModel->basic($cid);
160
-        if (!$clearance || time() < strtotime($basicInfo['begin_time'])) {
161
-            if($clearance == 3){
160
+        if (!$clearance || time()<strtotime($basicInfo['begin_time'])) {
161
+            if ($clearance==3) {
162 162
                 return Redirect::route('contest.admin', ['cid' => $cid]);
163
-            }else{
163
+            } else {
164 164
                 return Redirect::route('contest.detail', ['cid' => $cid]);
165 165
             }
166 166
         }
167 167
         $basicInfo=$contestModel->basic($cid);
168
-        if($basicInfo['public'] && !$basicInfo['audit_status']){
168
+        if ($basicInfo['public'] && !$basicInfo['audit_status']) {
169 169
             return Redirect::route('contest.detail', ['cid' => $cid]);
170 170
         }
171 171
         $contest_name=$contestModel->contestName($cid);
@@ -176,14 +176,14 @@  discard block
 block discarded – undo
176 176
 
177 177
         // To determine the ranking
178 178
         foreach ($contestRank as $i => &$r) {
179
-            if($i != 0) {
180
-                if($r['score'] == $contestRank[$i-1]['score'] && $r['penalty'] == $contestRank[$i-1]['penalty']){
181
-                    $r['rank'] = $contestRank[$i-1]['rank'];
182
-                }else{
183
-                    $r['rank'] = $i + 1;
179
+            if ($i!=0) {
180
+                if ($r['score']==$contestRank[$i-1]['score'] && $r['penalty']==$contestRank[$i-1]['penalty']) {
181
+                    $r['rank']=$contestRank[$i-1]['rank'];
182
+                } else {
183
+                    $r['rank']=$i+1;
184 184
                 }
185
-            }else{
186
-                $r['rank'] = 1;
185
+            } else {
186
+                $r['rank']=1;
187 187
             }
188 188
         }
189 189
         $rankFrozen=$contestModel->isFrozen($cid);
@@ -220,15 +220,15 @@  discard block
 block discarded – undo
220 220
         $contestModel=new ContestModel();
221 221
         $clearance=$contestModel->judgeClearance($cid, Auth::user()->id);
222 222
         $basicInfo=$contestModel->basic($cid);
223
-        if (!$clearance || time() < strtotime($basicInfo['begin_time'])) {
224
-            if($clearance == 3){
223
+        if (!$clearance || time()<strtotime($basicInfo['begin_time'])) {
224
+            if ($clearance==3) {
225 225
                 return Redirect::route('contest.admin', ['cid' => $cid]);
226
-            }else{
226
+            } else {
227 227
                 return Redirect::route('contest.detail', ['cid' => $cid]);
228 228
             }
229 229
         }
230 230
         $basicInfo=$contestModel->basic($cid);
231
-        if($basicInfo['public'] && !$basicInfo['audit_status']){
231
+        if ($basicInfo['public'] && !$basicInfo['audit_status']) {
232 232
             return Redirect::route('contest.detail', ['cid' => $cid]);
233 233
         }
234 234
         $contest_name=$contestModel->contestName($cid);
@@ -262,14 +262,14 @@  discard block
 block discarded – undo
262 262
         $contestModel=new ContestModel();
263 263
         $clearance=$contestModel->judgeClearance($cid, Auth::user()->id);
264 264
         $basicInfo=$contestModel->basic($cid);
265
-        if (!$clearance || time() < strtotime($basicInfo['begin_time'])) {
266
-            if($clearance == 3){
265
+        if (!$clearance || time()<strtotime($basicInfo['begin_time'])) {
266
+            if ($clearance==3) {
267 267
                 return Redirect::route('contest.admin', ['cid' => $cid]);
268
-            }else{
268
+            } else {
269 269
                 return Redirect::route('contest.detail', ['cid' => $cid]);
270 270
             }
271 271
         }
272
-        if($basicInfo['public'] && !$basicInfo['audit_status']){
272
+        if ($basicInfo['public'] && !$basicInfo['audit_status']) {
273 273
             return Redirect::route('contest.detail', ['cid' => $cid]);
274 274
         }
275 275
         $contest_name=$contestModel->contestName($cid);
@@ -300,14 +300,14 @@  discard block
 block discarded – undo
300 300
         $contestModel=new ContestModel();
301 301
         $clearance=$contestModel->judgeClearance($cid, Auth::user()->id);
302 302
         $basicInfo=$contestModel->basic($cid);
303
-        if (!$clearance || time() < strtotime($basicInfo['begin_time'])) {
304
-            if($clearance == 3){
303
+        if (!$clearance || time()<strtotime($basicInfo['begin_time'])) {
304
+            if ($clearance==3) {
305 305
                 return Redirect::route('contest.admin', ['cid' => $cid]);
306
-            }else{
306
+            } else {
307 307
                 return Redirect::route('contest.detail', ['cid' => $cid]);
308 308
             }
309 309
         }
310
-        if($basicInfo['public'] && !$basicInfo['audit_status']){
310
+        if ($basicInfo['public'] && !$basicInfo['audit_status']) {
311 311
             return Redirect::route('contest.detail', ['cid' => $cid]);
312 312
         }
313 313
         $contest_name=$contestModel->contestName($cid);
@@ -324,19 +324,19 @@  discard block
 block discarded – undo
324 324
         ]);
325 325
     }
326 326
 
327
-    public function analysis($cid){
327
+    public function analysis($cid) {
328 328
         $contestModel=new ContestModel();
329 329
         $clearance=$contestModel->judgeClearance($cid, Auth::user()->id);
330 330
         $basicInfo=$contestModel->basic($cid);
331
-        if (!$clearance || time() < strtotime($basicInfo['begin_time'])) {
332
-            if($clearance == 3){
331
+        if (!$clearance || time()<strtotime($basicInfo['begin_time'])) {
332
+            if ($clearance==3) {
333 333
                 return Redirect::route('contest.admin', ['cid' => $cid]);
334
-            }else{
334
+            } else {
335 335
                 return Redirect::route('contest.detail', ['cid' => $cid]);
336 336
             }
337 337
         }
338 338
         $basicInfo=$contestModel->basic($cid);
339
-        if($basicInfo['public'] && !$basicInfo['audit_status']){
339
+        if ($basicInfo['public'] && !$basicInfo['audit_status']) {
340 340
             return Redirect::route('contest.detail', ['cid' => $cid]);
341 341
         }
342 342
         $contest_name=$contestModel->contestName($cid);
Please login to merge, or discard this patch.
app/Models/AccountModel.php 1 patch
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 
12 12
 class AccountModel extends Model
13 13
 {
14
-    private $user_extra = [
14
+    private $user_extra=[
15 15
         0     => 'gender',
16 16
         1     => 'contact',
17 17
         2     => 'school',
@@ -26,11 +26,11 @@  discard block
 block discarded – undo
26 26
         1004  => 'github_token',
27 27
     ];
28 28
 
29
-    private $socialite_support = [
29
+    private $socialite_support=[
30 30
         //use the form "platform_id" for unique authentication
31 31
         //such as github_id
32 32
         'github' => [
33
-            'email','nickname','homepage','token'
33
+            'email', 'nickname', 'homepage', 'token'
34 34
         ],
35 35
     ];
36 36
 
@@ -48,8 +48,8 @@  discard block
 block discarded – undo
48 48
     public function feed($uid=null)
49 49
     {
50 50
         $ret=[];
51
-        $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();
52
-        foreach($solution as &$s){
51
+        $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();
52
+        foreach ($solution as &$s) {
53 53
             $s["type"]="event";
54 54
             $s["color"]="wemd-orange";
55 55
             $s["icon"]="comment-check-outline";
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
     public function generateContestAccount($cid, $ccode, $num)
62 62
     {
63 63
         $ret=[];
64
-        $starting=DB::table("users")->where('prefix','=',$ccode)->count();
64
+        $starting=DB::table("users")->where('prefix', '=', $ccode)->count();
65 65
         $contestModel=new ContestModel();
66 66
         for ($i=1; $i<=$num; $i++) {
67 67
             $pass=$this->generatePassword();
@@ -120,14 +120,14 @@  discard block
 block discarded – undo
120 120
         ])->join("problem", "problem.pid", "=", "submission.pid")->select('pcode')->distinct()->get()->all();
121 121
         $ret["solvedCount"]=count($ret["solved"]);
122 122
         // Casual
123
-        $ret["rank"]=Cache::tags(['rank',$ret["id"]])->get("rank", "N/A");
124
-        $ret["rankTitle"]=Cache::tags(['rank',$ret["id"]])->get("title");
123
+        $ret["rank"]=Cache::tags(['rank', $ret["id"]])->get("rank", "N/A");
124
+        $ret["rankTitle"]=Cache::tags(['rank', $ret["id"]])->get("title");
125 125
         $ret["rankTitleColor"]=RankModel::getColor($ret["rankTitle"]);
126 126
         // Professional
127 127
         $ret["professionalTitle"]=RankModel::getProfessionalTitle($ret["professional_rate"]);
128 128
         $ret["professionalTitleColor"]=RankModel::getProfessionalColor($ret["professionalTitle"]);
129 129
         // Administration Group
130
-        $ret["admin"]=$uid==1?1:0;
130
+        $ret["admin"]=$uid==1 ? 1 : 0;
131 131
         if (Cache::tags(['bing', 'pic'])->get(date("Y-m-d"))==null) {
132 132
             $bing=new BingPhoto([
133 133
                 'locale' => 'zh-CN',
@@ -146,26 +146,26 @@  discard block
 block discarded – undo
146 146
      * @param string|array $need An array is returned when an array is passed in,Only one value is returned when a string is passed in.
147 147
      * @return string|array $result
148 148
      */
149
-    public function getExtra($uid,$need, $secret_level = 0){
150
-        $ret = DB::table('users_extra')->where('uid',$uid)->orderBy('key')->get()->all();
151
-        $result = [];
152
-        if(!empty($ret)){
153
-            if(is_string($need)){
149
+    public function getExtra($uid, $need, $secret_level=0) {
150
+        $ret=DB::table('users_extra')->where('uid', $uid)->orderBy('key')->get()->all();
151
+        $result=[];
152
+        if (!empty($ret)) {
153
+            if (is_string($need)) {
154 154
                 foreach ($ret as $value) {
155
-                    if(empty($value['secret_level']) || $value['secret_level'] <= $secret_level){
156
-                        $key_name = $this->user_extra[$value['key']] ?? 'unknown';
157
-                        if($key_name == $need){
155
+                    if (empty($value['secret_level']) || $value['secret_level']<=$secret_level) {
156
+                        $key_name=$this->user_extra[$value['key']] ?? 'unknown';
157
+                        if ($key_name==$need) {
158 158
                             return $value['value'];
159 159
                         }
160 160
                     }
161 161
                 }
162 162
                 return null;
163
-            }else{
163
+            } else {
164 164
                 foreach ($ret as $value) {
165
-                    if(empty($value['secret_level']) || $value['secret_level'] <= $secret_level){
166
-                        $key_name = $this->user_extra[$value['key']] ?? 'unknown';
167
-                        if(in_array($key_name,$need)){
168
-                            $result[$key_name] = $value['value'];
165
+                    if (empty($value['secret_level']) || $value['secret_level']<=$secret_level) {
166
+                        $key_name=$this->user_extra[$value['key']] ?? 'unknown';
167
+                        if (in_array($key_name, $need)) {
168
+                            $result[$key_name]=$value['value'];
169 169
                         }
170 170
                     }
171 171
                 }
@@ -182,26 +182,26 @@  discard block
 block discarded – undo
182 182
      * @param string|null $value the extra info will be delete when value is null
183 183
      * @return mixed $result
184 184
      */
185
-    public function setExtra($uid,$key_name,$value = null,$secret_level = -1){
186
-        $key = array_search($key_name,$this->user_extra);
187
-        if($key === false){
185
+    public function setExtra($uid, $key_name, $value=null, $secret_level=-1) {
186
+        $key=array_search($key_name, $this->user_extra);
187
+        if ($key===false) {
188 188
             return false;
189 189
         }
190
-        $ret = DB::table('users_extra')->where('uid',$uid)->where('key',$key)->first();
191
-        if(!empty($ret)){
190
+        $ret=DB::table('users_extra')->where('uid', $uid)->where('key', $key)->first();
191
+        if (!empty($ret)) {
192 192
             unset($ret['id']);
193
-            if(!is_null($value)){
194
-                $ret['value'] = $value;
195
-            }else{
196
-                DB::table('users_extra')->where('uid',$uid)->where('key',$key)->delete();
193
+            if (!is_null($value)) {
194
+                $ret['value']=$value;
195
+            } else {
196
+                DB::table('users_extra')->where('uid', $uid)->where('key', $key)->delete();
197 197
                 return true;
198 198
             }
199
-            if($secret_level != -1){
200
-                $ret['secret_level'] = $secret_level;
199
+            if ($secret_level!=-1) {
200
+                $ret['secret_level']=$secret_level;
201 201
             }
202
-            return DB::table('users_extra')->where('uid',$uid)->where('key',$key)->update($ret);
203
-        }else{
204
-            if($value === null){
202
+            return DB::table('users_extra')->where('uid', $uid)->where('key', $key)->update($ret);
203
+        } else {
204
+            if ($value===null) {
205 205
                 return true;
206 206
             }
207 207
             return DB::table('users_extra')->insertGetId(
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
                     'uid' => $uid,
210 210
                     'key' => $key,
211 211
                     'value' => $value,
212
-                    'secret_level' => $secret_level == -1 ? 0 : $secret_level,
212
+                    'secret_level' => $secret_level==-1 ? 0 : $secret_level,
213 213
                 ]
214 214
             );
215 215
         }
@@ -221,33 +221,33 @@  discard block
 block discarded – undo
221 221
      * @param string $value the value
222 222
      * @return string $result
223 223
      */
224
-    public function findExtra($key,$value)
224
+    public function findExtra($key, $value)
225 225
     {
226
-        $key = array_search($key,$this->user_extra);
227
-        if($key){
228
-            return DB::table('users_extra')->where('key',$key)->where('value',$value)->first();
229
-        }else{
226
+        $key=array_search($key, $this->user_extra);
227
+        if ($key) {
228
+            return DB::table('users_extra')->where('key', $key)->where('value', $value)->first();
229
+        } else {
230 230
             return null;
231 231
         }
232 232
     }
233 233
 
234
-    public function getSocialiteInfo($uid,$secret_level = -1)
234
+    public function getSocialiteInfo($uid, $secret_level=-1)
235 235
     {
236
-        $socialites = [];
236
+        $socialites=[];
237 237
         foreach ($this->socialite_support as $key => $value) {
238
-            $id_keyname = $key.'_id';
239
-            $id = $this->getExtra($uid,$id_keyname);
240
-            if(!empty($id)){
241
-                $info = [
238
+            $id_keyname=$key.'_id';
239
+            $id=$this->getExtra($uid, $id_keyname);
240
+            if (!empty($id)) {
241
+                $info=[
242 242
                     'id' => $id,
243 243
                 ];
244 244
                 foreach ($value as $info_name) {
245
-                    $info_temp = $this->getExtra($uid,$key.'_'.$info_name);
246
-                    if($info_temp !== null){
247
-                        $info[$info_name] = $info_temp;
245
+                    $info_temp=$this->getExtra($uid, $key.'_'.$info_name);
246
+                    if ($info_temp!==null) {
247
+                        $info[$info_name]=$info_temp;
248 248
                     }
249 249
                 }
250
-                $socialites[$key] = $info;
250
+                $socialites[$key]=$info;
251 251
             }
252 252
         }
253 253
 
Please login to merge, or discard this patch.