Author Topic: stdheader(?) (in browser tab) not correct when standing in personal subfolders  (Read 6576 times)

Offline IBTB

  • Jr. Member
  • **
  • Posts: 14
I've been wondering how I'm suppose to describe my problem here, but I've taken two screenshots to try to explain it.

If you look at attachment "1.PNG", I'm staying in my inbox and the text in my browser tab is correctly shown as WEBMAIL :: Innboks (INBOX. is automaticly translated into Innboks (Norwegian)).

If you look at attachment "2.PNG", the view is changed. I've now moved to a subfolder under the inbox, but the norwegian translation is gone, and it shows the "stored path" (folder.sub-folder.sub-sub-folder and so on...)

I want the text to still show my localized name for inbox, with :: subfolder (or maybe just : subfolder).
So instead of "WEBMAIL :: INBOX.subfolder" I get (in Norwegian) "WEBMAIL :: Innboks : Subfolder"


So, my question is as follow:
Is it my settings that are incorrect, making the text as it is. Or is it made to be like this? And is there a way to change it to my likings?

I've been looking at the options called:
$rcmail_config['imap_ns_personal']
$rcmail_config['imap_ns_other']
$rcmail_config['imap_ns_shared']
but I don't know what I should set it to (if this is the correct place to be doing anything).


Hope anyone understand what I'm asking for, and that someone can give me some hints! :)

edit: editet the subject a little bit.

//IB
« Last Edit: December 02, 2012, 05:02:46 AM by IBTB »

Offline IBTB

  • Jr. Member
  • **
  • Posts: 14
Re: stdheader(?) not correct in personal subfolders
« Reply #1 on: December 01, 2012, 11:28:00 AM »
Not much response on my question.

Can anyone tell me what writes the name up in the "browser tab" ? Is it the stdheader?
Any clue to where I'm suppose to search would be great! :p

edit: This occurs in no matter what language is choosen.

//IB
« Last Edit: December 01, 2012, 03:54:40 PM by IBTB »

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,628
    • http://SKaero.com/
I think it is the correct behavior because the inbox is a special folder so there can be a translation, for other folders it just displays the IMAP path.

Offline IBTB

  • Jr. Member
  • **
  • Posts: 14
Aha, so it is like this in your version as well?
Well, it gives me some satisfaction that it's not my version that is messed up  ::)
But it doesn't stop me from beeing bothered about it  :P

Then I only got one last question;
Is this something worth mentioning to the roundcube guys as a enhancement, or is that a waste of their time?  :o


edit: And thanks for the reply!

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,628
    • http://SKaero.com/
I never really looked at the title before (I use Chrome and the tabs always to small  ;)) but in mine its just showing the folder name not the full IMAP path, which makes even more sense.

Offline IBTB

  • Jr. Member
  • **
  • Posts: 14
Yes, that makes more sense.
But why does your behave different than mine? òÓ

Any idèa of where the title is written (what file)?

//IB

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,628
    • http://SKaero.com/
I'm not sure why it is different, my first guess would be we have different IMAP structures. Doing a quick back the title comes from: <RC root>/program/steps/mail/func.inc
line 128: $OUTPUT->set_pagetitle(rcmail_localize_foldername($RCMAIL->storage->mod_folder($mbox_name)));

That line makes the following two calls:
1. It calls the function "mod_folder" which is in <RC root>/program/include/rcube_imap.php the function seams to make the path to the folder or the folder name, this would be the main function to scrutinize.

2. It calls the "rcmail_localize_foldername" function in: <RC root>/program/include/main.inc which call the "rcmail_folder_classname" function in the same file which will display the labels for the special folders.

Thats was just a quick trace so I may have missed something.

Offline IBTB

  • Jr. Member
  • **
  • Posts: 14
First, I have to admit, my knowledge when it comes to this is very low.
But I've gathered as much related data as I could, and trying my best to interpret it (at the bottom of the page).

My line in the func.inc is the same.

This is what I got containing mod_folder in rcube_imap.php:
Code: [Select]
        // Find personal namespace prefix for mod_folder()
        // Prefix can be removed when there is only one personal namespace
        if (is_array($this->namespace['personal']) && count($this->namespace['personal']) == 1) {
            $this->namespace['prefix'] = $this->namespace['personal'][0][0];
        }
