return $pArrays;
}
+ function getIms()
+ {
+ $ims = (isset($this->fields['im'])) ? $this->fields['im'] : null;
+ $iArrays = array();
+
+ if (empty($ims)) {
+ $iArrays[] = array(
+ 'label' => _m('IM'),
+ 'type' => 'im'
+ );
+ } else {
+ for ($i = 0; $i < sizeof($ims); $i++) {
+ $ia = array(
+ 'label' => _m('IM'),
+ 'type' => 'im',
+ 'index' => intval($ims[$i]->value_index),
+ 'rel' => $ims[$i]->rel,
+ 'value' => $ims[$i]->field_value,
+ );
+
+ $iArrays[] = $ia;
+ }
+ }
+ return $iArrays;
+ }
+
function getExperiences()
{
$companies = (isset($this->fields['company'])) ? $this->fields['company'] : null;
'label' => _m('Contact'),
'fields' => array(
'phone' => $this->getPhones(),
- 'im' => array(
- 'label' => _m('IM'),
- 'type' => 'im',
- 'multi' => true,
- ),
+ 'im' => $this->getIms(),
'website' => array(
'label' => _m('Websites'),
'type' => 'website',
switch($fieldName) {
case 'phone':
+ case 'im':
case 'experience':
case 'education':
$this->showMultiple($fieldName, $field);
$this->out->elementEnd('div');
}
+ protected function showIm($name, $field)
+ {
+ $this->out->elementStart('div', array('class' => 'im-display'));
+ $this->out->text($field['value']);
+ if (!empty($field['rel'])) {
+ $this->out->text(' (' . $field['rel'] . ')');
+ }
+ $this->out->elementEnd('div');
+ }
+
+ protected function showEditableIm($name, $field)
+ {
+ $index = isset($field['index']) ? $field['index'] : 0;
+ $id = "extprofile-$name-$index";
+ $rel = $id . '-rel';
+ $this->out->elementStart(
+ 'div', array(
+ 'id' => $id . '-edit',
+ 'class' => 'im-edit'
+ )
+ );
+ $this->out->input(
+ $id,
+ null,
+ isset($field['value']) ? $field['value'] : null
+ );
+ $this->out->dropdown(
+ $id . '-rel',
+ 'Type',
+ array(
+ 'jabber' => 'Jabber',
+ 'gtalk' => 'GTalk',
+ 'aim' => 'AIM',
+ 'yahoo' => 'Yahoo! Messenger',
+ 'msn' => 'MSN',
+ 'skype' => 'Skype',
+ 'other' => 'Other'
+ ),
+ null,
+ false,
+ isset($field['rel']) ? $field['rel'] : null
+ );
+
+ $this->showMultiControls();
+ $this->out->elementEnd('div');
+ }
+
protected function showEditablePhone($name, $field)
{
$index = isset($field['index']) ? $field['index'] : 0;
case 'phone':
$this->showPhone($name, $field);
break;
+ case 'im':
+ $this->showIm($name, $field);
+ break;
case 'experience':
$this->showExperience($name, $field);
break;
case 'phone':
$this->showEditablePhone($name, $field);
break;
+ case 'im':
+ $this->showEditableIm($name, $field);
+ break;
case 'experience':
$this->showEditableExperience($name, $field);
break;
}
$this->savePhoneNumbers($user);
+ $this->saveIms($user);
$this->saveExperiences($user);
$this->saveEducations($user);
return $phoneArray;
}
+ function findIms() {
+
+ // Form vals look like this:
+ // 'extprofile-im-0' => 'jed',
+ // 'extprofile-im-0-rel' => 'yahoo',
+
+ $ims = $this->sliceParams('im', 2);
+ $imArray = array();
+
+ foreach ($ims as $im) {
+ list($id, $rel) = array_values($im);
+ $imArray[] = array(
+ 'value' => $id,
+ 'rel' => $rel
+ );
+ }
+
+ return $imArray;
+ }
+
+ function saveIms($user) {
+ $ims = $this->findIms();
+ $this->removeAll($user, 'im');
+ $i = 0;
+ foreach($ims as $im) {
+ if (!empty($im['value'])) {
+ ++$i;
+ $this->saveField(
+ $user,
+ 'im',
+ $im['value'],
+ $im['rel'],
+ $i
+ );
+ }
+ }
+ }
+
function findExperiences() {
// Form vals look like this: