alecpl
2011-05-05 d08333ea578e3b6c6ab42bed05f808a2b7b93cf1
program/include/main.inc
@@ -26,7 +26,7 @@
 * @author Thomas Bruederli <roundcube@gmail.com>
 */
require_once 'lib/utf7.inc';
require_once 'utf7.inc';
require_once INSTALL_PATH . 'program/include/rcube_shared.inc';
// define constannts for input reading
@@ -1228,17 +1228,20 @@
  else
    $list = $RCMAIL->imap->list_mailboxes();
  foreach ($list as $folder)
  $delimiter = $RCMAIL->imap->get_hierarchy_delimiter();
  foreach ($list as $folder) {
    if (empty($p['exceptions']) || !in_array($folder, $p['exceptions']))
      rcmail_build_folder_tree($a_mailboxes, $folder, $RCMAIL->imap->get_hierarchy_delimiter());
      rcmail_build_folder_tree($a_mailboxes, $folder, $delimiter);
  }
  $select = new html_select($p);
  if ($p['noselection'])
    $select->add($p['noselection'], '');
  rcmail_render_folder_tree_select($a_mailboxes, $mbox, $p['maxlength'], $select, $p['realnames']);
  return $select;
}
@@ -1251,6 +1254,17 @@
function rcmail_build_folder_tree(&$arrFolders, $folder, $delm='/', $path='')
{
  global $RCMAIL;
  // Handle namespace prefix
  $prefix = '';
  if (!$path) {
    $n_folder = $folder;
    $folder = $RCMAIL->imap->mod_mailbox($folder);
    if ($n_folder != $folder) {
      $prefix = substr($n_folder, 0, -strlen($folder));
    }
  }
  $pos = strpos($folder, $delm);
@@ -1272,14 +1286,14 @@
    $virtual = false;
  }
  $path .= $currentFolder;
  // Check \Noselect option (if options are in cache)
  if (!$virtual && ($opts = $RCMAIL->imap->mailbox_options($path))) {
    $virtual = in_array('\\Noselect', $opts);
  }
  $path .= $prefix.$currentFolder;
  if (!isset($arrFolders[$currentFolder])) {
    // Check \Noselect option (if options are in cache)
    if (!$virtual && ($opts = $RCMAIL->imap->mailbox_options($path))) {
      $virtual = in_array('\\Noselect', $opts);
    }
    $arrFolders[$currentFolder] = array(
      'id' => $path,
      'name' => rcube_charset_convert($currentFolder, 'UTF7-IMAP'),
@@ -1673,14 +1687,20 @@
{
  // %n - host
  $n = preg_replace('/:\d+$/', '', $_SERVER['SERVER_NAME']);
  // %d - domain name without first part, e.g. %d=mail.domain.tld, %m=domain.tld
  // %d - domain name without first part, e.g. %n=mail.domain.tld, %d=domain.tld
  $d = preg_replace('/^[^\.]+\./', '', $n);
  // %h - IMAP host
  $h = $_SESSION['imap_host'] ? $_SESSION['imap_host'] : $host;
  // %z - IMAP domain without first part, e.g. %h=imap.domain.tld, %z=domain.tld
  $z = preg_replace('/^[^\.]+\./', '', $h);
  // %s - domain name after the '@' from e-mail address provided at login screen. Returns FALSE if an invalid email is provided
  if ( strpos($name, '%s') !== false ){
    $user_email = rcube_idn_convert(get_input_value('_user', RCUBE_INPUT_POST), true);
    if ( preg_match('/(.*)@([a-z0-9\.\-\[\]\:]+)/i', $user_email, $s) < 1 || filter_var($s[1]."@".$s[2], FILTER_VALIDATE_EMAIL) === false )
      return false;
  }
  $name = str_replace(array('%n', '%d', '%h', '%z'), array($n, $d, $h, $z), $name);
  $name = str_replace(array('%n', '%d', '%h', '%z', '%s'), array($n, $d, $h, $z, $s[2]), $name);
  return $name;
}