Code: [Select]
    /**
     * Modify folder name according to namespace.
     * For output it removes prefix of the personal namespace if it's possible.
     * For input it adds the prefix. Use it before creating a folder in root
     * of the folders tree.
     *
     * @param string $folder Folder name
     * @param string $mode    Mode name (out/in)
     *
     * @return string Folder name
     */
    public function mod_folder($folder, $mode = 'out')
    {
        if (!strlen($folder)) {
            return $folder;
        }

        $prefix     = $this->namespace['prefix']; // see set_env()
        $prefix_len = strlen($prefix);

        if (!$prefix_len) {
            return $folder;
        }

        // remove prefix for output
        if ($mode == 'out') {
            if (substr($folder, 0, $prefix_len) === $prefix) {
                return substr($folder, $prefix_len);
            }
        }
        // add prefix for input (e.g. folder creation)
        else {
            return $prefix . $folder;
        }

        return $folder;
    }
Code: [Select]
    public function mod_mailbox($folder, $mode = 'out')
    {
        return $this->mod_folder($folder, $mode);
    }


This is the code containing the rcmail_localize_foldername in main.inc
Code: [Select]
/**
 * Try to localize the given IMAP folder name.
 * UTF-7 decode it in case no localized text was found
 *
 * @param string Folder name
 * @return string Localized folder name in UTF-8 encoding
 */
function rcmail_localize_foldername($name)
{
  if ($folder_class = rcmail_folder_classname($name))
    return rcube_label($folder_class);
  else
    return rcube_charset_convert($name, 'UTF7-IMAP');
}


function rcmail_localize_folderpath($path)
{
    global $RCMAIL;

    $protect_folders = $RCMAIL->config->get('protect_default_folders');
    $default_folders = (array) $RCMAIL->config->get('default_folders');
    $delimiter       = $RCMAIL->storage->get_hierarchy_delimiter();
    $path            = explode($delimiter, $path);
    $result          = array();

    foreach ($path as $idx => $dir) {
        $directory = implode($delimiter, array_slice($path, 0, $idx+1));
        if ($protect_folders && in_array($directory, $default_folders)) {
            unset($result);
            $result[] = rcmail_localize_foldername($directory);
        }
        else {
            $result[] = rcube_charset_convert($dir, 'UTF7-IMAP');
        }
    }

    return implode($delimiter, $result);
}

And this is the last bit with the rcmail_folder_classname in the same file, main.inc
Code: [Select]
/**
 * Return html for a structured list &lt;ul&gt; for the mailbox tree
 * @access private
 * @return string
 */
function rcmail_render_folder_tree_html(&$arrFolders, &$mbox_name, &$jslist, $attrib, $nestLevel=0)
{
  global $RCMAIL, $CONFIG;

  $maxlength = intval($attrib['maxlength']);
  $realnames = (bool)$attrib['realnames'];
  $msgcounts = $RCMAIL->storage->get_cache('messagecount');

  $out = '';
  foreach ($arrFolders as $key => $folder) {
    $title        = null;
    $folder_class = rcmail_folder_classname($folder['id']);
    $collapsed    = strpos($CONFIG['collapsed_folders'], '&'.rawurlencode($folder['id']).'&') !== false;
    $unread       = $msgcounts ? intval($msgcounts[$folder['id']]['UNSEEN']) : 0;

    if ($folder_class && !$realnames) {
      $foldername = rcube_label($folder_class);
    }
    else {
      $foldername = $folder['name'];

      // shorten the folder name to a given length
      if ($maxlength && $maxlength > 1) {
        $fname = abbreviate_string($foldername, $maxlength);
        if ($fname != $foldername)
          $title = $foldername;
        $foldername = $fname;
      }
    }

    // make folder name safe for ids and class names
    $folder_id = html_identifier($folder['id'], true);
    $classes = array('mailbox');

    // set special class for Sent, Drafts, Trash and Junk
    if ($folder_class)
      $classes[] = $folder_class;

    if ($folder['id'] == $mbox_name)
      $classes[] = 'selected';

    if ($folder['virtual'])
      $classes[] = 'virtual';
    else if ($unread)

    $js_name = JQ($folder['id']);
    $html_name = Q($foldername) . ($unread ? html::span('unreadcount', sprintf($attrib['unreadwrap'], $unread)) : '');
    $link_attrib = $folder['virtual'] ? array() : array(
      'href' => rcmail_url('', array('_mbox' => $folder['id'])),
      'onclick' => sprintf("return %s.command('list','%s',this)", JS_OBJECT_NAME, $js_name),
      'rel' => $folder['id'],
      'title' => $title,
    );

    $out .= html::tag('li', array(
        'id' => "rcmli".$folder_id,
        'class' => join(' ', $classes),
        'noclose' => true),
      html::a($link_attrib, $html_name) .
      (!empty($folder['folders']) ? html::div(array(
        'class' => ($collapsed ? 'collapsed' : 'expanded'),
        'style' => "position:absolute",
        'onclick' => sprintf("%s.command('collapse-folder', '%s')", JS_OBJECT_NAME, $js_name)
      ), '&nbsp;') : ''));

    $jslist[$folder_id] = array('id' => $folder['id'], 'name' => $foldername, 'virtual' => $folder['virtual']);

    if (!empty($folder['folders'])) {
      $out .= html::tag('ul', array('style' => ($collapsed ? "display:none;" : null)),
        rcmail_render_folder_tree_html($folder['folders'], $mbox_name, $jslist, $attrib, $nestLevel+1));
    }

    $out .= "</li>\n";
  }

  return $out;
}
Code: [Select]
/**
 * Return html for a flat list <select> for the mailbox tree
 * @access private
 * @return string
 */
