add option of signing after 0:00 a.m. #21

This commit is contained in:
printempw 2016-07-29 13:57:03 +08:00
parent ce099562d2
commit 63bc3ec4e0
3 changed files with 26 additions and 4 deletions

View File

@ -173,8 +173,17 @@ class User
public function canSign($return_remaining_time = false)
{
// convert to timestamp
$remaining_time = (strtotime($this->getLastSignTime()) + Option::get('sign_gap_time') * 3600 - time()) / 3600;
return $return_remaining_time ? round($remaining_time) : ($remaining_time <= 0);
$last_sign_timestamp = strtotime($this->getLastSignTime());
$zero_timestamp_today = strtotime(date('Y-m-d',time()));
$zero_timestamp_tomorrow = strtotime(date('Y-m-d',strtotime('+1 day')));
if (Option::get('sign_after_zero')) {
$remaining_time = ($zero_timestamp_tomorrow - $last_sign_timestamp) / 3600;
return $return_remaining_time ? round($remaining_time) : ($last_sign_timestamp <= $zero_timestamp_today);
} else {
$remaining_time = ($last_sign_timestamp + Option::get('sign_gap_time') * 3600 - time()) / 3600;
return $return_remaining_time ? round($remaining_time) : ($remaining_time <= 0);
}
}
public function getLastSignTime()

View File

@ -84,6 +84,7 @@
$sign_score = $_POST['sign_score_from'].','.$_POST['sign_score_to'];
Option::set('sign_score', $sign_score);
Option::set('sign_gap_time', $_POST['sign_gap_time']);
Option::set('sign_after_zero', isset($_POST['sign_after_zero']) ? '1' : '0');
echo '<div class="callout callout-success">设置已保存。</div>';
} ?>
<table class="table">
@ -111,6 +112,17 @@
</td>
</tr>
<tr>
<td class="key">签到时间
<i class="fa fa-question-circle" title="勾选后将无视上一条,每天零时后均可签到" data-toggle="tooltip" data-placement="top"></i>
</td>
<td class="value">
<label for="sign_after_zero">
<input {{ (Option::get('sign_after_zero') == '1') ? 'checked="true"' : '' }} type="checkbox" id="sign_after_zero" name="sign_after_zero" value="1"> 每天零点后可签到
</label>
</td>
</tr>
</tbody>
</table>
</div><!-- /.box-body -->

View File

@ -3,7 +3,7 @@
* @Author: printempw
* @Date: 2016-07-29 11:53:11
* @Last Modified by: printempw
* @Last Modified time: 2016-07-29 12:06:38
* @Last Modified time: 2016-07-29 13:35:57
*/
return [
@ -27,5 +27,6 @@ return [
'sign_gap_time' => '24',
'sign_score' => '10,100',
'score_per_storage' => '1',
'score_per_player' => '100'
'score_per_player' => '100',
'sign_after_zero' => '0'
];