add donate until

This commit is contained in:
xiaomlove
2022-04-19 19:18:52 +08:00
parent 7267fb884b
commit 41e3ba55ee
10 changed files with 16 additions and 9 deletions
+1 -1
View File
@@ -434,7 +434,7 @@ class User extends Authenticatable
public function isDonating() public function isDonating()
{ {
if ($this->donoruntil && $this->donoruntil >= Carbon::now()->toDateTimeString()) { if ($this->donor == 'yes' && $this->donoruntil && $this->donoruntil->gte(Carbon::now())) {
return true; return true;
} }
return false; return false;
+2 -2
View File
@@ -800,10 +800,10 @@ class ExamRepository extends BaseRepository
if (!empty($filters->$filter) && count($filters->$filter) == 1) { if (!empty($filters->$filter) && count($filters->$filter) == 1) {
$donateStatus = $filters->$filter[0]; $donateStatus = $filters->$filter[0];
if ($donateStatus == User::DONATE_YES) { if ($donateStatus == User::DONATE_YES) {
$baseQuery->where("$userTable.donoruntil", ">=", Carbon::now()->toDateTimeString()); $baseQuery->where('donor', 'yes')->where("$userTable.donoruntil", ">=", Carbon::now()->toDateTimeString());
} elseif ($donateStatus == User::DONATE_NO) { } elseif ($donateStatus == User::DONATE_NO) {
$baseQuery->where(function (Builder $query) use ($userTable) { $baseQuery->where(function (Builder $query) use ($userTable) {
$query->whereNull("$userTable.donoruntil")->orWhere("$userTable.donoruntil", '<', Carbon::now()->toDateTimeString()); $query->where('donor', 'no')->orWhereNull("$userTable.donoruntil")->orWhere("$userTable.donoruntil", '<', Carbon::now()->toDateTimeString());
}); });
} else { } else {
do_log("{$exam->id} filter $filter: $donateStatus invalid.", "error"); do_log("{$exam->id} filter $filter: $donateStatus invalid.", "error");
+1 -1
View File
@@ -1013,7 +1013,7 @@ class TrackerRepository extends BaseRepository
if ($user->class >= \App\Models\HitAndRun::MINIMUM_IGNORE_USER_CLASS) { if ($user->class >= \App\Models\HitAndRun::MINIMUM_IGNORE_USER_CLASS) {
return; return;
} }
if ($user->donoruntil && $user->donoruntil->gte($now)) { if ($user->isDonating()) {
return; return;
} }
$hrMode = Setting::get('hr.mode'); $hrMode = Setting::get('hr.mode');
+2 -2
View File
@@ -1883,7 +1883,7 @@ function get_user_row($id)
{ {
global $Cache, $CURUSER; global $Cache, $CURUSER;
static $curuserRowUpdated = false; static $curuserRowUpdated = false;
static $neededColumns = array('id', 'noad', 'class', 'enabled', 'privacy', 'avatar', 'signature', 'uploaded', 'downloaded', 'last_access', 'username', 'donor', 'leechwarn', 'warned', 'title'); static $neededColumns = array('id', 'noad', 'class', 'enabled', 'privacy', 'avatar', 'signature', 'uploaded', 'downloaded', 'last_access', 'username', 'donor', 'donoruntil', 'leechwarn', 'warned', 'title');
if ($CURUSER && $id == $CURUSER['id']) { if ($CURUSER && $id == $CURUSER['id']) {
$row = array(); $row = array();
foreach($neededColumns as $column) { foreach($neededColumns as $column) {
@@ -3588,7 +3588,7 @@ function get_username($id, $big = false, $link = true, $bold = true, $target = f
$disabledpic = "disabled"; $disabledpic = "disabled";
$style = "style='margin-left: 2pt'"; $style = "style='margin-left: 2pt'";
} }
$pics = $arr["donor"] == "yes" ? "<img class=\"".$donorpic."\" src=\"pic/trans.gif\" alt=\"Donor\" ".$style." />" : ""; $pics = $arr["donor"] == "yes" && $arr['donoruntil'] !== null && $arr['donoruntil'] >= date('Y-m-d H:i:s') ? "<img class=\"".$donorpic."\" src=\"pic/trans.gif\" alt=\"Donor\" ".$style." />" : "";
if ($arr["enabled"] == "yes") if ($arr["enabled"] == "yes")
$pics .= ($arr["leechwarn"] == "yes" ? "<img class=\"".$leechwarnpic."\" src=\"pic/trans.gif\" alt=\"Leechwarned\" ".$style." />" : "") . ($arr["warned"] == "yes" ? "<img class=\"".$warnedpic."\" src=\"pic/trans.gif\" alt=\"Warned\" ".$style." />" : ""); $pics .= ($arr["leechwarn"] == "yes" ? "<img class=\"".$leechwarnpic."\" src=\"pic/trans.gif\" alt=\"Leechwarned\" ".$style." />" : "") . ($arr["warned"] == "yes" ? "<img class=\"".$warnedpic."\" src=\"pic/trans.gif\" alt=\"Warned\" ".$style." />" : "");
+2
View File
@@ -148,5 +148,7 @@ $lang_userdetails = array
'disable_user_migrated' => '启用或禁用用户请到管理后台操作', 'disable_user_migrated' => '启用或禁用用户请到管理后台操作',
'text_user_id'=> "用户ID/UID", 'text_user_id'=> "用户ID/UID",
'row_medal' => '勋章', 'row_medal' => '勋章',
'row_donoruntil' => '捐赠状态截止时间',
'text_donoruntil_note' => "时间格式为'年年年年-月月-日日 时时:分分:秒秒'。损赠有效需要捐赠状态为'是'且截止时间大于当前时间同时满足。",
); );
?> ?>
+2
View File
@@ -148,5 +148,7 @@ $lang_userdetails = array
'disable_user_migrated' => '啟用或禁用用戶請到管理後臺操作', 'disable_user_migrated' => '啟用或禁用用戶請到管理後臺操作',
'text_user_id'=> "用戶ID/UID", 'text_user_id'=> "用戶ID/UID",
'row_medal' => '勛章', 'row_medal' => '勛章',
'row_donoruntil' => '捐贈狀態截止時間',
'text_donoruntil_note' => "時間格式為'年年年年-月月-日日 時時:分分:秒秒'。損贈有效需要捐贈狀態為'是'且截止時間大於當前時間同時滿足。",
); );
?> ?>
+2
View File
@@ -148,5 +148,7 @@ $lang_userdetails = array
'disable_user_migrated' => 'Enable or disable use please go to the new management system.', 'disable_user_migrated' => 'Enable or disable use please go to the new management system.',
'text_user_id'=> "User ID", 'text_user_id'=> "User ID",
'row_medal' => 'Medal', 'row_medal' => 'Medal',
'row_donoruntil' => 'Donated until',
'text_donoruntil_note' => "Time format is YYYY-MM-DD hh:mm:ss. To be valid, the donation status must be 'Yes' and the deadline is greater than the current time.",
); );
?> ?>
+2 -2
View File
@@ -92,7 +92,7 @@ $seeder = ($left == 0) ? "yes" : "no";
// check passkey // check passkey
if (!$az = $Cache->get_value('user_passkey_'.$passkey.'_content')){ if (!$az = $Cache->get_value('user_passkey_'.$passkey.'_content')){
$res = sql_query("SELECT id, downloadpos, enabled, uploaded, downloaded, class, parked, clientselect, showclienterror, passkey, donoruntil FROM users WHERE passkey=". sqlesc($passkey)." LIMIT 1"); $res = sql_query("SELECT id, downloadpos, enabled, uploaded, downloaded, class, parked, clientselect, showclienterror, passkey, donor, donoruntil FROM users WHERE passkey=". sqlesc($passkey)." LIMIT 1");
$az = mysql_fetch_array($res); $az = mysql_fetch_array($res);
do_log("[check passkey], currentUser: " . nexus_json_encode($az), 'error'); do_log("[check passkey], currentUser: " . nexus_json_encode($az), 'error');
$Cache->cache_value('user_passkey_'.$passkey.'_content', $az, 950); $Cache->cache_value('user_passkey_'.$passkey.'_content', $az, 950);
@@ -452,7 +452,7 @@ elseif(isset($self))
if ( if (
$event == 'completed' $event == 'completed'
&& $az['class'] < \App\Models\HitAndRun::MINIMUM_IGNORE_USER_CLASS && $az['class'] < \App\Models\HitAndRun::MINIMUM_IGNORE_USER_CLASS
&& (empty($az['donoruntil']) || $az['donoruntil'] === '0000-00-00 00:00:00' || $az['donoruntil'] < date("Y-m-d H:i:s")) && ($az['donor'] == 'no' || empty($az['donoruntil']) || $az['donoruntil'] === null || $az['donoruntil'] < date("Y-m-d H:i:s"))
) { ) {
//think about H&R //think about H&R
$hrMode = get_setting('hr.mode'); $hrMode = get_setting('hr.mode');
+1 -1
View File
@@ -161,8 +161,8 @@ if ($action == "edituser")
$updateset[] = "donated = " . sqlesc($donated); $updateset[] = "donated = " . sqlesc($donated);
$updateset[] = "donated_cny = " . sqlesc($donated_cny); $updateset[] = "donated_cny = " . sqlesc($donated_cny);
} }
$updateset[] = "donor = " . sqlesc($donor); $updateset[] = "donor = " . sqlesc($donor);
$updateset[] = "donoruntil = " . sqlesc($_POST['donoruntil']);
} }
if ($chpassword != "" AND $passagain != "") { if ($chpassword != "" AND $passagain != "") {
+1
View File
@@ -363,6 +363,7 @@ if (get_user_class() >= $prfmanage_class && $user["class"] < get_user_class())
{ {
tr($lang_userdetails['row_donor_status'], "<input type=\"radio\" name=\"donor\" value=\"yes\"" .($user["donor"] == "yes" ? " checked=\"checked\"" : "")." />".$lang_userdetails['radio_yes']." <input type=\"radio\" name=\"donor\" value=\"no\"" .($user["donor"] == "no" ? " checked=\"checked\"" : "").">".$lang_userdetails['radio_no'], 1); tr($lang_userdetails['row_donor_status'], "<input type=\"radio\" name=\"donor\" value=\"yes\"" .($user["donor"] == "yes" ? " checked=\"checked\"" : "")." />".$lang_userdetails['radio_yes']." <input type=\"radio\" name=\"donor\" value=\"no\"" .($user["donor"] == "no" ? " checked=\"checked\"" : "").">".$lang_userdetails['radio_no'], 1);
tr($lang_userdetails['row_donated'], "USD: <input type=\"text\" size=\"5\" name=\"donated\" value=\"" . htmlspecialchars($user['donated']) . "\" />&nbsp;&nbsp;&nbsp;&nbsp;CNY: <input type=\"text\" size=\"5\" name=\"donated_cny\" value=\"" . htmlspecialchars($user['donated_cny']) . "\" />" . $lang_userdetails['text_transaction_memo'] . "<input type=\"text\" size=\"50\" name=\"donation_memo\" />", 1); tr($lang_userdetails['row_donated'], "USD: <input type=\"text\" size=\"5\" name=\"donated\" value=\"" . htmlspecialchars($user['donated']) . "\" />&nbsp;&nbsp;&nbsp;&nbsp;CNY: <input type=\"text\" size=\"5\" name=\"donated_cny\" value=\"" . htmlspecialchars($user['donated_cny']) . "\" />" . $lang_userdetails['text_transaction_memo'] . "<input type=\"text\" size=\"50\" name=\"donation_memo\" />", 1);
tr($lang_userdetails['row_donoruntil'], "<input type=\"text\" name=\"donoruntil\" value=\"".htmlspecialchars($user["donoruntil"])."\" /> ".$lang_userdetails['text_donoruntil_note'], 1);
} }
if (get_user_class() == $prfmanage_class) if (get_user_class() == $prfmanage_class)
$maxclass = UC_VIP; $maxclass = UC_VIP;