Extended profile - make experience save and display
This commit is contained in:
parent
27c75dd4bb
commit
07ccb6a9f8
@ -131,24 +131,36 @@ class ExtendedProfile
|
|||||||
|
|
||||||
function getExperiences()
|
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;
|
$start = (isset($this->fields['start'])) ? $this->fields['start'] : null;
|
||||||
$end = (isset($this->fields['end'])) ? $this->fields['end'] : null;
|
$end = (isset($this->fields['end'])) ? $this->fields['end'] : null;
|
||||||
|
|
||||||
$cArrays = array();
|
$eArrays = array();
|
||||||
|
|
||||||
if (empty($experiences)) {
|
if (empty($companies)) {
|
||||||
$eArrays[] = array(
|
$eArrays[] = array(
|
||||||
'label' => _m('Employer'),
|
'label' => _m('Employer'),
|
||||||
'type' => 'experience',
|
'type' => 'experience',
|
||||||
'company' => "Bozotronix",
|
'company' => null,
|
||||||
'start' => '1/5/10',
|
'start' => null,
|
||||||
'end' => '2/3/11',
|
'end' => null,
|
||||||
'current' => true,
|
'current' => false,
|
||||||
'index' => 0
|
'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;
|
return $eArrays;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -241,6 +241,10 @@ class ExtendedProfileWidget extends Form
|
|||||||
);
|
);
|
||||||
$this->out->elementEnd('li');
|
$this->out->elementEnd('li');
|
||||||
$this->out->elementStart('li');
|
$this->out->elementStart('li');
|
||||||
|
$this->out->hidden(
|
||||||
|
$id . '-current',
|
||||||
|
'false'
|
||||||
|
);
|
||||||
$this->out->checkbox(
|
$this->out->checkbox(
|
||||||
$id . '-current',
|
$id . '-current',
|
||||||
_m('Current'),
|
_m('Current'),
|
||||||
|
@ -96,10 +96,6 @@ class ProfileDetailSettingsAction extends ProfileSettingsAction
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
$this->saveStandardProfileDetails($user);
|
$this->saveStandardProfileDetails($user);
|
||||||
} catch (Exception $e) {
|
|
||||||
$this->showForm($e->getMessage(), false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$profile = $user->getProfile();
|
$profile = $user->getProfile();
|
||||||
|
|
||||||
@ -115,6 +111,11 @@ class ProfileDetailSettingsAction extends ProfileSettingsAction
|
|||||||
$this->savePhoneNumbers($user);
|
$this->savePhoneNumbers($user);
|
||||||
$this->saveExperiences($user);
|
$this->saveExperiences($user);
|
||||||
|
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$this->showForm($e->getMessage(), false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$this->showForm(_('Details saved.'), true);
|
$this->showForm(_('Details saved.'), true);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -170,11 +171,31 @@ class ProfileDetailSettingsAction extends ProfileSettingsAction
|
|||||||
$expArray = array();
|
$expArray = array();
|
||||||
|
|
||||||
foreach ($experiences as $exp) {
|
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(
|
$expArray[] = array(
|
||||||
'company' => $company,
|
'company' => $company,
|
||||||
'start' => $start,
|
'start' => common_sql_date($startTs),
|
||||||
'end' => $end,
|
'end' => common_sql_date($endTs),
|
||||||
'current' => $current,
|
'current' => $current,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -201,7 +222,7 @@ class ProfileDetailSettingsAction extends ProfileSettingsAction
|
|||||||
null,
|
null,
|
||||||
$i
|
$i
|
||||||
);
|
);
|
||||||
/*
|
|
||||||
$this->saveField(
|
$this->saveField(
|
||||||
$user,
|
$user,
|
||||||
'start',
|
'start',
|
||||||
@ -230,7 +251,7 @@ class ProfileDetailSettingsAction extends ProfileSettingsAction
|
|||||||
$experience['end']
|
$experience['end']
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user