diff --git a/addressbook/inc/class.bocontacts.inc.php b/addressbook/inc/class.bocontacts.inc.php index a0034f712f..2f294dbadb 100755 --- a/addressbook/inc/class.bocontacts.inc.php +++ b/addressbook/inc/class.bocontacts.inc.php @@ -141,7 +141,7 @@ class bocontacts extends socontacts 'n_family' => lang('last name'), 'n_suffix' => lang('suffix'), 'n_fn' => lang('full name'), - 'org_name' => lang('company name'), + 'org_name' => lang('company'), ); foreach($labels as $name => $label) { @@ -264,9 +264,8 @@ class bocontacts extends socontacts /** * saves contact to db * - * @param array &contact contact array from etemplate::exec + * @param array &$contact contact array from etemplate::exec * @return boolean true on success, false on failure, an error-message is in $contact['msg'] - * TODO make fullname format choosable at best with selectbox and javascript in edit dialoge */ function save(&$contact) { @@ -279,7 +278,6 @@ class bocontacts extends socontacts } if($contact['id'] && !$this->check_perms(EGW_ACL_EDIT,$contact)) { - $contact['msg'] = lang('You are not permittet to edit this contact'); return false; } // convert categories @@ -293,16 +291,10 @@ class bocontacts extends socontacts $contact['n_fn'] = $this->fullname($contact); $contact['n_fileas'] = $this->fileas($contact); - $error_nr = parent::save($contact); - - if(!$error_nr) + if(!($error_nr = parent::save($contact))) { $GLOBALS['egw']->contenthistory->updateTimeStamp('contacts', $contact['id'],$isUpdate ? 'modify' : 'add', time()); } - $contact['msg'] = $error_nr ? - lang('Something went wrong by saving this contact. Errorcode %1',$error_nr) : - lang('Contact saved'); - return !$error_nr; } @@ -416,7 +408,7 @@ class bocontacts extends socontacts } /** - * Called by delete-account hook if an account gets deleted + * Delete contact linked to account, called by delete-account hook, when an account get deleted * * @param array $data */ @@ -431,4 +423,35 @@ class bocontacts extends socontacts $this->delete($contact_id); } } + + /** + * Update contact if linked account get updated, called by edit-account hook, when an account get edited + * + * @param array $data + */ + function editaccount($data) + { + //echo "bocontacts::editaccount()"; _debug_array($data); + + // check if account is linked to a contact + if (($contact_id = $GLOBALS['egw']->accounts->id2name($data['account_id'],'person_id')) && + ($contact = $this->read($contact_id))) + { + $need_update = false; + foreach(array( + 'n_family' => 'lastname', + 'n_given' => 'firstname', + 'email' => 'email', + ) as $cname => $aname) + { + if ($contact[$cname] != $data[$aname]) $need_update = true; + + $contact[$cname] = $data[$aname]; + } + if ($need_update) + { + $this->save($contact); + } + } + } } diff --git a/addressbook/inc/class.socontacts.inc.php b/addressbook/inc/class.socontacts.inc.php index 8de5f2c7d7..f2e68fba02 100755 --- a/addressbook/inc/class.socontacts.inc.php +++ b/addressbook/inc/class.socontacts.inc.php @@ -147,10 +147,20 @@ class socontacts $custom =& CreateObject('admin.customfields',$contact_app); $this->customfields = $custom->get_customfields(); - if ($this->customfields && !is_array($this->customfields)) $this->customfields = unserialize($this->customfields); - if (!$this->customfields) $this->customfields = array(); +// if ($this->customfields && !is_array($this->customfields)) $this->customfields = unserialize($this->customfields); +// if (!$this->customfields) $this->customfields = array(); $this->content_types = $custom->get_content_types(); - if ($this->content_types && !is_array($this->content_types)) $this->content_types = unserialize($this->content_types); +// if ($this->content_types && !is_array($this->content_types)) $this->content_types = unserialize($this->content_types); + if (!$this->content_types) + { + $this->content_types = $custom->content_types = array('n' => array( + 'name' => 'contact', + 'options' => array( + 'template' => 'addressbook.edit', + 'icon' => 'navbar.png' + ))); + $custom->save_repository(); + } } /** diff --git a/addressbook/inc/class.socontacts_sql.inc.php b/addressbook/inc/class.socontacts_sql.inc.php index d791a209d0..0f2512caec 100644 --- a/addressbook/inc/class.socontacts_sql.inc.php +++ b/addressbook/inc/class.socontacts_sql.inc.php @@ -93,10 +93,7 @@ class socontacts_sql extends so_sql // having them double is ambigues if (!$only_keys) { - $account_table = $GLOBALS['egw']->db->get_table_definitions('phpgwapi',$this->accounts_table); // global db is on phpgwapi - // all addressbook columns, but the ones given with CASE ... AS above plus the account-columns - $only_keys = implode(',',array_merge(array_diff(array_keys($this->db_cols),array_keys($accounts2contacts)), - array_keys($account_table['fd']))); + $only_keys = array_diff(array_keys($this->db_cols),array_keys($accounts2contacts)); } elseif($only_keys !== true) { @@ -121,8 +118,9 @@ class socontacts_sql extends so_sql $filter[] = str_replace(' AS '.$db_col,'',$accounts2contacts[$db_col]). ($value === "!''" ? "!=''" : '='.$this->db->quote($value,$this->table_def['fd'][$db_col]['type'])); } - elseif($value == "!''") // not empty query, will match all accounts, as their value is NULL not '' + elseif($value === "!''") // not empty query, will match all accounts, as their value is NULL not '' { + unset($filter[$col]); $filter[] = "($db_col != '' AND $db_col IS NOT NULL)"; } } @@ -161,7 +159,7 @@ class socontacts_sql extends so_sql { parent::search($criteria,$only_keys,$order_by,$extra_cols,$wildcard,$empty,$op,'UNION',$filter, 'LEFT'.$this->accounts_join.' '.$join,$need_full_no_count); - $filter[] = 'person_id=0'; + $filter[] = '(person_id=0 OR person_id IS NULL)'; // unfortunally both is used in eGW parent::search($criteria,$only_keys,$order_by,$extra_cols,$wildcard,$empty,$op,'UNION',$filter, 'RIGHT'.$this->accounts_join.' '.$join,$need_full_no_count); } @@ -214,6 +212,10 @@ class socontacts_sql extends so_sql 'email' => $account->data['email'], 'owner' => 0, 'tid' => 'n', + 'creator' => $GLOBALS['egw_info']['user']['account_id'], + 'created' => time(), + 'modifier' => $GLOBALS['egw_info']['user']['account_id'], + 'modified' => time(), ),$account_id); return $this->data+array('account_id' => $account_id); @@ -244,8 +246,7 @@ class socontacts_sql extends so_sql 'n_family' => $lastname, 'private' => 0, )); - //echo "
soccontacts_sql::_find_unique_contacts($firstname,$lastname)
\n"; _debug_array($contacts); - + return $contacts && count($contacts) == 1 ? $contacts[0]['id'] : false; } diff --git a/addressbook/inc/class.uicontacts.inc.php b/addressbook/inc/class.uicontacts.inc.php index 61cbd444a5..44081a75b7 100644 --- a/addressbook/inc/class.uicontacts.inc.php +++ b/addressbook/inc/class.uicontacts.inc.php @@ -669,7 +669,8 @@ class uicontacts extends bocontacts { if (!isset($sel_options['owner'][(int)$content['owner']])) { - $sel_options['owner'][(int)$content['owner']] = $GLOBALS['egw']->common->grab_owner_name($content['owner']); + $sel_options['owner'][(int)$content['owner']] = !$content['owner'] ? lang('Accounts') : + $GLOBALS['egw']->common->grab_owner_name($content['owner']); } $readonlys['owner'] = !$content['owner'] || // dont allow to move accounts, as this mean deleting the user incl. all content he owns !$this->check_perms(EGW_ACL_DELETE,$content); // you need delete rights to move a contact into an other addressbook diff --git a/addressbook/setup/default_records.inc.php b/addressbook/setup/default_records.inc.php new file mode 100644 index 0000000000..4f9894bfab --- /dev/null +++ b/addressbook/setup/default_records.inc.php @@ -0,0 +1,17 @@ + * +* ------------------------------------------------------------------------ * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 2 of the License, or (at your * +* option) any later version. * +\**************************************************************************/ + +/* $Id$ */ + +// Create Addressbook for Default group, by setting a group ACL from the group to itself for all rights: add, read, edit and delete +$defaultgroup = $GLOBALS['egw_setup']->add_account('Default','Default','Group',False,False); +$GLOBALS['egw_setup']->add_acl('addressbook',$defaultgroup,$defaultgroup,1|2|4|8); diff --git a/addressbook/setup/phpgw_de.lang b/addressbook/setup/phpgw_de.lang index db631f5d81..028c21d933 100644 --- a/addressbook/setup/phpgw_de.lang +++ b/addressbook/setup/phpgw_de.lang @@ -16,6 +16,7 @@ address book - view addressbook de Adressbuch - Anzeigen address line 2 addressbook de Adresszeile 2 address type addressbook de Adresstyp addressbook common de Adressbuch +addressbook menu addressbook de Adressbuch Menü addressbook preferences addressbook de Adressbuch Einstellungen addressbook the contact should be saved to addressbook de Adressbuch in das der Kontakt gespeichert werden soll addressbook-fieldname addressbook de Adressbuch Feldname @@ -79,6 +80,7 @@ download export file (uncheck to debug output in browser) addressbook de Downloa download this contact as vcard file addressbook de Diese Adresse als vCard Datei herunterladen edit custom field addressbook de Benutzerdefiniertes Feld bearbeiten edit custom fields admin de Benutzerdefinierte Felder bearbeiten +edit extra account-data in the addressbook admin de Zusätzliche Benutzerdaten im Adressbuch bearbeiten. edit phonenumbers - addressbook de Telefonnummern bearbeiten email & internet addressbook de Email & Internet empty for all addressbook de leer für alle diff --git a/addressbook/setup/phpgw_en.lang b/addressbook/setup/phpgw_en.lang index b6332e0aef..8f5cb36ead 100644 --- a/addressbook/setup/phpgw_en.lang +++ b/addressbook/setup/phpgw_en.lang @@ -16,6 +16,7 @@ address book - view addressbook en Address book - view address line 2 addressbook en Address Line 2 address type addressbook en Address Type addressbook common en Addressbook +addressbook menu addressbook en Addressbook menu addressbook preferences addressbook en Addressbook preferences addressbook the contact should be saved to addressbook en Addressbook the contact should be saved to addressbook-fieldname addressbook en Addressbook-Fieldname @@ -79,6 +80,7 @@ download export file (uncheck to debug output in browser) addressbook en Downloa download this contact as vcard file addressbook en download this contact as vCard file edit custom field addressbook en Edit Custom Field edit custom fields admin en Edit Custom Fields +edit extra account-data in the addressbook admin en Edit extra account-data in the addressbook edit phonenumbers - addressbook en Edit Phonenumbers - email & internet addressbook en Email & Internet empty for all addressbook en empty for all diff --git a/addressbook/setup/setup.inc.php b/addressbook/setup/setup.inc.php index e5ed740de0..de5e6ad728 100755 --- a/addressbook/setup/setup.inc.php +++ b/addressbook/setup/setup.inc.php @@ -19,16 +19,15 @@ $setup_info['addressbook']['enable'] = 1; $setup_info['addressbook']['author'] = 'Ralf Becker, Cornelius Weiss, Lars Kneschke'; - $setup_info['addressbook']['note'] = 'The phpgwapi manages contact data. Addressbook manages servers for its remote capability.'; +// $setup_info['addressbook']['note'] = 'The phpgwapi manages contact data. Addressbook manages servers for its remote capability.'; $setup_info['addressbook']['license'] = 'GPL'; $setup_info['addressbook']['description'] = - 'Contact manager with Vcard support.