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', 'label', _m('Description'));
|
||||||
$this->out->element('div', 'field', $field['description']);
|
$this->out->element('div', 'field', $field['description']);
|
||||||
|
|
||||||
$this->out->input(
|
$this->out->textarea(
|
||||||
$id . '-description',
|
$id . '-description',
|
||||||
null,
|
null,
|
||||||
isset($field['description']) ? $field['description'] : null
|
isset($field['description']) ? $field['description'] : null
|
||||||
@ -463,6 +463,9 @@ class ExtendedProfileWidget extends Form
|
|||||||
case 'textarea':
|
case 'textarea':
|
||||||
$this->out->text($this->ext->getTextValue($name));
|
$this->out->text($this->ext->getTextValue($name));
|
||||||
break;
|
break;
|
||||||
|
case 'date':
|
||||||
|
$this->out->text($this->ext->getTextValue($name));
|
||||||
|
break;
|
||||||
case 'tags':
|
case 'tags':
|
||||||
$this->out->text($this->ext->getTags());
|
$this->out->text($this->ext->getTags());
|
||||||
break;
|
break;
|
||||||
@ -506,6 +509,9 @@ class ExtendedProfileWidget extends Form
|
|||||||
case 'text':
|
case 'text':
|
||||||
$out->input($id, null, $this->ext->getTextValue($name));
|
$out->input($id, null, $this->ext->getTextValue($name));
|
||||||
break;
|
break;
|
||||||
|
case 'date':
|
||||||
|
$out->input($id, null, $this->ext->getTextValue($name));
|
||||||
|
break;
|
||||||
case 'textarea':
|
case 'textarea':
|
||||||
$out->textarea($id, null, $this->ext->getTextValue($name));
|
$out->textarea($id, null, $this->ext->getTextValue($name));
|
||||||
break;
|
break;
|
||||||
|
@ -100,6 +100,7 @@ class ProfileDetailSettingsAction extends ProfileSettingsAction
|
|||||||
$profile = $user->getProfile();
|
$profile = $user->getProfile();
|
||||||
|
|
||||||
$simpleFieldNames = array('title', 'spouse', 'kids');
|
$simpleFieldNames = array('title', 'spouse', 'kids');
|
||||||
|
$dateFieldNames = array('birthday');
|
||||||
|
|
||||||
foreach ($simpleFieldNames as $name) {
|
foreach ($simpleFieldNames as $name) {
|
||||||
$value = $this->trimmed('extprofile-' . $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->savePhoneNumbers($user);
|
||||||
$this->saveIms($user);
|
$this->saveIms($user);
|
||||||
$this->saveWebsites($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) {
|
function savePhoneNumbers($user) {
|
||||||
$phones = $this->findPhoneNumbers();
|
$phones = $this->findPhoneNumbers();
|
||||||
$this->removeAll($user, 'phone');
|
$this->removeAll($user, 'phone');
|
||||||
@ -249,26 +283,10 @@ class ProfileDetailSettingsAction extends ProfileSettingsAction
|
|||||||
foreach ($experiences as $exp) {
|
foreach ($experiences as $exp) {
|
||||||
list($company, $current, $end, $start) = array_values($exp);
|
list($company, $current, $end, $start) = array_values($exp);
|
||||||
if (!empty($company)) {
|
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(
|
$expArray[] = array(
|
||||||
'company' => $company,
|
'company' => $company,
|
||||||
'start' => common_sql_date($startTs),
|
'start' => $this->parseDate('Start', $start, true),
|
||||||
'end' => common_sql_date($endTs),
|
'end' => $this->parseDate('End', $end, true),
|
||||||
'current' => ($current == 'false') ? false : true
|
'current' => ($current == 'false') ? false : true
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -344,31 +362,13 @@ class ProfileDetailSettingsAction extends ProfileSettingsAction
|
|||||||
|
|
||||||
foreach ($edus as $edu) {
|
foreach ($edus as $edu) {
|
||||||
list($school, $degree, $description, $end, $start) = array_values($edu);
|
list($school, $degree, $description, $end, $start) = array_values($edu);
|
||||||
|
|
||||||
if (!empty($school)) {
|
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(
|
$eduArray[] = array(
|
||||||
'school' => $school,
|
'school' => $school,
|
||||||
'degree' => $degree,
|
'degree' => $degree,
|
||||||
'description' => $description,
|
'description' => $description,
|
||||||
'start' => common_sql_date($startTs),
|
'start' => $this->parseDate('Start', $start, true),
|
||||||
'end' => common_sql_date($endTs)
|
'end' => $this->parseDate('End', $end, true)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user