Exemplo n.º 1
0
/** Print the $msgs messages from $mailbox mailbox
 */
function asearch_print_mailbox_msgs($imapConnection, &$aMailbox, $color)
{
    /**
     * A mailbox can contain different sets with uid's. Default, for normal
     * message list view we use '0' as setindex and for search a different
     * setindex.
     */
    $iSetIndx = $aMailbox['SETINDEX'];
    $mailbox_display = asearch_get_mailbox_display($aMailbox['NAME']);
    $mailbox_title = '<b><big>' . _("Folder:") . ' ' . $mailbox_display . '&nbsp;</big></b>';
    /**
     * UIDSET contains the array with uid's returned by a search
     */
    $cnt = count($aMailbox['UIDSET'][$iSetIndx]);
    $iLimit = $aMailbox['SHOWALL'][$iSetIndx] ? $cnt : $aMailbox['LIMIT'];
    $iEnd = $aMailbox['PAGEOFFSET'] + ($iLimit - 1) < $aMailbox['EXISTS'] ? $aMailbox['PAGEOFFSET'] + $iLimit - 1 : $cnt;
    $paginator_str = get_paginator_str($aMailbox['NAME'], $aMailbox['PAGEOFFSET'], $cnt, $aMailbox['LIMIT'], $aMailbox['SHOWALL'][$iSetIndx]);
    $msg_cnt_str = get_msgcnt_str($aMailbox['PAGEOFFSET'], $iEnd, $cnt);
    echo '<table border="0" width="100%" cellpadding="0" cellspacing="0">';
    echo '<tr><td>';
    mail_message_listing_beginning($imapConnection, $aMailbox, $msg_cnt_str, $mailbox_title . " {$paginator_str}");
    echo '</td></tr>';
    echo '<tr><td height="5" bgcolor="' . $color[4] . '"></td></tr>';
    echo '<tr><td>';
    echo '    <table width="100%" cellpadding="1" cellspacing="0" align="center"' . ' border="0" bgcolor="' . $color[9] . '">';
    echo '     <tr><td>';
    echo '       <table width="100%" cellpadding="1" cellspacing="0" align="center" border="0" bgcolor="' . $color[5] . '">';
    echo '        <tr><td>';
    printHeader($aMailbox);
    displayMessageArray($imapConnection, $aMailbox);
    echo '        </td></tr>';
    echo '       </table>';
    echo '     </td></tr>';
    echo '    </table>';
    mail_message_listing_end($cnt, '', $msg_cnt_str);
    echo '</td></tr>';
    echo '</table>';
}
Exemplo n.º 2
0
function showMessagesForMailbox($imapConnection, $mailbox, $num_msgs, $start_msg, $sort, $color, $show_num, $use_cache, $mode = '')
{
    global $msgs, $msort, $auto_expunge, $thread_sort_messages, $allow_server_sort, $server_sort_order;
    /*
     * For some reason, on PHP 4.3+, this being unset, and set in the session causes havoc
     * so setting it to an empty array beforehand seems to clean up the issue, and stopping the
     * "Your script possibly relies on a session side-effect which existed until PHP 4.2.3" error
     */
    if (!isset($msort)) {
        $msort = array();
    }
    if (!isset($msgs)) {
        $msgs = array();
    }
    //$start = microtime();
    /* If autoexpunge is turned on, then do it now. */
    $mbxresponse = sqimap_mailbox_select($imapConnection, $mailbox);
    $srt = $sort;
    /* If autoexpunge is turned on, then do it now. */
    if ($auto_expunge == true) {
        $exp_cnt = sqimap_mailbox_expunge($imapConnection, $mailbox, false, '');
        $mbxresponse['EXISTS'] = $mbxresponse['EXISTS'] - $exp_cnt;
        $num_msgs = $mbxresponse['EXISTS'];
    }
    if ($mbxresponse['EXISTS'] > 0) {
        /* if $start_msg is lower than $num_msgs, we probably deleted all messages
         * in the last page. We need to re-adjust the start_msg
         */
        if ($start_msg > $num_msgs) {
            $start_msg -= $show_num;
            if ($start_msg < 1) {
                $start_msg = 1;
            }
        }
        /* This code and the next if() block check for
         * server-side sorting methods. The $id array is
         * formatted and $sort is set to 6 to disable
         * SM internal sorting
         */
        if ($thread_sort_messages == 1) {
            $mode = 'thread';
        } elseif ($allow_server_sort == 1) {
            $mode = 'serversort';
        } else {
            $mode = '';
        }
        if ($use_cache) {
            sqgetGlobalVar('msgs', $msgs, SQ_SESSION);
            sqgetGlobalVar('msort', $msort, SQ_SESSION);
        } else {
            sqsession_unregister('msort');
            sqsession_unregister('msgs');
        }
        switch ($mode) {
            case 'thread':
                $id = get_thread_sort($imapConnection);
                $msgs = getServerMessages($imapConnection, $start_msg, $show_num, $num_msgs, $id);
                if ($msgs === false) {
                    echo '<b><small><center><font color="red">' . _("Thread sorting is not supported by your IMAP server.") . '<br />' . _("Please contact your system administrator and report this error.") . '</font></center></small></b>';
                    $thread_sort_messages = 0;
                    $msort = $msgs = array();
                } else {
                    $msort = $msgs;
                    $sort = 6;
                }
                break;
            case 'serversort':
                $id = sqimap_get_sort_order($imapConnection, $sort, $mbxresponse);
                $msgs = getServerMessages($imapConnection, $start_msg, $show_num, $num_msgs, $id);
                if ($msgs === false) {
                    echo '<b><small><center><font color="red">' . _("Server-side sorting is not supported by your IMAP server.") . '<br />' . _("Please contact your system administrator and report this error.") . '</font></center></small></b>';
                    $sort = $server_sort_order;
                    $allow_server_sort = FALSE;
                    $msort = $msgs = array();
                    $id = array();
                } else {
                    $msort = $msgs;
                    $sort = 6;
                }
                break;
            default:
                if (!$use_cache) {
                    $msgs = getSelfSortMessages($imapConnection, $start_msg, $show_num, $num_msgs, $sort, $mbxresponse);
                    $msort = calc_msort($msgs, $sort);
                }
                /* !use cache */
                break;
        }
        // switch
        sqsession_register($msort, 'msort');
        sqsession_register($msgs, 'msgs');
    }
    /* if exists > 0 */
    $res = getEndMessage($start_msg, $show_num, $num_msgs);
    $start_msg = $res[0];
    $end_msg = $res[1];
    if ($num_msgs > 0) {
        $paginator_str = get_paginator_str($mailbox, $start_msg, $end_msg, $num_msgs, $show_num, $sort);
    } else {
        $paginator_str = '';
    }
    $msg_cnt_str = get_msgcnt_str($start_msg, $end_msg, $num_msgs);
    do_hook('mailbox_index_before');
    $safe_name = preg_replace("/[^0-9A-Za-z_]/", '_', $mailbox);
    $form_name = "FormMsgs" . $safe_name;
    echo '<form name="' . $form_name . '" method="post" action="move_messages.php">' . "\n" . '<input type="hidden" name="mailbox" value="' . htmlspecialchars($mailbox) . '">' . "\n" . '<input type="hidden" name="startMessage" value="' . htmlspecialchars($start_msg) . '">' . "\n";
    echo '<table border="0" width="100%" cellpadding="0" cellspacing="0">';
    echo '<tr><td>';
    mail_message_listing_beginning($imapConnection, $mailbox, $sort, $msg_cnt_str, $paginator_str, $start_msg);
    /* line between the button area and the list */
    echo '<tr><td height="5" bgcolor="' . $color[4] . '"></td></tr>';
    echo '<tr><td>';
    echo '    <table width="100%" cellpadding="1" cellspacing="0" align="center"' . ' border="0" bgcolor="' . $color[9] . '">';
    echo '     <tr><td>';
    echo '       <table width="100%" cellpadding="1" cellspacing="0" align="center" border="0" bgcolor="' . $color[5] . '">';
    printHeader($mailbox, $srt, $color, !$thread_sort_messages);
    displayMessageArray($imapConnection, $num_msgs, $start_msg, $msort, $mailbox, $sort, $color, $show_num, 0, 0);
    echo '</table></td></tr></table>';
    mail_message_listing_end($num_msgs, $paginator_str, $msg_cnt_str, $color);
    echo '</table>';
    echo "\n</form>\n\n";
    //$t = elapsed($start);
    //echo("elapsed time = $t seconds\n");
}
/**
 * This function loops through a group of messages in the mailbox
 * and shows them to the user.
 *
 * @param mixed $imapConnection
 * @param array $aMailbox associative array with mailbox related vars
 */
