Roundcube Community Forum

Third Party Contributions => Old Style Plug-Ins => Topic started by: Nemesis02 on May 12, 2008, 11:55:27 PM

Title: Folder Redirect MOD
Post by: Nemesis02 on May 12, 2008, 11:55:27 PM
Good evening everyone, I came across an issue with roundcube where it just would not read my spam folder.  I have no idea why, but for some reason, it kept putting my spam folder name as Spam, and there is no Spam folder, only spam (case sensative).  When I went to the folder listing, it saw the test message I had in there, but can't view the contents of the folder.

Well, I decided to redirect the Junk folder to my folder called spam, but there's no real way of redirecting that so I made this mod.

Files affected:
config/main.inc.php
program/include/rcube_imap.inc

Open config/main.inc.php

Find
?>

Add before
$rcmail_config['mailbox_rename'] = array( "Junk" => "spam" );

Open program/include/rcube_imap.inc

Find
function set_mailbox($new_mbox)
    {

Add after
global $CONFIG;
    $new_mbox = $CONFIG['mailbox_rename'][$new_mbox] ? $CONFIG['mailbox_rename'][$new_mbox] : $new_mbox;

Find
function _mod_mailbox($mbox_name, $mode='in')
    {

Add after
global $CONFIG;

Find a few lines bellow
if (!empty($this->root_dir) && $mode=='in')
      $mbox_name = $this->root_dir.$this->delimiter.$mbox_name;
    else if (strlen($this->root_dir) && $mode=='out')
      $mbox_name = substr($mbox_name, strlen($this->root_dir)+1);

Replace with
if (!empty($this->root_dir) && $mode=='in')
      $mbox_name = $this->root_dir.$this->delimiter.($CONFIG['mailbox_rename'][$mbox_name] ? $CONFIG['mailbox_rename'][$mbox_name] : $mbox_name);
    else if (strlen($this->root_dir) && $mode=='out') {
      $mbox_name = substr($mbox_name, strlen($this->root_dir)+1);
      $mbox_name = array_search($mbox_name,$CONFIG['mailbox_rename']) === false ? $mbox_name : array_search($mbox_name,$CONFIG['mailbox_rename']);
}


You are DONE!!!

Now, if you would like to rename other folders... modify the $rcmail_config['mailbox_rename'] in the config file.

For example:
$rcmail_config['mailbox_rename'] = array( "Junk" => "spam", "College" => "Porn");

The above example will redirect the Junk folder to a folder called spam and the College folder to a folder called Porn.

ENJOY!! :)