diff options
Diffstat (limited to 'program/steps/addressbook')
-rw-r--r-- | program/steps/addressbook/edit.inc | 4 | ||||
-rw-r--r-- | program/steps/addressbook/func.inc | 36 | ||||
-rw-r--r-- | program/steps/addressbook/import.inc | 19 | ||||
-rw-r--r-- | program/steps/addressbook/save.inc | 10 | ||||
-rw-r--r-- | program/steps/addressbook/show.inc | 3 |
5 files changed, 38 insertions, 34 deletions
diff --git a/program/steps/addressbook/edit.inc b/program/steps/addressbook/edit.inc index b216a7c70..d175c05d9 100644 --- a/program/steps/addressbook/edit.inc +++ b/program/steps/addressbook/edit.inc @@ -52,7 +52,7 @@ else { // find writable addressbook if (!$CONTACTS || $CONTACTS->readonly) - $source = rcmail_default_source(true); + $source = $RCMAIL->get_address_book(-1, true); // Initialize addressbook $CONTACTS = rcmail_contact_source($source, true); @@ -239,7 +239,7 @@ function rcmail_source_selector($attrib) { global $RCMAIL, $SOURCE_ID; - $sources_list = $RCMAIL->get_address_sources(true); + $sources_list = $RCMAIL->get_address_sources(true, true); if (count($sources_list) < 2) { $source = $sources_list[$SOURCE_ID]; diff --git a/program/steps/addressbook/func.inc b/program/steps/addressbook/func.inc index 3a0508025..fded9a819 100644 --- a/program/steps/addressbook/func.inc +++ b/program/steps/addressbook/func.inc @@ -63,12 +63,6 @@ if (!$RCMAIL->action && !$OUTPUT->ajax_call) { // add list of address sources to client env $js_list = $RCMAIL->get_address_sources(); - $source = get_input_value('_source', RCUBE_INPUT_GPC); - - // use first directory by default - if (!strlen($source) || !isset($js_list[$source])) - $source = $js_list[key($js_list)]['id']; - // count all/writeable sources $writeable = 0; $count = 0; @@ -93,8 +87,16 @@ if (!$RCMAIL->action && !$OUTPUT->ajax_call) { $_SESSION['addressbooks_count'] = $count; $_SESSION['addressbooks_count_writeable'] = $writeable; - if (!strlen($source)) - $source = strval(key($js_list)); + // select address book + $source = get_input_value('_source', RCUBE_INPUT_GPC); + + // use first directory by default + if (!strlen($source) || !isset($js_list[$source])) { + $source = $RCMAIL->config->get('default_addressbook'); + if (!strlen($source) || !isset($js_list[$source])) { + $source = strval(key($js_list)); + } + } $CONTACTS = rcmail_contact_source($source, true); } @@ -158,17 +160,6 @@ function rcmail_contact_source($source=null, $init_env=false, $writable=false) } -function rcmail_default_source($writable=false) -{ - global $RCMAIL; - - // get list of address sources - $first = reset($RCMAIL->get_address_sources($writable)); - - // use first directory by default - return $first['id']; -} - function rcmail_set_sourcename($abook) { global $OUTPUT; @@ -367,12 +358,7 @@ function rcmail_contact_frame($attrib) if (!$attrib['id']) $attrib['id'] = 'rcmcontactframe'; - $attrib['name'] = $attrib['id']; - - $OUTPUT->set_env('contentframe', $attrib['name']); - $OUTPUT->set_env('blankpage', $attrib['src'] ? $OUTPUT->abs_url($attrib['src']) : 'program/resources/blank.gif'); - - return html::iframe($attrib); + return $OUTPUT->frame($attrib, true); } diff --git a/program/steps/addressbook/import.inc b/program/steps/addressbook/import.inc index fb2251f18..df07d64bc 100644 --- a/program/steps/addressbook/import.inc +++ b/program/steps/addressbook/import.inc @@ -30,7 +30,7 @@ function rcmail_import_form($attrib) $attrib += array('id' => "rcmImportForm"); - $writable_books = $RCMAIL->get_address_sources(true); + $writable_books = $RCMAIL->get_address_sources(true, true); $upload = new html_inputfield(array( 'type' => 'file', @@ -64,7 +64,7 @@ function rcmail_import_form($attrib) $OUTPUT->add_label('selectimportfile','importwait'); $OUTPUT->add_gui_object('importform', $attrib['id']); - $out = html::p(null, Q(rcube_label('importtext'), 'show')); + $out = html::p(null, Q(rcube_label('importdesc'), 'show')); $out .= $OUTPUT->form_tag(array( 'action' => $RCMAIL->url('import'), @@ -159,11 +159,22 @@ if (is_array($_FILES['_file'])) { $upload_error = $err; } else { + $file_content = file_get_contents($filepath); + // let rcube_vcard do the hard work :-) $vcard_o = new rcube_vcard(); $vcard_o->extend_fieldmap($CONTACTS->vcard_map); + $v_list = $vcard_o->import($file_content); + + if (!empty($v_list)) { + $vcards = array_merge($vcards, $v_list); + continue; + } - $v_list = $vcard_o->import(file_get_contents($filepath)); + // no vCards found, try CSV + $csv = new rcube_csv2vcard($_SESSION['language']); + $csv->import($file_content); + $v_list = $csv->export(); if (!empty($v_list)) { $vcards = array_merge($vcards, $v_list); @@ -181,7 +192,7 @@ if (is_array($_FILES['_file'])) { $OUTPUT->show_message('fileuploaderror', 'error'); } else { - $OUTPUT->show_message('importerror', 'error'); + $OUTPUT->show_message('importformaterror', 'error'); } } else { diff --git a/program/steps/addressbook/save.inc b/program/steps/addressbook/save.inc index 887e49827..901ea0190 100644 --- a/program/steps/addressbook/save.inc +++ b/program/steps/addressbook/save.inc @@ -179,18 +179,24 @@ else { $insert_id = $plugin['result']; if ($insert_id) { + $CONTACTS->reset(); + // add new contact to the specified group if ($CONTACTS->groups && $CONTACTS->group_id) { $plugin = $RCMAIL->plugins->exec_hook('group_addmembers', array( 'group_id' => $CONTACTS->group_id, 'ids' => $insert_id, 'source' => $source)); + $counts = $CONTACTS->count(); + if (!$plugin['abort']) { - if (($maxnum = $RCMAIL->config->get('max_group_members', 0)) && ($CONTACTS->count()->count + 1 > $maxnum)) + if (($maxnum = $RCMAIL->config->get('max_group_members', 0)) && ($counts->count + 1 > $maxnum)) $OUTPUT->show_message('maxgroupmembersreached', 'warning', array('max' => $maxnum)); $CONTACTS->add_to_group($gid, $plugin['ids']); } } + else + $counts = $CONTACTS->count(); if ((string)$source === (string)$orig_source) { // add contact row or jump to the page where it should appear @@ -202,7 +208,7 @@ else { // update record count display $CONTACTS->reset(); - $OUTPUT->command('parent.set_rowcount', rcmail_get_rowcount_text()); + $OUTPUT->command('parent.set_rowcount', rcmail_get_rowcount_text($counts)); } else { // re-set iframe diff --git a/program/steps/addressbook/show.inc b/program/steps/addressbook/show.inc index 48e37256d..16be89f94 100644 --- a/program/steps/addressbook/show.inc +++ b/program/steps/addressbook/show.inc @@ -5,7 +5,7 @@ | program/steps/addressbook/show.inc | | | | This file is part of the Roundcube Webmail client | - | Copyright (C) 2005-2009, The Roundcube Dev Team | + | Copyright (C) 2005-2012, The Roundcube Dev Team | | | | Licensed under the GNU General Public License version 3 or | | any later version with exceptions for skins & plugins. | @@ -32,6 +32,7 @@ $SOURCE_ID = $source; if ($cid && ($record = $CONTACTS->get_record($cid, true))) { $OUTPUT->set_env('readonly', $CONTACTS->readonly || $record['readonly']); $OUTPUT->set_env('cid', $record['ID']); + $OUTPUT->set_env('compose_extwin', $RCMAIL->config->get('compose_extwin',false)); } // get address book name (for display) |