Ignore:
Timestamp:
Nov 8, 2011 6:22:14 AM (19 months ago)
Author:
alec
Message:
  • Fix so folders with \Noinferiors attribute aren't listed in parent selector
  • Add LIST result and folder attributes cache
  • rcmail_render_folder_tree_select(): fix 'exceptions' parameter, add 'skip_noinferiors' option
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/roundcubemail/program/include/main.inc

    r5390 r5398  
    12331233    $select->add($p['noselection'], ''); 
    12341234 
    1235   rcmail_render_folder_tree_select($a_mailboxes, $mbox, $p['maxlength'], $select, $p['realnames'], 0, $p['exceptions']); 
     1235  rcmail_render_folder_tree_select($a_mailboxes, $mbox, $p['maxlength'], $select, $p['realnames'], 0, $p); 
    12361236 
    12371237  return $select; 
     
    12821282 
    12831283  if (!isset($arrFolders[$currentFolder])) { 
    1284     // Check \Noselect option (if options are in cache) 
    1285     if (!$virtual && ($opts = $RCMAIL->imap->mailbox_options($path))) { 
    1286       $virtual = in_array('\\Noselect', $opts); 
     1284    // Check \Noselect attribute (if attributes are in cache) 
     1285    if (!$virtual && ($attrs = $RCMAIL->imap->mailbox_attributes($path))) { 
     1286      $virtual = in_array('\\Noselect', $attrs); 
    12871287    } 
    12881288 
     
    14031403 * @return string 
    14041404 */ 
    1405 function rcmail_render_folder_tree_select(&$arrFolders, &$mbox_name, $maxlength, &$select, $realnames=false, $nestLevel=0, $exceptions=array()) 
    1406 { 
     1405function rcmail_render_folder_tree_select(&$arrFolders, &$mbox_name, $maxlength, &$select, $realnames=false, $nestLevel=0, $opts=array()) 
     1406{ 
     1407  global $RCMAIL; 
     1408 
    14071409  $out = ''; 
    14081410 
    14091411  foreach ($arrFolders as $key => $folder) { 
    1410     if (empty($exceptions) || !in_array($folder['id'], $exceptions)) { 
    1411       if (!$realnames && ($folder_class = rcmail_folder_classname($folder['id']))) 
    1412         $foldername = rcube_label($folder_class); 
    1413       else { 
    1414         $foldername = $folder['name']; 
    1415  
    1416         // shorten the folder name to a given length 
    1417         if ($maxlength && $maxlength>1) 
    1418           $foldername = abbreviate_string($foldername, $maxlength); 
    1419       } 
    1420  
    1421       $select->add(str_repeat(' ', $nestLevel*4) . $foldername, $folder['id']); 
    1422     } 
    1423     else if ($nestLevel) 
     1412    // skip exceptions (and its subfolders) 
     1413    if (!empty($opts['exceptions']) && in_array($folder['id'], $opts['exceptions'])) { 
    14241414      continue; 
     1415    } 
     1416 
     1417    // skip folders in which it isn't possible to create subfolders 
     1418    if (!empty($opts['skip_noinferiors']) && ($attrs = $RCMAIL->imap->mailbox_attributes($folder['id'])) 
     1419        && in_array('\\Noinferiors', $attrs) 
     1420    ) { 
     1421      continue; 
     1422    } 
     1423 
     1424    if (!$realnames && ($folder_class = rcmail_folder_classname($folder['id']))) 
     1425      $foldername = rcube_label($folder_class); 
     1426    else { 
     1427      $foldername = $folder['name']; 
     1428 
     1429      // shorten the folder name to a given length 
     1430      if ($maxlength && $maxlength>1) 
     1431        $foldername = abbreviate_string($foldername, $maxlength); 
     1432    } 
     1433 
     1434    $select->add(str_repeat(' ', $nestLevel*4) . $foldername, $folder['id']); 
    14251435 
    14261436    if (!empty($folder['folders'])) 
    14271437      $out .= rcmail_render_folder_tree_select($folder['folders'], $mbox_name, $maxlength, 
    1428         $select, $realnames, $nestLevel+1, $exceptions); 
     1438        $select, $realnames, $nestLevel+1, $opts); 
    14291439  } 
    14301440 
Note: See TracChangeset for help on using the changeset viewer.