summaryrefslogtreecommitdiff
path: root/program/steps/settings/manage_folders.inc
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/settings/manage_folders.inc
parent9e5d051e97441794d765b094ed46d8cc732c3944 (diff)
Merged branch devel-addressbook from r443 back to trunk
Diffstat (limited to 'program/steps/settings/manage_folders.inc')
-rw-r--r--program/steps/settings/manage_folders.inc100
1 files changed, 47 insertions, 53 deletions
diff --git a/program/steps/settings/manage_folders.inc b/program/steps/settings/manage_folders.inc
index 8dd898d26..7499fe3d4 100644
--- a/program/steps/settings/manage_folders.inc
+++ b/program/steps/settings/manage_folders.inc
@@ -5,7 +5,7 @@
| program/steps/settings/manage_folders.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: |
@@ -29,8 +29,8 @@ if ($_action=='subscribe')
if ($mboxes = get_input_value('_mboxes', RCUBE_INPUT_GET))
$IMAP->subscribe(array($mboxes));
- if ($REMOTE_REQUEST)
- rcube_remote_response('// subscribed');
+ if ($OUTPUT->ajax_call)
+ $OUTPUT->remote_response('// subscribed');
}
// unsubscribe one or more mailboxes
@@ -39,8 +39,8 @@ else if ($_action=='unsubscribe')
if ($mboxes = get_input_value('_mboxes', RCUBE_INPUT_GET))
$IMAP->unsubscribe(array($mboxes));
- if ($REMOTE_REQUEST)
- rcube_remote_response('// unsubscribed');
+ if ($OUTPUT->ajax_call)
+ $OUTPUT->remote_response('// unsubscribed');
}
// create a new mailbox
@@ -49,47 +49,40 @@ else if ($_action=='create-folder')
if (!empty($_GET['_name']))
$create = $IMAP->create_mailbox(trim(get_input_value('_name', RCUBE_INPUT_GET, FALSE, 'UTF-7')), TRUE);
- if ($create && $REMOTE_REQUEST)
+ if ($create && $OUTPUT->ajax_call)
{
- $commands = sprintf("this.add_folder_row('%s','%s')",
- JQ($create),
- JQ(rcube_charset_convert($create, 'UTF-7')));
- rcube_remote_response($commands);
+ $OUTPUT->command('add_folder_row', $create, rcube_charset_convert($create, 'UTF-7'));
+ $OUTPUT->send();
}
- else if (!$create && $REMOTE_REQUEST)
+ else if (!$create && $OUTPUT->ajax_call)
{
- $commands = show_message('errorsaving', 'error');
- rcube_remote_response($commands);
+ $OUTPUT->show_message('errorsaving', 'error');
+ $OUTPUT->remote_response();
}
else if (!$create)
- show_message('errorsaving', 'error');
+ $OUTPUT->show_message('errorsaving', 'error');
}
// rename a mailbox
else if ($_action=='rename-folder')
{
if (!empty($_GET['_folder_oldname']) && !empty($_GET['_folder_newname']))
- $rename = $IMAP->rename_mailbox(get_input_value('_folder_oldname', RCUBE_INPUT_GET), trim(get_input_value('_folder_newname', RCUBE_INPUT_GET, FALSE, 'UTF-7')));
+ $rename = $IMAP->rename_mailbox(($oldname = get_input_value('_folder_oldname', RCUBE_INPUT_GET)), trim(get_input_value('_folder_newname', RCUBE_INPUT_GET, FALSE, 'UTF-7')));
- if ($rename && $REMOTE_REQUEST)
+ if ($rename && $OUTPUT->ajax_call)
{
- $commands = sprintf("this.replace_folder_row('%s','%s','%s');\n",
- JQ(get_input_value('_folder_oldname', RCUBE_INPUT_GET)),
- JQ($rename),
- JQ(rcube_charset_convert($rename, 'UTF-7')));
-
- $commands .= "this.reset_folder_rename();\n";
-
- rcube_remote_response($commands);
+ $OUTPUT->command('replace_folder_row', $oldname, $rename, rcube_charset_convert($rename, 'UTF-7'));
+ $OUTPUT->command('reset_folder_rename');
+ $OUTPUT->send();
}
- else if (!$rename && $REMOTE_REQUEST)
+ else if (!$rename && $OUTPUT->ajax_call)
{
- $commands = "this.reset_folder_rename();\n";
- $commands .= show_message('errorsaving', 'error');
- rcube_remote_response($commands);
+ $OUTPUT->command('reset_folder_rename');
+ $OUTPUT->show_message('errorsaving', 'error');
+ $OUTPUT->send();
}
else if (!$rename)
- show_message('errorsaving', 'error');
+ $OUTPUT->show_message('errorsaving', 'error');
}
// delete an existing IMAP mailbox
@@ -98,16 +91,16 @@ else if ($_action=='delete-folder')
if ($mboxes = get_input_value('_mboxes', RCUBE_INPUT_GET))
$deleted = $IMAP->delete_mailbox(array($mboxes));
- if ($REMOTE_REQUEST && $deleted)
+ if ($OUTPUT->ajax_call && $deleted)
{
- $commands = sprintf("this.remove_folder_row('%s');\n", JQ(get_input_value('_mboxes', RCUBE_INPUT_GET)));
- $commands .= show_message('folderdeleted', 'confirmation');
- rcube_remote_response($commands);
+ $OUTPUT->command('remove_folder_row', get_input_value('_mboxes', RCUBE_INPUT_GET));
+ $OUTPUT->show_message('folderdeleted', 'confirmation');
+ $OUTPUT->send();
}
- else if ($REMOTE_REQUEST)
+ else if ($OUTPUT->ajax_call)
{
- $commands = show_message('errorsaving', 'error');
- rcube_remote_response($commands);
+ $OUTPUT->show_message('errorsaving', 'error');
+ $OUTPUT->send();
}
}
@@ -116,7 +109,7 @@ else if ($_action=='delete-folder')
// build table with all folders listed by server
function rcube_subscription_form($attrib)
{
- global $IMAP, $CONFIG, $OUTPUT, $JS_OBJECT_NAME;
+ global $IMAP, $CONFIG, $OUTPUT;
list($form_start, $form_end) = get_form_tags($attrib, 'folders');
unset($attrib['form']);
@@ -147,7 +140,7 @@ function rcube_subscription_form($attrib)
$a_subscribed = $IMAP->list_mailboxes();
$a_js_folders = array();
- $checkbox_subscribe = new checkbox(array('name' => '_subscribed[]', 'onclick' => "$JS_OBJECT_NAME.command(this.checked?'subscribe':'unsubscribe',this.value)"));
+ $checkbox_subscribe = new checkbox(array('name' => '_subscribed[]', 'onclick' => JS_OBJECT_NAME.".command(this.checked?'subscribe':'unsubscribe',this.value)"));
if (!empty($attrib['deleteicon']))
$del_button = sprintf('<img src="%s%s" alt="%s" border="0" />', $CONFIG['skin_path'], $attrib['deleteicon'], rcube_label('delete'));
@@ -166,11 +159,10 @@ function rcube_subscription_form($attrib)
$protected = ($CONFIG['protect_default_folders'] == TRUE && in_array($folder,$CONFIG['default_imap_folders']));
$zebra_class = $i%2 ? 'even' : 'odd';
$folder_js = JQ($folder);
- $folder_js_enc = JQ(rcube_charset_convert($folder, 'UTF-7'));
$folder_html = $CONFIG['protect_default_folders'] && in_array($folder, $CONFIG['default_imap_folders']) ? rcube_label(strtolower($folder)) : rcube_charset_convert($folder, 'UTF-7');
if (!$protected)
- $a_js_folders['rcmrow'.($i+1)] = array($folder_js, $folder_js_enc);
+ $a_js_folders['rcmrow'.($i+1)] = array($folder, rcube_charset_convert($folder, 'UTF-7'));
$out .= sprintf('<tr id="rcmrow%d" class="%s"><td>%s</td>',
$i+1,
@@ -186,11 +178,11 @@ function rcube_subscription_form($attrib)
if (!$protected)
$out .= sprintf('<td><a href="#rename" onclick="%s.command(\'rename-folder\',\'%s\')" title="%s">%s</a>'.
'<td><a href="#delete" onclick="%s.command(\'delete-folder\',\'%s\')" title="%s">%s</a></td>',
- $JS_OBJECT_NAME,
+ JS_OBJECT_NAME,
$folder_js,
rcube_label('renamefolder'),
$edit_button,
- $JS_OBJECT_NAME,
+ JS_OBJECT_NAME,
$folder_js,
rcube_label('deletefolder'),
$del_button);
@@ -203,10 +195,8 @@ function rcube_subscription_form($attrib)
$out .= "</tbody>\n</table>";
$out .= "\n$form_end";
-
- $javascript = sprintf("%s.gui_object('subscriptionlist', '%s');\n", $JS_OBJECT_NAME, $attrib['id']);
- $javascript .= sprintf("%s.set_env('subscriptionrows', %s);", $JS_OBJECT_NAME, array2js($a_js_folders));
- $OUTPUT->add_script($javascript);
+ $OUTPUT->add_gui_object('subscriptionlist', $attrib['id']);
+ $OUTPUT->set_env('subscriptionrows', $a_js_folders);
return $out;
}
@@ -214,8 +204,6 @@ function rcube_subscription_form($attrib)
function rcube_create_folder_form($attrib)
{
- global $JS_OBJECT_NAME;
-
list($form_start, $form_end) = get_form_tags($attrib, 'create-folder');
unset($attrib['form']);
@@ -230,7 +218,7 @@ function rcube_create_folder_form($attrib)
{
$button = new input_field(array('type' => 'button',
'value' => rcube_label('create'),
- 'onclick' => "$JS_OBJECT_NAME.command('create-folder',this.form)"));
+ 'onclick' => JS_OBJECT_NAME.".command('create-folder',this.form)"));
$out .= $button->show();
}
@@ -241,7 +229,7 @@ function rcube_create_folder_form($attrib)
function rcube_rename_folder_form($attrib)
{
- global $CONFIG, $IMAP, $JS_OBJECT_NAME;
+ global $CONFIG, $IMAP;
list($form_start, $form_end) = get_form_tags($attrib, 'rename-folder');
unset($attrib['form']);
@@ -270,7 +258,7 @@ function rcube_rename_folder_form($attrib)
{
$button = new input_field(array('type' => 'button',
'value' => rcube_label('rename'),
- 'onclick' => "$JS_OBJECT_NAME.command('rename-folder',this.form)"));
+ 'onclick' => JS_OBJECT_NAME.".command('rename-folder',this.form)"));
$out .= $button->show();
}
@@ -280,9 +268,15 @@ function rcube_rename_folder_form($attrib)
}
+// register UI objects
+$OUTPUT->add_handlers(array(
+ 'foldersubscription' => 'rcube_subscription_form',
+ 'createfolder' => 'rcube_create_folder_form',
+ 'renamefolder' => 'rcube_rename_folder_form'
+));
+
// add some labels to client
rcube_add_label('deletefolderconfirm');
-
-parse_template('managefolders');
+$OUTPUT->send('managefolders');
?>