Make phone number save and display from DB
This commit is contained in:
parent
3592397d77
commit
8efd2cf04d
@ -37,8 +37,10 @@ class ExtendedProfile
|
|||||||
{
|
{
|
||||||
$this->profile = $profile;
|
$this->profile = $profile;
|
||||||
$this->user = $profile->getUser();
|
$this->user = $profile->getUser();
|
||||||
$this->sections = $this->getSections();
|
|
||||||
$this->fields = $this->loadFields();
|
$this->fields = $this->loadFields();
|
||||||
|
$this->sections = $this->getSections();
|
||||||
|
//common_debug(var_export($this->sections, true));
|
||||||
|
|
||||||
//common_debug(var_export($this->fields, true));
|
//common_debug(var_export($this->fields, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,19 +98,36 @@ class ExtendedProfile
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function getPhones()
|
function getPhones()
|
||||||
{
|
{
|
||||||
return array(
|
$phones = $this->fields['phone'];
|
||||||
|
$pArrays = array();
|
||||||
|
|
||||||
|
if (empty($phones)) {
|
||||||
|
$pArrays[] = array(
|
||||||
'label' => _m('Phone'),
|
'label' => _m('Phone'),
|
||||||
'type' => 'phone',
|
'type' => 'phone',
|
||||||
'multi' => true,
|
'vcard' => 'tel',
|
||||||
'index' => 8123,
|
'multi' => true
|
||||||
'rel' => 'home',
|
);
|
||||||
'value' => '510-528-0079',
|
} else {
|
||||||
'vcard' => 'tel'
|
for ($i = 0; $i < sizeof($phones); $i++) {
|
||||||
|
$pa = array(
|
||||||
);
|
'label' => _m('Phone'),
|
||||||
|
'type' => 'phone',
|
||||||
|
'index' => $phones[$i]->value_index,
|
||||||
|
'rel' => $phones[$i]->rel,
|
||||||
|
'value' => $phones[$i]->field_value,
|
||||||
|
'vcard' => 'tel'
|
||||||
|
);
|
||||||
|
// Last phone record should allow adding more
|
||||||
|
if ($i == sizeof($phones) - 1) {
|
||||||
|
$pa['multi'] = true;
|
||||||
|
}
|
||||||
|
$pArrays[] = $pa;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $pArrays;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -101,8 +101,13 @@ class ExtendedProfileWidget extends Form
|
|||||||
{
|
{
|
||||||
$this->out->element('h3', null, $section['label']);
|
$this->out->element('h3', null, $section['label']);
|
||||||
$this->out->elementStart('table', array('class' => 'extended-profile'));
|
$this->out->elementStart('table', array('class' => 'extended-profile'));
|
||||||
|
|
||||||
foreach ($section['fields'] as $fieldName => $field) {
|
foreach ($section['fields'] as $fieldName => $field) {
|
||||||
$this->showExtendedProfileField($fieldName, $field);
|
if ($fieldName == 'phone') {
|
||||||
|
$this->showPhones($fieldName, $field);
|
||||||
|
} else {
|
||||||
|
$this->showExtendedProfileField($fieldName, $field);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$this->out->elementEnd('table');
|
$this->out->elementEnd('table');
|
||||||
}
|
}
|
||||||
@ -151,7 +156,6 @@ class ExtendedProfileWidget extends Form
|
|||||||
$this->out->text($this->ext->getTags());
|
$this->out->text($this->ext->getTags());
|
||||||
break;
|
break;
|
||||||
case 'phone':
|
case 'phone':
|
||||||
common_debug("GOT a PHONE!");
|
|
||||||
$this->showPhone($field);
|
$this->showPhone($field);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -159,11 +163,19 @@ class ExtendedProfileWidget extends Form
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function showPhones($name, $field) {
|
||||||
|
foreach ($field as $phone) {
|
||||||
|
$this->showExtendedProfileField($name, $phone);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected function showPhone($field)
|
protected function showPhone($field)
|
||||||
{
|
{
|
||||||
$this->out->elementStart('div', array('class' => 'phone-display'));
|
$this->out->elementStart('div', array('class' => 'phone-display'));
|
||||||
$this->out->text($field['value']);
|
$this->out->text($field['value']);
|
||||||
$this->out->text(' (' . $field['rel'] . ')');
|
if (!empty($field['rel'])) {
|
||||||
|
$this->out->text(' (' . $field['rel'] . ')');
|
||||||
|
}
|
||||||
$this->out->elementEnd('div');
|
$this->out->elementEnd('div');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user