예제 #1
0
파일: right_main.php 프로젝트: jprice/EHCP
 * registered session data.  :)                                      *
 *********************************************************************/
if (!isset($use_mailbox_cache)) {
    $use_mailbox_cache = 0;
}
if ($use_mailbox_cache && sqsession_is_registered('msgs')) {
    showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color, $show_num, $use_mailbox_cache);
} else {
    if (sqsession_is_registered('msgs')) {
        unset($msgs);
    }
    if (sqsession_is_registered('msort')) {
        unset($msort);
    }
    if (sqsession_is_registered('numMessages')) {
        unset($numMessages);
    }
    $numMessages = sqimap_get_num_messages($imapConnection, $mailbox);
    // set 8th argument to false in order to make sure that cache is not used.
    showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color, $show_num, false);
    if (sqsession_is_registered('msgs') && isset($msgs)) {
        sqsession_register($msgs, 'msgs');
    }
    if (sqsession_is_registered('msort') && isset($msort)) {
        sqsession_register($msort, 'msort');
    }
    sqsession_register($numMessages, 'numMessages');
}
do_hook('right_main_bottom');
sqimap_logout($imapConnection);
echo '</body></html>';
예제 #2
0
파일: left_main.php 프로젝트: jprice/EHCP
function formatMailboxName($imapConnection, $box_array)
{
    global $folder_prefix, $trash_folder, $sent_folder, $color, $move_to_sent, $move_to_trash, $unseen_notify, $unseen_type, $collapse_folders, $draft_folder, $save_as_draft, $use_special_folder_color;
    $real_box = $box_array['unformatted'];
    $mailbox = str_replace('&nbsp;', '', $box_array['formatted']);
    $mailboxURL = urlencode($real_box);
    /* Strip down the mailbox name. */
    if (ereg("^( *)([^ ]*)\$", $mailbox, $regs)) {
        $mailbox = $regs[2];
    }
    $unseen = 0;
    $status = array('', '');
    if ($unseen_notify == 2 && $real_box == 'INBOX' || $unseen_notify == 3) {
        $tmp_status = create_unseen_string($real_box, $box_array, $imapConnection, $unseen_type);
        if ($status !== false) {
            $status = $tmp_status;
        }
    }
    list($unseen_string, $unseen) = $status;
    $special_color = $use_special_folder_color && isSpecialMailbox($real_box);
    /* Start off with a blank line. */
    $line = '';
    /* If there are unseen message, bold the line. */
    if ($unseen > 0) {
        $line .= '<b>';
    }
    /* Create the link for this folder. */
    if ($status !== false) {
        $line .= '<a href="right_main.php?PG_SHOWALL=0&amp;sort=0&amp;startMessage=1&amp;mailbox=' . $mailboxURL . '" target="right" style="text-decoration:none">';
    }
    if ($special_color) {
        $line .= "<font color=\"{$color['11']}\">";
    }
    if ($mailbox == 'INBOX') {
        $line .= _("INBOX");
    } else {
        $line .= str_replace(array(' ', '<', '>'), array('&nbsp;', '&lt;', '&gt;'), $mailbox);
    }
    if ($special_color == TRUE) {
        $line .= '</font>';
    }
    if ($status !== false) {
        $line .= '</a>';
    }
    /* If there are unseen message, close bolding. */
    if ($unseen > 0) {
        $line .= "</b>";
    }
    /* Print unseen information. */
    if ($unseen_string != '') {
        $line .= "&nbsp;<small>{$unseen_string}</small>";
    }
    /* If it's the trash folder, show a purge link when needed */
    if ($move_to_trash && $real_box == $trash_folder) {
        if (!isset($numMessages)) {
            $numMessages = sqimap_get_num_messages($imapConnection, $real_box);
        }
        if ($numMessages > 0 or $box_array['parent'] == 1) {
            $urlMailbox = urlencode($real_box);
            $line .= "\n<small>\n" . '&nbsp;&nbsp;(<a href="empty_trash.php" style="text-decoration:none">' . _("Purge") . '</a>)' . '</small>';
        }
    }
    $line .= concat_hook_function('left_main_after_each_folder', array(isset($numMessages) ? $numMessages : '', $real_box, $imapConnection));
    /* Return the final product. */
    return $line;
}
function sqimap_mailbox_tree($imap_stream)
{
    global $boxesnew, $default_folder_prefix, $unseen_notify, $unseen_type;
    if (!isset($boxesnew)) {
        global $data_dir, $username, $list_special_folders_first, $folder_prefix, $delimiter, $trash_folder, $move_to_trash;
        $inbox_in_list = false;
        $inbox_subscribed = false;
        require_once SM_PATH . 'include/load_prefs.php';
        /* LSUB array */
        $lsub_ary = sqimap_run_command($imap_stream, "LSUB \"{$folder_prefix}\" \"*\"", true, $response, $message);
        /*
         * Section about removing the last element was removed 
         * We don't return "* OK" anymore from sqimap_read_data
         */
        $sorted_lsub_ary = array();
        $cnt = count($lsub_ary);
        for ($i = 0; $i < $cnt; $i++) {
            /*
             * Workaround for EIMS
             * Doesn't work if the mailbox name is multiple lines
             */
            if (isset($lsub_ary[$i + 1]) && ereg("^(\\* [A-Z]+.*)\\{[0-9]+\\}([ \n\r\t]*)\$", $lsub_ary[$i], $regs)) {
                $i++;
                $lsub_ary[$i] = $regs[1] . '"' . addslashes(trim($lsub_ary[$i])) . '"' . $regs[2];
            }
            /*
            if (preg_match("/^\*\s+LSUB\s+\((.*)\)\s+\"(.*)\"\s+\"?(.+(?=\")|.+).*$/",$lsub_ary[$i],$regs)) {
                $flag = $regs[1];
                $mbx = trim($regs[3]);
                $sorted_lsub_ary[] = array ('mbx' => $mbx, 'flag' => $flag); 
            }
            */
            $mbx = find_mailbox_name($lsub_ary[$i]);
            $noselect = check_is_noselect($lsub_ary[$i]);
            if (substr($mbx, -1) == $delimiter) {
                $mbx = substr($mbx, 0, strlen($mbx) - 1);
            }
            $sorted_lsub_ary[] = array('mbx' => $mbx, 'noselect' => $noselect);
        }
        array_multisort($sorted_lsub_ary, SORT_ASC, SORT_REGULAR);
        for ($i = 0; $i < $cnt; $i++) {
            if ($sorted_lsub_ary[$i]['mbx'] == 'INBOX') {
                $inbox_in_list = true;
                break;
            }
        }
        /*
         * Just in case they're not subscribed to their inbox,
         * we'll get it for them anyway
         */
        if (!$inbox_in_list) {
            $inbox_ary = sqimap_run_command($imap_stream, "LIST \"\" \"INBOX\"", true, $response, $message);
            /* Another workaround for EIMS */
            if (isset($inbox_ary[1]) && ereg("^(\\* [A-Z]+.*)\\{[0-9]+\\}([ \n\r\t]*)\$", $inbox_ary[0], $regs)) {
                $inbox_ary[0] = $regs[1] . '"' . addslashes(trim($inbox_ary[1])) . '"' . $regs[2];
            }
            $mbx = find_mailbox_name($inbox_ary[0]);
            if (substr($mbx, -1) == $delimiter) {
                $mbx = substr($mbx, 0, strlen($mbx) - 1);
            }
            if ($mbx == 'INBOX') {
                $sorted_lsub_ary[] = array('mbx' => $mbx, 'flag' => '');
                sqimap_subscribe($imap_stream, 'INBOX');
                $cnt++;
            }
            /*
            if (preg_match("/^\*\s+LIST\s+\((.*)\)\s+\"(.*)\"\s+\"?(.+(?=\")|.+).*$/",$inbox_ary[0],$regs)) {
                $flag = $regs[1];
                $mbx = trim($regs[3]);
                if (substr($mbx, -1) == $delimiter) {
                    $mbx = substr($mbx, 0, strlen($mbx) - 1);
                }
                $sorted_lsub_ary[] = array ('mbx' => $mbx, 'flag' => $flag); 
            }
            */
        }
        for ($i = 0; $i < $cnt; $i++) {
            $mbx = $sorted_lsub_ary[$i]['mbx'];
            if ($unseen_notify == 2 && $mbx == 'INBOX' || $unseen_notify == 3 || $move_to_trash && $mbx == $trash_folder) {
                if ($sorted_lsub_ary[$i]['noselect']) {
                    $sorted_lsub_ary[$i]['unseen'] = 0;
                } else {
                    $sorted_lsub_ary[$i]['unseen'] = sqimap_unseen_messages($imap_stream, $mbx);
                }
                if ($unseen_type == 2 || $move_to_trash && $mbx == $trash_folder || $mbx == $trash_folder) {
                    if ($sorted_lsub_ary[$i]['noselect']) {
                        $sorted_lsub_ary[$i]['nummessages'] = 0;
                    } else {
                        $sorted_lsub_ary[$i]['nummessages'] = sqimap_get_num_messages($imap_stream, $mbx);
                    }
                }
            }
        }
        $boxesnew = sqimap_fill_mailbox_tree($sorted_lsub_ary);
        return $boxesnew;
    }
}