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'],