summaryrefslogtreecommitdiff
path: root/program/steps/mail
diff options
context:
space:
mode:
authorthomascube <thomas@roundcube.net>2007-04-28 18:07:12 +0000
committerthomascube <thomas@roundcube.net>2007-04-28 18:07:12 +0000
commitf1154163b0a9efb21d722bc658352739040ffd61 (patch)
tree28ccaa50bc27fa2c3d10eb8650a9862710668494 /program/steps/mail
parent9e5d051e97441794d765b094ed46d8cc732c3944 (diff)
Merged branch devel-addressbook from r443 back to trunk
Diffstat (limited to 'program/steps/mail')
-rw-r--r--program/steps/mail/addcontact.inc70
-rw-r--r--program/steps/mail/check_recent.inc19
-rw-r--r--program/steps/mail/compose.inc98
-rw-r--r--program/steps/mail/folders.inc34
-rw-r--r--program/steps/mail/func.inc236
-rw-r--r--program/steps/mail/getunread.inc13
-rw-r--r--program/steps/mail/list.inc24
-rw-r--r--program/steps/mail/mark.inc24
-rw-r--r--program/steps/mail/move_del.inc49
-rw-r--r--program/steps/mail/quotadisplay.inc3
-rw-r--r--program/steps/mail/quotaimg.inc172
-rw-r--r--program/steps/mail/search.inc32
-rw-r--r--program/steps/mail/sendmail.inc79
-rw-r--r--program/steps/mail/show.inc37
-rw-r--r--program/steps/mail/upload.inc39
15 files changed, 335 insertions, 594 deletions
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('<li id="rcmfile%d"><a href="#delete" onclick="return %s.command(\'remove-attachment\',\'rcmfile%d\', this)" title="%s">%s</a>%s</li>',
$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 .= '</ul>';
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 = <<<EOF
<div$attrib_str>
@@ -725,13 +712,13 @@ function rcmail_compose_attachment_form($attrib)
$SESS_HIDDEN_FIELD
$input_field<br />
<input type="button" value="$label_close" class="button" onclick="document.getElementById('$attrib[id]').style.visibility='hidden'" />
-<input type="button" value="$label_send" class="button" onclick="$JS_OBJECT_NAME.command('send-attachment', this.form)" />
+<input type="button" value="$label_send" class="button" onclick="$js_instance.command('send-attachment', this.form)" />
</form>
</div>
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("<td>%s</td><td class=\"title\"><label for=\"%s\">%s</label></td>",
+ $selector .= sprintf("%s<label for=\"%s\">%s</label>",
$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 . "</$type>";
}
@@ -176,7 +178,7 @@ function rcmail_build_folder_tree(&$arrFolders, $folder, $delm='/', $path='')
// return html for a structured list <ul> for the mailbox tree
function rcmail_render_folder_tree_html(&$arrFolders, &$special, &$mbox_name, $maxlength, $nestLevel=0)
{
- global $JS_OBJECT_NAME, $COMM_PATH, $IMAP, $CONFIG, $OUTPUT;
+ global $COMM_PATH, $IMAP, $CONFIG, $OUTPUT;
$idx = 0;
$out = '';
@@ -207,7 +209,8 @@ function rcmail_render_folder_tree_html(&$arrFolders, &$special, &$mbox_name, $m
$foldername .= sprintf(' (%d)', $unread_count);
// make folder name safe for ids and class names
- $folder_css = $class_name = preg_replace('/[^a-z0-9\-_]/', '', $folder_lc);
+ $folder_id = preg_replace('/[^A-Za-z0-9\-_]/', '', $folder['id']);
+ $class_name = preg_replace('/[^a-z0-9\-_]/', '', $folder_lc);
// set special class for Sent, Drafts, Trash and Junk
if ($folder['id']==$CONFIG['sent_mbox'])
@@ -220,25 +223,24 @@ function rcmail_render_folder_tree_html(&$arrFolders, &$special, &$mbox_name, $m
$class_name = 'junk';
$js_name = htmlspecialchars(JQ($folder['id']));
- $out .= sprintf('<li id="rcmbx%s" class="mailbox %s %s%s%s"><a href="%s&amp;_mbox=%s"'.
- ' onclick="return %s.command(\'list\',\'%s\')"'.
- ' onmouseover="return %s.focus_mailbox(\'%s\')"' .
- ' onmouseout="return %s.unfocus_mailbox(\'%s\')"' .
- ' onmouseup="return %s.mbox_mouse_up(\'%s\')"%s>%s</a>',
- $folder_css,
+ $out .= sprintf('<li id="rcmli%s" class="mailbox %s %s%s%s"><a href="%s"'.
+ ' onclick="return %s.command(\'list\',\'%s\',this)"'.
+ ' onmouseover="return %s.focus_folder(\'%s\')"' .
+ ' onmouseout="return %s.unfocus_folder(\'%s\')"' .
+ ' onmouseup="return %s.folder_mouse_up(\'%s\')"%s>%s</a>',
+ $folder_id,
$class_name,
$zebra_class,
$unread_count ? ' unread' : '',
$folder['id']==$mbox_name ? ' selected' : '',
- $COMM_PATH,
- urlencode($folder['id']),
- $JS_OBJECT_NAME,
+ Q(rcmail_self_url('', array('_mbox' => $folder['id']))),
+ JS_OBJECT_NAME,
$js_name,
- $JS_OBJECT_NAME,
+ JS_OBJECT_NAME,
$js_name,
- $JS_OBJECT_NAME,
+ JS_OBJECT_NAME,
$js_name,
- $JS_OBJECT_NAME,
+ JS_OBJECT_NAME,
$js_name,
$title,
Q($foldername));
@@ -293,7 +295,7 @@ function rcmail_render_folder_tree_select(&$arrFolders, &$special, &$mbox_name,
// return the message list as HTML table
function rcmail_message_list($attrib)
{
- global $IMAP, $CONFIG, $COMM_PATH, $OUTPUT, $JS_OBJECT_NAME;
+ global $IMAP, $CONFIG, $COMM_PATH, $OUTPUT;
$skin_path = $CONFIG['skin_path'];
$image_tag = '<img src="%s%s" alt="%s" border="0" />';
@@ -358,28 +360,30 @@ function rcmail_message_list($attrib)
// asc link
if (!empty($attrib['sortascbutton']))
{
- $sort .= rcube_button(array('command' => 'sort',
- 'prop' => $col.'_ASC',
- 'image' => $attrib['sortascbutton'],
- 'align' => 'absmiddle',
- 'title' => 'sortasc'));
+ $sort .= $OUTPUT->button(array(
+ 'command' => 'sort',
+ 'prop' => $col.'_ASC',
+ 'image' => $attrib['sortascbutton'],
+ 'align' => 'absmiddle',
+ 'title' => 'sortasc'));
}
// desc link
if (!empty($attrib['sortdescbutton']))
{
- $sort .= rcube_button(array('command' => 'sort',
- 'prop' => $col.'_DESC',
- 'image' => $attrib['sortdescbutton'],
- 'align' => 'absmiddle',
- 'title' => 'sortdesc'));
+ $sort .= $OUTPUT->button(array(
+ 'command' => 'sort',
+ 'prop' => $col.'_DESC',
+ 'image' => $attrib['sortdescbutton'],
+ 'align' => 'absmiddle',
+ 'title' => 'sortdesc'));
}
}
// just add a link tag to the header
else
{
$col_name = sprintf('<a href="./#sort" onclick="return %s.command(\'sort\',\'%s\',this)" title="%s">%s</a>',
- $JS_OBJECT_NAME,
+ JS_OBJECT_NAME,
$col,
rcube_label('sortby'),
$col_name);
@@ -430,7 +434,7 @@ function rcmail_message_list($attrib)
else if ($attrib['messageicon'])
$message_icon = $attrib['messageicon'];
- // set attachment icon
+ // set attachment icon
if ($attrib['attachmenticon'] && preg_match("/multipart\/[mr]/i", $header->ctype))
$attach_icon = $attrib['attachmenticon'];
@@ -441,7 +445,7 @@ function rcmail_message_list($attrib)
$zebra_class);
$out .= sprintf("<td class=\"icon\">%s</td>\n", $message_icon ? sprintf($image_tag, $skin_path, $message_icon, '') : '');
-
+
// format each col
foreach ($a_show_cols as $col)
{
@@ -449,15 +453,13 @@ function rcmail_message_list($attrib)
$cont = Q(rcmail_address_string($header->$col, 3, $attrib['addicon']), 'show');
else if ($col=='subject')
{
- $cont = Q($IMAP->decode_header($header->$col));
- if (!$cont) $cont = Q(rcube_label('nosubject'));
- // firefox/mozilla temporary workaround to pad subject with content so that whitespace in rows responds to drag+drop
- $cont .= '<img src="./program/blank.gif" height="5" width="1000" alt="" />';
+ $cont = Q(rcube_imap::decode_mime_string($header->$col, $header->charset));
+ if (empty($cont)) $cont = Q(rcube_label('nosubject'));
}
else if ($col=='size')
$cont = show_bytes($header->$col);
else if ($col=='date')
- $cont = format_date($header->date); //date('m.d.Y G:i:s', strtotime($header->date));
+ $cont = format_date($header->date);
else
$cont = Q($header->$col);
@@ -478,50 +480,46 @@ function rcmail_message_list($attrib)
$message_count = $IMAP->messagecount();
// set client env
- $javascript .= sprintf("%s.gui_object('mailcontframe', '%s');\n", $JS_OBJECT_NAME, 'mailcontframe');
- $javascript .= sprintf("%s.gui_object('messagelist', '%s');\n", $JS_OBJECT_NAME, $attrib['id']);
- $javascript .= sprintf("%s.set_env('messagecount', %d);\n", $JS_OBJECT_NAME, $message_count);
- $javascript .= sprintf("%s.set_env('current_page', %d);\n", $JS_OBJECT_NAME, $IMAP->list_page);
- $javascript .= sprintf("%s.set_env('pagecount', %d);\n", $JS_OBJECT_NAME, ceil($message_count/$IMAP->page_size));
- $javascript .= sprintf("%s.set_env('sort_col', '%s');\n", $JS_OBJECT_NAME, $sort_col);
- $javascript .= sprintf("%s.set_env('sort_order', '%s');\n", $JS_OBJECT_NAME, $sort_order);
+ $OUTPUT->add_gui_object('mailcontframe', 'mailcontframe');
+ $OUTPUT->add_gui_object('messagelist', $attrib['id']);
+ $OUTPUT->set_env('messagecount', $message_count);
+ $OUTPUT->set_env('current_page', $IMAP->list_page);
+ $OUTPUT->set_env('pagecount', ceil($message_count/$IMAP->page_size));
+ $OUTPUT->set_env('sort_col', $sort_col);
+ $OUTPUT->set_env('sort_order', $sort_order);
if ($attrib['messageicon'])
- $javascript .= sprintf("%s.set_env('messageicon', '%s%s');\n", $JS_OBJECT_NAME, $skin_path, $attrib['messageicon']);
+ $OUTPUT->set_env('messageicon', $skin_path . $attrib['messageicon']);
if ($attrib['deletedicon'])
- $javascript .= sprintf("%s.set_env('deletedicon', '%s%s');\n", $JS_OBJECT_NAME, $skin_path, $attrib['deletedicon']);
+ $OUTPUT->set_env('deletedicon', $skin_path . $attrib['deletedicon']);
if ($attrib['unreadicon'])
- $javascript .= sprintf("%s.set_env('unreadicon', '%s%s');\n", $JS_OBJECT_NAME, $skin_path, $attrib['unreadicon']);
+ $OUTPUT->set_env('unreadicon', $skin_path . $attrib['unreadicon']);
if ($attrib['repliedicon'])
- $javascript .= sprintf("%s.set_env('repliedicon', '%s%s');\n", $JS_OBJECT_NAME, $skin_path, $attrib['repliedicon']);
+ $OUTPUT->set_env('repliedicon', $skin_path . $attrib['repliedicon']);
if ($attrib['attachmenticon'])
- $javascript .= sprintf("%s.set_env('attachmenticon', '%s%s');\n", $JS_OBJECT_NAME, $skin_path, $attrib['attachmenticon']);
-
- $javascript .= sprintf("%s.set_env('messages', %s);", $JS_OBJECT_NAME, array2js($a_js_message_arr));
+ $OUTPUT->set_env('attachmenticon', $skin_path . $attrib['attachmenticon']);
+
+ $OUTPUT->set_env('messages', array2js($a_js_message_arr));
- $OUTPUT->add_script($javascript);
$OUTPUT->include_script('list.js');
return $out;
}
-
-
// return javascript commands to add rows to the message list
function rcmail_js_message_list($a_headers, $insert_top=FALSE)
{
- global $CONFIG, $IMAP;
+ global $CONFIG, $IMAP, $OUTPUT;
- $commands = '';
$a_show_cols = is_array($CONFIG['list_cols']) ? $CONFIG['list_cols'] : array('subject');
// show 'to' instead of from in sent messages
- if (($IMAP->get_mailbox_name()==$CONFIG['sent_mbox'] || $IMAP->get_mailbox_name()==$CONFIG['drafts_mbox'])
- && ($f = array_search('from', $a_show_cols)) && !array_search('to', $a_show_cols))
+ if (($IMAP->get_mailbox_name() == $CONFIG['sent_mbox'] || $IMAP->get_mailbox_name() == $CONFIG['drafts_mbox'])
+ && (($f = array_search('from', $a_show_cols)) !== false) && array_search('to', $a_show_cols) === false)
$a_show_cols[$f] = 'to';
- $commands .= sprintf("this.set_message_coltypes(%s);\n", array2js($a_show_cols));
+ $OUTPUT->command('set_message_coltypes', $a_show_cols);
// loop through message headers
for ($n=0; $a_headers[$n]; $n++)
@@ -529,7 +527,7 @@ function rcmail_js_message_list($a_headers, $insert_top=FALSE)
$header = $a_headers[$n];
$a_msg_cols = array();
$a_msg_flags = array();
-
+
// format each col; similar as in rcmail_message_list()
foreach ($a_show_cols as $col)
{
@@ -537,13 +535,13 @@ function rcmail_js_message_list($a_headers, $insert_top=FALSE)
$cont = Q(rcmail_address_string($header->$col, 3), 'show');
else if ($col=='subject')
{
- $cont = Q($IMAP->decode_header($header->$col));
+ $cont = Q(rcube_imap::decode_mime_string($header->$col, $header->charset));
if (!$cont) $cont = Q(rcube_label('nosubject'));
}
else if ($col=='size')
$cont = show_bytes($header->$col);
else if ($col=='date')
- $cont = format_date($header->date); //date('m.d.Y G:i:s', strtotime($header->date));
+ $cont = format_date($header->date);
else
$cont = Q($header->$col);
@@ -553,22 +551,20 @@ function rcmail_js_message_list($a_headers, $insert_top=FALSE)
$a_msg_flags['deleted'] = $header->deleted ? 1 : 0;
$a_msg_flags['unread'] = $header->seen ? 0 : 1;
$a_msg_flags['replied'] = $header->answered ? 1 : 0;
- $commands .= sprintf("this.add_message_row(%s, %s, %s, %b, %b);\n",
- $header->uid,
- array2js($a_msg_cols),
- array2js($a_msg_flags),
- preg_match("/multipart\/m/i", $header->ctype),
- $insert_top);
+ $OUTPUT->command('add_message_row',
+ $header->uid,
+ $a_msg_cols,
+ $a_msg_flags,
+ preg_match("/multipart\/m/i", $header->ctype),
+ $insert_top);
}
-
- return $commands;
}
// return an HTML iframe for loading mail content
function rcmail_messagecontent_frame($attrib)
{
- global $OUTPUT, $JS_OBJECT_NAME;
+ global $OUTPUT;
if (empty($attrib['id']))
$attrib['id'] = 'rcmailcontentwindow';
@@ -581,52 +577,21 @@ function rcmail_messagecontent_frame($attrib)
$framename,
$attrib_str);
- $OUTPUT->add_script("$JS_OBJECT_NAME.set_env('contentframe', '$framename');");
+ $OUTPUT->set_env('contentframe', $framename);
+ $OUTPUT->set_env('blankpage', $attrib['src'] ? $OUTPUT->abs_url($attrib['src']) : 'program/blank.gif');
return $out;
}
-// return code for search function
-function rcmail_search_form($attrib)
- {
- global $OUTPUT, $JS_OBJECT_NAME;
-
- // add some labels to client
- rcube_add_label('searching');
-
- $attrib['name'] = '_q';
-
- if (empty($attrib['id']))
- $attrib['id'] = 'rcmqsearchbox';
-
- $input_q = new textfield($attrib);
- $out = $input_q->show();
-
- $OUTPUT->add_script(sprintf("%s.gui_object('qsearchbox', '%s');",
- $JS_OBJECT_NAME,
- $attrib['id']));
-
- // add form tag around text field
- if (empty($attrib['form']))
- $out = sprintf('<form name="rcmqsearchform" action="./" '.
- 'onsubmit="%s.command(\'search\');return false" style="display:inline;">%s</form>',
- $JS_OBJECT_NAME,
- $out);
-
- return $out;
- }
-
function rcmail_messagecount_display($attrib)
{
- global $IMAP, $OUTPUT, $JS_OBJECT_NAME;
+ global $IMAP, $OUTPUT;
if (!$attrib['id'])
$attrib['id'] = 'rcmcountdisplay';
- $OUTPUT->add_script(sprintf("%s.gui_object('countdisplay', '%s');",
- $JS_OBJECT_NAME,
- $attrib['id']));
+ $OUTPUT->add_gui_object('countdisplay', $attrib['id']);
// allow the following attributes to be added to the <span> tag
$attrib_str = create_attrib_string($attrib, array('style', 'class', 'id'));
@@ -641,12 +606,12 @@ function rcmail_messagecount_display($attrib)
function rcmail_quota_display($attrib)
{
- global $OUTPUT, $JS_OBJECT_NAME, $COMM_PATH;
+ global $OUTPUT, $COMM_PATH;
if (!$attrib['id'])
$attrib['id'] = 'rcmquotadisplay';
- $OUTPUT->add_script(sprintf("%s.gui_object('quotadisplay', '%s');", $JS_OBJECT_NAME, $attrib['id']));
+ $OUTPUT->add_gui_object('quotadisplay', $attrib['id']);
// allow the following attributes to be added to the <span> tag
$attrib_str = create_attrib_string($attrib, array('style', 'class', 'id'));
@@ -675,8 +640,7 @@ function rcmail_quota_content($display)
if ($display == 'image' && function_exists('imagegif'))
{
$attrib = array('width' => 100, 'height' => 14);
- $quota_text = sprintf('<img src="%s&amp;_action=quotaimg&amp;u=%s&amp;q=%d&amp;w=%d&amp;h=%d" width="%d" height="%d" alt="%s" title="%s / %s" />',
- $COMM_PATH,
+ $quota_text = sprintf('<img src="./bin/quotaimg.php?u=%s&amp;q=%d&amp;w=%d&amp;h=%d" width="%d" height="%d" alt="%s" title="%s / %s" />',
$quota['used'], $quota['total'],
$attrib['width'], $attrib['height'],
$attrib['width'], $attrib['height'],
@@ -723,7 +687,7 @@ function rcmail_get_messagecount_text($count=NULL, $page=NULL)
function rcmail_print_body($part, $safe=FALSE, $plain=FALSE)
{
- global $IMAP, $REMOTE_OBJECTS, $JS_OBJECT_NAME;
+ global $IMAP, $REMOTE_OBJECTS;
$body = is_array($part->replaces) ? strtr($part->body, $part->replaces) : $part->body;
@@ -795,7 +759,7 @@ function rcmail_print_body($part, $safe=FALSE, $plain=FALSE)
$convert_replaces[] = "rcmail_str_replacement('\\1<a href=\"http://\\2\\3\" target=\"_blank\">\\2\\3</a>', \$replace_strings)";
$convert_patterns[] = '/([a-z0-9][a-z0-9\-\.\+\_]*@[a-z0-9]([a-z0-9\-][.]?)*[a-z0-9]\\.[a-z]{2,5})/ie';
- $convert_replaces[] = "rcmail_str_replacement('<a href=\"mailto:\\1\" onclick=\"return $JS_OBJECT_NAME.command(\'compose\',\'\\1\',this)\">\\1</a>', \$replace_strings)";
+ $convert_replaces[] = "rcmail_str_replacement('<a href=\"mailto:\\1\" onclick=\"return ".JS_OBJECT_NAME.".command(\'compose\',\'\\1\',this)\">\\1</a>', \$replace_strings)";
if ($part->ctype_parameters['format'] != 'flowed')
$body = wordwrap(trim($body), 80);
@@ -1052,7 +1016,7 @@ function rcmail_message_headers($attrib, $headers=NULL)
// get associative array of headers object
if (!$headers)
$headers = is_object($MESSAGE['headers']) ? get_object_vars($MESSAGE['headers']) : $MESSAGE['headers'];
-
+
$header_count = 0;
// allow the following attributes to be added to the <table> tag
@@ -1072,7 +1036,7 @@ function rcmail_message_headers($attrib, $headers=NULL)
else if (in_array($hkey, array('from', 'to', 'cc', 'bcc', 'reply-to')))
$header_value = Q(rcmail_address_string($headers[$hkey], NULL, $attrib['addicon']), 'show');
else
- $header_value = Q($IMAP->decode_header($headers[$hkey]));
+ $header_value = Q(rcube_imap::decode_mime_string($headers[$hkey], $headers['charset']));
$out .= "\n<tr>\n";
$out .= '<td class="header-title">'.Q(rcube_label($hkey)).":&nbsp;</td>\n";
@@ -1089,7 +1053,7 @@ function rcmail_message_headers($attrib, $headers=NULL)
function rcmail_message_body($attrib)
{
- global $CONFIG, $OUTPUT, $MESSAGE, $IMAP, $GET_URL, $REMOTE_OBJECTS, $JS_OBJECT_NAME;
+ global $CONFIG, $OUTPUT, $MESSAGE, $IMAP, $GET_URL, $REMOTE_OBJECTS;
if (!is_array($MESSAGE['parts']) && !$MESSAGE['body'])
return '';
@@ -1169,7 +1133,7 @@ function rcmail_message_body($attrib)
// tell client that there are blocked remote objects
if ($REMOTE_OBJECTS && !$safe_mode)
- $OUTPUT->add_script(sprintf("%s.set_env('blockedobjects', true);", $JS_OBJECT_NAME));
+ $OUTPUT->set_env('blockedobjects', true);
$out .= "\n</div>";
return $out;
@@ -1261,7 +1225,7 @@ function rcmail_alter_html_link($in)
if (stristr((string)$attrib['href'], 'mailto:'))
$attrib['onclick'] = sprintf("return %s.command('compose','%s',this)",
- $GLOBALS['JS_OBJECT_NAME'],
+ JS_OBJECT_NAME,
JQ(substr($attrib['href'], 7)));
else if (!empty($attrib['href']) && $attrib['href']{0}!='#')
$attrib['target'] = '_blank';
@@ -1383,7 +1347,7 @@ function rcmail_first_text_part($message_struct)
// decode address string and re-format it as HTML links
function rcmail_address_string($input, $max=NULL, $addicon=NULL)
{
- global $IMAP, $PRINT_MODE, $CONFIG, $OUTPUT, $JS_OBJECT_NAME, $EMAIL_ADDRESS_PATTERN;
+ global $IMAP, $PRINT_MODE, $CONFIG, $OUTPUT, $EMAIL_ADDRESS_PATTERN;
$a_parts = $IMAP->decode_address_list($input);
@@ -1403,14 +1367,14 @@ function rcmail_address_string($input, $max=NULL, $addicon=NULL)
{
$out .= sprintf('<a href="mailto:%s" onclick="return %s.command(\'compose\',\'%s\',this)" class="rcmContactAddress" title="%s">%s</a>',
Q($part['mailto']),
- $JS_OBJECT_NAME,
+ JS_OBJECT_NAME,
JQ($part['mailto']),
Q($part['mailto']),
Q($part['name']));
if ($addicon)
$out .= sprintf('&nbsp;<a href="#add" onclick="return %s.command(\'add-contact\',\'%s\',this)" title="%s"><img src="%s%s" alt="add" border="0" /></a>',
- $JS_OBJECT_NAME,
+ JS_OBJECT_NAME,
urlencode($part['string']),
rcube_label('addtoaddressbook'),
$CONFIG['skin_path'],
@@ -1500,6 +1464,20 @@ function rcmail_compose_cleanup()
unset($_SESSION['compose']);
}
-
-
+
+
+// register UI objects
+$OUTPUT->add_handlers(array(
+ 'mailboxlist' => 'rcmail_mailbox_list',
+ 'messages' => 'rcmail_message_list',
+ 'messagecountdisplay' => 'rcmail_messagecount_display',
+ 'quotadisplay' => 'rcmail_quota_display',
+ 'messageheaders' => 'rcmail_message_headers',
+ 'messagebody' => 'rcmail_message_body',
+ 'messagecontentframe' => 'rcmail_messagecontent_frame',
+ 'messagepartframe' => 'rcmail_message_part_frame',
+ 'messagepartcontrols' => 'rcmail_message_part_controls',
+ 'searchform' => 'rcmail_search_form'
+));
+
?> \ No newline at end of file
diff --git a/program/steps/mail/getunread.inc b/program/steps/mail/getunread.inc
index ed4a5fb77..e6b3843e4 100644
--- a/program/steps/mail/getunread.inc
+++ b/program/steps/mail/getunread.inc
@@ -19,18 +19,13 @@
*/
-$REMOTE_REQUEST = TRUE;
-
$a_folders = $IMAP->list_mailboxes();
if (!empty($a_folders))
- {
+{
foreach ($a_folders as $mbox_row)
- {
- $commands = sprintf("this.set_unread_count('%s', %d);\n", addslashes($mbox_row), $IMAP->messagecount($mbox_row, 'UNSEEN'));
- rcube_remote_response($commands, TRUE);
- }
- }
+ $OUTPUT->command('set_unread_count', $mbox_row, $IMAP->messagecount($mbox_row, 'UNSEEN'));
+}
-exit;
+$OUTPUT->send();
?>
diff --git a/program/steps/mail/list.inc b/program/steps/mail/list.inc
index 6e0637441..162624c36 100644
--- a/program/steps/mail/list.inc
+++ b/program/steps/mail/list.inc
@@ -19,25 +19,23 @@
*/
-$REMOTE_REQUEST = TRUE;
$OUTPUT_TYPE = 'js';
-
// is there a sort type for this request?
if ($sort = get_input_value('_sort', RCUBE_INPUT_GET))
- {
+{
// yes, so set the sort vars
list($sort_col, $sort_order) = explode('_', $sort);
// set session vars for sort (so next page and task switch know how to sort)
$_SESSION['sort_col'] = $sort_col;
$_SESSION['sort_order'] = $sort_order;
- }
+}
else
- {
+{
// use session settings if set, defaults if not
$sort_col = isset($_SESSION['sort_col']) ? $_SESSION['sort_col'] : $CONFIG['message_sort_col'];
$sort_order = isset($_SESSION['sort_order']) ? $_SESSION['sort_order'] : $CONFIG['message_sort_order'];
- }
+}
// fetch message headers
@@ -48,22 +46,20 @@ $unseen = $IMAP->messagecount($mbox_name, 'UNSEEN', !empty($_GET['_refresh']) ?
// update message count display
$pages = ceil($count/$IMAP->page_size);
-$commands = sprintf("this.set_env('messagecount', %d);\n", $count);
-$commands .= sprintf("this.set_env('pagecount', %d);\n", $pages);
-$commands .= sprintf("this.set_rowcount('%s');\n", rcmail_get_messagecount_text($count));
+$OUTPUT->set_env('messagecount', $count);
+$OUTPUT->set_env('pagecount', $pages);
+$OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($count));
// update mailboxlist
-$mbox_name = $IMAP->get_mailbox_name();
-$commands .= sprintf("this.set_unread_count('%s', %d);\n", addslashes($mbox_name), $unseen);
+$OUTPUT->command('set_unread_count', $IMAP->get_mailbox_name(), $unseen);
// add message rows
if (isset($a_headers) && count($a_headers))
- $commands .= rcmail_js_message_list($a_headers);
+ rcmail_js_message_list($a_headers);
// send response
-rcube_remote_response($commands);
+$OUTPUT->send();
-exit;
?> \ No newline at end of file
diff --git a/program/steps/mail/mark.inc b/program/steps/mail/mark.inc
index 780bf5c6e..0dd781e08 100644
--- a/program/steps/mail/mark.inc
+++ b/program/steps/mail/mark.inc
@@ -4,7 +4,7 @@
| program/steps/mail/mark.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: |
@@ -18,24 +18,24 @@
*/
-$REMOTE_REQUEST = TRUE;
-
-$a_flags_map = array('undelete' => 'UNDELETED',
- 'delete' => 'DELETED',
- 'read' => 'SEEN',
- 'unread' => 'UNSEEN');
+$a_flags_map = array(
+ 'undelete' => 'UNDELETED',
+ 'delete' => 'DELETED',
+ 'read' => 'SEEN',
+ 'unread' => 'UNSEEN');
if (($uids = get_input_value('_uid', RCUBE_INPUT_GET)) && ($flag = get_input_value('_flag', RCUBE_INPUT_GET)))
- {
+{
$flag = $a_flags_map[$flag] ? $a_flags_map[$flag] : strtoupper($flag);
$marked = $IMAP->set_flag($uids, $flag);
+
if ($marked != -1)
- {
+ {
$mbox_name = $IMAP->get_mailbox_name();
- $commands = sprintf("this.set_unread_count('%s', %d);\n", $mbox_name, $IMAP->messagecount($mbox_name, 'UNSEEN'));
- rcube_remote_response($commands);
- }
+ $OUTPUT->command('set_unread_count', $mbox_name, $IMAP->messagecount($mbox_name, 'UNSEEN'));
+ $OUTPUT->send();
}
+}
exit;
?> \ No newline at end of file
diff --git a/program/steps/mail/move_del.inc b/program/steps/mail/move_del.inc
index 8d31e3aa5..fb8a0af4c 100644
--- a/program/steps/mail/move_del.inc
+++ b/program/steps/mail/move_del.inc
@@ -5,7 +5,7 @@
| program/steps/mail/move_del.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,46 +19,42 @@
*/
-$REMOTE_REQUEST = TRUE;
-
// move messages
if ($_action=='moveto' && !empty($_GET['_uid']) && !empty($_GET['_target_mbox']))
- {
+{
$count = sizeof(explode(',', ($uids = get_input_value('_uid', RCUBE_INPUT_GET))));
$target = get_input_value('_target_mbox', RCUBE_INPUT_GET);
$moved = $IMAP->move_message($uids, $target, get_input_value('_mbox', RCUBE_INPUT_GET));
if (!$moved)
- {
+ {
// send error message
- $commands = "this.list_mailbox();\n";
- $commands .= show_message('errormoving', 'error');
- rcube_remote_response($commands);
+ $OUTPUT->command('list_mailbox');
+ $OUTPUT->show_message('errormoving', 'error');
+ $OUTPUT->send();
exit;
- }
}
+}
// delete messages
else if ($_action=='delete' && !empty($_GET['_uid']))
- {
+{
$count = sizeof(explode(',', ($uids = get_input_value('_uid', RCUBE_INPUT_GET))));
$del = $IMAP->delete_message($uids, get_input_value('_mbox', RCUBE_INPUT_GET));
if (!$del)
- {
+ {
// send error message
- $commands = "this.list_mailbox();\n";
- $commands .= show_message('errordeleting', 'error');
- rcube_remote_response($commands);
+ $OUTPUT->command('list_mailbox');
+ $OUTPUT->show_message('errordeleting', 'error');
+ $OUTPUT->send();
exit;
- }
}
+}
// unknown action or missing query param
else
- {
exit;
- }
// refresh saved seach set after moving some messages
if (($search_request = get_input_value('_search', RCUBE_INPUT_GPC)) && $IMAP->search_set)
@@ -68,34 +64,33 @@ if (($search_request = get_input_value('_search', RCUBE_INPUT_GPC)) && $IMAP->se
// update message count display
$msg_count = $IMAP->messagecount();
$pages = ceil($msg_count / $IMAP->page_size);
-$commands = sprintf("this.set_rowcount('%s');\n", rcmail_get_messagecount_text($msg_count));
-$commands .= sprintf("this.set_env('pagecount', %d);\n", $pages);
+$OUTPUT->set_env('pagecount', $pages);
+$OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($msg_count));
// update mailboxlist
$mbox = $IMAP->get_mailbox_name();
-$commands .= sprintf("this.set_unread_count('%s', %d);\n", $mbox, $IMAP->messagecount($mbox, 'UNSEEN'));
+$OUTPUT->command('set_unread_count', $mbox, $IMAP->messagecount($mbox, 'UNSEEN'));
if ($_action=='moveto' && $target)
- $commands .= sprintf("this.set_unread_count('%s', %d);\n", $target, $IMAP->messagecount($target, 'UNSEEN'));
+ $OUTPUT->command('set_unread_count', $target, $IMAP->messagecount($target, 'UNSEEN'));
-$commands .= sprintf("this.set_quota('%s');\n", $IMAP->get_quota());
+$OUTPUT->command('set_quota', $IMAP->get_quota());
// add new rows from next page (if any)
if ($_GET['_from']!='show' && $pages>1 && $IMAP->list_page < $pages)
- {
+{
$sort_col = isset($_SESSION['sort_col']) ? $_SESSION['sort_col'] : $CONFIG['message_sort_col'];
$sort_order = isset($_SESSION['sort_order']) ? $_SESSION['sort_order'] : $CONFIG['message_sort_order'];
$a_headers = $IMAP->list_headers($mbox, NULL, $sort_col, $sort_order);
$a_headers = array_slice($a_headers, -$count, $count);
- $commands .= rcmail_js_message_list($a_headers);
- }
+ rcmail_js_message_list($a_headers);
+}
// send response
-rcube_remote_response($commands);
+$OUTPUT->send();
-exit;
?>
diff --git a/program/steps/mail/quotadisplay.inc b/program/steps/mail/quotadisplay.inc
index c96a7a7ee..accecdb91 100644
--- a/program/steps/mail/quotadisplay.inc
+++ b/program/steps/mail/quotadisplay.inc
@@ -22,8 +22,7 @@
$display = isset($_GET['_display']) ? $_GET['_display'] : 'text';
$id = isset($_GET['_id']) ? $_GET['_id'] : 'rcmquotadisplay';
$quota = rcmail_quota_content($display);
-$command = sprintf("this.gui_objects.%s.innerHTML = '%s';\n", $id, $quota);
-rcube_remote_response($command);
+$OUTPUT->remote_response(sprintf("this.gui_objects.%s.innerHTML = '%s';\n", $id, $quota));
exit;
?>
diff --git a/program/steps/mail/quotaimg.inc b/program/steps/mail/quotaimg.inc
deleted file mode 100644
index 643ae1c55..000000000
--- a/program/steps/mail/quotaimg.inc
+++ /dev/null
@@ -1,172 +0,0 @@
-<?php
-
-/*
- +-----------------------------------------------------------------------+
- | program/steps/mail/quotaimg.inc |
- | |
- | This file is part of the RoundCube Webmail client |
- | Copyright (C) 2005, RoundCube Dev. - Switzerland |
- | Licensed under the GNU GPL |
- | |
- | PURPOSE: |
- | Create a GIF image showing the mailbox quot as bar |
- | |
- +-----------------------------------------------------------------------+
- | Author: Brett Patterson <brett2@umbc.edu> |
- +-----------------------------------------------------------------------+
-
- $Id: $
-
-*/
-
-$used = ((isset($_GET['u']) && !empty($_GET['u'])) || $_GET['u']=='0')?(int)$_GET['u']:'??';
-$quota = ((isset($_GET['q']) && !empty($_GET['q'])) || $_GET['q']=='0')?(int)$_GET['q']:'??';
-$width = empty($_GET['w']) ? 100 : (int)$_GET['w'];
-$height = empty($_GET['h']) ? 14 : (int)$_GET['h'];
-
-function genQuota($used, $total, $width, $height)
-{
- /**
- * Quota Display
- *
- * Modify the following few elements to change the display of the image.
- * Modifiable attributes are:
- * bool border :: Defines whether you want to show a border around it or not.
- * bool unknown :: Leave default; Defines whether quota is "unknown"
- *
- * int height :: Defines height of the image
- * int width :: Defines width of the image
- * int font :: Changes the font size & font used in the GD library.
- * Available values are from 1 to 5.
- * int padding :: Changes the offset (in pixels) from the top of the image to
- * where the top of the text will be aligned. User greater than
- * 0 to ensure text is off the border.
- * array limit :: Holds the integer values of in an associative array as to what
- * defines the upper and lower levels for quota display.
- * High - Quota is nearing capacity.
- * Mid - Quota is around the middle
- * Low - Currently not used.
- * array color :: An associative array of strings of comma separated values (R,G,B)
- * for use in color creation. Define the RGB values you'd like to
- * use. A list of colors (and their RGB values) can be found here:
- * http://www.december.com/html/spec/colorcodes.html
- **/
-
- $unknown = false;
- $border = 0;
-
- $font = 2;
- $padding = 0;
-
- $limit['high'] = 70;
- $limit['mid'] = 45;
- $limit['low'] = 0;
-
- // Fill Colors
- $color['fill']['high'] = '215, 13, 13'; // Near quota fill color
- $color['fill']['mid'] = '126, 192, 238';// Mid-area of quota fill color
- $color['fill']['low'] = '147, 225, 100'; // Far from quota fill color
-
- // Background colors
- $color['bg']['OL'] = '215, 13, 13'; // Over limit bbackground
- $color['bg']['Unknown'] = '238, 99, 99';// Unknown background
- $color['bg']['quota'] = '255, 255, 255';// Normal quota background
-
- // Misc. Colors
- $color['border'] = '0, 0, 0';
- $color['text'] = '102, 102, 102';
-
-
- /****************************
- ***** DO NOT EDIT BELOW HERE *****
- ****************************/
-
- if(ereg("^[^0-9?]*$", $used) || ereg("^[^0-9?]*$", $total))
- {
- return false;
- }
- if(strpos($used, '?')!==false || strpos($total, '?')!==false && $used != 0)
- {
- $unknown = true;
- }
-
- $im = imagecreate($width, $height);
-
- if($border)
- {
- list($r, $g, $b) = explode(',', $color['border']);
- $borderc = imagecolorallocate($im, $r, $g, $b);
- imageline($im, 0, 0, $width, 0, $borderc);
- imageline($im, 0, $height-$border, 0, 0, $borderc);
- imageline($im, $width-1, 0, $width-$border, $height, $borderc);
- imageline($im, $width, $height-$border, 0, $height-$border, $borderc);
- }
-
- list($r, $g, $b) = explode(',', $color['text']);
- $text = imagecolorallocate($im, $r, $g, $b);
-
- if($unknown)
- {
- list($r, $g, $b) = explode(',', $color['bg']['Unknown']);
- $background = imagecolorallocate($im, $r, $g, $b);
- imagefilledrectangle($im, 0, 0, $width, $height, $background);
-
- $string = 'Unknown';
- $mid = floor(($width-(strlen($string)*imagefontwidth($font)))/2)+1;
- imagestring($im, $font, $mid, $padding, $string, $text);
- }
- else if($used > $total)
- {
- list($r, $g, $b) = explode(',', $color['bg']['OL']);
- $background = imagecolorallocate($im, $r, $g, $b);
- imagefilledrectangle($im, 0, 0, $width, $height, $background);
-
- $string = 'Over Limit';
- $mid = floor(($width-(strlen($string)*imagefontwidth($font)))/2)+1;
- imagestring($im, $font, $mid, $padding, $string, $text);
- }
- else
- {
- list($r, $g, $b) = explode(',', $color['bg']['quota']);
- $background = imagecolorallocate($im, $r, $b, $g);
- imagefilledrectangle($im, 0, 0, $width, $height, $background);
-
- $quota = ($used==0)?0:(round($used/$total, 2)*100);
-
- if($quota >= $limit['high'])
- {
- list($r, $g, $b) = explode(',', $color['fill']['high']);
- $fill = imagecolorallocate($im, $r, $g, $b);
- }
- elseif($quota >= $limit['mid'])
- {
- list($r, $g, $b) = explode(',', $color['fill']['mid']);
- $fill = imagecolorallocate($im, $r, $g, $b);
- }
- else // if($quota >= $limit['low'])
- {
- list($r, $g, $b) = explode(',', $color['fill']['low']);
- $fill = imagecolorallocate($im, $r, $g, $b);
- }
-
- $quota_width = $quota / 100 * $width;
- imagefilledrectangle($im, $border, 0, $quota, $height-2*$border, $fill);
-
- $string = $quota.'%';
- $mid = floor(($width-(strlen($string)*imagefontwidth($font)))/2)+1;
- imagestring($im, $font, $mid, $padding, $string, $text); // Print percent in black
- }
-
- header('Content-Type: image/gif');
- header("Expires: ".gmdate("D, d M Y H:i:s", mktime()+86400)." GMT");
- header("Cache-Control: ");
- header("Pragma: ");
-
- imagegif($im);
- imagedestroy($im);
-}
-
-
-genQuota($used, $quota, $width, $height);
-exit;
-?> \ No newline at end of file
diff --git a/program/steps/mail/search.inc b/program/steps/mail/search.inc
index c4b843b55..bef821b40 100644
--- a/program/steps/mail/search.inc
+++ b/program/steps/mail/search.inc
@@ -25,7 +25,7 @@ $_SESSION['page'] = 1;
$imap_charset = 'UTF-8';
// get search string
-$str = get_input_value('_search', RCUBE_INPUT_GET);
+$str = get_input_value('_q', RCUBE_INPUT_GET);
$mbox = get_input_value('_mbox', RCUBE_INPUT_GET);
$search_request = md5($mbox.$str);
@@ -71,16 +71,14 @@ else
// execute IMAP search
$result = $IMAP->search($mbox, $subject, $search, $imap_charset);
-
-$commands = '';
$count = 0;
// Make sure our $result is legit..
if (is_array($result) && $result[0] != '')
- {
+{
// Get the headers
$result_h = $IMAP->list_header_set($mbox, $result, 1, $_SESSION['sort_col'], $_SESSION['sort_order']);
- $count = count($result);
+ $count = count($result_h);
// save search results in session
if (!is_array($_SESSION['search']))
@@ -88,24 +86,24 @@ if (is_array($result) && $result[0] != '')
// Make sure we got the headers
if ($result_h != NULL)
- {
+ {
$_SESSION['search'][$search_request] = $IMAP->get_search_set();
- $commands = rcmail_js_message_list($result_h);
- $commands .= show_message('searchsuccessful', 'confirmation', array('nr' => $count));
- }
+ rcmail_js_message_list($result_h);
+ $OUTPUT->show_message('searchsuccessful', 'confirmation', array('nr' => $count));
}
+}
else
- {
- $commands = show_message('searchnomatch', 'warning');
+{
+ $OUTPUT->show_message('searchnomatch', 'warning');
$search_request = -1;
- }
+}
// update message count display
$pages = ceil($count/$IMAP->page_size);
-$commands .= sprintf("\nthis.set_env('search_request', '%s')\n", $search_request);
-$commands .= sprintf("this.set_env('messagecount', %d);\n", $count);
-$commands .= sprintf("this.set_env('pagecount', %d);\n", $pages);
-$commands .= sprintf("this.set_rowcount('%s');\n", rcmail_get_messagecount_text($count, 1));
-rcube_remote_response($commands);
+$OUTPUT->set_env('search_request', $search_request);
+$OUTPUT->set_env('messagecount', $count);
+$OUTPUT->set_env('pagecount', $pages);
+$OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($count, 1));
+$OUTPUT->send();
?> \ No newline at end of file
diff --git a/program/steps/mail/sendmail.inc b/program/steps/mail/sendmail.inc
index 4a65ee390..bc454b309 100644
--- a/program/steps/mail/sendmail.inc
+++ b/program/steps/mail/sendmail.inc
@@ -5,7 +5,7 @@
| program/steps/mail/sendmail.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: |
@@ -39,7 +39,7 @@ if (!isset($_SESSION['compose']['id']))
function rcmail_get_identity($id)
{
- global $DB, $CHARSET, $OUTPUT;
+ global $DB, $OUTPUT;
// get identity record
$sql_result = $DB->query("SELECT *, email AS mailto
@@ -55,7 +55,7 @@ function rcmail_get_identity($id)
$out = $sql_arr;
$name = strpos($sql_arr['name'], ",") ? '"'.$sql_arr['name'].'"' : $sql_arr['name'];
$out['string'] = sprintf('%s <%s>',
- rcube_charset_convert($name, $CHARSET, $OUTPUT->get_charset()),
+ rcube_charset_convert($name, RCMAIL_CHARSET, $OUTPUT->get_charset()),
$sql_arr['mailto']);
return $out;
}
@@ -110,9 +110,8 @@ function rcmail_attach_emoticons(&$mime_message)
// add the image to the MIME message
$img_file = $INSTALL_PATH . '/' . $searchstr . $image_name;
if(! $mime_message->addHTMLImage($img_file, 'image/gif', '', true, '_' . $image_name))
- {
- show_message("emoticonerror", 'error');
- }
+ $OUTPUT->show_message("emoticonerror", 'error');
+
array_push($included_images, $image_name);
}
@@ -132,7 +131,7 @@ $savedraft = !empty($_POST['_draft']) ? TRUE : FALSE;
// remove all scripts and act as called in frame
$OUTPUT->reset();
-$_framed = TRUE;
+$OUTPUT->framed = TRUE;
/****** check submission and compose message ********/
@@ -140,8 +139,8 @@ $_framed = TRUE;
if (!$savedraft && empty($_POST['_to']) && empty($_POST['_subject']) && $_POST['_message'])
{
- show_message("sendingfailed", 'error');
- rcube_iframe_response();
+ $OUTPUT->show_message("sendingfailed", 'error');
+ $OUTPUT->send('iframe');
return;
}
@@ -168,7 +167,7 @@ if (empty($identity_arr['string']))
// compose headers array
$headers = array('Date' => date('D, j M Y H:i:s O'),
- 'From' => rcube_charset_convert($identity_arr['string'], $CHARSET, $message_charset),
+ 'From' => rcube_charset_convert($identity_arr['string'], RCMAIL_CHARSET, $message_charset),
'To' => $mailto);
// additional recipients
@@ -304,7 +303,7 @@ if ($MBSTRING && function_exists("mb_encode_mimeheader"))
{
mb_internal_encoding($message_charset);
$mb_subject = mb_encode_mimeheader($headers['Subject'], $message_charset, 'Q');
- mb_internal_encoding($CHARSET);
+ mb_internal_encoding(RCMAIL_CHARSET);
}
// Begin SMTP Delivery Block
@@ -334,13 +333,8 @@ if (!$savedraft) {
// log error
if (!$sent)
- {
- raise_error(array('code' => 800,
- 'type' => 'smtp',
- 'line' => __LINE__,
- 'file' => __FILE__,
+ raise_error(array('code' => 800, 'type' => 'smtp', 'line' => __LINE__, 'file' => __FILE__,
'message' => "SMTP error: ".join("\n", $smtp_response)), TRUE, FALSE);
- }
}
// send mail using PHP's mail() function
@@ -368,8 +362,8 @@ if (!$savedraft) {
// return to compose page if sending failed
if (!$sent)
{
- show_message("sendingfailed", 'error');
- rcube_iframe_response();
+ $OUTPUT->show_message("sendingfailed", 'error');
+ $OUTPUT->send('iframe');
return;
}
@@ -409,13 +403,11 @@ if ($CONFIG[$store_target])
// raise error if saving failed
if (!$saved)
{
- raise_error(array('code' => 800,
- 'type' => 'imap',
- 'file' => __FILE__,
+ raise_error(array('code' => 800, 'type' => 'imap', 'file' => __FILE__,
'message' => "Could not save message in $CONFIG[$store_target]"), TRUE, FALSE);
- show_message('errorsaving', 'error');
- rcube_iframe_response($errorout);
+ $OUTPUT->show_message('errorsaving', 'error');
+ $OUTPUT->send('iframe');
}
if ($olddraftmessageid)
@@ -426,41 +418,36 @@ if ($CONFIG[$store_target])
// raise error if deletion of old draft failed
if (!$deleted)
- raise_error(array('code' => 800,
- 'type' => 'imap',
- 'file' => __FILE__,
+ raise_error(array('code' => 800, 'type' => 'imap', 'file' => __FILE__,
'message' => "Could not delete message from ".$CONFIG['drafts_mbox']), TRUE, FALSE);
}
}
if ($savedraft)
{
- // clear the "saving message" busy status, and display success
- show_message('messagesaved', 'confirmation');
-
- // update "_draft_saveid" on the page, which is used to delete a previous draft
- $frameout = "var foundid = parent.rcube_find_object('_draft_saveid', parent.document);\n";
- $frameout .= sprintf("foundid.value = '%s';\n", str_replace(array('<','>'), "", $message_id));
+ // display success
+ $OUTPUT->show_message('messagesaved', 'confirmation');
- // update the "cmp_hash" to prevent "Unsaved changes" warning
- $frameout .= sprintf("parent.%s.cmp_hash = parent.%s.compose_field_hash();\n", $JS_OBJECT_NAME, $JS_OBJECT_NAME);
+ // update "_draft_saveid" and the "cmp_hash" to prevent "Unsaved changes" warning
+ $OUTPUT->command('set_draft_id', str_replace(array('<','>'), "", $message_id));
+ $OUTPUT->command('compose_field_hash', true);
// start the auto-save timer again
- $frameout .= sprintf("parent.%s.auto_save_start();", $JS_OBJECT_NAME);
+ $OUTPUT->command('auto_save_start');
- // send html page with JS calls as response
- rcube_iframe_response($frameout);
+ $OUTPUT->send('iframe');
}
else
{
if ($CONFIG['smtp_log'])
{
- $log_entry = sprintf("[%s] User: %d on %s; Message for %s; %s\n",
- date("d-M-Y H:i:s O", mktime()),
- $_SESSION['user_id'],
- $_SERVER['REMOTE_ADDR'],
- $mailto,
- !empty($smtp_response) ? join('; ', $smtp_response) : '');
+ $log_entry = sprintf(
+ "[%s] User: %d on %s; Message for %s; %s\n",
+ date("d-M-Y H:i:s O", mktime()),
+ $_SESSION['user_id'],
+ $_SERVER['REMOTE_ADDR'],
+ $mailto,
+ !empty($smtp_response) ? join('; ', $smtp_response) : '');
if ($fp = @fopen($CONFIG['log_dir'].'/sendmail', 'a'))
{
@@ -470,8 +457,8 @@ else
}
rcmail_compose_cleanup();
- rcube_iframe_response(sprintf("parent.$JS_OBJECT_NAME.sent_successfully('%s');",
- JQ(rcube_label('messagesent'))));
+ $OUTPUT->command('sent_successfully', rcube_label('messagesent'));
+ $OUTPUT->send('iframe');
}
diff --git a/program/steps/mail/show.inc b/program/steps/mail/show.inc
index 19e6e56a9..6c247aea9 100644
--- a/program/steps/mail/show.inc
+++ b/program/steps/mail/show.inc
@@ -5,7 +5,7 @@
| program/steps/mail/show.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: |
@@ -32,7 +32,7 @@ if ($_GET['_uid'])
// go back to list if message not found (wrong UID)
if (!$MESSAGE['headers'])
{
- show_message('messageopenerror', 'error');
+ $OUTPUT->show_message('messageopenerror', 'error');
if ($_action=='preview' && template_exists('messagepreview'))
parse_template('messagepreview');
else
@@ -51,8 +51,8 @@ if ($_GET['_uid'])
else
send_modified_header($_SESSION['login_time'], $etag);
-
- $MESSAGE['subject'] = $IMAP->decode_header($MESSAGE['headers']->subject);
+ $MESSAGE['subject'] = rcube_imap::decode_mime_string($MESSAGE['headers']->subject, $MESSAGE['headers']->charset);
+ $OUTPUT->set_pagetitle($MESSAGE['subject']);
if ($MESSAGE['structure'] = $IMAP->get_structure($MESSAGE['UID']))
list($MESSAGE['parts'], $MESSAGE['attachments']) = rcmail_parse_message(
@@ -70,8 +70,8 @@ if ($_GET['_uid'])
$IMAP->set_flag($MESSAGE['UID'], 'SEEN');
// give message uid to the client
- $javascript = sprintf("%s.set_env('uid', '%s');\n", $JS_OBJECT_NAME, $MESSAGE['UID']);
- $javascript .= sprintf("%s.set_env('safemode', '%b');", $JS_OBJECT_NAME, $_GET['_safe']);
+ $OUTPUT->set_env('uid', $MESSAGE['UID']);
+ $OUTPUT->set_env('safemode', (bool)$_GET['_safe']);
$next = $prev = -1;
// get previous, first, next and last message UID
@@ -99,22 +99,20 @@ if ($_GET['_uid'])
}
if ($prev > 0)
- $javascript .= sprintf("\n%s.set_env('prev_uid', '%s');", $JS_OBJECT_NAME, $prev);
+ $OUTPUT->set_env('prev_uid', $prev);
if ($first >0)
- $javascript .= sprintf("\n%s.set_env('first_uid', '%s');", $JS_OBJECT_NAME, $first);
+ $OUTPUT->set_env('first_uid', $first);
if ($next > 0)
- $javascript .= sprintf("\n%s.set_env('next_uid', '%s');", $JS_OBJECT_NAME, $next);
+ $OUTPUT->set_env('next_uid', $next);
if ($last >0)
- $javascript .= sprintf("\n%s.set_env('last_uid', '%s');", $JS_OBJECT_NAME, $last);
-
- $OUTPUT->add_script($javascript);
+ $OUTPUT->set_env('last_uid', $last);
}
function rcmail_message_attachments($attrib)
{
- global $CONFIG, $OUTPUT, $PRINT_MODE, $MESSAGE, $GET_URL, $JS_OBJECT_NAME;
+ global $CONFIG, $OUTPUT, $PRINT_MODE, $MESSAGE, $GET_URL;
if (sizeof($MESSAGE['attachments']))
{
@@ -132,7 +130,7 @@ function rcmail_message_attachments($attrib)
$out .= sprintf('<li><a href="%s&amp;_part=%s" onclick="return %s.command(\'load-attachment\',{part:\'%s\', mimetype:\'%s\'},this)">%s</a></li>'."\n",
htmlspecialchars($GET_URL),
$attach_prop->mime_id,
- $JS_OBJECT_NAME,
+ JS_OBJECT_NAME,
$attach_prop->mime_id,
$attach_prop->mimetype,
$attach_prop->filename);
@@ -147,7 +145,7 @@ function rcmail_message_attachments($attrib)
function rcmail_remote_objects_msg($attrib)
{
- global $CONFIG, $OUTPUT, $JS_OBJECT_NAME;
+ global $CONFIG, $OUTPUT;
if (!$attrib['id'])
$attrib['id'] = 'rcmremoteobjmsg';
@@ -158,16 +156,21 @@ function rcmail_remote_objects_msg($attrib)
$out .= sprintf('%s&nbsp;<a href="#loadimages" onclick="%s.command(\'load-images\')">%s</a>',
Q(rcube_label('blockedimages')),
- $JS_OBJECT_NAME,
+ JS_OBJECT_NAME,
Q(rcube_label('showimages')));
$out .= '</div>';
- $OUTPUT->add_script(sprintf("%s.gui_object('remoteobjectsmsg', '%s');", $JS_OBJECT_NAME, $attrib['id']));
+ $OUTPUT->add_gui_object('remoteobjectsmsg', $attrib['id']);
return $out;
}
+$OUTPUT->add_handlers(array(
+ 'messageattachments' => 'rcmail_message_attachments',
+ 'blockedobjects' => 'rcmail_remote_objects_msg'));
+
+
if ($_action=='print' && template_exists('printmessage'))
parse_template('printmessage');
else if ($_action=='preview' && template_exists('messagepreview'))
diff --git a/program/steps/mail/upload.inc b/program/steps/mail/upload.inc
index 06ed26591..a28c3e8e2 100644
--- a/program/steps/mail/upload.inc
+++ b/program/steps/mail/upload.inc
@@ -47,23 +47,22 @@ foreach ($_FILES['_attachments']['tmp_name'] as $i => $filepath)
'path' => $tmpfname);
if (is_file($CONFIG['skin_path'] . '/images/icons/remove-attachment.png'))
- $button = sprintf('<img src="%s/images/icons/remove-attachment.png" alt="%s" border="0" style="padding-right:2px;vertical-align:middle" />',
- $CONFIG['skin_path'],
- Q(rcube_label('delete')));
+ $button = sprintf(
+ '<img src="%s/images/icons/remove-attachment.png" alt="%s" border="0" style="padding-right:2px;vertical-align:middle" />',
+ $CONFIG['skin_path'],
+ Q(rcube_label('delete')));
else
$button = Q(rcube_label('delete'));
- $content = sprintf('<a href="#delete" onclick="return %s.command(\\\'remove-attachment\\\', \\\'rcmfile%d\\\', this)" title="%s">%s</a>%s',
- $JS_OBJECT_NAME,
- $id,
- Q(rcube_label('delete')),
- $button,
- Q($_FILES['_attachments']['name'][$i]));
-
- $response .= sprintf('parent.%s.add2attachment_list(\'rcmfile%d\',\'%s\');',
- $JS_OBJECT_NAME,
- $id,
- $content);
+ $content = sprintf(
+ '<a href="#delete" onclick="return %s.command(\'remove-attachment\', \'rcmfile%d\', this)" title="%s">%s</a>%s',
+ JS_OBJECT_NAME,
+ $id,
+ Q(rcube_label('delete')),
+ $button,
+ Q($_FILES['_attachments']['name'][$i]));
+
+ $OUTPUT->command('add2attachment_list', "rcmfile$id", $content);
}
else // upload failed
{
@@ -73,18 +72,14 @@ foreach ($_FILES['_attachments']['tmp_name'] as $i => $filepath)
else
$msg = rcube_label('fileuploaderror');
- $response = sprintf("parent.%s.display_message('%s', 'error');", $JS_OBJECT_NAME, JQ($msg));
+ $OUTPUT->command('display_message', $msg, 'error');
}
}
// send html page with JS calls as response
-$frameout = <<<EOF
-$response
-parent.$JS_OBJECT_NAME.show_attachment_form(false);
-parent.$JS_OBJECT_NAME.auto_save_start();
-EOF;
-
-rcube_iframe_response($frameout);
+$OUTPUT->command('show_attachment_form', false);
+$OUTPUT->command('auto_save_start', false);
+$OUTPUT->send('iframe');
?>