diff options
author | thomascube <thomas@roundcube.net> | 2007-04-28 18:07:12 +0000 |
---|---|---|
committer | thomascube <thomas@roundcube.net> | 2007-04-28 18:07:12 +0000 |
commit | f1154163b0a9efb21d722bc658352739040ffd61 (patch) | |
tree | 28ccaa50bc27fa2c3d10eb8650a9862710668494 /program/steps/settings | |
parent | 9e5d051e97441794d765b094ed46d8cc732c3944 (diff) |
Merged branch devel-addressbook from r443 back to trunk
Diffstat (limited to 'program/steps/settings')
-rw-r--r-- | program/steps/settings/delete_identity.inc | 31 | ||||
-rw-r--r-- | program/steps/settings/edit_identity.inc | 17 | ||||
-rw-r--r-- | program/steps/settings/func.inc | 20 | ||||
-rw-r--r-- | program/steps/settings/identities.inc | 10 | ||||
-rw-r--r-- | program/steps/settings/manage_folders.inc | 100 | ||||
-rw-r--r-- | program/steps/settings/save_identity.inc | 10 | ||||
-rw-r--r-- | program/steps/settings/save_prefs.inc | 9 |
7 files changed, 95 insertions, 102 deletions
diff --git a/program/steps/settings/delete_identity.inc b/program/steps/settings/delete_identity.inc index 560a2b10b..3614a3e96 100644 --- a/program/steps/settings/delete_identity.inc +++ b/program/steps/settings/delete_identity.inc @@ -5,7 +5,7 @@ | program/steps/settings/delete_identity.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: | @@ -20,32 +20,29 @@ */ if (($ids = get_input_value('_iid', RCUBE_INPUT_GET)) && preg_match('/^[0-9]+(,[0-9]+)*$/', $ids)) - { - $DB->query("UPDATE ".get_table_name('identities')." - SET del=1 - WHERE user_id=? - AND identity_id IN (".$ids.")", - $_SESSION['user_id']); +{ + $DB->query( + "UPDATE ".get_table_name('identities')." + SET del=1 + WHERE user_id=? + AND identity_id IN (".$ids.")", + $_SESSION['user_id']); $count = $DB->affected_rows(); if ($count) - { - $commands = show_message('deletedsuccessfully', 'confirmation'); - } + $OUTPUT->show_message('deletedsuccessfully', 'confirmation'); // send response - if ($REMOTE_REQUEST) - rcube_remote_response($commands); - } + if ($OUTPUT->ajax_call) + $OUTPUT->send(); +} -if ($REMOTE_REQUEST) +if ($OUTPUT->ajax_call) exit; // go to identities page -$_action = 'identities'; +rcmail_overwrite_action('identities'); -// overwrite action variable -$OUTPUT->add_script(sprintf("\n%s.set_env('action', '%s');", $JS_OBJECT_NAME, $_action)); ?> diff --git a/program/steps/settings/edit_identity.inc b/program/steps/settings/edit_identity.inc index 5fa531a11..51a0cd0a0 100644 --- a/program/steps/settings/edit_identity.inc +++ b/program/steps/settings/edit_identity.inc @@ -5,7 +5,7 @@ | program/steps/settings/edit_identity.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: | @@ -31,12 +31,12 @@ if (($_GET['_iid'] || $_POST['_iid']) && $_action=='edit-identity') $IDENTITY_RECORD = $DB->fetch_assoc(); if (is_array($IDENTITY_RECORD)) - $OUTPUT->add_script(sprintf("%s.set_env('iid', '%s');", $JS_OBJECT_NAME, $IDENTITY_RECORD['identity_id'])); - - $PAGE_TITLE = rcube_label('edititem'); + $OUTPUT->set_env('iid', $IDENTITY_RECORD['identity_id']); + + $OUTPUT->set_pagetitle(rcube_label('edititem')); } else - $PAGE_TITLE = rcube_label('newitem'); + $OUTPUT->set_pagetitle(rcube_label('newitem')); $OUTPUT->include_script('list.js'); @@ -44,7 +44,7 @@ $OUTPUT->include_script('list.js'); function rcube_identity_form($attrib) { - global $IDENTITY_RECORD, $JS_OBJECT_NAME, $OUTPUT; + global $IDENTITY_RECORD, $OUTPUT; $OUTPUT->include_script('tiny_mce/tiny_mce_src.js'); $OUTPUT->add_script("tinyMCE.init({ mode : 'specific_textareas'," . @@ -63,8 +63,7 @@ function rcube_identity_form($attrib) return rcube_label('notfound'); // add some labels to client - rcube_add_label('noemailwarning'); - rcube_add_label('nonamewarning'); + rcube_add_label('noemailwarning', 'nonamewarning'); list($form_start, $form_end) = get_form_tags($attrib, 'save-identity', array('name' => '_iid', 'value' => $IDENTITY_RECORD['identity_id'])); @@ -136,7 +135,7 @@ function rcube_identity_form($attrib) return $out; } - +$OUTPUT->add_handler('identityform', 'rcube_identity_form'); if ($_action=='add-identity' && template_exists('addidentity')) parse_template('addidentity'); diff --git a/program/steps/settings/func.inc b/program/steps/settings/func.inc index e51f6838e..91212e174 100644 --- a/program/steps/settings/func.inc +++ b/program/steps/settings/func.inc @@ -5,7 +5,7 @@ | program/steps/settings/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: | @@ -26,7 +26,7 @@ $sql_result = $DB->query("SELECT username, mail_host FROM ".get_table_name('user $_SESSION['user_id']); if ($USER_DATA = $DB->fetch_assoc($sql_result)) - $PAGE_TITLE = sprintf('%s %s@%s', rcube_label('settingsfor'), $USER_DATA['username'], $USER_DATA['mail_host']); + $OUTPUT->set_pagetitle(sprintf('%s %s@%s', rcube_label('settingsfor'), $USER_DATA['username'], $USER_DATA['mail_host'])); @@ -202,7 +202,7 @@ function rcmail_user_prefs_form($attrib) function rcmail_identities_list($attrib) { - global $DB, $CONFIG, $OUTPUT, $JS_OBJECT_NAME; + global $DB, $CONFIG, $OUTPUT; // get contacts from DB @@ -224,8 +224,7 @@ function rcmail_identities_list($attrib) $out = rcube_table_output($attrib, $sql_result, $a_show_cols, 'identity_id'); // set client env - $javascript = sprintf("%s.gui_object('identitieslist', '%s');\n", $JS_OBJECT_NAME, $attrib['id']); - $OUTPUT->add_script($javascript); + $OUTPUT->add_gui_object('identitieslist', $attrib['id']); return $out; } @@ -235,7 +234,7 @@ function rcmail_identities_list($attrib) // similar function as in /steps/addressbook/edit.inc function get_form_tags($attrib, $action, $add_hidden=array()) { - global $OUTPUT, $JS_OBJECT_NAME, $EDIT_FORM, $SESS_HIDDEN_FIELD; + global $OUTPUT, $EDIT_FORM, $SESS_HIDDEN_FIELD; $form_start = ''; if (!strlen($EDIT_FORM)) @@ -258,7 +257,7 @@ function get_form_tags($attrib, $action, $add_hidden=array()) $form_name = strlen($attrib['form']) ? $attrib['form'] : 'form'; if (!strlen($EDIT_FORM)) - $OUTPUT->add_script("$JS_OBJECT_NAME.gui_object('editform', '$form_name');"); + $OUTPUT->add_gui_object('editform', $form_name); $EDIT_FORM = $form_name; @@ -266,4 +265,11 @@ function get_form_tags($attrib, $action, $add_hidden=array()) } +// register UI objects +$OUTPUT->add_handlers(array( + 'userprefs' => 'rcmail_user_prefs_form', + 'itentitieslist' => 'rcmail_identities_list' +)); + + ?>
\ No newline at end of file diff --git a/program/steps/settings/identities.inc b/program/steps/settings/identities.inc index caaa45342..9284e525d 100644 --- a/program/steps/settings/identities.inc +++ b/program/steps/settings/identities.inc @@ -5,7 +5,7 @@ | program/steps/settings/identities.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: | @@ -20,7 +20,7 @@ */ if ($USER_DATA = $DB->fetch_assoc($sql_result)) - $PAGE_TITLE = sprintf('%s (%s@%s)', rcube_label('identities'), $USER_DATA['username'], $USER_DATA['mail_host']); + $OUTPUT->set_pagetitle(sprintf('%s (%s@%s)', rcube_label('identities'), $USER_DATA['username'], $USER_DATA['mail_host'])); $OUTPUT->include_script('list.js'); @@ -28,14 +28,14 @@ $OUTPUT->include_script('list.js'); // similar function as /steps/addressbook/func.inc::rcmail_contact_frame() function rcmail_identity_frame($attrib) { - global $OUTPUT, $JS_OBJECT_NAME; + global $OUTPUT; if (!$attrib['id']) $attrib['id'] = 'rcmIdentityFrame'; $attrib['name'] = $attrib['id']; - $OUTPUT->add_script(sprintf("%s.set_env('contentframe', '%s');", $JS_OBJECT_NAME, $attrib['name'])); + $OUTPUT->set_env('contentframe', $attrib['name']); $attrib_str = create_attrib_string($attrib, array('name', 'id', 'class', 'style', 'src', 'width', 'height', 'frameborder')); $out = '<iframe'. $attrib_str . '></iframe>'; @@ -43,7 +43,7 @@ function rcmail_identity_frame($attrib) return $out; } - +$OUTPUT->add_handler('identityframe', 'rcmail_identity_frame'); parse_template('identities'); ?>
\ No newline at end of file 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'); ?> diff --git a/program/steps/settings/save_identity.inc b/program/steps/settings/save_identity.inc index ce1c6f6b4..8079b589a 100644 --- a/program/steps/settings/save_identity.inc +++ b/program/steps/settings/save_identity.inc @@ -27,7 +27,7 @@ $updated = $default_id = false; // check input if (empty($_POST['_name']) || empty($_POST['_email'])) { - show_message('formincomplete', 'warning'); + $OUTPUT->show_message('formincomplete', 'warning'); rcmail_overwrite_action('edit-identitiy'); return; } @@ -72,7 +72,7 @@ if ($_POST['_iid']) if ($updated) { - show_message('successfullysaved', 'confirmation'); + $OUTPUT->show_message('successfullysaved', 'confirmation'); if (!empty($_POST['_standard'])) $default_id = get_input_value('_iid', RCUBE_INPUT_POST); @@ -86,7 +86,7 @@ if ($_POST['_iid']) else if ($DB->is_error()) { // show error message - show_message('errorsaving', 'error'); + $OUTPUT->show_message('errorsaving', 'error'); rcmail_overwrite_action('edit-identitiy'); return; } @@ -133,7 +133,7 @@ else else { // show error message - show_message('errorsaving', 'error'); + $OUTPUT->show_message('errorsaving', 'error'); rcmail_overwrite_action('edit-identity'); return; } @@ -152,6 +152,6 @@ if ($default_id) $default_id); // go to next step -rcmail_overwrite_action($_POST['_framed'] ? 'edit-identity' : 'identities'); +rcmail_overwrite_action($_framed ? 'edit-identity' : 'identities'); ?>
\ No newline at end of file diff --git a/program/steps/settings/save_prefs.inc b/program/steps/settings/save_prefs.inc index fd254f9f3..4945a4fff 100644 --- a/program/steps/settings/save_prefs.inc +++ b/program/steps/settings/save_prefs.inc @@ -5,7 +5,7 @@ | program/steps/settings/save_prefs.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: | @@ -43,13 +43,10 @@ if (isset($_POST['_language'])) } if (rcmail_save_user_prefs($a_user_prefs)) - show_message('successfullysaved', 'confirmation'); + $OUTPUT->show_message('successfullysaved', 'confirmation'); // go to next step -$_action = 'preferences'; - -// overwrite action variable -$OUTPUT->add_script(sprintf("\n%s.set_env('action', '%s');", $JS_OBJECT_NAME, $_action)); +rcmail_overwrite_action('preferences'); ?> |