diff --git a/addressbook/inc/class.socontacts.inc.php b/addressbook/inc/class.socontacts.inc.php index 2220ac490c..9265dfcbb3 100755 --- a/addressbook/inc/class.socontacts.inc.php +++ b/addressbook/inc/class.socontacts.inc.php @@ -327,4 +327,17 @@ class socontacts } return $need_full_no_count ? count($result) : $result; } + + /** + * gets all contact fields from database + */ + function get_contact_conlumns() + { + $fields = $this->somain->db_data_cols; + foreach ((array)$this->customfields as $cfield => $coptions) + { + $fields['#'.$cfield] = '#'.$cfield; + } + return $fields; + } } diff --git a/addressbook/inc/class.uiaddressbook.inc.php b/addressbook/inc/class.uiaddressbook.inc.php index e5ad773e03..e571485c2c 100644 --- a/addressbook/inc/class.uiaddressbook.inc.php +++ b/addressbook/inc/class.uiaddressbook.inc.php @@ -678,20 +678,14 @@ $fields['n_given'] = $names[0]; $fields['n_family'] = $names[1]; } - $fields['n_given'] = $fields['n_given'] ? $fields['n_given'] : ' '; - $fields['n_family'] = $fields['n_family'] ? $fields['n_family'] : ' '; - $fields['fn'] = $fields['n_given'] . ' ' . $fields['n_family']; - $fields['email'] = $add_email; - $fields['access'] = 'private'; - $fields['tid'] = 'n'; - $referer = urlencode($referer); - $fields['owner'] = $GLOBALS['egw_info']['user']['account_id']; -// _debug_array($fields);exit; - $this->bo->add_entry($fields); - $ab_id = $this->bo->get_lastid(); - - $GLOBALS['egw']->redirect_link('/index.php','menuaction=addressbook.uiaddressbook.view&ab_id=' . $ab_id . '&referer=' . $referer); + $GLOBALS['egw']->redirect_link('/index.php', array( + 'menuaction' => 'addressbook.uicontacts.edit', + 'presets[n_given]' => $fields['n_given'] ? $fields['n_given'] : ' ', + 'presets[n_middle]' => $fields['n_middle'] ? $fields['n_middle'] : '', + 'presets[n_family]' => $fields['n_family'] ? $fields['n_family'] : ' ', + 'presets[email]' => $add_email, + )); } function copy() diff --git a/addressbook/inc/class.uicontacts.inc.php b/addressbook/inc/class.uicontacts.inc.php index 7946de4456..7f85e264f7 100644 --- a/addressbook/inc/class.uicontacts.inc.php +++ b/addressbook/inc/class.uicontacts.inc.php @@ -110,12 +110,20 @@ class uicontacts extends bocontacts { $content = array(); $contact_id = $_GET['contact_id'] ? $_GET['contact_id'] : 0; - $view = $_GET['view'];// == 1 ? true : false; + $view = $_GET['view']; if ($contact_id) { $content = $this->read($contact_id); } + else // look if we have presets for a new contact + { + foreach($this->get_contact_conlumns() as $field => $data) + { + if ($_GET['presets'][$field]) $content[$field] = $_GET['presets'][$field]; + } + } + if($content && $_GET['makecp']) // copy the contact { $content['link_to']['to_id'] = 0;