From 0bf568a655fede2e12e90960659f51f4e4187318 Mon Sep 17 00:00:00 2001 From: Hide_D Date: Fri, 19 Aug 2022 01:27:11 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EA=B5=AD=EB=B0=A9=20=EC=84=A4=EC=A0=95?= =?UTF-8?q?=20=EC=8B=9C,=20=EC=9E=91=EC=84=B1=EC=9E=90=EC=99=80=20?= =?UTF-8?q?=EC=9E=91=EC=84=B1=20=EC=9D=BC=EC=8B=9C=EB=A5=BC=20=EA=B8=B0?= =?UTF-8?q?=EB=A1=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/func.php | 4 ++-- hwe/func_gamerule.php | 2 +- hwe/sammo/API/Nation/SetNotice.php | 10 ++++++++-- hwe/v_nationStratFinan.php | 2 +- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/hwe/func.php b/hwe/func.php index 0d6b22e0..e7546e1e 100644 --- a/hwe/func.php +++ b/hwe/func.php @@ -906,7 +906,7 @@ function nationMsg(General $general) $nationID = $general->getNationID(); $nationStor = KVStorage::getStorage($db, $nationID, 'nation_env'); - return $nationStor->notice ?? ''; + return $nationStor->nationNotice['msg'] ?? ''; } function banner() @@ -1812,7 +1812,7 @@ function deleteNation(General $lord, bool $applyDB): array $nation['generals'] = array_keys($nationGeneralList); $nation['aux'] = Json::decode($nation['aux']); - $nation['msg'] = $nationStor->notice; + $nation['msg'] = $nationStor->nationNotice['msg'] ?? ''; $nation['scout_msg'] = $nationStor->scout_msg; $nation['aux'] += $nationStor->max_power; $nation['history'] = getNationHistoryLogAll($nationID); diff --git a/hwe/func_gamerule.php b/hwe/func_gamerule.php index b01cf691..6c296a68 100644 --- a/hwe/func_gamerule.php +++ b/hwe/func_gamerule.php @@ -1142,7 +1142,7 @@ function checkEmperior() $nation = $nation; $nation['generals'] = $db->queryFirstColumn('SELECT `no` FROM general WHERE nation=%i', $nation['nation']); $nation['aux'] = Json::decode($nation['aux']); - $nation['msg'] = $nationStor->notice; + $nation['msg'] = $nationStor->nationNotice['msg'] ?? '';; $nation['scout_msg'] = $nationStor->scout_msg; $nation['aux'] += $nationStor->max_power; $nation['history'] = getNationHistoryLogAll($nation['nation']); diff --git a/hwe/sammo/API/Nation/SetNotice.php b/hwe/sammo/API/Nation/SetNotice.php index 6c30ac57..c52c5dc1 100644 --- a/hwe/sammo/API/Nation/SetNotice.php +++ b/hwe/sammo/API/Nation/SetNotice.php @@ -6,6 +6,7 @@ use sammo\Session; use DateTimeInterface; use sammo\DB; use sammo\KVStorage; +use sammo\TimeUtil; use sammo\Validator; use sammo\WebUtil; @@ -36,7 +37,7 @@ class SetNotice extends \sammo\BaseAPI $msg = $this->args['msg']; $userID = $session->userID; $db = DB::db(); - $me = $db->queryFirstRow('SELECT `no`,nation,`officer_level`,permission,penalty FROM general WHERE `owner`=%i', $userID); + $me = $db->queryFirstRow('SELECT `no`,`name`,nation,`officer_level`,permission,penalty FROM general WHERE `owner`=%i', $userID); $permission = checkSecretPermission($me, false); if($permission < 0){ @@ -49,7 +50,12 @@ class SetNotice extends \sammo\BaseAPI $nationID = $me['nation']; $nationStor = KVStorage::getStorage($db, $nationID, 'nation_env'); - $nationStor->notice = WebUtil::htmlPurify($msg); + $nationStor->nationNotice = [ + 'date'=>TimeUtil::now(), + 'msg'=>WebUtil::htmlPurify($msg), + 'author'=>$me['name'], + 'authorID'=>$me['no'], + ]; return [ 'result' => true diff --git a/hwe/v_nationStratFinan.php b/hwe/v_nationStratFinan.php index a7320ecb..96163cd7 100644 --- a/hwe/v_nationStratFinan.php +++ b/hwe/v_nationStratFinan.php @@ -122,7 +122,7 @@ $outcome = getOutcome(100, $dedicationList); [ 'editable' => ($me['officer_level'] >= 5 || $permission == 4), - 'nationMsg' => $nationStor->notice ?? '', + 'nationMsg' => $nationStor->nationNotice['msg'] ?? '', 'scoutMsg' => $nationStor->scout_msg ?? '', 'nationID' => $nationID, 'officerLevel' => $me['officer_level'],