diff options
Diffstat (limited to 'program/steps/addressbook')
-rw-r--r-- | program/steps/addressbook/delete.inc | 40 | ||||
-rw-r--r-- | program/steps/addressbook/edit.inc | 6 | ||||
-rw-r--r-- | program/steps/addressbook/export.inc | 4 | ||||
-rw-r--r-- | program/steps/addressbook/func.inc | 68 | ||||
-rw-r--r-- | program/steps/addressbook/move.inc | 24 | ||||
-rw-r--r-- | program/steps/addressbook/photo.inc | 8 | ||||
-rw-r--r-- | program/steps/addressbook/save.inc | 39 | ||||
-rw-r--r-- | program/steps/addressbook/show.inc | 7 | ||||
-rw-r--r-- | program/steps/addressbook/undo.inc | 3 |
9 files changed, 122 insertions, 77 deletions
diff --git a/program/steps/addressbook/delete.inc b/program/steps/addressbook/delete.inc index 3d57d7074..f5b8e4eb5 100644 --- a/program/steps/addressbook/delete.inc +++ b/program/steps/addressbook/delete.inc @@ -77,6 +77,17 @@ foreach ($cids as $source => $cid) { } } +if (!empty($_SESSION['contact_undo'])) { + $_SESSION['contact_undo']['ts'] = time(); + $msg = html::span(null, $RCMAIL->gettext('contactdeleted')) + . ' ' . html::a(array('onclick' => rcmail_output::JS_OBJECT_NAME.".command('undo', '', this)"), $RCMAIL->gettext('undo')); + + $OUTPUT->show_message($msg, 'confirmation', null, true, $undo_time); +} +else { + $OUTPUT->show_message('contactdeleted', 'confirmation'); +} + $page = isset($_SESSION['page']) ? $_SESSION['page'] : 1; // update saved search after data changed @@ -87,8 +98,13 @@ if (($records = rcmail_search_update(true)) !== false) { $result = new rcube_result_set($count, $first); $pages = ceil((count($records) + $delcnt) / $PAGE_SIZE); + // last page and it's empty, display previous one + if ($result->count && $result->count <= ($PAGE_SIZE * ($page - 1))) { + $OUTPUT->command('list_page', 'prev'); + $rowcount = $RCMAIL->gettext('loading'); + } // get records from the next page to add to the list - if ($_GET['_from'] != 'show' && $pages > 1 && $page < $pages) { + else if ($pages > 1 && $page < $pages) { // sort the records ksort($records, SORT_LOCALE_STRING); @@ -110,10 +126,15 @@ if (($records = rcmail_search_update(true)) !== false) { else { // count contacts for this user $result = $CONTACTS->count(); + $pages = ceil(($result->count + $delcnt) / $PAGE_SIZE); + // last page and it's empty, display previous one + if ($result->count && $result->count <= ($PAGE_SIZE * ($page - 1))) { + $OUTPUT->command('list_page', 'prev'); + $rowcount = $RCMAIL->gettext('loading'); + } // get records from the next page to add to the list - $pages = ceil(($result->count + $delcnt) / $PAGE_SIZE); - if ($_GET['_from'] != 'show' && $pages > 1 && $page < $pages) { + else if ($pages > 1 && $page < $pages) { $CONTACTS->set_page($page); $records = $CONTACTS->list_records(null, -$delcnt); } @@ -121,18 +142,7 @@ else { // update message count display $OUTPUT->set_env('pagecount', ceil($result->count / $PAGE_SIZE)); -$OUTPUT->command('set_rowcount', rcmail_get_rowcount_text($result)); - -if (!empty($_SESSION['contact_undo'])) { - $_SESSION['contact_undo']['ts'] = time(); - $msg = html::span(null, $RCMAIL->gettext('contactdeleted')) - . ' ' . html::a(array('onclick' => rcmail_output::JS_OBJECT_NAME.".command('undo', '', this)"), $RCMAIL->gettext('undo')); - - $OUTPUT->show_message($msg, 'confirmation', null, true, $undo_time); -} -else { - $OUTPUT->show_message('contactdeleted', 'confirmation'); -} +$OUTPUT->command('set_rowcount', $rowcount ? $rowcount : rcmail_get_rowcount_text($result)); // add new rows from next page (if any) if (!empty($records)) { diff --git a/program/steps/addressbook/edit.inc b/program/steps/addressbook/edit.inc index 3bbbfccdf..a7def586d 100644 --- a/program/steps/addressbook/edit.inc +++ b/program/steps/addressbook/edit.inc @@ -69,6 +69,8 @@ $OUTPUT->add_handlers(array( 'filedroparea' => 'rcmail_photo_drop_area', )); +$OUTPUT->set_pagetitle($RCMAIL->gettext(($RCMAIL->action == 'add' ? 'addcontact' : 'editcontact'))); + if ($RCMAIL->action == 'add' && $OUTPUT->template_exists('contactadd')) { $OUTPUT->send('contactadd'); } @@ -98,12 +100,15 @@ function rcmail_get_edit_record() function rcmail_contact_edithead($attrib) { + global $RCMAIL; + // check if we have a valid result $record = rcmail_get_edit_record(); $i_size = !empty($attrib['size']) ? $attrib['size'] : 20; $form = array( 'head' => array( + 'name' => $RCMAIL->gettext('contactnameandorg'), 'content' => array( 'prefix' => array('size' => $i_size), 'firstname' => array('size' => $i_size, 'visible' => true), @@ -253,6 +258,7 @@ function get_form_tags($attrib) if ($RCMAIL->action == 'edit') $hiddenfields->add(array('name' => '_source', 'value' => $SOURCE_ID)); $hiddenfields->add(array('name' => '_gid', 'value' => $CONTACTS->group_id)); + $hiddenfields->add(array('name' => '_search', 'value' => rcube_utils::get_input_value('_search', rcube_utils::INPUT_GPC))); if (($result = $CONTACTS->get_result()) && ($record = $result->first())) $hiddenfields->add(array('name' => '_cid', 'value' => $record['ID'])); diff --git a/program/steps/addressbook/export.inc b/program/steps/addressbook/export.inc index 2b45e5cd1..a6d3af978 100644 --- a/program/steps/addressbook/export.inc +++ b/program/steps/addressbook/export.inc @@ -103,7 +103,9 @@ header('Content-Type: text/x-vcard; charset='.RCUBE_CHARSET); header('Content-Disposition: attachment; filename="contacts.vcf"'); while ($result && ($row = $result->next())) { - prepare_for_export($row, $CONTACTS); + if ($CONTACTS) { + prepare_for_export($row, $CONTACTS); + } // fix folding and end-of-line chars $row['vcard'] = preg_replace('/\r|\n\s+/', '', $row['vcard']); diff --git a/program/steps/addressbook/func.inc b/program/steps/addressbook/func.inc index be0dd2a33..2c22d5a47 100644 --- a/program/steps/addressbook/func.inc +++ b/program/steps/addressbook/func.inc @@ -81,7 +81,6 @@ if (!$RCMAIL->action && !$OUTPUT->ajax_call) { $OUTPUT->set_env('search_mods', $search_mods); $OUTPUT->set_env('address_sources', $js_list); $OUTPUT->set_env('writable_source', $writeable); - $OUTPUT->set_env('compose_extwin', $RCMAIL->config->get('compose_extwin',false)); $OUTPUT->set_pagetitle($RCMAIL->gettext('addressbook')); $_SESSION['addressbooks_count'] = $count; @@ -112,7 +111,7 @@ if ($undo = $_SESSION['contact_undo']) { // register UI objects $OUTPUT->add_handlers(array( 'directorylist' => 'rcmail_directory_list', -// 'groupslist' => 'rcmail_contact_groups', + 'savedsearchlist' => 'rcmail_savedsearch_list', 'addresslist' => 'rcmail_contacts_list', 'addresslisttitle' => 'rcmail_contacts_list_title', 'addressframe' => 'rcmail_contact_frame', @@ -251,6 +250,28 @@ function rcmail_directory_list($attrib) $out .= '</li>'; } + $OUTPUT->set_env('contactgroups', $jsdata); + $OUTPUT->set_env('collapsed_abooks', (string)$RCMAIL->config->get('collapsed_abooks','')); + $OUTPUT->add_gui_object('folderlist', $attrib['id']); + $OUTPUT->include_script('treelist.js'); + + // add some labels to client + $OUTPUT->add_label('deletegroupconfirm', 'groupdeleting', 'addingmember', 'removingmember', + 'newgroup', 'grouprename', 'searchsave', 'namex', 'save' + ); + + return html::tag('ul', $attrib, $out, html::$common_attrib); +} + + +function rcmail_savedsearch_list($attrib) +{ + global $RCMAIL, $OUTPUT; + + if (!$attrib['id']) + $attrib['id'] = 'rcmsavedsearchlist'; + + $out = ''; $line_templ = html::tag('li', array( 'id' => 'rcmli%s', 'class' => '%s'), html::a(array('href' => '#', 'rel' => 'S%s', @@ -263,26 +284,19 @@ function rcmail_directory_list($attrib) $js_id = rcube::JQ($id); // set class name(s) - $class_name = 'contactsearch'; - if ($current === $id) - $class_name .= ' selected'; - if ($source['class_name']) - $class_name .= ' ' . $source['class_name']; + $classes = array('contactsearch'); + if (!empty($source['class_name'])) + $classes[] = $source['class_name']; $out .= sprintf($line_templ, rcube_utils::html_identifier('S'.$id, true), - $class_name, + join(' ', $classes), $id, - $js_id, (!empty($source['name']) ? rcube::Q($source['name']) : rcube::Q($id))); + $js_id, (!empty($source['name']) ? rcube::Q($source['name']) : rcube::Q($id)) + ); } - $OUTPUT->set_env('contactgroups', $jsdata); - $OUTPUT->set_env('collapsed_abooks', (string)$RCMAIL->config->get('collapsed_abooks','')); - $OUTPUT->add_gui_object('folderlist', $attrib['id']); - $OUTPUT->include_script('treelist.js'); - - // add some labels to client - $OUTPUT->add_label('deletegroupconfirm', 'groupdeleting', 'addingmember', 'removingmember'); + $OUTPUT->add_gui_object('savedsearchlist', $attrib['id']); return html::tag('ul', $attrib, $out, html::$common_attrib); } @@ -395,7 +409,7 @@ function rcmail_js_contacts_list($result, $prefix='') ), '»'); } else - $val = ' '; + $val = ''; break; default: @@ -422,7 +436,7 @@ function rcmail_contacts_list_title($attrib) unset($attrib['name']); $OUTPUT->add_gui_object('addresslist_title', $attrib['id']); - $OUTPUT->add_label('contacts'); + $OUTPUT->add_label('contacts','uponelevel'); return html::tag($attrib['tag'], $attrib, $RCMAIL->gettext($attrib['label']), html::$common_attrib); } @@ -518,7 +532,7 @@ function rcmail_contact_form($form, $record, $attrib = null) foreach ($coltypes as $col => $prop) { if ($prop['subtypes']) { $subtype_names = array_map('rcmail_get_type_label', $prop['subtypes']); - $select_subtype = new html_select(array('name' => '_subtype_'.$col.'[]', 'class' => 'contactselectsubtype')); + $select_subtype = new html_select(array('name' => '_subtype_'.$col.'[]', 'class' => 'contactselectsubtype', 'title' => $prop['label'] . ' ' . $RCMAIL->gettext('type'))); $select_subtype->add($subtype_names, $prop['subtypes']); $coltypes[$col]['subtypes_select'] = $select_subtype->show(); } @@ -607,7 +621,7 @@ function rcmail_contact_form($form, $record, $attrib = null) // prepare subtype selector in edit mode if ($edit_mode && is_array($colprop['subtypes'])) { $subtype_names = array_map('rcmail_get_type_label', $colprop['subtypes']); - $select_subtype = new html_select(array('name' => '_subtype_'.$col.'[]', 'class' => 'contactselectsubtype')); + $select_subtype = new html_select(array('name' => '_subtype_'.$col.'[]', 'class' => 'contactselectsubtype', 'title' => $colprop['label'] . ' ' . $RCMAIL->gettext('type'))); $select_subtype->add($subtype_names, $colprop['subtypes']); } else @@ -649,6 +663,8 @@ function rcmail_contact_form($form, $record, $attrib = null) if ($subtypes[$i]) $subtype = $subtypes[$i]; + $colprop['id'] = 'ff_' . $col . intval($coltypes[$field]['count']); + // render composite field if ($colprop['type'] == 'composite') { $composite = array(); $j = 0; @@ -714,7 +730,7 @@ function rcmail_contact_form($form, $record, $attrib = null) // display row with label if ($label) { $rows .= html::div('row', - html::div('contactfieldlabel label', $select_subtype ? $select_subtype->show($subtype) : rcube::Q($label)) . + html::div('contactfieldlabel label', $select_subtype ? $select_subtype->show($subtype) : html::label($colprop['id'], rcube::Q($label))) . html::div('contactfieldcontent '.$colprop['type'], $val)); } else // row without label @@ -800,11 +816,15 @@ function rcmail_contact_photo($attrib) } $photo_img = $RCMAIL->url($url); } - else + else { $ff_value = '-del-'; // will disable delete-photo action + } - $img = html::img(array('src' => $photo_img, 'border' => 1, 'alt' => '')); - $content = html::div($attrib, $img); + $content = html::div($attrib, html::img(array( + 'src' => $photo_img, + 'alt' => $RCMAIL->gettext('contactphoto'), + 'onerror' => 'this.src = rcmail.env.photo_placeholder', + ))); if ($CONTACT_COLTYPES['photo'] && ($RCMAIL->action == 'edit' || $RCMAIL->action == 'add')) { $RCMAIL->output->add_gui_object('contactphoto', $attrib['id']); diff --git a/program/steps/addressbook/move.inc b/program/steps/addressbook/move.inc index 7a730af77..e83276523 100644 --- a/program/steps/addressbook/move.inc +++ b/program/steps/addressbook/move.inc @@ -142,10 +142,6 @@ foreach ($cids as $source => $source_cids) { } if (!$deleted || $deleted != $all) { - // update saved search after data changed - if ($deleted) { - rcmail_search_update(); - } $OUTPUT->command('list_contacts'); } else { @@ -157,8 +153,13 @@ else { $result = new rcube_result_set($count, $first); $pages = ceil((count($records) + $delcnt) / $PAGE_SIZE); + // last page and it's empty, display previous one + if ($result->count && $result->count <= ($PAGE_SIZE * ($page - 1))) { + $OUTPUT->command('list_page', 'prev'); + $rowcount = $RCMAIL->gettext('loading'); + } // get records from the next page to add to the list - if ($_GET['_from'] != 'show' && $pages > 1 && $page < $pages) { + else if ($pages > 1 && $page < $pages) { // sort the records ksort($records, SORT_LOCALE_STRING); @@ -180,10 +181,15 @@ else { else { // count contacts for this user $result = $CONTACTS->count(); - // get records from the next page to add to the list - $pages = ceil(($result->count + $deleted) / $PAGE_SIZE); + $pages = ceil(($result->count + $deleted) / $PAGE_SIZE); - if ($_GET['_from'] != 'show' && $pages > 1 && $page < $pages) { + // last page and it's empty, display previous one + if ($result->count && $result->count <= ($PAGE_SIZE * ($page - 1))) { + $OUTPUT->command('list_page', 'prev'); + $rowcount = $RCMAIL->gettext('loading'); + } + // get records from the next page to add to the list + else if ($pages > 1 && $page < $pages) { $CONTACTS->set_page($page); $records = $CONTACTS->list_records(null, -$deleted); } @@ -191,7 +197,7 @@ else { // update message count display $OUTPUT->set_env('pagecount', ceil($result->count / $PAGE_SIZE)); - $OUTPUT->command('set_rowcount', rcmail_get_rowcount_text($result)); + $OUTPUT->command('set_rowcount', $rowcount ? $rowcount : rcmail_get_rowcount_text($result)); // add new rows from next page (if any) if (!empty($records)) { diff --git a/program/steps/addressbook/photo.inc b/program/steps/addressbook/photo.inc index 482185735..30d09ffcc 100644 --- a/program/steps/addressbook/photo.inc +++ b/program/steps/addressbook/photo.inc @@ -72,8 +72,12 @@ $plugin = $RCMAIL->plugins->exec_hook('contact_photo', if ($plugin['url']) { $RCMAIL->output->redirect($plugin['url']); } -else { - $data = $plugin['data']; + +$data = $plugin['data']; + +// detect if photo data is an URL +if (strlen($data) < 1024 && filter_var($data, FILTER_VALIDATE_URL)) { + $RCMAIL->output->redirect($data); } // deliver alt image diff --git a/program/steps/addressbook/save.inc b/program/steps/addressbook/save.inc index 94556f96b..4f30fd4b7 100644 --- a/program/steps/addressbook/save.inc +++ b/program/steps/addressbook/save.inc @@ -148,6 +148,15 @@ if (!empty($cid)) { $result = $plugin['result']; if ($result) { + // show confirmation + $OUTPUT->show_message('successfullysaved', 'confirmation', null, false); + + // in search mode, just reload the list (#1490015) + if ($_REQUEST['_search']) { + $OUTPUT->command('parent.command', 'list'); + $OUTPUT->send('iframe'); + } + // LDAP DN change if (is_string($result) && strlen($result)>1) { $newcid = $result; @@ -165,11 +174,13 @@ if (!empty($cid)) { $a_js_cols[] = rcube::Q((string)$record[$col]); } + // performance: unset some big data items we don't need here + $record = array_intersect_key($record, array('ID' => 1,'email' => 1,'name' => 1)); + $record['_type'] = 'person'; + // update the changed col in list $OUTPUT->command('parent.update_contact_row', $cid, $a_js_cols, $newcid, $source, $record); - // show confirmation - $OUTPUT->show_message('successfullysaved', 'confirmation', null, false); $RCMAIL->overwrite_action('show'); } else { @@ -224,29 +235,13 @@ else { $CONTACTS->add_to_group($plugin['group_id'], $plugin['ids']); } } - else { - $counts = $CONTACTS->count(); - } - - if ((string)$source === (string)$orig_source) { - // add contact row or jump to the page where it should appear - $CONTACTS->reset(); - $result = $CONTACTS->search($CONTACTS->primary_key, $insert_id); - - rcmail_js_contacts_list($result, 'parent.'); - $OUTPUT->command('parent.contact_list.select', rcube_utils::html_identifier($insert_id)); - - // update record count display - $CONTACTS->reset(); - $OUTPUT->command('parent.set_rowcount', rcmail_get_rowcount_text($counts)); - } - else { - // re-set iframe - $OUTPUT->command('parent.show_contentframe'); - } // show confirmation $OUTPUT->show_message('successfullysaved', 'confirmation', null, false); + + $OUTPUT->command('parent.set_rowcount', $RCMAIL->gettext('loading')); + $OUTPUT->command('parent.list_contacts'); + $OUTPUT->send('iframe'); } else { diff --git a/program/steps/addressbook/show.inc b/program/steps/addressbook/show.inc index f4224a3e2..5835ce7e5 100644 --- a/program/steps/addressbook/show.inc +++ b/program/steps/addressbook/show.inc @@ -32,7 +32,11 @@ $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)); + + // remember current search request ID (if in search mode) + if ($search = rcube_utils::get_input_value('_search', rcube_utils::INPUT_GET)) { + $OUTPUT->set_env('search_request', $search); + } } // get address book name (for display) @@ -60,6 +64,7 @@ function rcmail_contact_head($attrib) $form = array( 'head' => array( // section 'head' is magic! + 'name' => $RCMAIL->gettext('contactnameandorg'), 'content' => array( 'prefix' => array('type' => 'text'), 'firstname' => array('type' => 'text'), diff --git a/program/steps/addressbook/undo.inc b/program/steps/addressbook/undo.inc index ec3feb9c0..91547b765 100644 --- a/program/steps/addressbook/undo.inc +++ b/program/steps/addressbook/undo.inc @@ -45,9 +45,6 @@ foreach ((array)$undo['data'] as $source => $cid) { } } -// update saved search after data changed -rcmail_search_update(); - $RCMAIL->session->remove('contact_undo'); $OUTPUT->show_message('contactrestored', 'confirmation'); |