Extended profile - make birthday save
This commit is contained in:
parent
1ff1af0fc8
commit
e4eb6719a5
|
@ -399,7 +399,7 @@ class ExtendedProfileWidget extends Form
|
|||
$this->out->element('div', 'label', _m('Description'));
|
||||
$this->out->element('div', 'field', $field['description']);
|
||||
|
||||
$this->out->input(
|
||||
$this->out->textarea(
|
||||
$id . '-description',
|
||||
null,
|
||||
isset($field['description']) ? $field['description'] : null
|
||||
|
@ -463,6 +463,9 @@ class ExtendedProfileWidget extends Form
|
|||
case 'textarea':
|
||||
$this->out->text($this->ext->getTextValue($name));
|
||||
break;
|
||||
case 'date':
|
||||
$this->out->text($this->ext->getTextValue($name));
|
||||
break;
|
||||
case 'tags':
|
||||
$this->out->text($this->ext->getTags());
|
||||
break;
|
||||
|
@ -506,6 +509,9 @@ class ExtendedProfileWidget extends Form
|
|||
case 'text':
|
||||
$out->input($id, null, $this->ext->getTextValue($name));
|
||||
break;
|
||||
case 'date':
|
||||
$out->input($id, null, $this->ext->getTextValue($name));
|
||||
break;
|
||||
case 'textarea':
|
||||
$out->textarea($id, null, $this->ext->getTextValue($name));
|
||||
break;
|
||||
|
|
|
@ -100,6 +100,7 @@ class ProfileDetailSettingsAction extends ProfileSettingsAction
|
|||
$profile = $user->getProfile();
|
||||
|
||||
$simpleFieldNames = array('title', 'spouse', 'kids');
|
||||
$dateFieldNames = array('birthday');
|
||||
|
||||
foreach ($simpleFieldNames as $name) {
|
||||
$value = $this->trimmed('extprofile-' . $name);
|
||||
|
@ -108,6 +109,15 @@ class ProfileDetailSettingsAction extends ProfileSettingsAction
|
|||
}
|
||||
}
|
||||
|
||||
foreach ($dateFieldNames as $name) {
|
||||
$value = $this->trimmed('extprofile-' . $name);
|
||||
$this->saveField(
|
||||
$user,
|
||||
$name,
|
||||
$this->parseDate($name, $value)
|
||||
);
|
||||
}
|
||||
|
||||
$this->savePhoneNumbers($user);
|
||||
$this->saveIms($user);
|
||||
$this->saveWebsites($user);
|
||||
|
@ -123,6 +133,30 @@ class ProfileDetailSettingsAction extends ProfileSettingsAction
|
|||
|
||||
}
|
||||
|
||||
function parseDate($fieldname, $datestr, $required = false)
|
||||
{
|
||||
if (empty($datestr) && $required) {
|
||||
$msg = sprintf(
|
||||
_m('You must supply a date for "%s".'),
|
||||
$fieldname
|
||||
);
|
||||
throw new Exception($msg);
|
||||
} else {
|
||||
$ts = strtotime($datestr);
|
||||
if ($ts === false) {
|
||||
throw new Exception(
|
||||
sprintf(
|
||||
_m('Invalid date entered for "%s": %s'),
|
||||
$fieldname,
|
||||
$ts
|
||||
)
|
||||
);
|
||||
}
|
||||
return common_sql_date($ts);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function savePhoneNumbers($user) {
|
||||
$phones = $this->findPhoneNumbers();
|
||||
$this->removeAll($user, 'phone');
|
||||
|
@ -249,26 +283,10 @@ class ProfileDetailSettingsAction extends ProfileSettingsAction
|
|||
foreach ($experiences as $exp) {
|
||||
list($company, $current, $end, $start) = array_values($exp);
|
||||
if (!empty($company)) {
|
||||
$startTs = strtotime($start);
|
||||
|
||||
if ($startTs === false) {
|
||||
$msg = empty($start) ? _m('You must supply a start date.')
|
||||
: sprintf(_m("Invalid start date: %s"), $start);
|
||||
throw new Exception($msg);
|
||||
}
|
||||
|
||||
$endTs = strtotime($end);
|
||||
|
||||
if ($current === 'false' && $endTs === false) {
|
||||
$msg = empty($end) ? _m('You must supply an end date.')
|
||||
: sprintf(_m("Invalid end date: %s"), $end);
|
||||
throw new Exception($msg);
|
||||
}
|
||||
|
||||
$expArray[] = array(
|
||||
'company' => $company,
|
||||
'start' => common_sql_date($startTs),
|
||||
'end' => common_sql_date($endTs),
|
||||
'start' => $this->parseDate('Start', $start, true),
|
||||
'end' => $this->parseDate('End', $end, true),
|
||||
'current' => ($current == 'false') ? false : true
|
||||
);
|
||||
}
|
||||
|
@ -344,31 +362,13 @@ class ProfileDetailSettingsAction extends ProfileSettingsAction
|
|||
|
||||
foreach ($edus as $edu) {
|
||||
list($school, $degree, $description, $end, $start) = array_values($edu);
|
||||
|
||||
if (!empty($school)) {
|
||||
|
||||
$startTs = strtotime($start);
|
||||
|
||||
if ($startTs === false) {
|
||||
$msg = empty($start) ? _m('You must supply a start date.')
|
||||
: sprintf(_m("Invalid start date: %s"), $start);
|
||||
throw new Exception($msg);
|
||||
}
|
||||
|
||||
$endTs = strtotime($end);
|
||||
|
||||
if ($endTs === false) {
|
||||
$msg = empty($end) ? _m('You must supply an end date.')
|
||||
: sprintf(_m("Invalid end date: %s"), $end);
|
||||
throw new Exception($msg);
|
||||
}
|
||||
|
||||
$eduArray[] = array(
|
||||
'school' => $school,
|
||||
'degree' => $degree,
|
||||
'description' => $description,
|
||||
'start' => common_sql_date($startTs),
|
||||
'end' => common_sql_date($endTs)
|
||||
'start' => $this->parseDate('Start', $start, true),
|
||||
'end' => $this->parseDate('End', $end, true)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user