add clear shout box

This commit is contained in:
xiaomlove
2022-10-23 19:42:08 +08:00
parent c98e5153d5
commit 71bd2ad3f7
5 changed files with 39 additions and 2 deletions

View File

@@ -105,6 +105,8 @@ $lang_index = array
'top_uploader_toggle_time_range_tab' => '点击切换时间范围',
'top_uploader_toggle_time_range_recently' => '最近 30 天',
'top_uploader_toggle_time_range_all' => '全部时间',
'clear_shout_box' => '清空群聊区',
'sure_to_clear_shout_box' => '确定要清空群聊区吗?',
);

View File

@@ -104,6 +104,8 @@ $lang_index = array
'top_uploader_toggle_time_range_tab' => '點擊切換時間範圍',
'top_uploader_toggle_time_range_recently' => '最近 30 天',
'top_uploader_toggle_time_range_all' => '全部時間',
'clear_shout_box' => '清空群聊區',
'sure_to_clear_shout_box' => '確定要清空群聊區嗎?',
);
?>

View File

@@ -104,6 +104,8 @@ $lang_index = array
'top_uploader_toggle_time_range_tab' => 'Click to toggle the time range',
'top_uploader_toggle_time_range_recently' => 'Last 30 days',
'top_uploader_toggle_time_range_all' => 'All time',
'clear_shout_box' => 'Clear shout box',
'sure_to_clear_shout_box' => 'Are you sure you want to clear the shout box?',
);
?>

View File

@@ -123,3 +123,11 @@ function consumeBenefit($params)
$rep = new \App\Repositories\UserRepository();
return $rep->consumeBenefit($CURUSER['id'], $params);
}
function clearShoutBox($params)
{
global $CURUSER;
user_can('sbmanage', true);
\Nexus\Database\NexusDB::table('shoutbox')->delete();
return true;
}

View File

@@ -137,10 +137,33 @@ if ($showfunbox_main == "yes" && (!isset($CURUSER) || $CURUSER['showfb'] == "yes
// ------------- start: shoutbox ------------------//
if ($showshoutbox_main == "yes") {
?>
<h2><?php echo $lang_index['text_shoutbox'] ?> - <font class="small"><?php echo $lang_index['text_auto_refresh_after']?></font><font class='striking' id="countdown"></font><font class="small"><?php echo $lang_index['text_seconds']?></font></h2>
<h2>
<?php echo $lang_index['text_shoutbox'] ?> - <font class="small"><?php echo $lang_index['text_auto_refresh_after']?></font>
<font class='striking' id="countdown"></font><font class="small"><?php echo $lang_index['text_seconds']?></font>
<?php
if (user_can('sbmanage')) {
echo ' - <font class="small" id="clear-shout-box">[<a class="altlink" href="javascript:;"><b>'.$lang_index['clear_shout_box'].'</b></a>]</font>';
$clearShoutBoxJs = <<<JS
jQuery('#clear-shout-box').on("click", function () {
layer.confirm("{$lang_index['sure_to_clear_shout_box']}", {title: "Info", btn: ['Yes', "Cancel"], btnAlign: 'c'}, function (layerIndex) {
jQuery.post("ajax.php", {"action": "clearShoutBox"}, function (response) {
layer.close(layerIndex)
if (response.ret != 0) {
layer.alert(response.msg, {title: "Info", btn: ['OK', 'Cancel'], btnAlign: 'c'})
} else {
document.getElementById('iframe-shout-box').src='shoutbox.php?type=shoutbox';
}
}, "json")
})
})
JS;
\Nexus\Nexus::js($clearShoutBoxJs, 'footer', false);
}
?>
</h2>
<?php
print("<table width=\"100%\"><tr><td class=\"text\">\n");
print("<iframe src='shoutbox.php?type=shoutbox' width='100%' height='180' frameborder='0' name='sbox' marginwidth='0' marginheight='0'></iframe><br /><br />\n");
print("<iframe id='iframe-shout-box' src='shoutbox.php?type=shoutbox' width='100%' height='180' frameborder='0' name='sbox' marginwidth='0' marginheight='0'></iframe><br /><br />\n");
print("<form action='shoutbox.php' method='get' target='sbox' name='shbox'>\n");
print('<div style="display: flex">');
print("<label for='shbox_text'>".$lang_index['text_message']."</label><input type='text' name='shbox_text' id='shbox_text' size='100' style='flex-grow: 1; border: 1px solid gray;' /> <input type='submit' id='hbsubmit' class='btn' name='shout' value=\"".$lang_index['sumbit_shout']."\" />");