diff --git a/hwe/j_board_article_add.php b/hwe/j_board_article_add.php index 5d78c074..e212a239 100644 --- a/hwe/j_board_article_add.php +++ b/hwe/j_board_article_add.php @@ -68,6 +68,7 @@ $db->insert('board', [ ]); Json::die([ - 'result'=>false, - 'reason'=>'success' + 'result'=>true, + 'reason'=>'success', + 'row_id'=>$db->insertId() ]); \ No newline at end of file diff --git a/hwe/j_board_comment_add.php b/hwe/j_board_comment_add.php index f5f8a04d..42d56c20 100644 --- a/hwe/j_board_comment_add.php +++ b/hwe/j_board_comment_add.php @@ -76,6 +76,7 @@ $db->insert('comment', [ ]); Json::die([ - 'result'=>false, - 'reason'=>'success' + 'result'=>true, + 'reason'=>'success', + 'row_id'=>$db->insertId() ]); \ No newline at end of file diff --git a/hwe/j_diplomacy_respond_letter.php b/hwe/j_diplomacy_respond_letter.php new file mode 100644 index 00000000..b2fd78ba --- /dev/null +++ b/hwe/j_diplomacy_respond_letter.php @@ -0,0 +1,84 @@ +setReadOnly(); +$userID = Session::getUserID(); + +$db = DB::db(); + +$letterNo = Util::getReq('letterNo', 'int'); +$isAgree = Util::getReq('isAgree', 'bool', false); +$reason = Util::getReq('reason', 'string', ''); + + + + +increaseRefresh("회의실", 1); + +$me = $db->queryFirstRow('SELECT no, nation, level, permission, con, turntime, belong, penalty FROM general WHERE owner=%i', $userID); + +$con = checkLimit($me['con']); +if ($con >= 2) { + Json::die([ + 'result'=>false, + 'reason'=>'접속 제한입니다.' + ]); +} + +if($letterNo === null){ + Json::die([ + 'result'=>false, + 'reason'=>'올바르지 않은 입력입니다.' + ]); +} + + +$permission = checkSecretPermission($me); +if ($permission < 4) { + Json::die([ + 'result'=>false, + 'reason'=>'권한이 부족합니다. 수뇌부가 아닙니다.' + ]); +} + +$reason = trim($reason); + +$letter = $db->queryFirstRow('SELECT * FROM ng_diplomacy WHERE no=%i AND dest_nation_id = %i AND state = \'proposed\'', $letterNo, $me['nation']); +if(!$letter){ + Json::die([ + 'result'=>false, + 'reason'=>'서신이 없습니다.' + ]); +} + +$aux = Json::decode($letter['aux']); + +if($isAgree){ + $aux['dest']['generalName'] = $me['name']; + $db->update('ng_diplomacy', [ + 'state'=>'activated', + 'dest_signer'=>$me['no'], + 'aux'=>Json::encode($aux) + ], 'no=%i', $letterNo); + //TODO: 외교 서신에 대한 메시지를 양국에 발송해야함 +} +else{ + $aux['reason'] = [ + 'who'=>$me['no'], + 'action'=>'disagree', + 'reason'=>$reason + ]; + $db->update('ng_diplomacy', [ + 'state'=>'cancelled', + 'aux'=>Json::encode($aux) + ]); + //TODO: 외교 서신에 대한 메시지를 양국에 발송해야함 +} + +Json::die([ + 'result'=>true, + 'reason'=>'success' +]); \ No newline at end of file diff --git a/hwe/j_diplomacy_send_letter.php b/hwe/j_diplomacy_send_letter.php index 56a4aeb0..70becf13 100644 --- a/hwe/j_diplomacy_send_letter.php +++ b/hwe/j_diplomacy_send_letter.php @@ -52,7 +52,7 @@ if(!$textBrief){ $permission = checkSecretPermission($me); -if ($permission < 2) { +if ($permission < 4) { Json::die([ 'result'=>false, 'reason'=>'권한이 부족합니다. 수뇌부가 아닙니다.' @@ -89,7 +89,8 @@ if($prevNo !== null){ $prevAux = Json::decode($prevLetter['aux']); $prevAux['reason'] = [ 'who'=>$me['no'], - 'action'=>'new_letter' + 'action'=>'new_letter', + 'reason'=>'new_letter' ]; $db->update('ng_diplomacy', [ 'state'=>'cancelled', @@ -131,8 +132,11 @@ $db->insert('ng_diplomacy', [ ]), ]); + +//TODO: 외교 서신에 대한 메시지를 양국에 발송해야함 + Json::die([ - 'result'=>false, + 'result'=>true, 'reason'=>'success', 'row_id'=>$db->insertId() ]); \ No newline at end of file