function showMessagesForMailbox($imapConnection, &$aMailbox)
{
    global $color;
    // to retrieve the internaldate pref: (I know this is not the right place to do that, move up in front
    // and use a properties array as function argument to provide user preferences
    global $data_dir, $username;
    if (!fetchMessageHeaders($imapConnection, $aMailbox)) {
        return false;
    }
    $iSetIndx = $aMailbox['SETINDEX'];
    $iLimit = $aMailbox['SHOWALL'][$iSetIndx] ? $aMailbox['EXISTS'] : $aMailbox['LIMIT'];
    $iEnd = $aMailbox['PAGEOFFSET'] + ($iLimit - 1) < $aMailbox['EXISTS'] ? $aMailbox['PAGEOFFSET'] + $iLimit - 1 : $aMailbox['EXISTS'];
    $paginator_str = get_paginator_str($aMailbox['NAME'], $aMailbox['PAGEOFFSET'], $aMailbox['EXISTS'], $aMailbox['LIMIT'], $aMailbox['SHOWALL'][$iSetIndx]);
    $msg_cnt_str = get_msgcnt_str($aMailbox['PAGEOFFSET'], $iEnd, $aMailbox['EXISTS']);
    do_hook('mailbox_index_before');
    ?>
<table border="0" width="100%" cellpadding="0" cellspacing="0">
<tr>
    <td>
    <?php 
    mail_message_listing_beginning($imapConnection, $aMailbox, $msg_cnt_str, $paginator_str);
    ?>
    </td>
</tr>
<tr><td height="5" bgcolor="<?php 
    echo $color[4];
    ?>
"></td></tr>
<tr>
    <td>
    <table width="100%" cellpadding="1" cellspacing="0" align="center" border="0" bgcolor="<?php 
    echo $color[9];
    ?>
">
        <tr>
        <td>
            <table width="100%" cellpadding="1" cellspacing="0" align="center" border="0" bgcolor="<?php 
    echo $color[5];
    ?>
">
            <tr>
                <td>
                <?php 
    printHeader($aMailbox);
    displayMessageArray($imapConnection, $aMailbox);
    ?>
                </td>
            </tr>
            </table>
        </td>
        </tr>
    </table>
    <?php 
    mail_message_listing_end($aMailbox['EXISTS'], $paginator_str, $msg_cnt_str);
    ?>
    </td>
</tr>
</table>
<?php 
}
Exemplo n.º 4
0
function printSearchMessages($msgs, $mailbox, $cnt, $imapConnection, $where, $what, $usecache = false, $newsort = false)
{
    global $sort, $color, $allow_server_sort, $allow_server_thread;
    if ($cnt > 0) {
        if (!empty($allow_server_sort) && $allow_server_sort || !empty($allow_server_thread) && $allow_server_thread) {
            $msort = $msgs;
        } else {
            $msort = calc_msort($msgs, $sort);
        }
        if ($mailbox == 'INBOX') {
            $showbox = _("INBOX");
        } else {
            $showbox = imap_utf7_decode_local($mailbox);
        }
        echo html_tag('div', '<b><big>' . _("Folder:") . ' ' . htmlspecialchars($showbox) . '</big></b>', 'center') . "\n";
        $msg_cnt_str = get_msgcnt_str(1, $cnt, $cnt);
        $toggle_all = get_selectall_link(1, $sort);
        $safe_name = preg_replace("/[^0-9A-Za-z_]/", '_', $mailbox);
        $form_name = "FormMsgs" . $safe_name;
        echo '<form name="' . $form_name . '" method="post" action="move_messages.php">' . "\n" . '<input type="hidden" name="mailbox" value="' . htmlspecialchars($mailbox) . '">' . "\n" . '<input type="hidden" name="startMessage" value="1">' . "\n";
        echo '<table border="0" width="100%" cellpadding="0" cellspacing="0">';
        echo '<tr><td>';
        mail_message_listing_beginning($imapConnection, $mailbox, $sort, $msg_cnt_str, $toggle_all, 1);
        echo '</td></tr>';
        echo '<tr><td height="5" bgcolor="' . $color[4] . '"></td></tr>';
        echo '<tr><td>';
        echo '    <table width="100%" cellpadding="1" cellspacing="0" align="center"' . ' border="0" bgcolor="' . $color[9] . '">';
        echo '     <tr><td>';
        echo '       <table width="100%" cellpadding="1" cellspacing="0" align="center" border="0" bgcolor="' . $color[5] . '">';
        echo '<tr><td>';
        printHeader($mailbox, 6, $color, false);
        displayMessageArray($imapConnection, $cnt, 1, $msort, $mailbox, $sort, $color, $cnt, $where, $what);
        echo '</td></tr></table></td></tr></table>';
        mail_message_listing_end($cnt, '', $msg_cnt_str, $color);
        echo "\n</table></form>\n\n";
    }
}