Roundcube Community Forum

Third Party Contributions => Old Style Plug-Ins => Topic started by: lacri on March 11, 2009, 07:06:31 AM

Title: Toggle empty and full trash icon
Post by: lacri on March 11, 2009, 07:06:31 AM
to toggle Trash Icon to show if trash is empty or full
add this to /skins/default/mail.css

Code: [Select]
#mailboxlist li.trash.unread
{
  background-image: url(images/icons/folder-trash_f.png);
}

you must only upload the attached image to /skins/default/images/icons/
Title: Toggle empty and full trash icon
Post by: lacri on March 11, 2009, 09:40:27 AM
for full details and fix for read messages in trash see
#1485775 (Toggle Trash Icon Empty or Full Trash) ? RoundCube Webmail (http://trac.roundcube.net/ticket/1485775)
Title: Toggle empty and full trash icon
Post by: lacri on March 12, 2009, 05:35:38 AM
her is the final optimized and perfekt working version for toggle Trash Icon

display full trash Icon if any messages in the trash folder (read or unread messages)
and display if read or unread messages in the trash
icon will toogle when messages move into empty trash and toggle to empty trash icon
when you clear trash or move messages in another folder.
its fully implemented for using drag and drop.

add this to /skins/default/mail.css

#mailboxlist li.trash.unread,
#mailboxlist li.trash.full
 {
   background-image: url(images/icons/folder-trash_f.png);
 }
modifie the /program/include/main.inc
search to

$maxlength = intval($attrib['maxlength']);
$realnames = (bool)$attrib['realnames'];
$msgcounts = $RCMAIL->imap->get_cache('messagecount');
and add after this

$trashcounts = $RCMAIL->imap->messagecount($CONFIG['trash_mbox']);
search to

else if ($folder['id']==$CONFIG['drafts_mbox'])
       $classes[] = 'drafts';
else if ($folder['id']==$CONFIG['trash_mbox'])
       $classes[] = 'trash';
and replace with

else if ($folder['id']==$CONFIG['drafts_mbox'])
       $classes[] = 'drafts';
else if ($folder['id']==$CONFIG['trash_mbox'] and $trashcounts == 0)
       $classes[] = 'trash';
else if ($folder['id']==$CONFIG['trash_mbox'] and $trashcounts >= 1) {
       $classes[] = 'trash';
       $classes[] = 'full';
}
modifie the /program/js/app.js
search to

var reg, text_obj, item, mycount, childcount, div;

     if (item = this.get_folder_li(mbox))
       {
       mycount = this.env.unread_counts[mbox] ? this.env.unread_counts[mbox] : 0;
and replace with

var reg, text_obj, item, mycount, childcount, div, trashcounts;

     if (item = this.get_folder_li(mbox))
       {
       mycount = this.env.unread_counts[mbox] ? this.env.unread_counts[mbox] : 0;
       trashcounts = this.env.trashcount ? this.env.trashcount : 0;
      search to

this.set_unread_count_display(mbox, set_title);
}
and add after this

// update the trashcount
  this.set_trashcount = function(mbox, count, set_title)
    {
     if (!this.gui_objects.mailboxlist)
       return false;
 
   this.env.trashcount = count;
    this.set_unread_count_display(mbox, set_title);
    }
search to

this.set_classname(item, 'unread', (mycount+childcount)>0 ? true : false);
and add after this

this.set_classname(item, 'full', (trashcounts)>0 ? true : false);
modifie the /program/steps/mail/func.inc

search to

$OUTPUT->add_gui_object('messagelist', $attrib['id']);
$OUTPUT->set_env('messagecount', $message_count);
and add after this

$trashcounts = $IMAP->messagecount($CONFIG['trash_mbox']);
$OUTPUT->set_env('trashcount', $trashcounts);
modifie the /program/steps/mail/check_recent.inc

search to

$OUTPUT->set_env('messagecount', $all_count);
$OUTPUT->set_env('pagesize', $IMAP->page_size);
and add before

$trashcounts = $IMAP->messagecount($CONFIG['trash_mbox']);
 $OUTPUT->set_env('trashcount', $trashcounts);
search to

else if ($unseen = $IMAP->messagecount($mbox_name, 'UNSEEN', $check_all)) {
$OUTPUT->command('set_unread_count', $mbox_name, $unseen);
and replace with

else if ($unseen = $IMAP->messagecount($mbox_name, 'UNSEEN', $check_all) or $trashcounts = $IMAP->messagecount($CONFIG['trash_mbox'])) {
       $OUTPUT->command('set_unread_count', $mbox_name, $unseen);
       $OUTPUT->command('set_trashcount', $CONFIG['trash_mbox'], $trashcounts);

modifie the /program/steps/mail/folders.inc
search to
else
       $commands = "// purged: $success";
   }and add after this

$trashcounts    = $IMAP->messagecount($CONFIG['trash_mbox']);
$OUTPUT->set_env('trashcount', $trashcounts);
$OUTPUT->command('set_trashcount', $CONFIG['trash_mbox'], $trashcounts);
modifie the /program/steps/mail/getunread.inc
search to
$OUTPUT->command('set_unread_count', $mbox_row, $IMAP->messagecount($mbox_row, 'UNSEEN'), $inbox && $mbox_row == 'INBOX');and add after this

$trashcounts    = $IMAP->messagecount($CONFIG['trash_mbox']);
$OUTPUT->set_env('trashcount', $trashcounts);
$OUTPUT->command('set_trashcount', $CONFIG['trash_mbox'], $trashcounts);

modifie the /program/steps/mail/move_del.inc

search to

$pages          = ceil($msg_count / $IMAP->page_size);
 $nextpage_count = $old_count - $IMAP->page_size * $IMAP->list_page;
 $remaining      = $msg_count - $IMAP->page_size * ($IMAP->list_page - 1);
and add after this

$trashcounts    = $IMAP->messagecount($CONFIG['trash_mbox']);
search to

$OUTPUT->set_env('pagecount', $pages);
$OUTPUT->set_env('messagecount', $msg_count);
and add after this

$OUTPUT->set_env('trashcount', $trashcounts);
search to

$OUTPUT->command('set_unread_count', $target, $IMAP->messagecount($target, 'UNSEEN'));
and add after this

$OUTPUT->command('set_trashcount', $CONFIG['trash_mbox'], $trashcounts);
and the last search to

// update mailboxlist
 $OUTPUT->command('set_unread_count', $mbox, $IMAP->messagecount($mbox, 'UNSEEN'), ($mbox == 'INBOX'));
and finaly add after this

$OUTPUT->command('set_trashcount', $CONFIG['trash_mbox'], $trashcounts);
Title: Toggle empty and full trash icon
Post by: lacri on June 05, 2009, 09:14:53 AM
Here is a new version based on SVN r2611

i have this modification over 3 Months in my installation and no issue works perfekt.

:)