function getExperiences()
{
- $companies = (isset($this->fields['companies'])) ? $this->fields['company'] : null;
+ $companies = (isset($this->fields['company'])) ? $this->fields['company'] : null;
$start = (isset($this->fields['start'])) ? $this->fields['start'] : null;
$end = (isset($this->fields['end'])) ? $this->fields['end'] : null;
- $cArrays = array();
+ $eArrays = array();
- if (empty($experiences)) {
+ if (empty($companies)) {
$eArrays[] = array(
'label' => _m('Employer'),
'type' => 'experience',
- 'company' => "Bozotronix",
- 'start' => '1/5/10',
- 'end' => '2/3/11',
- 'current' => true,
+ 'company' => null,
+ 'start' => null,
+ 'end' => null,
+ 'current' => false,
'index' => 0
);
+ } else {
+ for ($i = 0; $i < sizeof($companies); $i++) {
+ $ea = array(
+ 'label' => _m('Employer'),
+ 'type' => 'experience',
+ 'company' => $companies[$i]->field_value,
+ 'index' => intval($companies[$i]->value_index),
+ 'current' => $end[$i]->rel,
+ 'start' => $start[$i]->date,
+ 'end' => $end[$i]->date
+ );
+ $eArrays[] = $ea;
+ }
}
-
return $eArrays;
}
$user = common_current_user();
try {
- $this->saveStandardProfileDetails($user);
- } catch (Exception $e) {
- $this->showForm($e->getMessage(), false);
- return;
- }
+ $this->saveStandardProfileDetails($user);
- $profile = $user->getProfile();
+ $profile = $user->getProfile();
- $simpleFieldNames = array('title', 'spouse', 'kids');
+ $simpleFieldNames = array('title', 'spouse', 'kids');
- foreach ($simpleFieldNames as $name) {
- $value = $this->trimmed('extprofile-' . $name);
- if (!empty($value)) {
- $this->saveField($user, $name, $value);
+ foreach ($simpleFieldNames as $name) {
+ $value = $this->trimmed('extprofile-' . $name);
+ if (!empty($value)) {
+ $this->saveField($user, $name, $value);
+ }
}
- }
- $this->savePhoneNumbers($user);
- $this->saveExperiences($user);
+ $this->savePhoneNumbers($user);
+ $this->saveExperiences($user);
+
+ } catch (Exception $e) {
+ $this->showForm($e->getMessage(), false);
+ return;
+ }
$this->showForm(_('Details saved.'), true);
$expArray = array();
foreach ($experiences as $exp) {
- list($company, $current, $start, $end) = array_values($exp);
+
+ common_debug('Experience: ' . var_export($exp, true));
+
+ list($company, $current, $end, $start) = array_values($exp);
+
+ $startTs = strtotime($start);
+
+ if ($startTs === false) {
+ throw new Exception(
+ sprintf(_m("Invalid start date: %s"), $start)
+ );
+ }
+
+ $endTs = strtotime($end);
+
+ if ($current === 'false' && $endTs === false) {
+ throw new Exception(
+ sprintf(_m("Invalid end date: %s"), $start)
+ );
+ }
+
$expArray[] = array(
'company' => $company,
- 'start' => $start,
- 'end' => $end,
+ 'start' => common_sql_date($startTs),
+ 'end' => common_sql_date($endTs),
'current' => $current,
);
}
null,
$i
);
- /*
+
$this->saveField(
$user,
'start',
$experience['end']
);
}
- */
+
}
}
}