remove leech warn

This commit is contained in:
xiaomlove
2022-05-13 15:56:09 +08:00
parent 6eeac797a4
commit 155d4ddcb6
10 changed files with 77 additions and 23 deletions
+4 -4
View File
@@ -45,7 +45,7 @@ class NexusUpdate extends Command
require ROOT_PATH . 'nexus/Database/helpers.php';
//Step 1
$step = $this->update->currentStep();
$log = "Step 1, Checking environment...";
$log = sprintf('Step %s, %s...', $step, $this->update->getStepName($step));
$this->doLog($log);
$requirements = $this->update->listRequirementTableRows();
$fails = $requirements['fails'];
@@ -58,17 +58,17 @@ class NexusUpdate extends Command
$this->update->gotoStep(++$step);
//Step 2
$log = "Step 2, get files, cli skip...";
$log = sprintf('Step %s, %s, cli skip...', $step, $this->update->getStepName($step));
$this->doLog($log);
$this->update->gotoStep(++$step);
//Step 3
$log = "Step 3, update .env, cli skip...";
$log = sprintf('Step %s, %s, cli skip...', $step, $this->update->getStepName($step));
$this->doLog($log);
$this->update->gotoStep(++$step);
//Step 4
$log = "Step 4, perform update...";
$log = sprintf('Step %s, %s...', $step, $this->update->getStepName($step));
$this->doLog($log);
$settingTableRows = $this->update->listSettingTableRows();
$settings = $settingTableRows['settings'];
+16
View File
@@ -282,6 +282,22 @@ class UserRepository extends BaseRepository
return true;
}
public function removeLeechWarn($operator, $uid): bool
{
if (!$operator instanceof User) {
$operator = User::query()->findOrFail(intval($operator), User::$commonFields);
}
$classRequire = Setting::get('authority.prfmanage');
if ($operator->class < $classRequire) {
throw new \RuntimeException("No permission.");
}
$user = User::query()->findOrFail($uid, User::$commonFields);
NexusDB::cache_del('user_'.$uid.'_content');
$user->leechwarn = 'no';
$user->leechwarnuntil = null;
return $user->save();
}
}
+1
View File
@@ -151,5 +151,6 @@ $lang_userdetails = array
'row_donoruntil' => '捐赠状态截止时间',
'text_donoruntil_note' => "时间格式为'年年年年-月月-日日 时时:分分:秒秒'。留空永久有效。",
'change_field_value_migrated' => '修改请到管理后台操作',
'sure_to_remove_leech_warn' => '确定要清除此吸血警告吗?',
);
?>
+6 -1
View File
@@ -243,7 +243,12 @@ $lang_usercp = array
'text_show_advertisement_note' => "我想看到廣告",
'row_promotion_link' => "宣傳鏈結",
'text_update_promotion_link' => "更新宣傳鏈結",
'text_read_more' => "了解更多"
'text_read_more' => "了解更多",
'row_two_step_secret' => '兩步驗證',
'text_two_step_secret_bind_by_qrdoe_note' => '你可以使用 Google Authenticator 或 Authy 掃描左側二維碼<br/><br/>如果左側二維碼沒有加載成功,可以嘗試打開此鏈接進行加載:',
'text_two_step_secret_bind_manually_note' => '或者在 APP 中手動輸入以下 Key',
'text_two_step_secret_bind_complete_note' => '輸入 code 完成兩步驗證',
'text_two_step_secret_unbind_note' => '輸入 code 取消兩步驗證',
);
?>
+1
View File
@@ -151,5 +151,6 @@ $lang_userdetails = array
'row_donoruntil' => '捐贈狀態截止時間',
'text_donoruntil_note' => "時間格式為'年年年年-月月-日日 時時:分分:秒秒'。留空永久有效。",
'change_field_value_migrated' => '修改請到管理後臺操作',
'sure_to_remove_leech_warn' => '確定要清除此吸血警告嗎?',
);
?>
+4 -2
View File
@@ -247,8 +247,10 @@ $lang_usercp = array
'text_update_promotion_link' => "Update Promotion Link",
'text_read_more' => "Read More",
'row_two_step_secret' => 'Two step authentication',
'text_two_step_secret_bind_note' => '',
'text_two_step_secret_remove_note' => '',
'text_two_step_secret_bind_by_qrdoe_note' => 'You can use Google Authenticator or Authy to scan the QR code on the left<br/><br/>If the QR code on the left does not load successfully, you can try to open this link to load: ',
'text_two_step_secret_bind_manually_note' => 'Or manually enter the following key in the APP: ',
'text_two_step_secret_bind_complete_note' => 'Enter code to complete the two-step authentication',
'text_two_step_secret_unbind_note' => 'Enter code to cancel two-step authentication',
);
?>
+1
View File
@@ -151,5 +151,6 @@ $lang_userdetails = array
'row_donoruntil' => 'Donated until',
'text_donoruntil_note' => "Time format is YYYY-MM-DD hh:mm:ss. Leave blank permanently.",
'change_field_value_migrated' => 'Modification please go to the background management system.',
'sure_to_remove_leech_warn' => 'Are you sure to remove this leech warn ?',
);
?>
+5
View File
@@ -672,4 +672,9 @@ class Install
$this->doLog("set lock at: $fullFilename, result: " . var_export($res, true));
}
public function getStepName($step): string
{
return $this->steps[$step - 1] ?? '';
}
}
+7
View File
@@ -61,3 +61,10 @@ function removeClaim($params)
return $rep->delete($params['id'], $CURUSER['id']);
}
function removeUserLeechWarn($params)
{
global $CURUSER;
$rep = new \App\Repositories\UserRepository();
return $rep->removeLeechWarn($CURUSER['id'], $params['uid']);
}
+32 -16
View File
@@ -279,6 +279,20 @@ tr_small($lang_userdetails['row_avatar'], return_avatar_image(htmlspecialchars(t
if ($userInfo->valid_medals->isNotEmpty()) {
tr_small($lang_userdetails['row_medal'], build_medal_image($userInfo->valid_medals, 200, $CURUSER['id'] == $user['id']), 1);
$warnMedalJs = <<<JS
jQuery('input[type="checkbox"][name="medal_wearing_status"]').on("change", function (e) {
let input = jQuery(this);
let checked = input.prop("checked")
jQuery.post('ajax.php', {params: {id: this.value}, action: 'toggleUserMedalStatus'}, function (response) {
console.log(response)
if (response.ret != 0) {
input.prop("checked", !checked)
alert(response.msg)
}
}, 'json')
})
JS;
\Nexus\Nexus::js($warnMedalJs, 'footer', false);
}
$uclass = get_user_class_image($user["class"]);
@@ -456,6 +470,24 @@ if (get_user_class() >= $prfmanage_class && $user["class"] < get_user_class())
{
print($lang_userdetails['text_until'].$leechwarnuntil);
print("<br />(" . mkprettytime(strtotime($leechwarnuntil) - strtotime(date("Y-m-d H:i:s"))) .$lang_userdetails['text_to_go'].")");
printf('&nbsp;<input id="remove-leech-warn" type="button" class="btn" value="Remove" data-uid="%s" />', $user['id']);
$removeLeechWarnJs = <<<JS
jQuery('#remove-leech-warn').on('click', function () {
if (!window.confirm('{$lang_userdetails['sure_to_remove_leech_warn']}')) {
return
}
let params = {action: 'removeUserLeechWarn', params: {uid: jQuery(this).attr('data-uid')}}
jQuery.post('ajax.php', params, function (response) {
console.log(response)
if (response.ret == 0) {
location.reload()
} else {
alert(response.msg)
}
}, 'json')
})
JS;
\Nexus\Nexus::js($removeLeechWarnJs, 'footer', false);
}else{
print("<i>".$lang_userdetails['text_for_unlimited_time']."</i>");
}
@@ -504,21 +536,5 @@ if (get_user_class() >= $prfmanage_class && $user["class"] < get_user_class())
}
}
end_main_frame();
echo <<<EOT
<script>
jQuery('input[type="checkbox"][name="medal_wearing_status"]').on("change", function (e) {
let input = jQuery(this);
let checked = input.prop("checked")
jQuery.post('ajax.php', {params: {id: this.value}, action: 'toggleUserMedalStatus'}, function (response) {
console.log(response)
if (response.ret != 0) {
input.prop("checked", !checked)
alert(response.msg)
}
}, 'json')
})
</script>
EOT;
stdfoot();
?>