$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
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;
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;
$profile = $user->getProfile();
$simpleFieldNames = array('title', 'spouse', 'kids');
+ $dateFieldNames = array('birthday');
foreach ($simpleFieldNames as $name) {
$value = $this->trimmed('extprofile-' . $name);
}
}
+ 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);
}
+ 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');
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
);
}
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)
);
}
}