Completed
Push — master ( c106d2...7c3edb )
by John
14s queued 10s
created
app/Models/Babel/ExtensionModel.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -22,13 +22,13 @@  discard block
 block discarded – undo
22 22
         $ret=[];
23 23
         $marketspaceRaw=self::getRemote();
24 24
         $marketspace=[];
25
-        foreach($marketspaceRaw["packages"] as $extension){
25
+        foreach ($marketspaceRaw["packages"] as $extension) {
26 26
             $marketspace[$extension["name"]]=$extension;
27 27
         }
28 28
 
29 29
         $localList=self::getLocal();
30 30
 
31
-        foreach($localList as $extension){
31
+        foreach ($localList as $extension) {
32 32
             $temp=[
33 33
                 "details"=>$extension,
34 34
                 "status"=>0,
@@ -37,30 +37,30 @@  discard block
 block discarded – undo
37 37
                 "settings"=>null,
38 38
                 "available"=>null
39 39
             ];
40
-            $temp["details"]["typeParsed"]=$temp["details"]["type"]=="virtual-judge"?"VirtualJudge":"OnlineJudge";
40
+            $temp["details"]["typeParsed"]=$temp["details"]["type"]=="virtual-judge" ? "VirtualJudge" : "OnlineJudge";
41 41
             try {
42 42
                 if ($extension["version"]=='__cur__') {
43 43
                     $extension["version"]=explode("-", version())[0];
44 44
                 }
45 45
                 $downloadedVersion=new Version($extension["version"]);
46 46
 
47
-                if(isset($marketspace[$extension["name"]])){
47
+                if (isset($marketspace[$extension["name"]])) {
48 48
                     //remote extension, else is local extension
49 49
                     $remoteVersion=new Version($marketspace[$extension["name"]]["version"]);
50 50
                     $temp["updatable"]=$remoteVersion->isGreaterThan($downloadedVersion);
51 51
                     $temp["details"]["official"]=$marketspace[$extension["name"]]["official"];
52
-                } else{
52
+                } else {
53 53
                     $temp["updatable"]=false;
54 54
                     $temp["details"]["official"]=0;
55 55
                 }
56 56
 
57 57
                 $installedConfig=OJModel::where(["ocode"=>$extension["code"]])->first();
58
-                if (is_null($installedConfig)){
58
+                if (is_null($installedConfig)) {
59 59
                     $temp["status"]=1;
60 60
                 } else {
61 61
                     $temp["version"]=$installedConfig->version; // local installed version
62 62
                     $installedVersion=new Version($temp["version"]);
63
-                    if ($downloadedVersion->isGreaterThan($installedVersion)){
63
+                    if ($downloadedVersion->isGreaterThan($installedVersion)) {
64 64
                         $temp["status"]=1;
65 65
                     } else {
66 66
                         $temp["status"]=2;
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
                     $temp["settings"]=false;
69 69
                     $temp["available"]=$installedConfig->status;
70 70
                 }
71
-            }catch (Throwable $e){
71
+            } catch (Throwable $e) {
72 72
                 continue;
73 73
             }
74 74
             $ret[]=$temp;
@@ -80,8 +80,8 @@  discard block
 block discarded – undo
80 80
     {
81 81
         $ret=[];
82 82
         $marketspaceRaw=self::getRemote();
83
-        if(empty($marketspaceRaw)) return [];
84
-        foreach($marketspaceRaw["packages"] as $extension){
83
+        if (empty($marketspaceRaw)) return [];
84
+        foreach ($marketspaceRaw["packages"] as $extension) {
85 85
             $temp=[
86 86
                 "details"=>$extension,
87 87
                 "status"=>0,
@@ -90,11 +90,11 @@  discard block
 block discarded – undo
90 90
                 "settings"=>null,
91 91
                 "available"=>null
92 92
             ];
93
-            $temp["details"]["typeParsed"]=$temp["details"]["type"]=="virtual-judge"?"VirtualJudge":"OnlineJudge";
93
+            $temp["details"]["typeParsed"]=$temp["details"]["type"]=="virtual-judge" ? "VirtualJudge" : "OnlineJudge";
94 94
             try {
95 95
                 try {
96 96
                     $BabelConfig=json_decode(file_get_contents(babel_path("Extension/{$extension['code']}/babel.json")), true);
97
-                }catch (Throwable $e){
97
+                } catch (Throwable $e) {
98 98
                     $BabelConfig=[];
99 99
                 }
100 100
                 if (!empty($BabelConfig)) {
@@ -106,12 +106,12 @@  discard block
 block discarded – undo
106 106
                     $temp["updatable"]=$remoteVersion->isGreaterThan($downloadedVersion);
107 107
 
108 108
                     $installedConfig=OJModel::where(["ocode"=>$extension["code"]])->first();
109
-                    if (is_null($installedConfig)){
109
+                    if (is_null($installedConfig)) {
110 110
                         $temp["status"]=1;
111 111
                     } else {
112 112
                         $temp["version"]=$installedConfig->version; // local installed version
113 113
                         $installedVersion=new Version($temp["version"]);
114
-                        if ($downloadedVersion->isGreaterThan($installedVersion)){
114
+                        if ($downloadedVersion->isGreaterThan($installedVersion)) {
115 115
                             $temp["status"]=1;
116 116
                         } else {
117 117
                             $temp["status"]=2;
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
                         $temp["available"]=$installedConfig->status;
121 121
                     }
122 122
                 }
123
-            }catch (Throwable $e){
123
+            } catch (Throwable $e) {
124 124
                 continue;
125 125
             }
126 126
             $ret[]=$temp;
@@ -132,11 +132,11 @@  discard block
 block discarded – undo
132 132
     public static function getLocal()
133 133
     {
134 134
         $ret=[];
135
-        $dirs = array_filter(glob(babel_path("Extension/*")), 'is_dir');
136
-        foreach($dirs as $d){
135
+        $dirs=array_filter(glob(babel_path("Extension/*")), 'is_dir');
136
+        foreach ($dirs as $d) {
137 137
             $extension=basename($d);
138 138
             $BabelConfig=json_decode(file_get_contents(babel_path("Extension/$extension/babel.json")), true);
139
-            if($extension==$BabelConfig["code"]) $ret[]=$BabelConfig;
139
+            if ($extension==$BabelConfig["code"]) $ret[]=$BabelConfig;
140 140
         }
141 141
         return $ret;
142 142
     }
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
     {
146 146
         try {
147 147
             return json_decode(file_get_contents(config('babel.mirror')."/babel.json"), true);
148
-        }catch(Throwable $e){
148
+        } catch (Throwable $e) {
149 149
             return [];
150 150
         }
151 151
     }
@@ -153,10 +153,10 @@  discard block
 block discarded – undo
153 153
     public static function remoteDetail($code)
154 154
     {
155 155
         $babelConfig=self::getRemote();
156
-        if(empty($babelConfig)) return [];
156
+        if (empty($babelConfig)) return [];
157 157
         $babelConfigPackages=$babelConfig["packages"];
158
-        foreach($babelConfigPackages as $package) {
159
-            if($package["code"]==$code) return $package;
158
+        foreach ($babelConfigPackages as $package) {
159
+            if ($package["code"]==$code) return $package;
160 160
         }
161 161
         return [];
162 162
     }
Please login to merge, or discard this patch.
app/Http/Controllers/MessageController.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -10,8 +10,8 @@  discard block
 block discarded – undo
10 10
 {
11 11
     public function index()
12 12
     {
13
-        $uid = Auth::user()->id;
14
-        $messages = MessageModel::list($uid);
13
+        $uid=Auth::user()->id;
14
+        $messages=MessageModel::list($uid);
15 15
         return view('message.index', [
16 16
             'page_title'=>"Message",
17 17
             'site_title'=>config("app.name"),
@@ -22,8 +22,8 @@  discard block
 block discarded – undo
22 22
 
23 23
     public function detail($id)
24 24
     {
25
-        $message = MessageModel::read($id);
26
-        if(empty($message || $message->receiver != Auth::user()->id)){
25
+        $message=MessageModel::read($id);
26
+        if (empty($message || $message->receiver!=Auth::user()->id)) {
27 27
             return Redirect::route('message.index');
28 28
         }
29 29
         return view('message.detail', [
Please login to merge, or discard this patch.
app/Http/Controllers/Ajax/ContestAdminController.php 1 patch
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -20,22 +20,22 @@  discard block
 block discarded – undo
20 20
             'cid' => 'required|integer',
21 21
             'uid' => 'required|integer'
22 22
         ]);
23
-        $cid = $request->input('cid');
24
-        $uid = $request->input('uid');
23
+        $cid=$request->input('cid');
24
+        $uid=$request->input('uid');
25 25
 
26
-        $groupModel = new GroupModel();
27
-        $contestModel = new ContestModel();
26
+        $groupModel=new GroupModel();
27
+        $contestModel=new ContestModel();
28 28
 
29
-        $contest_info = $contestModel->basic($cid);
30
-        if($contestModel->judgeClearance($cid,Auth::user()->id) != 3){
29
+        $contest_info=$contestModel->basic($cid);
30
+        if ($contestModel->judgeClearance($cid, Auth::user()->id)!=3) {
31 31
             return ResponseModel::err(2001);
32 32
         }
33 33
 
34
-        if($groupModel->judgeClearance($contest_info['gid'],$uid) < 2){
34
+        if ($groupModel->judgeClearance($contest_info['gid'], $uid)<2) {
35 35
             return ResponseModel::err(7004);
36 36
         }
37 37
 
38
-        $contestModel->assignMember($cid,$uid);
38
+        $contestModel->assignMember($cid, $uid);
39 39
         return ResponseModel::success(200);
40 40
     }
41 41
 
@@ -44,30 +44,30 @@  discard block
 block discarded – undo
44 44
         $request->validate([
45 45
             'cid' => 'required|integer',
46 46
         ]);
47
-        $cid = $request->input('cid');
47
+        $cid=$request->input('cid');
48 48
 
49
-        $contestModel = new ContestModel();
50
-        $groupModel = new GroupModel();
49
+        $contestModel=new ContestModel();
50
+        $groupModel=new GroupModel();
51 51
 
52
-        $contest_problems = $contestModel->problems($cid);
53
-        $contest_detail = $contestModel->basic($cid);
54
-        $contest_detail['problems'] = $contest_problems;
55
-        $assign_uid = $contest_detail['assign_uid'];
56
-        $clearance = $contestModel->judgeClearance($cid,Auth::user()->id);
57
-        if($clearance != 3){
52
+        $contest_problems=$contestModel->problems($cid);
53
+        $contest_detail=$contestModel->basic($cid);
54
+        $contest_detail['problems']=$contest_problems;
55
+        $assign_uid=$contest_detail['assign_uid'];
56
+        $clearance=$contestModel->judgeClearance($cid, Auth::user()->id);
57
+        if ($clearance!=3) {
58 58
             return ResponseModel::err(2001);
59 59
         }
60
-        if($assign_uid != 0){
61
-            $assignee = $groupModel->userProfile($assign_uid,$contest_detail['gid']);
62
-        }else{
63
-            $assignee = null;
60
+        if ($assign_uid!=0) {
61
+            $assignee=$groupModel->userProfile($assign_uid, $contest_detail['gid']);
62
+        } else {
63
+            $assignee=null;
64 64
         }
65
-        $ret = [
65
+        $ret=[
66 66
             'contest_info' => $contest_detail,
67 67
             'assignee' => $assignee,
68
-            'is_admin' => $clearance == 3,
68
+            'is_admin' => $clearance==3,
69 69
         ];
70
-        return ResponseModel::success(200,null,$ret);
70
+        return ResponseModel::success(200, null, $ret);
71 71
     }
72 72
 
73 73
     public function rejudge(Request $request)
@@ -101,15 +101,15 @@  discard block
 block discarded – undo
101 101
             'end_time' => 'required|date|after:begin_time',
102 102
             'description' => 'string'
103 103
         ]);
104
-        $all_data = $request->all();
105
-        $cid = $all_data['cid'];
104
+        $all_data=$request->all();
105
+        $cid=$all_data['cid'];
106 106
 
107
-        $contestModel = new ContestModel();
108
-        if($contestModel->judgeClearance($all_data['cid'],Auth::user()->id) != 3){
107
+        $contestModel=new ContestModel();
108
+        if ($contestModel->judgeClearance($all_data['cid'], Auth::user()->id)!=3) {
109 109
             return ResponseModel::err(2001);
110 110
         }
111 111
 
112
-        if($contestModel->remainingTime($cid) > 0){
112
+        if ($contestModel->remainingTime($cid)>0) {
113 113
             $problems=explode(",", $all_data["problems"]);
114 114
             if (count($problems)>26) {
115 115
                 return ResponseModel::err(4002);
@@ -126,32 +126,32 @@  discard block
 block discarded – undo
126 126
                     ];
127 127
                 }
128 128
             }
129
-            $allow_update = ['name','description','begin_time','end_time'];
129
+            $allow_update=['name', 'description', 'begin_time', 'end_time'];
130 130
 
131
-            foreach($all_data as $key => $value){
132
-                if(!in_array($key,$allow_update)){
131
+            foreach ($all_data as $key => $value) {
132
+                if (!in_array($key, $allow_update)) {
133 133
                     unset($all_data[$key]);
134 134
                 }
135 135
             }
136
-            $contestModel->contestUpdate($cid,$all_data,$problemSet);
136
+            $contestModel->contestUpdate($cid, $all_data, $problemSet);
137 137
             return ResponseModel::success(200);
138
-        }else{
139
-            $allow_update = ['name','description'];
138
+        } else {
139
+            $allow_update=['name', 'description'];
140 140
 
141
-            foreach($all_data as $key => $value){
142
-                if(!in_array($key,$allow_update)){
141
+            foreach ($all_data as $key => $value) {
142
+                if (!in_array($key, $allow_update)) {
143 143
                     unset($all_data[$key]);
144 144
                 }
145 145
             }
146
-            $contestModel->contestUpdate($cid,$all_data,false);
147
-            return ResponseModel::success(200,'
146
+            $contestModel->contestUpdate($cid, $all_data, false);
147
+            return ResponseModel::success(200, '
148 148
                 Successful! However, only the name and description of the match can be changed for the match that has been finished.
149 149
             ');
150 150
         }
151 151
 
152 152
     }
153 153
 
154
-    public function issueAnnouncement(Request $request){
154
+    public function issueAnnouncement(Request $request) {
155 155
         $request->validate([
156 156
             'cid' => 'required|integer',
157 157
             'title' => 'required|string|max:250',
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
         }
172 172
     }
173 173
 
174
-    public function replyClarification(Request $request){
174
+    public function replyClarification(Request $request) {
175 175
         $request->validate([
176 176
             'cid' => 'required|integer',
177 177
             'ccid' => 'required|integer',
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
         }
192 192
     }
193 193
 
194
-    public function setClarificationPublic(Request $request){
194
+    public function setClarificationPublic(Request $request) {
195 195
         $request->validate([
196 196
             'cid' => 'required|integer',
197 197
             'ccid' => 'required|integer',
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
         $groupModel=new GroupModel();
225 225
         $contestModel=new ContestModel();
226 226
         $verified=$contestModel->isVerified($all_data["cid"]);
227
-        if(!$verified){
227
+        if (!$verified) {
228 228
             return ResponseModel::err(2001);
229 229
         }
230 230
         $gid=$contestModel->gid($all_data["cid"]);
@@ -245,18 +245,18 @@  discard block
 block discarded – undo
245 245
         $request->validate([
246 246
             'cid' => 'required|integer',
247 247
         ]);
248
-        $cid = $request->input('cid');
249
-        $contestModel = new ContestModel();
250
-        if($contestModel->judgeClearance($cid,Auth::user()->id) != 3){
248
+        $cid=$request->input('cid');
249
+        $contestModel=new ContestModel();
250
+        if ($contestModel->judgeClearance($cid, Auth::user()->id)!=3) {
251 251
             return ResponseModel::err(2001);
252 252
         }
253
-        if($contestModel->remainingTime($cid) >= 0){
253
+        if ($contestModel->remainingTime($cid)>=0) {
254 254
             return ResponseModel::err(4008);
255 255
         }
256
-        if($contestModel->basic($cid)['froze_length'] == 0){
256
+        if ($contestModel->basic($cid)['froze_length']==0) {
257 257
             return ResponseModel::err(4009);
258 258
         }
259
-        $data = $contestModel->getScrollBoardData($cid);
259
+        $data=$contestModel->getScrollBoardData($cid);
260 260
         return ResponseModel::success(200, null, $data);
261 261
     }
262 262
 }
Please login to merge, or discard this patch.
app/Http/Controllers/Ajax/MessageController.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -15,24 +15,24 @@
 block discarded – undo
15 15
         $request->validate([
16 16
             'uid' => 'required|integer'
17 17
         ]);
18
-        $uid = $request->input('uid');
19
-        if(!Auth::check() || Auth::user()->id != $uid){
18
+        $uid=$request->input('uid');
19
+        if (!Auth::check() || Auth::user()->id!=$uid) {
20 20
             return ResponseModel::err(2001);
21 21
         }
22
-        $ret = MessageModel::unread($uid);
23
-        return ResponseModel::success(200,null,$ret);
22
+        $ret=MessageModel::unread($uid);
23
+        return ResponseModel::success(200, null, $ret);
24 24
     }
25 25
 
26 26
     public function allRead()
27 27
     {
28
-        $uid = Auth::user()->id;
28
+        $uid=Auth::user()->id;
29 29
         MessageModel::allRead($uid);
30 30
         return ResponseModel::success(200);
31 31
     }
32 32
 
33 33
     public function deleteAll()
34 34
     {
35
-        $uid = Auth::user()->id;
35
+        $uid=Auth::user()->id;
36 36
         MessageModel::removeAllRead($uid);
37 37
         return ResponseModel::success(200);
38 38
     }
Please login to merge, or discard this patch.
app/Http/Controllers/Ajax/ProblemController.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -110,8 +110,8 @@  discard block
 block discarded – undo
110 110
         if (empty($basic)) {
111 111
             return ResponseModel::err(3001);
112 112
         }
113
-        $ret=$problemModel->addSolution($pid,Auth::user()->id,$content);
114
-        return $ret?ResponseModel::success(200):ResponseModel::err(3003);
113
+        $ret=$problemModel->addSolution($pid, Auth::user()->id, $content);
114
+        return $ret ?ResponseModel::success(200) : ResponseModel::err(3003);
115 115
     }
116 116
     /**
117 117
      * The Ajax Problem Solution Discussion Update.
@@ -126,8 +126,8 @@  discard block
 block discarded – undo
126 126
         $problemModel=new ProblemModel();
127 127
         $psoid=$all_data["psoid"];
128 128
         $content=$all_data["content"];
129
-        $ret=$problemModel->updateSolution($psoid,Auth::user()->id,$content);
130
-        return $ret?ResponseModel::success(200):ResponseModel::err(3004);
129
+        $ret=$problemModel->updateSolution($psoid, Auth::user()->id, $content);
130
+        return $ret ?ResponseModel::success(200) : ResponseModel::err(3004);
131 131
     }
132 132
     /**
133 133
      * The Ajax Problem Solution Discussion Delete.
@@ -141,8 +141,8 @@  discard block
 block discarded – undo
141 141
         $all_data=$request->all();
142 142
         $problemModel=new ProblemModel();
143 143
         $psoid=$all_data["psoid"];
144
-        $ret=$problemModel->removeSolution($psoid,Auth::user()->id);
145
-        return $ret?ResponseModel::success(200):ResponseModel::err(3004);
144
+        $ret=$problemModel->removeSolution($psoid, Auth::user()->id);
145
+        return $ret ?ResponseModel::success(200) : ResponseModel::err(3004);
146 146
     }
147 147
     /**
148 148
      * The Ajax Problem Solution Discussion Vote.
@@ -157,8 +157,8 @@  discard block
 block discarded – undo
157 157
         $problemModel=new ProblemModel();
158 158
         $psoid=$all_data["psoid"];
159 159
         $type=$all_data["type"];
160
-        $ret=$problemModel->voteSolution($psoid,Auth::user()->id,$type);
161
-        return $ret["ret"]?ResponseModel::success(200,null,["votes"=>$ret["votes"],"select"=>$ret["select"]]):ResponseModel::err(3004);
160
+        $ret=$problemModel->voteSolution($psoid, Auth::user()->id, $type);
161
+        return $ret["ret"] ?ResponseModel::success(200, null, ["votes"=>$ret["votes"], "select"=>$ret["select"]]) : ResponseModel::err(3004);
162 162
     }
163 163
     /**
164 164
      * The Ajax Problem Solution Submit.
@@ -252,8 +252,8 @@  discard block
 block discarded – undo
252 252
         if (empty($basic)) {
253 253
             return ResponseModel::err(3001);
254 254
         }
255
-        $ret=$problemModel->addDiscussion(Auth::user()->id,$pid,$title,$content);
256
-        return $ret?ResponseModel::success(200, null, $ret):ResponseModel::err(3003);
255
+        $ret=$problemModel->addDiscussion(Auth::user()->id, $pid, $title, $content);
256
+        return $ret ?ResponseModel::success(200, null, $ret) : ResponseModel::err(3003);
257 257
     }
258 258
 
259 259
     public function addComment(Request $request)
@@ -272,8 +272,8 @@  discard block
 block discarded – undo
272 272
         if (empty($basic)) {
273 273
             return ResponseModel::err(3001);
274 274
         }
275
-        $ret=$problemModel->addComment(Auth::user()->id,$pdid,$content,$reply_id);
276
-        return $ret?ResponseModel::success(200, null, $ret):ResponseModel::err(3003);
275
+        $ret=$problemModel->addComment(Auth::user()->id, $pdid, $content, $reply_id);
276
+        return $ret ?ResponseModel::success(200, null, $ret) : ResponseModel::err(3003);
277 277
     }
278 278
   
279 279
     /**
@@ -292,15 +292,15 @@  discard block
 block discarded – undo
292 292
 
293 293
         $submissionData=$submissionModel->basic($all_data["sid"]);
294 294
 
295
-        if($submissionData["uid"]!=Auth::user()->id){
295
+        if ($submissionData["uid"]!=Auth::user()->id) {
296 296
             return ResponseModel::err(2001);
297 297
         }
298 298
 
299
-        if($submissionData["verdict"]!="Submission Error"){
299
+        if ($submissionData["verdict"]!="Submission Error") {
300 300
             return ResponseModel::err(6003);
301 301
         }
302 302
 
303
-        $submissionModel->updateSubmission($all_data["sid"],[
303
+        $submissionModel->updateSubmission($all_data["sid"], [
304 304
             "verdict"=>"Pending",
305 305
             "time"=>0,
306 306
             "memory"=>0
Please login to merge, or discard this patch.
app/Models/GroupModel.php 1 patch
Spacing   +120 added lines, -120 removed lines patch added patch discarded remove patch
@@ -57,10 +57,10 @@  discard block
 block discarded – undo
57 57
         foreach ($trending_groups as &$t) {
58 58
             $t["members"]=$this->countGroupMembers($t["gid"]);
59 59
         }
60
-        usort($trending_groups, function ($a, $b) {
60
+        usort($trending_groups, function($a, $b) {
61 61
             return $b["members"]<=>$a["members"];
62 62
         });
63
-        Cache::tags(['group'])->put('trending', array_slice($trending_groups,0,12), 3600*24);
63
+        Cache::tags(['group'])->put('trending', array_slice($trending_groups, 0, 12), 3600 * 24);
64 64
     }
65 65
 
66 66
     public function userGroups($uid)
@@ -100,13 +100,13 @@  discard block
 block discarded – undo
100 100
 
101 101
     public function changeGroupName($gid, $GroupName)
102 102
     {
103
-        return DB::table("group")->where('gid',$gid)->update([
103
+        return DB::table("group")->where('gid', $gid)->update([
104 104
             "name"=>$GroupName
105 105
         ]);
106 106
     }
107 107
 
108
-    public function changeJoinPolicy($gid, $JoinPolicy){
109
-        return DB::table("group")->where('gid',$gid)->update([
108
+    public function changeJoinPolicy($gid, $JoinPolicy) {
109
+        return DB::table("group")->where('gid', $gid)->update([
110 110
             "join_policy"=>$JoinPolicy
111 111
         ]);
112 112
     }
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
     public function details($gcode)
121 121
     {
122 122
         $basic_info=DB::table($this->tableName)->where(["gcode"=>$gcode])->first();
123
-        if(empty($basic_info)) return [];
123
+        if (empty($basic_info)) return [];
124 124
         $basic_info["members"]=$this->countGroupMembers($basic_info["gid"]);
125 125
         $basic_info["tags"]=$this->getGroupTags($basic_info["gid"]);
126 126
         $basic_info["create_time_foramt"]=date_format(date_create($basic_info["create_time"]), 'M jS, Y');
@@ -137,10 +137,10 @@  discard block
 block discarded – undo
137 137
     public function userProfile($uid, $gid)
138 138
     {
139 139
         $info=DB::table("group_member")
140
-        ->join('users','users.id','=','group_member.uid')
140
+        ->join('users', 'users.id', '=', 'group_member.uid')
141 141
         ->where(["gid"=>$gid, "uid"=>$uid])
142 142
         ->where("role", ">", 0)
143
-        ->select('avatar','describes','email','gid','uid','name','nick_name','professional_rate','role','sub_group')
143
+        ->select('avatar', 'describes', 'email', 'gid', 'uid', 'name', 'nick_name', 'professional_rate', 'role', 'sub_group')
144 144
         ->first();
145 145
         if (!empty($info)) {
146 146
             $info["role_parsed"]=$this->role[$info["role"]];
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
         foreach ($user_list as &$u) {
169 169
             $u["role_parsed"]=$this->role[$u["role"]];
170 170
             $u["role_color"]=$this->role_color[$u["role"]];
171
-            if(is_null($u["sub_group"])) $u["sub_group"]="None";
171
+            if (is_null($u["sub_group"])) $u["sub_group"]="None";
172 172
         }
173 173
         return $user_list;
174 174
     }
@@ -229,16 +229,16 @@  discard block
 block discarded – undo
229 229
         ])->where("role", ">", 0)->count();
230 230
     }
231 231
 
232
-    public function problemTags($gid,$pid = -1)
232
+    public function problemTags($gid, $pid=-1)
233 233
     {
234
-        if($pid == -1){
235
-            $tags =  DB::table('group_problem_tag')
234
+        if ($pid==-1) {
235
+            $tags=DB::table('group_problem_tag')
236 236
             ->select('tag')
237
-            ->where('gid',$gid)
237
+            ->where('gid', $gid)
238 238
             ->distinct()
239 239
             ->get()->all();
240
-        }else{
241
-            $tags =  DB::table('group_problem_tag')
240
+        } else {
241
+            $tags=DB::table('group_problem_tag')
242 242
             ->select('tag')
243 243
             ->where('gid', $gid)
244 244
             ->where('pid', $pid)
@@ -246,10 +246,10 @@  discard block
 block discarded – undo
246 246
             ->get()->all();
247 247
         }
248 248
 
249
-        $tags_arr = [];
250
-        if(!empty($tags)){
249
+        $tags_arr=[];
250
+        if (!empty($tags)) {
251 251
             foreach ($tags as $value) {
252
-                array_push($tags_arr,$value['tag']);
252
+                array_push($tags_arr, $value['tag']);
253 253
             }
254 254
         }
255 255
         return $tags_arr;
@@ -257,28 +257,28 @@  discard block
 block discarded – undo
257 257
 
258 258
     public function problems($gid)
259 259
     {
260
-        $contestModel = new ContestModel();
261
-        $problems = DB::table('contest_problem')
262
-        ->join('contest','contest_problem.cid', '=', 'contest.cid')
263
-        ->join('problem','contest_problem.pid', '=', 'problem.pid' )
260
+        $contestModel=new ContestModel();
261
+        $problems=DB::table('contest_problem')
262
+        ->join('contest', 'contest_problem.cid', '=', 'contest.cid')
263
+        ->join('problem', 'contest_problem.pid', '=', 'problem.pid')
264 264
         ->select('contest_problem.cid as cid', 'problem.pid as pid', 'pcode', 'title')
265
-        ->where('contest.gid',$gid)
266
-        ->where('contest.practice',1)
267
-        ->orderBy('contest.create_time','desc')
265
+        ->where('contest.gid', $gid)
266
+        ->where('contest.practice', 1)
267
+        ->orderBy('contest.create_time', 'desc')
268 268
         ->distinct()
269 269
         ->get()->all();
270
-        $user_id = Auth::user()->id;
271
-        foreach($problems as $key => $value){
272
-            if($contestModel->judgeClearance($value['cid'],$user_id) != 3){
270
+        $user_id=Auth::user()->id;
271
+        foreach ($problems as $key => $value) {
272
+            if ($contestModel->judgeClearance($value['cid'], $user_id)!=3) {
273 273
                 unset($problems[$key]);
274
-            }else{
275
-                $problems[$key]['tags'] = $this->problemTags($gid,$value['pid']);
274
+            } else {
275
+                $problems[$key]['tags']=$this->problemTags($gid, $value['pid']);
276 276
             }
277 277
         }
278 278
         return $problems;
279 279
     }
280 280
 
281
-    public function problemAddTag($gid,$pid,$tag)
281
+    public function problemAddTag($gid, $pid, $tag)
282 282
     {
283 283
         return DB::table("group_problem_tag")->insert([
284 284
             "gid"=>$gid,
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
         ]);
288 288
     }
289 289
 
290
-    public function problemRemoveTag($gid,$pid,$tag)
290
+    public function problemRemoveTag($gid, $pid, $tag)
291 291
     {
292 292
         return DB::table("group_problem_tag")->where([
293 293
             "gid"=>$gid,
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
     public function judgeEmailClearance($gid, $email)
333 333
     {
334 334
         $user=DB::table("users")->where(["email"=>$email])->first();
335
-        if(empty($user)) return -4;
335
+        if (empty($user)) return -4;
336 336
         $ret=DB::table("group_member")->where([
337 337
             "gid"=>$gid,
338 338
             "uid"=>$user["id"],
@@ -423,20 +423,20 @@  discard block
 block discarded – undo
423 423
 
424 424
     public function groupMemberPracticeContestStat($gid)
425 425
     {
426
-        $contestModel = new ContestModel();
426
+        $contestModel=new ContestModel();
427 427
 
428
-        $allPracticeContest = DB::table('contest')
428
+        $allPracticeContest=DB::table('contest')
429 429
             ->where([
430 430
                 'gid' => $gid,
431 431
                 'practice' => 1,
432 432
             ])
433
-            ->select('cid','name')
433
+            ->select('cid', 'name')
434 434
             ->get()->all();
435
-        $user_list = $this->userList($gid);
435
+        $user_list=$this->userList($gid);
436 436
 
437
-        $memberData = [];
437
+        $memberData=[];
438 438
         foreach ($user_list as $u) {
439
-            $memberData[$u['uid']] = [
439
+            $memberData[$u['uid']]=[
440 440
                 'name' => $u['name'],
441 441
                 'nick_name' => $u['nick_name'],
442 442
                 'elo' => $u['ranking'],
@@ -447,61 +447,61 @@  discard block
 block discarded – undo
447 447
             ];
448 448
         }
449 449
         foreach ($allPracticeContest as $c) {
450
-            $contestRankRaw = $contestModel->contestRank($c['cid']);
451
-            foreach($contestRankRaw as $key => $contestRank){
452
-                if(isset($contestRank['remote']) && $contestRank['remote']){
450
+            $contestRankRaw=$contestModel->contestRank($c['cid']);
451
+            foreach ($contestRankRaw as $key => $contestRank) {
452
+                if (isset($contestRank['remote']) && $contestRank['remote']) {
453 453
                     unset($contestRankRaw[$key]);
454 454
                 }
455 455
             }
456
-            $contestRank = array_values($contestRankRaw);
457
-            $problemsCount = DB::table('contest_problem')
458
-                ->where('cid',$c['cid'])
456
+            $contestRank=array_values($contestRankRaw);
457
+            $problemsCount=DB::table('contest_problem')
458
+                ->where('cid', $c['cid'])
459 459
                 ->count();
460
-            $index = 1;
461
-            $rank = 1;
462
-            $last_cr = [];
463
-            $last_rank = 1;
460
+            $index=1;
461
+            $rank=1;
462
+            $last_cr=[];
463
+            $last_rank=1;
464 464
             foreach ($contestRank as $cr) {
465
-                $last_rank = $index;
466
-                if(!empty($last_cr)){
467
-                    if($cr['solved'] == $last_cr['solved'] && $cr['penalty'] == $last_cr['penalty'] ){
468
-                        $rank = $last_rank;
469
-                    }else{
470
-                        $rank = $index;
471
-                        $last_rank = $rank;
465
+                $last_rank=$index;
466
+                if (!empty($last_cr)) {
467
+                    if ($cr['solved']==$last_cr['solved'] && $cr['penalty']==$last_cr['penalty']) {
468
+                        $rank=$last_rank;
469
+                    } else {
470
+                        $rank=$index;
471
+                        $last_rank=$rank;
472 472
                     }
473 473
                 }
474
-                if(in_array($cr['uid'],array_keys($memberData))) {
475
-                    $memberData[$cr['uid']]['solved_all'] += $cr['solved'];
476
-                    $memberData[$cr['uid']]['problem_all'] += $problemsCount;
477
-                    $memberData[$cr['uid']]['penalty'] += $cr['penalty'];
478
-                    $memberData[$cr['uid']]['contest_detial'][$c['cid']] = [
474
+                if (in_array($cr['uid'], array_keys($memberData))) {
475
+                    $memberData[$cr['uid']]['solved_all']+=$cr['solved'];
476
+                    $memberData[$cr['uid']]['problem_all']+=$problemsCount;
477
+                    $memberData[$cr['uid']]['penalty']+=$cr['penalty'];
478
+                    $memberData[$cr['uid']]['contest_detial'][$c['cid']]=[
479 479
                         'rank' => $rank,
480 480
                         'solved' => $cr['solved'],
481 481
                         'problems' => $problemsCount,
482 482
                         'penalty' => $cr['penalty']
483 483
                     ];
484 484
                 }
485
-                $last_cr = $cr;
485
+                $last_cr=$cr;
486 486
                 $index++;
487 487
             }
488 488
         }
489
-        $new_memberData = [];
489
+        $new_memberData=[];
490 490
         foreach ($memberData as $uid => $data) {
491
-            $contest_count = 0;
492
-            $rank_sum = 0;
491
+            $contest_count=0;
492
+            $rank_sum=0;
493 493
             foreach ($data['contest_detial'] as $cid => $c) {
494
-                $rank_sum += $c['rank'];
495
-                $contest_count += 1;
494
+                $rank_sum+=$c['rank'];
495
+                $contest_count+=1;
496 496
             }
497
-            $temp = $data;
498
-            $temp['uid'] = $uid;
499
-            if($contest_count != 0){
500
-                $temp['rank_ave'] = $rank_sum/$contest_count;
497
+            $temp=$data;
498
+            $temp['uid']=$uid;
499
+            if ($contest_count!=0) {
500
+                $temp['rank_ave']=$rank_sum / $contest_count;
501 501
             }
502
-            array_push($new_memberData,$temp);
502
+            array_push($new_memberData, $temp);
503 503
         }
504
-        $ret = [
504
+        $ret=[
505 505
             'contest_list' => $allPracticeContest,
506 506
             'member_data' => $new_memberData
507 507
         ];
@@ -510,58 +510,58 @@  discard block
 block discarded – undo
510 510
 
511 511
     public function groupMemberPracticeTagStat($gid)
512 512
     {
513
-        $tags = $this->problemTags($gid);
514
-        $tag_problems = [];
513
+        $tags=$this->problemTags($gid);
514
+        $tag_problems=[];
515 515
 
516
-        $user_list = $this->userList($gid);
516
+        $user_list=$this->userList($gid);
517 517
         foreach ($tags as $tag) {
518
-            $tag_problems[$tag] = DB::table('problem')
519
-                ->join('group_problem_tag','problem.pid','=','group_problem_tag.pid')
518
+            $tag_problems[$tag]=DB::table('problem')
519
+                ->join('group_problem_tag', 'problem.pid', '=', 'group_problem_tag.pid')
520 520
                 ->where([
521 521
                     'group_problem_tag.gid' => $gid,
522 522
                     'tag' => $tag
523 523
                 ])
524
-                ->select('group_problem_tag.pid as pid','pcode','title')
524
+                ->select('group_problem_tag.pid as pid', 'pcode', 'title')
525 525
                 ->get()->all();
526 526
         }
527
-        $all_problems = [];
527
+        $all_problems=[];
528 528
         foreach ($tag_problems as &$tag_problem_set) {
529 529
             foreach ($tag_problem_set as $problem) {
530
-                $all_problems[$problem['pid']] = $problem;
530
+                $all_problems[$problem['pid']]=$problem;
531 531
             }
532
-            $tag_problem_set = array_column($tag_problem_set,'pid');
532
+            $tag_problem_set=array_column($tag_problem_set, 'pid');
533 533
         }
534
-        $submission_data =  DB::table('submission')
535
-            ->whereIn('pid',array_keys($all_problems))
536
-            ->whereIn('uid',array_column($user_list,'uid'))
537
-            ->where('verdict','Accepted')
538
-            ->select('pid','uid')
534
+        $submission_data=DB::table('submission')
535
+            ->whereIn('pid', array_keys($all_problems))
536
+            ->whereIn('uid', array_column($user_list, 'uid'))
537
+            ->where('verdict', 'Accepted')
538
+            ->select('pid', 'uid')
539 539
             ->get()->all();
540 540
 
541
-        $memberData = [];
541
+        $memberData=[];
542 542
         foreach ($user_list as $member) {
543
-            $completion = [];
544
-            foreach($tag_problems as $tag => $problems) {
545
-                $completion[$tag] = [];
543
+            $completion=[];
544
+            foreach ($tag_problems as $tag => $problems) {
545
+                $completion[$tag]=[];
546 546
                 foreach ($problems as $problem) {
547
-                    $is_accepted = 0;
547
+                    $is_accepted=0;
548 548
                     foreach ($submission_data as $sd) {
549
-                        if($sd['pid'] == $problem && $sd['uid'] == $member['uid']){
550
-                            $is_accepted = 1;
549
+                        if ($sd['pid']==$problem && $sd['uid']==$member['uid']) {
550
+                            $is_accepted=1;
551 551
                             break;
552 552
                         }
553 553
                     }
554
-                    $completion[$tag][$problem] = $is_accepted;
554
+                    $completion[$tag][$problem]=$is_accepted;
555 555
                 }
556 556
             }
557
-            array_push($memberData,[
557
+            array_push($memberData, [
558 558
                 'uid' => $member['uid'],
559 559
                 'name' => $member['name'],
560 560
                 'nick_name' => $member['nick_name'],
561 561
                 'completion' => $completion,
562 562
             ]);
563 563
         }
564
-        $ret = [
564
+        $ret=[
565 565
             'all_problems' => $all_problems,
566 566
             'tag_problems' => $tag_problems,
567 567
             'member_data' => $memberData
@@ -571,10 +571,10 @@  discard block
 block discarded – undo
571 571
 
572 572
     public function refreshAllElo()
573 573
     {
574
-        $result = [];
575
-        $gids = DB::table('group')->select('gid','name')->get()->all();
574
+        $result=[];
575
+        $gids=DB::table('group')->select('gid', 'name')->get()->all();
576 576
         foreach ($gids as $gid) {
577
-            $result[$gid['gid']] = [
577
+            $result[$gid['gid']]=[
578 578
                 'name' => $gid['name'],
579 579
                 'result' => $this->refreshElo($gid['gid']),
580 580
             ];
@@ -585,41 +585,41 @@  discard block
 block discarded – undo
585 585
     public function refreshElo($gid)
586 586
     {
587 587
         DB::table('group_rated_change_log')
588
-            ->where('gid',$gid)
588
+            ->where('gid', $gid)
589 589
             ->delete();
590 590
         DB::table('group_member')
591
-            ->where('gid',$gid)
591
+            ->where('gid', $gid)
592 592
             ->update([
593 593
                 'ranking' => 1500
594 594
             ]);
595
-        $contests = DB::table('contest')
595
+        $contests=DB::table('contest')
596 596
             ->where([
597 597
                 'gid' => $gid,
598 598
                 'practice' => 1
599 599
             ])
600
-            ->where('end_time','<',date("Y-m-d H:i:s"))
601
-            ->select('cid','name')
600
+            ->where('end_time', '<', date("Y-m-d H:i:s"))
601
+            ->select('cid', 'name')
602 602
             ->orderBy('end_time')
603 603
             ->get()->all();
604 604
 
605
-        if(empty($contests)) {
605
+        if (empty($contests)) {
606 606
             return [];
607 607
         }
608
-        $result = [];
609
-        $contestModel = new ContestModel();
608
+        $result=[];
609
+        $contestModel=new ContestModel();
610 610
         foreach ($contests as $contest) {
611
-            $judge_status = $contestModel->judgeOver($contest['cid']);
612
-            if($judge_status['result'] == true){
613
-                $calc = new GroupRatingCalculator($contest['cid']);
611
+            $judge_status=$contestModel->judgeOver($contest['cid']);
612
+            if ($judge_status['result']==true) {
613
+                $calc=new GroupRatingCalculator($contest['cid']);
614 614
                 $calc->calculate();
615 615
                 $calc->storage();
616
-                $result[] = [
616
+                $result[]=[
617 617
                     'ret' => 'success',
618 618
                     'cid' => $contest['cid'],
619 619
                     'name' => $contest['name']
620 620
                 ];
621
-            }else{
622
-                $result[] = [
621
+            } else {
622
+                $result[]=[
623 623
                     'ret' => 'judging',
624 624
                     'cid' => $contest['cid'],
625 625
                     'name' => $contest['name'],
@@ -631,23 +631,23 @@  discard block
 block discarded – undo
631 631
         return $result;
632 632
     }
633 633
 
634
-    public function getEloChangeLog($gid,$uid)
634
+    public function getEloChangeLog($gid, $uid)
635 635
     {
636
-        $ret = DB::table('group_rated_change_log')
637
-            ->join('contest','group_rated_change_log.cid','=','contest.cid')
636
+        $ret=DB::table('group_rated_change_log')
637
+            ->join('contest', 'group_rated_change_log.cid', '=', 'contest.cid')
638 638
             ->where([
639 639
                 'group_rated_change_log.gid' => $gid,
640 640
                 'group_rated_change_log.uid' => $uid
641 641
             ])->select('group_rated_change_log.cid as cid', 'contest.name as name', 'ranking', 'end_time')
642 642
             ->orderBy('contest.end_time')
643 643
             ->get()->all();
644
-            $begin = [
644
+            $begin=[
645 645
                 'cid' => -1,
646 646
                 'name' => '',
647 647
                 'ranking' => '1500',
648
-                'end_time' => date("Y-m-d H:i:s",(strtotime($ret[0]['end_time'] ?? time())  - 3600*24)),
648
+                'end_time' => date("Y-m-d H:i:s", (strtotime($ret[0]['end_time'] ?? time())-3600 * 24)),
649 649
             ];
650
-            $ret = array_prepend($ret,$begin);
650
+            $ret=array_prepend($ret, $begin);
651 651
         return $ret;
652 652
     }
653 653
 }
Please login to merge, or discard this patch.
app/Http/Controllers/Ajax/GroupManageController.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 
36 36
         $all_data=$request->all();
37 37
 
38
-        if(($all_data['public'] ?? 0) && ($all_data['practice'] ?? 0)){
38
+        if (($all_data['public'] ?? 0) && ($all_data['practice'] ?? 0)) {
39 39
             return ResponseModel::err(4007);
40 40
         }
41 41
 
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
             return ResponseModel::err(1003);
67 67
         }
68 68
 
69
-        $cid = $contestModel->arrangeContest($all_data["gid"], [
69
+        $cid=$contestModel->arrangeContest($all_data["gid"], [
70 70
             "assign_uid"=>Auth::user()->id,
71 71
             "name"=>$all_data["name"],
72 72
             "description"=>$all_data["description"],
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
             "public"=>$all_data["public"] ?? 0,
77 77
         ], $problemSet);
78 78
 
79
-        return ResponseModel::success(200,'Successful!',$cid);
79
+        return ResponseModel::success(200, 'Successful!', $cid);
80 80
     }
81 81
 
82 82
     public function changeGroupName(Request $request)
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 
91 91
         $groupModel=new GroupModel();
92 92
         $clearance=$groupModel->judgeClearance($all_data["gid"], Auth::user()->id);
93
-        if ($clearance < 2){
93
+        if ($clearance<2) {
94 94
             return ResponseModel::err(2001);
95 95
         }
96 96
 
@@ -109,11 +109,11 @@  discard block
 block discarded – undo
109 109
 
110 110
         $groupModel=new GroupModel();
111 111
         $clearance=$groupModel->judgeClearance($all_data["gid"], Auth::user()->id);
112
-        if ($clearance < 2){
112
+        if ($clearance<2) {
113 113
             return ResponseModel::err(2001);
114 114
         }
115 115
 
116
-        if ($all_data["join_policy"] < 1 || $all_data["join_policy"] > 3){
116
+        if ($all_data["join_policy"]<1 || $all_data["join_policy"]>3) {
117 117
             return ResponseModel::err(1007);
118 118
         }
119 119
 
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
             'gid' => 'required|integer',
128 128
         ]);
129 129
 
130
-        $all_data = $request->all();
130
+        $all_data=$request->all();
131 131
 
132 132
         if (!empty($request->file('img')) && $request->file('img')->isValid()) {
133 133
             $extension=$request->file('img')->extension();
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 
140 140
         $groupModel=new GroupModel();
141 141
         $clearance=$groupModel->judgeClearance($all_data["gid"], Auth::user()->id);
142
-        if ($clearance < 2){
142
+        if ($clearance<2) {
143 143
             return ResponseModel::err(2001);
144 144
         }
145 145
 
@@ -177,18 +177,18 @@  discard block
 block discarded – undo
177 177
         $clearance=$groupModel->judgeClearance($all_data["gid"], Auth::user()->id);
178 178
         $target_clearance=$groupModel->judgeClearance($all_data["gid"], $all_data['uid']);
179 179
 
180
-        if($target_clearance == -3){
180
+        if ($target_clearance==-3) {
181 181
             return ResponseModel::err(7004);
182 182
         }
183 183
 
184
-        if($target_clearance >= $clearance || $clearance < 2 || $all_data['permission'] >= $clearance){
184
+        if ($target_clearance>=$clearance || $clearance<2 || $all_data['permission']>=$clearance) {
185 185
             return ResponseModel::err(2001);
186 186
         }
187 187
 
188 188
         $groupModel->changeClearance($all_data['uid'], $all_data["gid"], $all_data['permission']);
189 189
 
190
-        $result_info = $groupModel->userProfile($all_data['uid'],$all_data["gid"]);
191
-        return ResponseModel::success(200,null,$result_info);
190
+        $result_info=$groupModel->userProfile($all_data['uid'], $all_data["gid"]);
191
+        return ResponseModel::success(200, null, $result_info);
192 192
     }
193 193
 
194 194
     public function approveMember(Request $request)
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
         $clearance=$groupModel->judgeClearance($all_data["gid"], Auth::user()->id);
205 205
         $targetClearance=$groupModel->judgeClearance($all_data["gid"], $all_data["uid"]);
206 206
         if ($clearance>1) {
207
-            if($targetClearance!=0) {
207
+            if ($targetClearance!=0) {
208 208
                 return ResponseModel::err(7003);
209 209
             }
210 210
             $groupModel->changeClearance($all_data["uid"], $all_data["gid"], 1);
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
         $groupModel=new GroupModel();
226 226
         $clearance=$groupModel->judgeClearance($all_data["gid"], Auth::user()->id);
227 227
         $targetClearance=$groupModel->judgeClearance($all_data["gid"], $all_data["uid"]);
228
-        if ($clearance <= 1 || $clearance <= $targetClearance){
228
+        if ($clearance<=1 || $clearance<=$targetClearance) {
229 229
             return ResponseModel::err(7002);
230 230
         }
231 231
 
@@ -245,16 +245,16 @@  discard block
 block discarded – undo
245 245
 
246 246
         $groupModel=new GroupModel();
247 247
         $is_user=$groupModel->isUser($all_data["email"]);
248
-        if(!$is_user) return ResponseModel::err(2006);
248
+        if (!$is_user) return ResponseModel::err(2006);
249 249
         $clearance=$groupModel->judgeClearance($all_data["gid"], Auth::user()->id);
250
-        if($clearance<2) return ResponseModel::err(7002);
250
+        if ($clearance<2) return ResponseModel::err(7002);
251 251
         $targetClearance=$groupModel->judgeEmailClearance($all_data["gid"], $all_data["email"]);
252
-        if($targetClearance!=-3) return ResponseModel::err(7003);
252
+        if ($targetClearance!=-3) return ResponseModel::err(7003);
253 253
         $groupModel->inviteMember($all_data["gid"], $all_data["email"]);
254
-        $basic = $groupModel->basic($all_data['gid']);
255
-        $url = route('group.detail',['gcode' => $basic['gcode']]);
256
-        $receiverInfo = UserModel::where('email',$all_data['email'])->first();
257
-        $sender_name = Auth::user()->name;
254
+        $basic=$groupModel->basic($all_data['gid']);
255
+        $url=route('group.detail', ['gcode' => $basic['gcode']]);
256
+        $receiverInfo=UserModel::where('email', $all_data['email'])->first();
257
+        $sender_name=Auth::user()->name;
258 258
         sendMessage([
259 259
             'receiver' => $receiverInfo["id"],
260 260
             'sender' => Auth::user()->id,
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
 
297 297
         $groupModel=new GroupModel();
298 298
         $clearance=$groupModel->judgeClearance($all_data["gid"], Auth::user()->id);
299
-        if ($clearance < 2){
299
+        if ($clearance<2) {
300 300
             return ResponseModel::err(2001);
301 301
         }
302 302
         $groupModel->createNotice($all_data["gid"], Auth::user()->id, $all_data["title"], $all_data["content"]);
Please login to merge, or discard this patch.
app/Admin/Controllers/BabelController.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
     {
133 133
         $extensionList=ExtensionModel::list();
134 134
 
135
-        if(empty($extensionList)){
135
+        if (empty($extensionList)) {
136 136
             return view('admin::babel.empty');
137 137
         }
138 138
 
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
     {
146 146
         $details=ExtensionModel::remoteDetail($code);
147 147
 
148
-        if(empty($details)){
148
+        if (empty($details)) {
149 149
             return view('admin::babel.empty');
150 150
         }
151 151
 
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
     {
159 159
         $details=ExtensionModel::remoteDetail($extension);
160 160
 
161
-        if(empty($details)){
161
+        if (empty($details)) {
162 162
             return view('admin::babel.empty');
163 163
         }
164 164
 
@@ -169,15 +169,15 @@  discard block
 block discarded – undo
169 169
 
170 170
     private static function executeArtisan($command)
171 171
     {
172
-        $fp = popen('php "'.base_path('artisan').'" '.$command, "r");
173
-        while($b = fgets($fp, 2048)) {
172
+        $fp=popen('php "'.base_path('artisan').'" '.$command, "r");
173
+        while ($b=fgets($fp, 2048)) {
174 174
             echo str_pad(json_encode([
175 175
                 "ret"=>200,
176 176
                 "desc"=>"Succeed",
177 177
                 "data"=>[
178 178
                     "message"=>$b
179 179
                 ]
180
-            ])."\n",4096);
180
+            ])."\n", 4096);
181 181
             @ob_flush();
182 182
             flush();
183 183
         }
Please login to merge, or discard this patch.
app/Http/Controllers/OAuth/GithubController.php 1 patch
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -12,20 +12,20 @@  discard block
 block discarded – undo
12 12
 {
13 13
     public function redirectTo()
14 14
     {
15
-        $accountModel = new AccountModel();
16
-        if(Auth::check()){
15
+        $accountModel=new AccountModel();
16
+        if (Auth::check()) {
17 17
             $info=$accountModel->detail(Auth::user()->id);
18
-            if(Auth::check() && $info['contest_account']){
18
+            if (Auth::check() && $info['contest_account']) {
19 19
                 return redirect('/account/settings');
20 20
             }
21 21
         }
22
-        if(Auth::check() && $accountModel->getExtra(Auth::user()->id ,'github_id')){
23
-            return view('oauth.index',[
22
+        if (Auth::check() && $accountModel->getExtra(Auth::user()->id, 'github_id')) {
23
+            return view('oauth.index', [
24 24
                 'page_title'=>"OAuth",
25 25
                 'site_title'=>config("app.name"),
26 26
                 'navigation'=>"OAuth",
27 27
                 'platform' => 'Github',
28
-                'display_html' => 'You\'re already tied to the github account : <span class="text-info">'.$accountModel->getExtra(Auth::user()->id ,'github_email').'</span><br />
28
+                'display_html' => 'You\'re already tied to the github account : <span class="text-info">'.$accountModel->getExtra(Auth::user()->id, 'github_email').'</span><br />
29 29
                 You can choose to unbind or go back to the homepage',
30 30
                 'buttons' => [
31 31
                     [
@@ -45,19 +45,19 @@  discard block
 block discarded – undo
45 45
 
46 46
     public function handleCallback()
47 47
     {
48
-        try{
49
-            $github_user = Socialite::driver('github')->user();
50
-        }catch(\Laravel\Socialite\Two\InvalidStateException $e){
48
+        try {
49
+            $github_user=Socialite::driver('github')->user();
50
+        } catch (\Laravel\Socialite\Two\InvalidStateException $e) {
51 51
             return redirect('/');
52 52
         }
53 53
 
54
-        $accountModel = new AccountModel();
55
-        if(Auth::check()){
56
-            $user_id = Auth::user()->id;
57
-            $ret = $accountModel->findExtra('github_id',$github_user->id);
58
-            if(!empty($ret) && $ret['uid'] != $user_id){
59
-                $user = UserModel::find($ret['uid']);
60
-                return view('oauth.index',[
54
+        $accountModel=new AccountModel();
55
+        if (Auth::check()) {
56
+            $user_id=Auth::user()->id;
57
+            $ret=$accountModel->findExtra('github_id', $github_user->id);
58
+            if (!empty($ret) && $ret['uid']!=$user_id) {
59
+                $user=UserModel::find($ret['uid']);
60
+                return view('oauth.index', [
61 61
                     'page_title'=>"OAuth",
62 62
                     'site_title'=>config("app.name"),
63 63
                     'navigation'=>"OAuth",
@@ -72,17 +72,17 @@  discard block
 block discarded – undo
72 72
                     ]
73 73
                 ]);
74 74
             }
75
-            $accountModel->setExtra($user_id,'github_id',$github_user->id);
76
-            $accountModel->setExtra($user_id,'github_email',$github_user->email);
77
-            $accountModel->setExtra($user_id,'github_nickname',$github_user->nickname);
78
-            $accountModel->setExtra($user_id,'github_homepage',($github_user->user)['html_url']);
79
-            $accountModel->setExtra($user_id,'github_token',$github_user->token,101);
80
-            return view('oauth.index',[
75
+            $accountModel->setExtra($user_id, 'github_id', $github_user->id);
76
+            $accountModel->setExtra($user_id, 'github_email', $github_user->email);
77
+            $accountModel->setExtra($user_id, 'github_nickname', $github_user->nickname);
78
+            $accountModel->setExtra($user_id, 'github_homepage', ($github_user->user)['html_url']);
79
+            $accountModel->setExtra($user_id, 'github_token', $github_user->token, 101);
80
+            return view('oauth.index', [
81 81
                 'page_title'=>"OAuth",
82 82
                 'site_title'=>config("app.name"),
83 83
                 'navigation'=>"OAuth",
84 84
                 'platform' => 'Github',
85
-                'display_html' => 'You have successfully tied up the github account : <span class="text-info">'.$accountModel->getExtra(Auth::user()->id ,'github_email').'</span><br />
85
+                'display_html' => 'You have successfully tied up the github account : <span class="text-info">'.$accountModel->getExtra(Auth::user()->id, 'github_email').'</span><br />
86 86
                 You can log in to '.config("app.name").' later using this account',
87 87
                 'buttons' => [
88 88
                     [
@@ -91,18 +91,18 @@  discard block
 block discarded – undo
91 91
                     ],
92 92
                 ]
93 93
             ]);
94
-        }else{
95
-            $ret = $accountModel->findExtra('github_id',$github_user->id);
96
-            if(!empty($ret)){
94
+        } else {
95
+            $ret=$accountModel->findExtra('github_id', $github_user->id);
96
+            if (!empty($ret)) {
97 97
                 Auth::loginUsingId($ret['uid']);
98
-                $user_id = Auth::user()->id;
99
-                $accountModel->setExtra($user_id,'github_email',$github_user->email);
100
-                $accountModel->setExtra($user_id,'github_nickname',$github_user->nickname);
101
-                $accountModel->setExtra($user_id,'github_homepage',($github_user->user)['html_url']);
102
-                $accountModel->setExtra($user_id,'github_token',$github_user->token,101);
98
+                $user_id=Auth::user()->id;
99
+                $accountModel->setExtra($user_id, 'github_email', $github_user->email);
100
+                $accountModel->setExtra($user_id, 'github_nickname', $github_user->nickname);
101
+                $accountModel->setExtra($user_id, 'github_homepage', ($github_user->user)['html_url']);
102
+                $accountModel->setExtra($user_id, 'github_token', $github_user->token, 101);
103 103
                 return redirect('/');
104
-            }else{
105
-                return view('oauth.index',[
104
+            } else {
105
+                return view('oauth.index', [
106 106
                     'page_title'=>"OAuth",
107 107
                     'site_title'=>config("app.name"),
108 108
                     'navigation'=>"OAuth",
@@ -125,19 +125,19 @@  discard block
 block discarded – undo
125 125
 
126 126
     public function unbind()
127 127
     {
128
-        if(!Auth::check()){
128
+        if (!Auth::check()) {
129 129
             return redirect('/');
130 130
         }
131
-        $accountModel = new AccountModel();
132
-        if($accountModel->getExtra(Auth::user()->id ,'github_id')){
133
-            return view('oauth.index',[
131
+        $accountModel=new AccountModel();
132
+        if ($accountModel->getExtra(Auth::user()->id, 'github_id')) {
133
+            return view('oauth.index', [
134 134
                 'page_title'=>"OAuth",
135 135
                 'site_title'=>config("app.name"),
136 136
                 'navigation'=>"OAuth",
137 137
                 'platform' => 'Github',
138 138
                 'display_html' => 'You are trying to unbind the following two : <br />
139 139
                 Your '.config("app.name").' account : <span class="text-info">'.Auth::user()->email.'</span><br />
140
-                This Github account : <span class="text-info">'.$accountModel->getExtra(Auth::user()->id ,'github_email').'</span><br />
140
+                This Github account : <span class="text-info">'.$accountModel->getExtra(Auth::user()->id, 'github_email').'</span><br />
141 141
                 Make your decision carefully, although you can later establish the binding again',
142 142
                 'buttons' => [
143 143
                     [
@@ -151,8 +151,8 @@  discard block
 block discarded – undo
151 151
                     ],
152 152
                 ]
153 153
             ]);
154
-        }else{
155
-            return view('oauth.index',[
154
+        } else {
155
+            return view('oauth.index', [
156 156
                 'page_title'=>"OAuth",
157 157
                 'site_title'=>config("app.name"),
158 158
                 'navigation'=>"OAuth",
@@ -170,18 +170,18 @@  discard block
 block discarded – undo
170 170
 
171 171
     public function confirmUnbind()
172 172
     {
173
-        if(!Auth::check()){
173
+        if (!Auth::check()) {
174 174
             return redirect('/');
175 175
         }
176
-        $accountModel = new AccountModel();
177
-        $user_id = Auth::user()->id;
178
-        if($accountModel->getExtra($user_id ,'github_id')){
179
-            $accountModel->setExtra($user_id,'github_id',null);
180
-            $accountModel->setExtra($user_id,'github_email',null);
181
-            $accountModel->setExtra($user_id,'github_nickname',null);
182
-            $accountModel->setExtra($user_id,'github_homepage',null);
183
-            $accountModel->setExtra($user_id,'github_token',null);
184
-            return view('oauth.index',[
176
+        $accountModel=new AccountModel();
177
+        $user_id=Auth::user()->id;
178
+        if ($accountModel->getExtra($user_id, 'github_id')) {
179
+            $accountModel->setExtra($user_id, 'github_id', null);
180
+            $accountModel->setExtra($user_id, 'github_email', null);
181
+            $accountModel->setExtra($user_id, 'github_nickname', null);
182
+            $accountModel->setExtra($user_id, 'github_homepage', null);
183
+            $accountModel->setExtra($user_id, 'github_token', null);
184
+            return view('oauth.index', [
185 185
                 'page_title'=>"OAuth",
186 186
                 'site_title'=>config("app.name"),
187 187
                 'navigation'=>"OAuth",
@@ -194,8 +194,8 @@  discard block
 block discarded – undo
194 194
                     ],
195 195
                 ]
196 196
             ]);
197
-        }else{
198
-            return view('oauth.index',[
197
+        } else {
198
+            return view('oauth.index', [
199 199
                 'page_title'=>"OAuth",
200 200
                 'site_title'=>config("app.name"),
201 201
                 'navigation'=>"OAuth",
Please login to merge, or discard this patch.