alecpl 17 years ago
parent 164c7d4d26
commit c5097c633b

@ -1648,16 +1648,14 @@ class rcube_imap
/** /**
* Subscribe to a specific mailbox(es) * Subscribe to a specific mailbox(es)
* *
* @param string Mailbox name(s) * @param array Mailbox name(s)
* @return boolean True on success * @return boolean True on success
*/ */
function subscribe($mbox_name) function subscribe($a_mboxes)
{ {
if (is_array($mbox_name)) if (!is_array($a_mboxes))
$a_mboxes = $mbox_name; $a_mboxes = array($a_mboxes);
else if (is_string($mbox_name) && strlen($mbox_name))
$a_mboxes = explode(',', $mbox_name);
// let this common function do the main work // let this common function do the main work
return $this->_change_subscription($a_mboxes, 'subscribe'); return $this->_change_subscription($a_mboxes, 'subscribe');
} }
@ -1666,15 +1664,13 @@ class rcube_imap
/** /**
* Unsubscribe mailboxes * Unsubscribe mailboxes
* *
* @param string Mailbox name(s) * @param array Mailbox name(s)
* @return boolean True on success * @return boolean True on success
*/ */
function unsubscribe($mbox_name) function unsubscribe($a_mboxes)
{ {
if (is_array($mbox_name)) if (!is_array($a_mboxes))
$a_mboxes = $mbox_name; $a_mboxes = array($a_mboxes);
else if (is_string($mbox_name) && strlen($mbox_name))
$a_mboxes = (array)$mbox_name;
// let this common function do the main work // let this common function do the main work
return $this->_change_subscription($a_mboxes, 'unsubscribe'); return $this->_change_subscription($a_mboxes, 'unsubscribe');

@ -2825,60 +2825,18 @@ function rcube_webmail()
this.subscribe_folder = function(folder) this.subscribe_folder = function(folder)
{ {
var form; if (folder)
if ((form = this.gui_objects.editform) && form.elements['_unsubscribed']) this.http_post('subscribe', '_mbox='+urlencode(folder));
this.change_subscription('_unsubscribed', '_subscribed', 'subscribe');
else if (folder)
this.http_post('subscribe', '_mboxes='+urlencode(folder));
}; };
this.unsubscribe_folder = function(folder) this.unsubscribe_folder = function(folder)
{ {
var form; if (folder)
if ((form = this.gui_objects.editform) && form.elements['_subscribed']) this.http_post('unsubscribe', '_mbox='+urlencode(folder));
this.change_subscription('_subscribed', '_unsubscribed', 'unsubscribe');
else if (folder)
this.http_post('unsubscribe', '_mboxes='+urlencode(folder));
}; };
this.change_subscription = function(from, to, action)
{
var form;
if (form = this.gui_objects.editform)
{
var a_folders = new Array();
var list_from = form.elements[from];
for (var i=0; list_from && i<list_from.options.length; i++)
{
if (list_from.options[i] && list_from.options[i].selected)
{
a_folders[a_folders.length] = list_from.options[i].value;
list_from[i] = null;
i--;
}
}
// yes, we have some folders selected
if (a_folders.length)
{
var list_to = form.elements[to];
var index;
for (var n=0; n<a_folders.length; n++)
{
index = list_to.options.length;
list_to[index] = new Option(a_folders[n]);
}
this.http_post(action, '_mboxes='+urlencode(a_folders.join(',')));
}
}
};
// helper method to find a specific mailbox row ID // helper method to find a specific mailbox row ID
this.get_folder_row_id = function(folder) this.get_folder_row_id = function(folder)
{ {

@ -28,8 +28,8 @@ $OUTPUT->include_script('list.js');
// subscribe to one or more mailboxes // subscribe to one or more mailboxes
if ($_action=='subscribe') if ($_action=='subscribe')
{ {
if ($mboxes = get_input_value('_mboxes', RCUBE_INPUT_POST)) if ($mbox = get_input_value('_mbox', RCUBE_INPUT_POST))
$IMAP->subscribe($mboxes); $IMAP->subscribe(array($mbox));
if ($OUTPUT->ajax_call) if ($OUTPUT->ajax_call)
$OUTPUT->remote_response('// subscribed'); $OUTPUT->remote_response('// subscribed');
@ -38,8 +38,8 @@ if ($_action=='subscribe')
// unsubscribe one or more mailboxes // unsubscribe one or more mailboxes
else if ($_action=='unsubscribe') else if ($_action=='unsubscribe')
{ {
if ($mboxes = get_input_value('_mboxes', RCUBE_INPUT_POST)) if ($mbox = get_input_value('_mbox', RCUBE_INPUT_POST))
$IMAP->unsubscribe($mboxes); $IMAP->unsubscribe(array($mbox));
if ($OUTPUT->ajax_call) if ($OUTPUT->ajax_call)
$OUTPUT->remote_response('// unsubscribed'); $OUTPUT->remote_response('// unsubscribed');

Loading…
Cancel
Save