From: Zach Copley Date: Fri, 11 Mar 2011 00:57:41 +0000 (-0800) Subject: Make phone number save and display from DB X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=8efd2cf04dfb3343b88cb51f5740bb1688ba3c05;p=quix0rs-gnu-social.git Make phone number save and display from DB --- diff --git a/plugins/ExtendedProfile/extendedprofile.php b/plugins/ExtendedProfile/extendedprofile.php index 908f0bc721..2a10759d91 100644 --- a/plugins/ExtendedProfile/extendedprofile.php +++ b/plugins/ExtendedProfile/extendedprofile.php @@ -37,8 +37,10 @@ class ExtendedProfile { $this->profile = $profile; $this->user = $profile->getUser(); - $this->sections = $this->getSections(); $this->fields = $this->loadFields(); + $this->sections = $this->getSections(); + //common_debug(var_export($this->sections, true)); + //common_debug(var_export($this->fields, true)); } @@ -96,19 +98,36 @@ class ExtendedProfile } } - function getPhones() { - return array( + $phones = $this->fields['phone']; + $pArrays = array(); + + if (empty($phones)) { + $pArrays[] = array( 'label' => _m('Phone'), 'type' => 'phone', - 'multi' => true, - 'index' => 8123, - 'rel' => 'home', - 'value' => '510-528-0079', - 'vcard' => 'tel' - - ); + 'vcard' => 'tel', + 'multi' => true + ); + } else { + 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; } /** diff --git a/plugins/ExtendedProfile/extendedprofilewidget.php b/plugins/ExtendedProfile/extendedprofilewidget.php index f5685e9981..d31a34b1e2 100644 --- a/plugins/ExtendedProfile/extendedprofilewidget.php +++ b/plugins/ExtendedProfile/extendedprofilewidget.php @@ -101,8 +101,13 @@ class ExtendedProfileWidget extends Form { $this->out->element('h3', null, $section['label']); $this->out->elementStart('table', array('class' => 'extended-profile')); + 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'); } @@ -151,7 +156,6 @@ class ExtendedProfileWidget extends Form $this->out->text($this->ext->getTags()); break; case 'phone': - common_debug("GOT a PHONE!"); $this->showPhone($field); break; 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) { $this->out->elementStart('div', array('class' => 'phone-display')); $this->out->text($field['value']); - $this->out->text(' (' . $field['rel'] . ')'); + if (!empty($field['rel'])) { + $this->out->text(' (' . $field['rel'] . ')'); + } $this->out->elementEnd('div'); }