//100dimp_hook_msglist_format
// This is an example hook function for displaying additional message
// information in the message listing screen for a mailbox.  This example hook
// will add a icon if the message contains attachments and will change the
// display of the message entry based on the X-Priority header.

if (!function_exists('_dimp_hook_msglist_format')) \{
    function _dimp_hook_msglist_format($mailbox, $uid)
    \{
        // Required return (array):
        //   'atc'   - Attachment type (either 'signed', 'encrypted', or
        //             'attachment').
        //   'class' - An array of CSS classnames that will be added to
        //             the row.
        $ret = array('atc' => '', 'class' => array());

        require_once IMP_BASE . '/lib/IMAP/MessageCache.php';
        $cache = &IMP_MessageCache::singleton();
        $cache_entry = $cache->retrieve($mailbox, array($uid), 8 | 32);
        $ob = reset($cache_entry);

        // Add attachment information
        require_once IMP_BASE . '/lib/UI/Mailbox.php';
        $imp_ui = new IMP_UI_Mailbox();
        $ret['atc'] = $imp_ui->getAttachmentType($ob->structure);

        // Add xpriority information
        switch ($ob->header->getXpriority()) \{
        case 'high':
            $ret['class'][] = 'important';
            break;

        case 'low':
            $ret['class'][] = 'unimportant';
            break;
        \}

        return $ret;
    \}
\}
