From 59478e06c25303a790a0840ab2ac30662c4ef781 Mon Sep 17 00:00:00 2001 From: Hugues Hiegel Date: Tue, 5 Aug 2014 16:46:22 +0200 Subject: c'est la merde.. --- program/steps/addressbook/copy.inc | 12 +- program/steps/addressbook/delete.inc | 38 +- program/steps/addressbook/export.inc | 113 +- program/steps/addressbook/func.inc | 187 +-- program/steps/addressbook/import.inc | 71 +- program/steps/addressbook/list.inc | 49 +- program/steps/addressbook/save.inc | 29 +- program/steps/addressbook/show.inc | 63 +- program/steps/addressbook/undo.inc | 25 +- program/steps/mail/attachments.inc | 5 +- program/steps/mail/check_recent.inc | 9 +- program/steps/mail/compose.inc | 103 +- program/steps/mail/func.inc | 336 ++--- program/steps/mail/func.inc.orig | 1964 ++++++++++++++++++++++++++++++ program/steps/mail/get.inc | 86 +- program/steps/mail/list.inc | 1 + program/steps/mail/list_contacts.inc | 29 +- program/steps/mail/move_del.inc | 11 +- program/steps/mail/sendmail.inc | 30 +- program/steps/mail/show.inc | 61 +- program/steps/mail/show.inc.orig | 315 +++++ program/steps/settings/about.inc | 67 +- program/steps/settings/edit_folder.inc | 5 +- program/steps/settings/edit_prefs.inc | 2 +- program/steps/settings/edit_response.inc | 107 ++ program/steps/settings/folders.inc | 16 +- program/steps/settings/func.inc | 1961 +++++++++++++---------------- program/steps/settings/responses.inc | 128 ++ program/steps/settings/save_prefs.inc | 4 - program/steps/utils/save_pref.inc | 22 +- program/steps/utils/spell.inc | 7 - program/steps/utils/spell_html.inc | 5 - 32 files changed, 3963 insertions(+), 1898 deletions(-) create mode 100644 program/steps/mail/func.inc.orig create mode 100644 program/steps/mail/show.inc.orig create mode 100644 program/steps/settings/edit_response.inc create mode 100644 program/steps/settings/responses.inc (limited to 'program/steps') diff --git a/program/steps/addressbook/copy.inc b/program/steps/addressbook/copy.inc index d4387194a..480a9b52e 100644 --- a/program/steps/addressbook/copy.inc +++ b/program/steps/addressbook/copy.inc @@ -57,16 +57,10 @@ foreach ($cids as $source => $cid) foreach ($cid as $cid) { $a_record = $CONTACTS->get_record($cid, true); - // avoid copying groups - if ($a_record['_type'] == 'group') - continue; - // Check if contact exists, if so, we'll need it's ID // Note: Some addressbooks allows empty email address field - // @TODO: should we check all email addresses? - $email = $CONTACTS->get_col_values('email', $a_record, true); - if (!empty($email)) - $result = $TARGET->search('email', $email[0], 1, true, true); + if (!empty($a_record['email'])) + $result = $TARGET->search('email', $a_record['email'], 1, true, true); else if (!empty($a_record['name'])) $result = $TARGET->search('name', $a_record['name'], 1, true, true); else @@ -120,7 +114,7 @@ foreach ($cids as $source => $cid) } } -if (!$success) +if ($success == 0) $OUTPUT->show_message($errormsg, 'error'); else $OUTPUT->show_message('copysuccess', 'notice', array('nr' => $success)); diff --git a/program/steps/addressbook/delete.inc b/program/steps/addressbook/delete.inc index 3bb2ef500..56118583c 100644 --- a/program/steps/addressbook/delete.inc +++ b/program/steps/addressbook/delete.inc @@ -68,14 +68,48 @@ foreach ($cids as $source => $cid) $page = isset($_SESSION['page']) ? $_SESSION['page'] : 1; // update saved search after data changed -if (($records = rcmail_search_update(true)) !== false) { +if (($search_request = $_REQUEST['_search']) && isset($_SESSION['search'][$search_request])) { + $sort_col = $RCMAIL->config->get('addressbook_sort_col', 'name'); + $afields = $RCMAIL->config->get('contactlist_fields'); + $search = (array)$_SESSION['search'][$search_request]; + $records = array(); + + // Get records from all sources (refresh search) + foreach ($search as $s => $set) { + $source = $RCMAIL->get_address_book($s); + + // reset page + $source->set_page(1); + $source->set_pagesize(9999); + $source->set_search_set($set); + + // get records + $result = $source->list_records($afields); + + if (!$result->count) { + unset($search[$s]); + continue; + } + + while ($row = $result->next()) { + $row['sourceid'] = $s; + $key = rcube_addressbook::compose_contact_key($row, $sort_col); + $records[$key] = $row; + } + unset($result); + + $search[$s] = $source->get_search_set(); + } + + $_SESSION['search'][$search_request] = $search; + // create resultset object $count = count($records); $first = ($page-1) * $PAGE_SIZE; $result = new rcube_result_set($count, $first); - $pages = ceil((count($records) + $delcnt) / $PAGE_SIZE); // get records from the next page to add to the list + $pages = ceil((count($records) + $delcnt) / $PAGE_SIZE); if ($_GET['_from'] != 'show' && $pages > 1 && $page < $pages) { // sort the records ksort($records, SORT_LOCALE_STRING); diff --git a/program/steps/addressbook/export.inc b/program/steps/addressbook/export.inc index 1e988feab..11c9ca493 100644 --- a/program/steps/addressbook/export.inc +++ b/program/steps/addressbook/export.inc @@ -5,7 +5,7 @@ | program/steps/addressbook/export.inc | | | | This file is part of the Roundcube Webmail client | - | Copyright (C) 2008-2013, The Roundcube Dev Team | + | Copyright (C) 2008-2011, The Roundcube Dev Team | | Copyright (C) 2011, Kolab Systems AG | | | | Licensed under the GNU General Public License version 3 or | @@ -21,46 +21,6 @@ +-----------------------------------------------------------------------+ */ - -/** - * Copy contact record properties into a vcard object - */ -function prepare_for_export(&$record, $source = null) -{ - $groups = $source && $source->groups && $source->export_groups ? $source->get_record_groups($record['ID']) : null; - - if (empty($record['vcard'])) { - $vcard = new rcube_vcard(); - if ($source) { - $vcard->extend_fieldmap($source->vcard_map); - } - $vcard->load($record['vcard']); - $vcard->reset(); - - foreach ($record as $key => $values) { - list($field, $section) = explode(':', $key); - foreach ((array)$values as $value) { - if (is_array($value) || @strlen($value)) { - $vcard->set($field, $value, strtoupper($section)); - } - } - } - - // append group names - if ($groups) { - $vcard->set('groups', join(',', $groups), null); - } - - $record['vcard'] = $vcard->export(true); - } - // patch categories to alread existing vcard block - else if ($record['vcard'] && !empty($groups) && !strpos($record['vcard'], 'CATEGORIES:')) { - $vgroups = 'CATEGORIES:' . rcube_vcard::vcard_quote(join(',', $groups)); - $record['vcard'] = str_replace('END:VCARD', $vgroups . rcube_vcard::$eol . 'END:VCARD', $record['vcard']); - } -} - - // Use search result if (!empty($_REQUEST['_search']) && isset($_SESSION['search'][$_REQUEST['_search']])) { @@ -80,15 +40,11 @@ if (!empty($_REQUEST['_search']) && isset($_SESSION['search'][$_REQUEST['_search // get records $result = $source->list_records(); - while ($record = $result->next()) { - // because vcard_map is per-source we need to create vcard here - prepare_for_export($record, $source); - - $record['sourceid'] = $s; - $key = rcube_addressbook::compose_contact_key($record, $sort_col); - $records[$key] = $record; + while ($row = $result->next()) { + $row['sourceid'] = $s; + $key = rcube_addressbook::compose_contact_key($row, $sort_col); + $records[$key] = $row; } - unset($result); } @@ -100,35 +56,6 @@ if (!empty($_REQUEST['_search']) && isset($_SESSION['search'][$_REQUEST['_search $result = new rcube_result_set($count); $result->records = array_values($records); } -// selected contacts -else if (!empty($_REQUEST['_cid'])) { - $sort_col = $RCMAIL->config->get('addressbook_sort_col', 'name'); - $records = array(); - - // Selected contact IDs (with multi-source support) - $cids = rcmail_get_cids(); - - foreach ($cids as $s => $ids) { - $source = $RCMAIL->get_address_book($s); - $result = $source->search('ID', $ids, 1, true, true); - - while ($record = $result->next()) { - // because vcard_map is per-source we need to create vcard here - prepare_for_export($record, $source); - - $record['sourceid'] = $s; - $key = rcube_addressbook::compose_contact_key($record, $sort_col); - $records[$key] = $record; - } - } - - ksort($records, SORT_LOCALE_STRING); - - // create resultset object - $count = count($records); - $result = new rcube_result_set($count); - $result->records = array_values($records); -} // selected directory/group else { $CONTACTS = rcmail_contact_source(null, true); @@ -141,15 +68,33 @@ else { // send downlaod headers header('Content-Type: text/x-vcard; charset='.RCMAIL_CHARSET); -header('Content-Disposition: attachment; filename="contacts.vcf"'); +header('Content-Disposition: attachment; filename="rcube_contacts.vcf"'); while ($result && ($row = $result->next())) { - prepare_for_export($row, $CONTACTS); + // we already have a vcard record + if ($row['vcard'] && $row['name']) { + // fix folding and end-of-line chars + $row['vcard'] = preg_replace('/\r|\n\s+/', '', $row['vcard']); + $row['vcard'] = preg_replace('/\n/', rcube_vcard::$eol, $row['vcard']); + echo rcube_vcard::rfc2425_fold($row['vcard']) . rcube_vcard::$eol; + } + // copy values into vcard object + else { + $vcard = new rcube_vcard(); + $vcard->extend_fieldmap($CONTACTS->vcard_map); + $vcard->load($row['vcard']); + $vcard->reset(); + + foreach ($row as $key => $values) { + list($field, $section) = explode(':', $key); + foreach ((array)$values as $value) { + if (is_array($value) || @strlen($value)) + $vcard->set($field, $value, strtoupper($section)); + } + } - // fix folding and end-of-line chars - $row['vcard'] = preg_replace('/\r|\n\s+/', '', $row['vcard']); - $row['vcard'] = preg_replace('/\n/', rcube_vcard::$eol, $row['vcard']); - echo rcube_vcard::rfc2425_fold($row['vcard']) . rcube_vcard::$eol; + echo $vcard->export(true) . rcube_vcard::$eol; + } } exit; diff --git a/program/steps/addressbook/func.inc b/program/steps/addressbook/func.inc index f94d15338..989b7c1c4 100644 --- a/program/steps/addressbook/func.inc +++ b/program/steps/addressbook/func.inc @@ -183,10 +183,11 @@ function rcmail_directory_list($attrib) $attrib['id'] = 'rcmdirectorylist'; $out = ''; + $local_id = '0'; $jsdata = array(); $line_templ = html::tag('li', array( - 'id' => 'rcmli%s', 'class' => '%s', 'noclose' => true), + 'id' => 'rcmli%s', 'class' => '%s'), html::a(array('href' => '%s', 'rel' => '%s', 'onclick' => "return ".JS_OBJECT_NAME.".command('list','%s',this)"), '%s')); @@ -212,7 +213,7 @@ function rcmail_directory_list($attrib) $name = !empty($source['name']) ? $source['name'] : $id; $out .= sprintf($line_templ, - rcube_utils::html_identifier($id, true), + html_identifier($id), $class_name, Q(rcmail_url(null, array('_source' => $id))), $source['id'], @@ -223,11 +224,10 @@ function rcmail_directory_list($attrib) $groupdata = rcmail_contact_groups($groupdata); $jsdata = $groupdata['jsdata']; $out = $groupdata['out']; - $out .= ''; } $line_templ = html::tag('li', array( - 'id' => 'rcmli%s', 'class' => '%s'), + 'id' => 'rcmliS%s', 'class' => '%s'), html::a(array('href' => '#', 'rel' => 'S%s', 'onclick' => "return ".JS_OBJECT_NAME.".command('listsearch', '%s', this)"), '%s')); @@ -245,17 +245,14 @@ function rcmail_directory_list($attrib) $class_name .= ' ' . $source['class_name']; $out .= sprintf($line_templ, - rcube_utils::html_identifier('S'.$id, true), + html_identifier($id), $class_name, $id, $js_id, (!empty($source['name']) ? Q($source['name']) : 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'); @@ -267,23 +264,19 @@ function rcmail_contact_groups($args) { global $RCMAIL; - $groups_html = ''; $groups = $RCMAIL->get_address_book($args['source'])->list_groups(); if (!empty($groups)) { $line_templ = html::tag('li', array( - 'id' => 'rcmli%s', 'class' => 'contactgroup'), + 'id' => 'rcmliG%s', 'class' => 'contactgroup'), html::a(array('href' => '#', 'rel' => '%s:%s', 'onclick' => "return ".JS_OBJECT_NAME.".command('listgroup',{'source':'%s','id':'%s'},this)"), '%s')); - // append collapse/expand toggle and open a new