- global $RCMAIL, $CONTACTS, $OUTPUT;
-
- // check if we have a valid result
- if ($RCMAIL->action != 'add' && !(($result = $CONTACTS->get_result()) && ($record = $result->first())))
- {
- $OUTPUT->show_message('contactnotfound');
- return false;
- }
-
- // add some labels to client
- $OUTPUT->add_label('noemailwarning', 'nonamewarning');
-
- list($form_start, $form_end) = get_form_tags($attrib);
- unset($attrib['form']);
-
- // a specific part is requested
- if ($attrib['part'])
- {
- $out = $form_start;
- $out .= rcmail_get_edit_field($attrib['part'], $record[$attrib['part']], $attrib);
- return $out;
- }
-
-
- // return the complete address edit form as table
- $out = "$form_start<table>\n\n";
-
- $a_show_cols = array('name', 'firstname', 'surname', 'email');
- foreach ($a_show_cols as $col)
- {
- $attrib['id'] = 'rcmfd_'.$col;
- $value = rcmail_get_edit_field($col, $record[$col], $attrib);
- $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n",
- $attrib['id'],
- Q(rcube_label($col)),
- $value);
- }
-
- $out .= "\n</table>$form_end";
-
- return $out;
+ global $RCMAIL, $CONTACT_COLTYPES;
+
+ $record = rcmail_get_edit_record();
+
+ // add some labels to client
+ $RCMAIL->output->add_label('noemailwarning', 'nonamewarning');
+
+ // copy (parsed) address template to client
+ if (preg_match_all('/\{([a-z0-9]+)\}([^{]*)/i', $RCMAIL->config->get('address_template', ''), $templ, PREG_SET_ORDER))
+ $RCMAIL->output->set_env('address_template', $templ);
+
+ $i_size = !empty($attrib['size']) ? $attrib['size'] : 40;
+ $t_rows = !empty($attrib['textarearows']) ? $attrib['textarearows'] : 10;
+ $t_cols = !empty($attrib['textareacols']) ? $attrib['textareacols'] : 40;
+
+ $form = array(
+ 'contact' => array(
+ 'name' => rcube_label('properties'),
+ 'content' => array(
+ 'email' => array('size' => $i_size, 'visible' => true),
+ 'phone' => array('size' => $i_size, 'visible' => true),
+ 'address' => array('visible' => true),
+ 'website' => array('size' => $i_size),
+ 'im' => array('size' => $i_size),
+ ),
+ ),
+ 'personal' => array(
+ 'name' => rcube_label('personalinfo'),
+ 'content' => array(
+ 'gender' => array('visible' => true),
+ 'maidenname' => array('size' => $i_size),
+ 'birthday' => array('visible' => true),
+ 'anniversary' => array(),
+ 'manager' => array('size' => $i_size),
+ 'assistant' => array('size' => $i_size),
+ 'spouse' => array('size' => $i_size),
+ ),
+ ),
+ );
+
+ if (isset($CONTACT_COLTYPES['notes'])) {
+ $form['notes'] = array(
+ 'name' => rcube_label('notes'),
+ 'content' => array(
+ 'notes' => array('size' => $t_cols, 'rows' => $t_rows, 'label' => false, 'visible' => true, 'limit' => 1),
+ ),
+ 'single' => true,
+ );
+ }
+
+ list($form_start, $form_end) = get_form_tags($attrib);
+ unset($attrib['form']);
+
+ // return the complete address edit form as table
+ $out = rcmail_contact_form($form, $record, $attrib);
+
+ return $form_start . $out . $form_end;