Add support for NULLs as user_birthday

This commit is contained in:
Yury Buldakov 2017-08-27 07:05:01 +03:00
commit 59916c9bf5
4 changed files with 8 additions and 7 deletions

View file

@ -321,9 +321,9 @@ foreach ($profile_fields as $field => $can_edit) {
* Возраст (edit)
*/
case 'user_birthday':
$user_birthday = isset($_POST['user_birthday']) ? (string)$_POST['user_birthday'] : $pr_data['user_birthday'];
$user_birthday = !empty($_POST['user_birthday']) ? (string)$_POST['user_birthday'] : $pr_data['user_birthday'];
if ($submit && $user_birthday != $pr_data['user_birthday']) {
if ($submit && $user_birthday !== $pr_data['user_birthday']) {
$birthday_date = date_parse($user_birthday);
if (!empty($birthday_date['year'])) {
@ -336,8 +336,7 @@ foreach ($profile_fields as $field => $can_edit) {
}
}
$pr_data['user_birthday'] = $user_birthday;
$db_data['user_birthday'] = $user_birthday;
$pr_data['user_birthday'] = $db_data['user_birthday'] = !empty($user_birthday) ? $user_birthday : null;
}
$tp_data['USER_BIRTHDAY'] = $pr_data['user_birthday'];
break;

View file

@ -114,8 +114,8 @@ $template->assign_vars(array(
'TWITTER' => $profiledata['user_twitter'],
'USER_POINTS' => $profiledata['user_points'],
'GENDER' => ($bb_cfg['gender']) ? $lang['GENDER_SELECT'][$profiledata['user_gender']] : '',
'BIRTHDAY' => ($bb_cfg['birthday_enabled'] && $profiledata['user_birthday'] != '0000-00-00') ? $profiledata['user_birthday'] : '',
'AGE' => ($bb_cfg['birthday_enabled'] && $profiledata['user_birthday'] != '0000-00-00') ? birthday_age($profiledata['user_birthday']) : '',
'BIRTHDAY' => ($bb_cfg['birthday_enabled'] && !empty($profiledata['user_birthday']) && $profiledata['user_birthday'] != '0000-00-00') ? $profiledata['user_birthday'] : '',
'AGE' => ($bb_cfg['birthday_enabled'] && !empty($profiledata['user_birthday']) && $profiledata['user_birthday'] != '0000-00-00') ? birthday_age($profiledata['user_birthday']) : '',
'L_VIEWING_PROFILE' => sprintf($lang['VIEWING_USER_PROFILE'], $profiledata['username']),
'L_MY_PROFILE' => sprintf($lang['VIEWING_MY_PROFILE'], 'profile.php?mode=editprofile'),