Ticket #1484681: #1484681.200711301604.patch

File #1484681.200711301604.patch, 4.1 kB (added by robin, 12 months ago)

Always use array when subscribing folders.

  • program/include/rcube_imap.inc

     
    16221622   * @param string Mailbox name(s) 
    16231623   * @return boolean True on success 
    16241624   */  
    1625   function subscribe($mbox_name) 
     1625  function subscribe($a_mboxes) 
    16261626    { 
    1627     if (is_array($mbox_name)) 
    1628       $a_mboxes = $mbox_name; 
    1629     else if (is_string($mbox_name) && strlen($mbox_name)) 
    1630       $a_mboxes = explode(',', $mbox_name); 
    1631      
    16321627    // let this common function do the main work 
    16331628    return $this->_change_subscription($a_mboxes, 'subscribe'); 
    16341629    } 
     
    16401635   * @param string Mailbox name(s) 
    16411636   * @return boolean True on success 
    16421637   */ 
    1643   function unsubscribe($mbox_name) 
     1638  function unsubscribe($a_mboxes) 
    16441639    { 
    1645     if (is_array($mbox_name)) 
    1646       $a_mboxes = $mbox_name; 
    1647     else if (is_string($mbox_name) && strlen($mbox_name)) 
    1648       $a_mboxes = explode(',', $mbox_name); 
    1649  
    16501640    // let this common function do the main work 
    16511641    return $this->_change_subscription($a_mboxes, 'unsubscribe'); 
    16521642    } 
  • program/js/app.js

     
    27662766 
    27672767  this.subscribe_folder = function(folder) 
    27682768    { 
    2769     var form; 
    2770     if ((form = this.gui_objects.editform) && form.elements['_unsubscribed']) 
    2771       this.change_subscription('_unsubscribed', '_subscribed', 'subscribe'); 
    2772     else if (folder) 
    2773       this.http_post('subscribe', '_mboxes='+urlencode(folder)); 
     2769    if (folder) 
     2770      this.http_post('subscribe', '_mbox='+urlencode(folder)); 
    27742771    }; 
    27752772 
    27762773 
    27772774  this.unsubscribe_folder = function(folder) 
    27782775    { 
    2779     var form; 
    2780     if ((form = this.gui_objects.editform) && form.elements['_subscribed']) 
    2781       this.change_subscription('_subscribed', '_unsubscribed', 'unsubscribe'); 
    2782     else if (folder) 
    2783       this.http_post('unsubscribe', '_mboxes='+urlencode(folder)); 
     2776    if (folder) 
     2777      this.http_post('unsubscribe', '_mbox='+urlencode(folder)); 
    27842778    }; 
    27852779     
    27862780 
    2787   this.change_subscription = function(from, to, action) 
    2788     { 
    2789     var form; 
    2790     if (form = this.gui_objects.editform) 
    2791       { 
    2792       var a_folders = new Array(); 
    2793       var list_from = form.elements[from]; 
    2794  
    2795       for (var i=0; list_from && i<list_from.options.length; i++) 
    2796         { 
    2797         if (list_from.options[i] && list_from.options[i].selected) 
    2798           { 
    2799           a_folders[a_folders.length] = list_from.options[i].value; 
    2800           list_from[i] = null; 
    2801           i--; 
    2802           } 
    2803         } 
    2804  
    2805       // yes, we have some folders selected 
    2806       if (a_folders.length) 
    2807         { 
    2808         var list_to = form.elements[to]; 
    2809         var index; 
    2810          
    2811         for (var n=0; n<a_folders.length; n++) 
    2812           { 
    2813           index = list_to.options.length; 
    2814           list_to[index] = new Option(a_folders[n]); 
    2815           } 
    2816            
    2817         this.http_post(action, '_mboxes='+urlencode(a_folders.join(','))); 
    2818         } 
    2819       } 
    2820        
    2821     }; 
    2822  
    28232781  // helper method to find a specific mailbox row ID 
    28242782  this.get_folder_row_id = function(folder) 
    28252783    { 
  • program/steps/settings/manage_folders.inc

     
    2828// subscribe to one or more mailboxes 
    2929if ($_action=='subscribe') 
    3030  { 
    31   if ($mboxes = get_input_value('_mboxes', RCUBE_INPUT_POST)) 
    32     $IMAP->subscribe($mboxes); 
     31  if ($mbox = get_input_value('_mbox', RCUBE_INPUT_POST)) 
     32    $IMAP->subscribe(array($mbox)); 
    3333 
    3434  if ($OUTPUT->ajax_call) 
    3535    $OUTPUT->remote_response('// subscribed'); 
     
    3838// unsubscribe one or more mailboxes 
    3939else if ($_action=='unsubscribe') 
    4040  { 
    41   if ($mboxes = get_input_value('_mboxes', RCUBE_INPUT_POST)) 
    42     $IMAP->unsubscribe($mboxes); 
     41  if ($mbox = get_input_value('_mbox', RCUBE_INPUT_POST)) 
     42    $IMAP->unsubscribe(array($mbox)); 
    4343 
    4444  if ($OUTPUT->ajax_call) 
    4545    $OUTPUT->remote_response('// unsubscribed');