From f1154163b0a9efb21d722bc658352739040ffd61 Mon Sep 17 00:00:00 2001 From: thomascube Date: Sat, 28 Apr 2007 18:07:12 +0000 Subject: Merged branch devel-addressbook from r443 back to trunk --- program/steps/mail/addcontact.inc | 70 +++++------ program/steps/mail/check_recent.inc | 19 ++- program/steps/mail/compose.inc | 98 +++++++-------- program/steps/mail/folders.inc | 34 +++--- program/steps/mail/func.inc | 236 ++++++++++++++++-------------------- program/steps/mail/getunread.inc | 13 +- program/steps/mail/list.inc | 24 ++-- program/steps/mail/mark.inc | 24 ++-- program/steps/mail/move_del.inc | 49 ++++---- program/steps/mail/quotadisplay.inc | 3 +- program/steps/mail/quotaimg.inc | 172 -------------------------- program/steps/mail/search.inc | 32 +++-- program/steps/mail/sendmail.inc | 79 +++++------- program/steps/mail/show.inc | 37 +++--- program/steps/mail/upload.inc | 39 +++--- 15 files changed, 335 insertions(+), 594 deletions(-) delete mode 100644 program/steps/mail/quotaimg.inc (limited to 'program/steps/mail') diff --git a/program/steps/mail/addcontact.inc b/program/steps/mail/addcontact.inc index b040581aa..484b0d4ba 100644 --- a/program/steps/mail/addcontact.inc +++ b/program/steps/mail/addcontact.inc @@ -5,7 +5,7 @@ | program/steps/mail/addcontact.inc | | | | This file is part of the RoundCube Webmail client | - | Copyright (C) 2005, RoundCube Dev. - Switzerland | + | Copyright (C) 2005-2007, RoundCube Dev. - Switzerland | | Licensed under the GNU GPL | | | | PURPOSE: | @@ -19,49 +19,37 @@ */ -$REMOTE_REQUEST = TRUE; +require_once('include/rcube_contacts.inc'); -if (!empty($_GET['_address'])) - { - $contact_arr = $IMAP->decode_address_list(get_input_value('_address', RCUBE_INPUT_GET, TRUE)); - if (sizeof($contact_arr)) - { - $contact = $contact_arr[1]; - - if ($contact['mailto']) - $sql_result = $DB->query("SELECT 1 FROM ".get_table_name('contacts')." - WHERE user_id=? - AND email=? - AND del<>1", - $_SESSION['user_id'],$contact['mailto']); - - // contact entry with this mail address exists - if ($sql_result && $DB->num_rows($sql_result)) - $existing_contact = TRUE; - - else if ($contact['mailto']) - { - $DB->query("INSERT INTO ".get_table_name('contacts')." - (user_id, changed, del, name, email) - VALUES (?, ".$DB->now().", 0, ?, ?)", - $_SESSION['user_id'], - $contact['name'], - $contact['mailto']); +$done = false; - $added = $DB->insert_id(get_sequence_name('contacts')); - } - } - - if ($added) - $commands = show_message('addedsuccessfully', 'confirmation'); - else if ($existing_contact) - $commands = show_message('contactexists', 'warning'); +if (!empty($_POST['_address'])) +{ + $CONTACTS = new rcube_contacts($DB, $_SESSION['user_id']); + $contact_arr = $IMAP->decode_address_list(get_input_value('_address', RCUBE_INPUT_POST, true), 1, false); + + if (!empty($contact_arr[1]['mailto'])) + { + $contact = array( + 'email' => $contact_arr[1]['mailto'], + 'name' => $contact_arr[1]['name'] + ); + + // use email address part for name + if (empty($contact['name']) || $contact['name'] == $contact['email']) + $contact['name'] = ucfirst(preg_replace('/[\.\-]/', ' ', substr($contact['email'], 0, strpos($contact['email'], '@')))); + + // check for existing contacts + $existing = $CONTACTS->search('email', $contact['email'], false); + if ($done = $existing->count) + $OUTPUT->show_message('contactexists', 'warning'); + else if ($done = $CONTACTS->insert($contact)) + $OUTPUT->show_message('addedsuccessfully', 'confirmation'); } +} +if (!$done) + $OUTPUT->show_message('errorsavingcontact', 'warning'); -if (!$commands) - $commands = show_message('errorsavingcontact', 'warning'); - -rcube_remote_response($commands); -exit; +$OUTPUT->send(); ?> \ No newline at end of file diff --git a/program/steps/mail/check_recent.inc b/program/steps/mail/check_recent.inc index ca35725ea..119d481ab 100644 --- a/program/steps/mail/check_recent.inc +++ b/program/steps/mail/check_recent.inc @@ -5,7 +5,7 @@ | program/steps/mail/check_recent.inc | | | | This file is part of the RoundCube Webmail client | - | Copyright (C) 2005, RoundCube Dev. - Switzerland | + | Copyright (C) 2005-2007, RoundCube Dev. - Switzerland | | Licensed under the GNU GPL | | | | PURPOSE: | @@ -19,8 +19,6 @@ */ -$REMOTE_REQUEST = TRUE; - $a_mailboxes = $IMAP->list_mailboxes(); foreach ($a_mailboxes as $mbox_name) @@ -32,10 +30,10 @@ foreach ($a_mailboxes as $mbox_name) $count = $IMAP->messagecount(NULL, 'ALL', TRUE); $unread_count = $IMAP->messagecount(NULL, 'UNSEEN', TRUE); - $commands .= sprintf("this.set_unread_count('%s', %d);\n", addslashes($mbox_name), $unread_count); - $commands .= sprintf("this.set_env('messagecount', %d);\n", $count); - $commands .= sprintf("this.set_rowcount('%s');\n", rcmail_get_messagecount_text($count)); - $commands .= sprintf("this.set_quota('%s');\n", $IMAP->get_quota()); + $OUTPUT->set_env('messagecount', $count); + $OUTPUT->command('set_unread_count', $mbox_name, $unread_count); + $OUTPUT->command('set_rowcount', rcmail_get_messagecount_text()); + $OUTPUT->command('set_quota', $IMAP->get_quota()); // add new message headers to list $a_headers = array(); @@ -46,15 +44,16 @@ foreach ($a_mailboxes as $mbox_name) $a_headers[] = $header; } - $commands .= rcmail_js_message_list($a_headers, TRUE); + rcmail_js_message_list($a_headers, TRUE); } } else { if ($IMAP->messagecount($mbox_name, 'RECENT')) - $commands .= sprintf("this.set_unread_count('%s', %d);\n", addslashes($mbox_name), $IMAP->messagecount($mbox_name, 'UNSEEN')); + $OUTPUT->command('set_unread_count', $mbox_name, $IMAP->messagecount($mbox_name, 'UNSEEN')); } } -rcube_remote_response($commands); +$OUTPUT->send(); + ?> diff --git a/program/steps/mail/compose.inc b/program/steps/mail/compose.inc index 24057a224..4e73b4ba1 100644 --- a/program/steps/mail/compose.inc +++ b/program/steps/mail/compose.inc @@ -36,8 +36,8 @@ if ($_action=='remove-attachment' && preg_match('/^rcmfile([0-9]+)$/', $_GET['_f { @unlink($_SESSION['compose']['attachments'][$id]['path']); $_SESSION['compose']['attachments'][$id] = NULL; - $commands = sprintf("parent.%s.remove_from_attachment_list('rcmfile%d');\n", $JS_OBJECT_NAME, $id); - rcube_remote_response($commands); + $OUTPUT->command('remove_from_attachment_list', "rcmfile$id"); + $OUTPUT->send(); exit; } } @@ -61,7 +61,7 @@ if (!is_array($_SESSION['compose']) || $_SESSION['compose']['id'] != get_input_v rcube_add_label('nosubject', 'norecipientwarning', 'nosubjectwarning', 'nobodywarning', 'notsentwarning', 'savingmessage', 'sendingmessage', 'messagesaved', 'converting'); // add config parameter to client script -$OUTPUT->add_script(sprintf("%s.set_env('draft_autosave', %d);", $JS_OBJECT_NAME, !empty($CONFIG['drafts_mbox']) ? $CONFIG['draft_autosave'] : 0)); +$OUTPUT->set_env('draft_autosave', !empty($CONFIG['drafts_mbox']) ? $CONFIG['draft_autosave'] : 0); // get reference message and set compose mode @@ -125,24 +125,10 @@ function rcmail_compose_headers($attrib) case 'to': $fname = '_to'; $header = 'to'; - - // we have contact id's as get parameters - if (!empty($_GET['_to']) && preg_match('/^[0-9]+(,[0-9]+)*$/', $_GET['_to'])) - { - $a_recipients = array(); - $sql_result = $DB->query("SELECT name, email - FROM ".get_table_name('contacts')." - WHERE user_id=? - AND del<>1 - AND contact_id IN (".$_GET['_to'].")", - $_SESSION['user_id']); - - while ($sql_arr = $DB->fetch_assoc($sql_result)) - $a_recipients[] = format_email_recipient($sql_arr['email'], $sql_arr['name']); - - if (sizeof($a_recipients)) - $fvalue = join(', ', $a_recipients); - } + + // we have a set of recipients stored is session + if (($mailto_id = get_input_value('_mailto', RCUBE_INPUT_GET)) && $_SESSION['mailto'][$mailto_id]) + $fvalue = $_SESSION['mailto'][$mailto_id]; else if (!empty($_GET['_to'])) $fvalue = get_input_value('_to', RCUBE_INPUT_GET); @@ -246,7 +232,7 @@ function rcmail_compose_headers($attrib) function rcmail_compose_header_from($attrib) { - global $IMAP, $MESSAGE, $DB, $OUTPUT, $JS_OBJECT_NAME, $compose_mode; + global $IMAP, $MESSAGE, $DB, $OUTPUT, $compose_mode; // pass the following attributes to the form class $field_attrib = array('name' => '_from'); @@ -291,7 +277,7 @@ function rcmail_compose_header_from($attrib) $from_id = 0; $a_signatures = array(); - $field_attrib['onchange'] = "$JS_OBJECT_NAME.change_identity(this)"; + $field_attrib['onchange'] = JS_OBJECT_NAME.".change_identity(this)"; $select_from = new select($field_attrib); while ($sql_arr = $DB->fetch_assoc($sql_result)) @@ -330,7 +316,7 @@ function rcmail_compose_header_from($attrib) $out = $select_from->show($from_id); // add signatures to client - $OUTPUT->add_script(sprintf("%s.set_env('signatures', %s);", $JS_OBJECT_NAME, array2js($a_signatures))); + $OUTPUT->set_env('signatures', $a_signatures); } else { @@ -348,7 +334,7 @@ function rcmail_compose_header_from($attrib) function rcmail_compose_body($attrib) { - global $CONFIG, $OUTPUT, $MESSAGE, $JS_OBJECT_NAME, $compose_mode; + global $CONFIG, $OUTPUT, $MESSAGE, $compose_mode; list($form_start, $form_end) = get_form_tags($attrib); unset($attrib['form']); @@ -470,7 +456,7 @@ function rcmail_compose_body($attrib) $lang_set, substr($_SESSION['user_lang'], 0, 2), $attrib['id'], - $JS_OBJECT_NAME), 'foot'); + JS_OBJECT_NAME), 'foot'); rcube_add_label('checking'); } @@ -666,7 +652,7 @@ function rcmail_compose_subject($attrib) function rcmail_compose_attachment_list($attrib) { - global $OUTPUT, $JS_OBJECT_NAME, $CONFIG; + global $OUTPUT, $CONFIG; // add ID if not given if (!$attrib['id']) @@ -690,14 +676,14 @@ function rcmail_compose_attachment_list($attrib) foreach ($_SESSION['compose']['attachments'] as $id => $a_prop) $out .= sprintf('
  • %s%s
  • ', $id, - $JS_OBJECT_NAME, + JS_OBJECT_NAME, $id, Q(rcube_label('delete')), $button, Q($a_prop['name'])); } - $OUTPUT->add_script(sprintf("%s.gui_object('attachmentlist', '%s');", $JS_OBJECT_NAME, $attrib['id'])); + $OUTPUT->add_gui_object('attachmentlist', $attrib['id']); $out .= ''; return $out; @@ -707,7 +693,7 @@ function rcmail_compose_attachment_list($attrib) function rcmail_compose_attachment_form($attrib) { - global $OUTPUT, $JS_OBJECT_NAME, $SESS_HIDDEN_FIELD; + global $OUTPUT, $SESS_HIDDEN_FIELD; // add ID if not given if (!$attrib['id']) @@ -718,6 +704,7 @@ function rcmail_compose_attachment_form($attrib) $input_field = rcmail_compose_attachment_field(array()); $label_send = rcube_label('upload'); $label_close = rcube_label('close'); + $js_instance = JS_OBJECT_NAME; $out = << @@ -725,13 +712,13 @@ function rcmail_compose_attachment_form($attrib) $SESS_HIDDEN_FIELD $input_field
    - + EOF; - $OUTPUT->add_script(sprintf("%s.gui_object('uploadbox', '%s');", $JS_OBJECT_NAME, $attrib['id'])); + $OUTPUT->add_gui_object('uploadbox', $attrib['id']); return $out; } @@ -829,7 +816,7 @@ function rcmail_editor_selector($attrib) $attrib['id'] = '_' . $value; $rb = new radiobutton($attrib); - $selector .= sprintf("%s", + $selector .= sprintf("%s", $rb->show($value), $attrib['id'], rcube_label($text)); @@ -841,7 +828,7 @@ function rcmail_editor_selector($attrib) function get_form_tags($attrib) { - global $CONFIG, $OUTPUT, $JS_OBJECT_NAME, $MESSAGE_FORM, $SESS_HIDDEN_FIELD; + global $CONFIG, $OUTPUT, $MESSAGE_FORM, $SESS_HIDDEN_FIELD; $form_start = ''; if (!strlen($MESSAGE_FORM)) @@ -858,7 +845,7 @@ function get_form_tags($attrib) $form_name = !empty($attrib['form']) ? $attrib['form'] : 'form'; if (!strlen($MESSAGE_FORM)) - $OUTPUT->add_script("$JS_OBJECT_NAME.gui_object('messageform', '$form_name');"); + $OUTPUT->add_gui_object('messageform', $form_name); $MESSAGE_FORM = $form_name; @@ -866,38 +853,35 @@ function get_form_tags($attrib) } -function format_email_recipient($email, $name='') - { - if ($name && $name != $email) - return sprintf('%s <%s>', strpos($name, ",") ? '"'.$name.'"' : $name, $email); - else - return $email; - } - - -function rcmail_charset_pulldown($selected='ISO-8859-1') - { - $select = new select(); - - - return $select->show($selected); - } +// register UI objects +$OUTPUT->add_handlers(array( + 'composeheaders' => 'rcmail_compose_headers', + 'composesubject' => 'rcmail_compose_subject', + 'composebody' => 'rcmail_compose_body', + 'composeattachmentlist' => 'rcmail_compose_attachment_list', + 'composeattachmentform' => 'rcmail_compose_attachment_form', + 'composeattachment' => 'rcmail_compose_attachment_field', + 'priorityselector' => 'rcmail_priority_selector', + 'editorselector' => 'rcmail_editor_selector', + 'receiptcheckbox' => 'rcmail_receipt_checkbox', +)); /****** get contacts for this user and add them to client scripts ********/ -$sql_result = $DB->query("SELECT name, email - FROM ".get_table_name('contacts')." WHERE user_id=? - AND del<>1",$_SESSION['user_id']); +require_once('include/rcube_contacts.inc'); + +$CONTACTS = new rcube_contacts($DB, $_SESSION['user_id']); +$CONTACTS->set_pagesize(1000); -if ($DB->num_rows($sql_result)) +if ($result = $CONTACTS->list_records()) { $a_contacts = array(); - while ($sql_arr = $DB->fetch_assoc($sql_result)) + while ($sql_arr = $result->iterate()) if ($sql_arr['email']) $a_contacts[] = format_email_recipient($sql_arr['email'], JQ($sql_arr['name'])); - $OUTPUT->add_script(sprintf("$JS_OBJECT_NAME.set_env('contacts', %s);", array2js($a_contacts))); + $OUTPUT->set_env('contacts', $a_contacts); } diff --git a/program/steps/mail/folders.inc b/program/steps/mail/folders.inc index 1b7007c39..a97057e2c 100644 --- a/program/steps/mail/folders.inc +++ b/program/steps/mail/folders.inc @@ -18,44 +18,40 @@ $Id$ */ -$REMOTE_REQUEST = TRUE; $mbox_name = $IMAP->get_mailbox_name(); - // send EXPUNGE command if ($_action=='expunge') - { +{ $success = $IMAP->expunge(get_input_value('_mbox', RCUBE_INPUT_GET)); // reload message list if current mailbox if ($success && !empty($_GET['_reload'])) - { - rcube_remote_response('this.message_list.clear();', TRUE); + { + $OUTPUT->command('message_list.clear'); $_action = 'list'; return; - } + } else $commands = "// expunged: $success\n"; - } +} // clear mailbox else if ($_action=='purge') - { +{ $success = $IMAP->clear_mailbox(get_input_value('_mbox', RCUBE_INPUT_GET)); if ($success && !empty($_GET['_reload'])) - { - $commands = "this.message_list.clear();\n"; - $commands .= "this.set_env('messagecount', 0);\n"; - $commands .= "this.set_env('pagecount', 0);\n"; - $commands .= sprintf("this.set_rowcount('%s');\n", rcmail_get_messagecount_text()); - $commands .= sprintf("this.set_unread_count('%s', 0);\n", addslashes($mbox_name)); - } + { + $OUTPUT->set_env('messagecount', 0); + $OUTPUT->set_env('pagecount', 0); + $OUTPUT->command('message_list.clear'); + $OUTPUT->command('set_rowcount', rcmail_get_messagecount_text()); + $OUTPUT->command('set_unread_count', $mbox_name, 0); + } else $commands = "// purged: $success"; - } - - +} -rcube_remote_response($commands); +$OUTPUT->send($commands); ?> \ No newline at end of file diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc index a0bdf0995..7416fb5d4 100644 --- a/program/steps/mail/func.inc +++ b/program/steps/mail/func.inc @@ -5,7 +5,7 @@ | program/steps/mail/func.inc | | | | This file is part of the RoundCube Webmail client | - | Copyright (C) 2005, RoundCube Dev. - Switzerland | + | Copyright (C) 2005-2007, RoundCube Dev. - Switzerland | | Licensed under the GNU GPL | | | | PURPOSE: | @@ -25,9 +25,8 @@ require_once('lib/enriched.inc'); $EMAIL_ADDRESS_PATTERN = '/([a-z0-9][a-z0-9\-\.\+\_]*@[a-z0-9]([a-z0-9\-][.]?)*[a-z0-9]\\.[a-z]{2,5})/i'; -if (empty($_SESSION['mbox'])){ +if (empty($_SESSION['mbox'])) $_SESSION['mbox'] = $IMAP->get_mailbox_name(); -} // set imap properties and session vars if ($mbox = get_input_value('_mbox', RCUBE_INPUT_GPC)) @@ -63,21 +62,24 @@ if (strlen($_GET['_uid'])) // set current mailbox in client environment -$OUTPUT->add_script(sprintf("%s.set_env('mailbox', '%s');", $JS_OBJECT_NAME, $IMAP->get_mailbox_name())); +$OUTPUT->set_env('mailbox', $IMAP->get_mailbox_name()); +//$OUTPUT->set_pagetitle(rcube_charset_convert($IMAP->get_mailbox_name(), 'UTF-7', 'UTF-8')); if ($CONFIG['trash_mbox']) - $OUTPUT->add_script(sprintf("%s.set_env('trash_mailbox', '%s');", $JS_OBJECT_NAME, $CONFIG['trash_mbox'])); - + $OUTPUT->set_env('trash_mailbox', $CONFIG['trash_mbox']); if ($CONFIG['drafts_mbox']) - $OUTPUT->add_script(sprintf("%s.set_env('drafts_mailbox', '%s');", $JS_OBJECT_NAME, $CONFIG['drafts_mbox'])); - + $OUTPUT->set_env('drafts_mailbox', $CONFIG['drafts_mbox']); if ($CONFIG['junk_mbox']) - $OUTPUT->add_script(sprintf("%s.set_env('junk_mailbox', '%s');", $JS_OBJECT_NAME, $CONFIG['junk_mbox'])); + $OUTPUT->set_env('junk_mailbox', $CONFIG['junk_mbox']); + +if (!$OUTPUT->ajax_call) + rcube_add_label('checkingmail'); + // return the mailboxlist in HTML function rcmail_mailbox_list($attrib) { - global $IMAP, $CONFIG, $OUTPUT, $JS_OBJECT_NAME, $COMM_PATH; + global $IMAP, $CONFIG, $OUTPUT, $COMM_PATH; static $s_added_script = FALSE; static $a_mailboxes; @@ -136,7 +138,7 @@ function rcmail_mailbox_list($attrib) if ($type=='ul') - $OUTPUT->add_script(sprintf("%s.gui_object('mailboxlist', '%s');", $JS_OBJECT_NAME, $attrib['id'])); + $OUTPUT->add_gui_object('mailboxlist', $attrib['id']); return $out . ""; } @@ -176,7 +178,7 @@ function rcmail_build_folder_tree(&$arrFolders, $folder, $delm='/', $path='') // return html for a structured list