[RCD] Code modification for a personal implementation or a Plugin?

A.L.E.C alec at alec.pl
Fri Mar 9 10:16:55 CET 2018


On 09.03.2018 09:41, Philip Rhoades wrote:
>> What I would like is, since there is already the facility to highlight
>> newly arrived mails in blue
> 
> That should be: "since there is already the facility to highlight
> FOLDERS with newly arrived emails in blue".
> 
>> - to modify this facility a little so that
>> ANY mails that are less than 24 hours old are highlighted in blue.
>> This would be useful for when I have had to exit out of RCM and reload
>> it for some reason - currently all the blue highlighted mails lose the
>> highlight on re-opening RCM.

That would be definitely a plugin. It would do an ajax request just
after initial getunread request, where it would go through list of
folders doing an imap search for "unread messages arrived in last 24 hours".

Some hints for PHP code:

$rcmail    = rcmail::get_instance();
$storage   = $rcmail->get_storage();
$a_folders = $storage->list_folders_subscribed('', '*', 'mail');
$unseen_folders = array();

foreach ($a_folders as $mbox) {
    // IMAP SEARCH supports date-only format
    $index = $storage->search_once($mbox, 'UNSEEN SINCE ...');
    if ($index->count()) {
        $unseen_folders[] = $mbox;
    }
    // you may also/instead need to check timestamp of the most recent
message
}

$rcmail->output->command('set_unseen_folders', $unseen_folders);

Of course, you'd need the client-side part that does the request and
updates folders classes.

Also, considering performance you might need to store the list of unseen
folders in some database and update the state when you like and remember
when the user visited such a folder to not mark it unseen again, etc.

-- 
Aleksander 'A.L.E.C' Machniak
Kolab Groupware Developer         [http://kolab.org]
Roundcube Webmail Developer   [http://roundcube.net]
----------------------------------------------------
PGP: 19359DC1 # Blog: https://kolabian.wordpress.com


More information about the dev mailing list