@@ -10,8 +10,8 @@ discard block |
||
| 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 |
||
| 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', [ |
@@ -245,11 +245,17 @@ |
||
| 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) { |
|
| 249 | + return ResponseModel::err(2006); |
|
| 250 | + } |
|
| 249 | 251 | $clearance=$groupModel->judgeClearance($all_data["gid"], Auth::user()->id); |
| 250 | - if($clearance<2) return ResponseModel::err(7002); |
|
| 252 | + if($clearance<2) { |
|
| 253 | + return ResponseModel::err(7002); |
|
| 254 | + } |
|
| 251 | 255 | $targetClearance=$groupModel->judgeEmailClearance($all_data["gid"], $all_data["email"]); |
| 252 | - if($targetClearance!=-3) return ResponseModel::err(7003); |
|
| 256 | + if($targetClearance!=-3) { |
|
| 257 | + return ResponseModel::err(7003); |
|
| 258 | + } |
|
| 253 | 259 | $groupModel->inviteMember($all_data["gid"], $all_data["email"]); |
| 254 | 260 | $basic = $groupModel->basic($all_data['gid']); |
| 255 | 261 | $url = route('group.detail',['gcode' => $basic['gcode']]); |
@@ -35,7 +35,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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"]); |
@@ -15,24 +15,24 @@ |
||
| 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 | } |
@@ -110,8 +110,8 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
@@ -132,7 +132,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | } |