//100imp_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('_imp_hook_msglist_format')) \{
     function _imp_hook_msglist_format($mailbox, $uid)
    \{
         // Required return (array):
          //   'class' - An array of CSS classnames that will be added to
         //             the row.
         //   'flagbits' - An integer value which will be OR'd with the
         //                current flags set for the row.  The IMAP flag
         //                constants used in IMP can be found at the top
         //                of lib/IMP.php.
         //   'status' - HTML code to add to the status column for the row.
         $ret = array('class' => array(), 'flagbits' => 0, 'status' => '');

         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();
         if (($attachment = $imp_ui->getAttachmentType($ob->structure))) \{
             $ret['status'] = Horde::img($attachment . '.png', $imp_ui->getAttachmentAlt($attachment), array('title' => $imp_ui->getAttachmentAlt($attachment)));
         \}

         // Add xpriority information
         switch ($ob->header->getXpriority()) \{
         case 'high':
             $ret['flagbits'] = IMP_FLAGGED;
             $ret['status'] .= Horde::img('mail_priority_high.png', _("High Priority"), array('title' => _("High Priority")));
             $ret['class'][] = 'important';
             break;

         case 'low':
             $ret['status'] .= Horde::img('mail_priority_low.png', _("Low Priority"), array('title' => _("Low Priority")));
             $ret['class'][] = 'unimportant';
             break;
         \}

         return $ret;
     \}
 \}