function rcmail_render_folder_tree_select(&$arrFolders, &$mbox_name, $maxlength, &$select, $realnames=false, $nestLevel=0, $opts=array())
{
  global $RCMAIL;

  $out = '';

  foreach ($arrFolders as $key => $folder) {
    // skip exceptions (and its subfolders)
    if (!empty($opts['exceptions']) && in_array($folder['id'], $opts['exceptions'])) {
      continue;
    }

    // skip folders in which it isn't possible to create subfolders
    if (!empty($opts['skip_noinferiors']) && ($attrs = $RCMAIL->storage->folder_attributes($folder['id']))
        && in_array('\\Noinferiors', $attrs)
    ) {
      continue;
    }

    if (!$realnames && ($folder_class = rcmail_folder_classname($folder['id'])))
      $foldername = rcube_label($folder_class);
    else {
      $foldername = $folder['name'];

      // shorten the folder name to a given length
      if ($maxlength && $maxlength>1)
        $foldername = abbreviate_string($foldername, $maxlength);
    }

    $select->add(str_repeat('&nbsp;', $nestLevel*4) . $foldername, $folder['id']);

    if (!empty($folder['folders']))
      $out .= rcmail_render_folder_tree_select($folder['folders'], $mbox_name, $maxlength,
        $select, $realnames, $nestLevel+1, $opts);
  }

  return $out;
}
Code: [Select]
/**
 * Return internal name for the given folder if it matches the configured special folders
 * @access private
 * @return string
 */
function rcmail_folder_classname($folder_id)
{
  global $CONFIG;

  if ($folder_id == 'INBOX')
    return 'inbox';

  // for these mailboxes we have localized labels and css classes
  foreach (array('sent', 'drafts', 'trash', 'junk') as $smbx)
  {
    if ($folder_id == $CONFIG[$smbx.'_mbox'])
      return $smbx;
  }
}
Code: [Select]
/**
 * Try to localize the given IMAP folder name.
 * UTF-7 decode it in case no localized text was found
 *
 * @param string Folder name
 * @return string Localized folder name in UTF-8 encoding
 */
function rcmail_localize_foldername($name)
{
  if ($folder_class = rcmail_folder_classname($name))
    return rcube_label($folder_class);
  else
    return rcube_charset_convert($name, 'UTF7-IMAP');
}

In the second code-box, it sais that I have to do something when creating a folder in the root three (I haven't done this?).

The rest, I really didn't see anything that I manage to pull the full context out of.
I see that this re-writes the foldernames and stuff, but not where it pastes it all together.

Is it in the second to last code-box where it sais:
    if ($folder_id == $CONFIG[$smbx.'_mbox'])
      return $smbx;

Maybe? :o

This was a little bit more complicated then I first expected. I don't expect anyone of you to put much effort into it.

...but if anyone see the problem quite obvious, I'll be watching this post as a hawk for replies!  ;D

And thanks for your tips so far SKaero! I will take a new look at this tomorrow, when my brain (hopefully) has recharged again! :)


//IB

Offline alec

  • Hero Member
  • *****
  • Posts: 1,202
Looks like an issue. You should create a ticket in Roundcube bugtracker.

Offline IBTB

  • Jr. Member
  • **
  • Posts: 14
Just one last question (so I know what to write when I submit the bug).
Does your subfolders link directly to the imap-path?

Like to me, the subfolders (when clicking them) linking to (for example):
http://xxx.xxx/?_task=mail&_mbox=INBOX.Paypal
http://xxx.xxx/?_task=mail&_mbox=INBOX.Handel.Reise.Hotel

What I'm interested in, is if it shows the subfolders with dots between each "level".

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,628
    • http://SKaero.com/
My folder links do have the full IMAP path, but not the titles do not.