addHidden("msg_id", $id, function ($msg_id) { global $user; if (!validateUInt($msg_id)) { return '消息 ID 不是有效的数字'; } $msg = DB::selectFirst("select * from user_system_msg where id = {$msg_id}"); if (!$msg || $msg['receiver'] != $user['username']) { return '消息不存在'; } return ''; }, null); $form->handle = function () { $msg_id = $_POST["msg_id"]; DB::delete("delete from user_system_msg where id = {$msg_id}"); }; $form->config['submit_button']['class'] = 'btn btn-link text-decoration-none text-danger p-0'; $form->config['submit_button']['text'] = '删除'; $form->config['submit_container']['class'] = 'd-inline'; $form->config['confirm']['smart'] = true; return $form; } $pag_config = [ 'page_len' => 10, 'col_names' => ['*'], 'table_name' => 'user_system_msg', 'cond' => "receiver = '{$user['username']}'", 'tail' => 'order by send_time desc', ]; $pag = new Paginator($pag_config); $system_msgs = []; foreach ($pag->get() as $idx => $msg) { $system_msgs[$idx] = $msg; if (isSuperUser(Auth::user())) { $delete_form = newDeleteSystemMsgForm($msg['id']); $delete_form->runAtServer(); $system_msgs[$idx]['delete_form'] = $delete_form; } } ?>