Esempio n. 1
0
/**
 * Does the actual password changing (meaning it calls the hook function
 * from the backend that does this. If something goes wrong, return error
 * message(s). If everything ok, change the password in the session so the
 * user doesn't have to log out, and redirect back to the options screen.
 */
function cpw_do_change()
{
    global $cpw_backend;
    sqgetGlobalVar('cpw_curpass', $curpw, SQ_POST);
    sqgetGlobalVar('cpw_newpass', $newpw, SQ_POST);
    sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION);
    sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION);
    sqgetGlobalVar('key', $key, SQ_COOKIE);
    sqgetGlobalVar('username', $username, SQ_SESSION);
    require_once SM_PATH . 'plugins/change_password/backend/' . $cpw_backend . '.php';
    $msgs = do_hook('change_password_dochange', $temp = array('username' => &$username, 'curpw' => &$curpw, 'newpw' => &$newpw));
    /* something bad happened, return */
    if (count($msgs) > 0) {
        return $msgs;
    }
    /* update our password stored in the session */
    $onetimepad = OneTimePadCreate(strlen($newpw));
    sqsession_register($onetimepad, 'onetimepad');
    $key = OneTimePadEncrypt($newpw, $onetimepad);
    sqsetcookie('key', $key, 0, $base_uri);
    /* make sure we write the session data before we redirect */
    session_write_close();
    header('Location: ' . SM_PATH . 'src/options.php?optmode=submit&optpage=change_password&plugin_change_password=1&smtoken=' . sm_generate_security_token());
    exit;
}
Esempio n. 2
0
</b></div>
</td><?php 
if (isset($Messages) && count($Messages) > 0) {
    echo "<tr><td>\n";
    foreach ($Messages as $line) {
        echo sm_encode_html_special_chars($line) . "<br />\n";
    }
    echo "</td></tr>\n";
}
?>
<tr><td>
    <?php 
echo addForm($_SERVER['PHP_SELF'], 'post');
?>
    <input type="hidden" name="smtoken" value="<?php 
echo sm_generate_security_token();
?>
" />
    <table>
      <tr>
        <th align="right"><?php 
echo _("Current Password:"******"right"><?php 
            $a['MatchField'] = _("To");
            break;
        case 'cc':
            $a['MatchField'] = _("Cc");
            break;
        case 'to_cc':
            $a['MatchField'] = _("To or Cc");
            break;
        case 'subject':
            $a['MatchField'] = _("subject");
            break;
    }
    $rules[$index] = $a;
}
$oTemplate->assign('current_rules', $rules);
$token = sm_generate_security_token();
$oTemplate->assign('add_rule', 'options_highlight.php?action=add');
$oTemplate->assign('edit_rule', 'options_highlight.php?action=edit&amp;theid=');
$oTemplate->assign('delete_rule', 'options_highlight.php?action=delete&amp;smtoken=' . $token . '&amp;theid=');
$oTemplate->assign('move_up', 'options_highlight.php?action=up&amp;smtoken=' . $token . '&amp;theid=');
$oTemplate->assign('move_down', 'options_highlight.php?action=down&amp;smtoken=' . $token . '&amp;theid=');
$oTemplate->display('options_highlight_list.tpl');
/**
 * Optionally, display the add/edit dialog
 */
if ($action == 'edit' || $action == 'add') {
    $color_list[0] = '4444aa';
    $color_list[1] = '44aa44';
    $color_list[2] = 'aaaa44';
    $color_list[3] = '44aaaa';
    $color_list[4] = 'aa44aa';
Esempio n. 4
0
/**
 * This function computes the paginator string.
 *
 * @param string  $box               mailbox name
 * @param integer $iOffset           offset in total number of messages
 * @param integer $iTotal            total number of messages
 * @param integer $iLimit            maximum number of messages to show on a page
 * @param bool    $bShowAll          whether or not to show all messages at once 
 *                                   ("show all" == non paginate mode)
 * @param bool    $page_selector     whether or not to show the page selection widget
 * @param integer $page_selector_max maximum number of pages to show on the screen
 *
 * @return string $result   paginate string with links to pages
 *
 */
function get_paginator_str($box, $iOffset, $iTotal, $iLimit, $bShowAll, $page_selector, $page_selector_max)
{
    static $accesskeys_constructed = FALSE;
    /* This will be used as a space. */
    global $oTemplate, $nbsp;
    sqgetGlobalVar('PHP_SELF', $php_self, SQ_SERVER);
    /* Initialize paginator string chunks. */
    $prv_str = '';
    $nxt_str = '';
    $pg_str = '';
    $all_str = '';
    $box = urlencode($box);
    /* Create simple strings that will be creating the paginator. */
    /* This will be used as a seperator. */
    $sep = '|';
    /* Make sure that our start message number is not too big. */
    $iOffset = min($iOffset, $iTotal);
    /* Compute the starting message of the previous and next page group. */
    $next_grp = $iOffset + $iLimit;
    $prev_grp = $iOffset - $iLimit;
    if (!$bShowAll) {
        /* Compute the basic previous and next strings. */
        global $accesskey_mailbox_previous, $accesskey_mailbox_next;
        if ($next_grp <= $iTotal && $prev_grp >= 0) {
            $prv_str = get_paginator_link($box, $prev_grp, _("Previous"), $accesskeys_constructed ? 'NONE' : $accesskey_mailbox_previous);
            $nxt_str = get_paginator_link($box, $next_grp, _("Next"), $accesskeys_constructed ? 'NONE' : $accesskey_mailbox_next);
        } else {
            if ($next_grp > $iTotal && $prev_grp >= 0) {
                $prv_str = get_paginator_link($box, $prev_grp, _("Previous"), $accesskeys_constructed ? 'NONE' : $accesskey_mailbox_previous);
                $nxt_str = _("Next");
            } else {
                if ($next_grp <= $iTotal && $prev_grp < 0) {
                    $prv_str = _("Previous");
                    $nxt_str = get_paginator_link($box, $next_grp, _("Next"), $accesskeys_constructed ? 'NONE' : $accesskey_mailbox_next);
                }
            }
        }
        /* Page selector block. Following code computes page links. */
        if ($iLimit != 0 && $page_selector && $iTotal > $iLimit) {
            /* Most importantly, what is the current page!!! */
            $cur_pg = intval($iOffset / $iLimit) + 1;
            /* Compute total # of pages and # of paginator page links. */
            $tot_pgs = ceil($iTotal / $iLimit);
            /* Total number of Pages */
            $vis_pgs = min($page_selector_max, $tot_pgs - 1);
            /* Visible Pages    */
            /* Compute the size of the four quarters of the page links. */
            /* If we can, just show all the pages. */
            if ($tot_pgs - 1 <= $page_selector_max) {
                $q1_pgs = $cur_pg - 1;
                $q2_pgs = $q3_pgs = 0;
                $q4_pgs = $tot_pgs - $cur_pg;
                /* Otherwise, compute some magic to choose the four quarters. */
            } else {
                /*
                 * Compute the magic base values. Added together,
                 * these values will always equal to the $pag_pgs.
                 * NOTE: These are DEFAULT values and do not take
                 * the current page into account. That is below.
                 */
                $q1_pgs = floor($vis_pgs / 4);
                $q2_pgs = round($vis_pgs / 4, 0);
                $q3_pgs = ceil($vis_pgs / 4);
                $q4_pgs = round(($vis_pgs - $q2_pgs) / 3, 0);
                /* Adjust if the first quarter contains the current page. */
                if ($cur_pg - $q1_pgs < 1) {
                    $extra_pgs = $q1_pgs - ($cur_pg - 1) + $q2_pgs;
                    $q1_pgs = $cur_pg - 1;
                    $q2_pgs = 0;
                    $q3_pgs += ceil($extra_pgs / 2);
                    $q4_pgs += floor($extra_pgs / 2);
                    /* Adjust if the first and second quarters intersect. */
                } else {
                    if ($cur_pg - $q2_pgs - ceil($q2_pgs / 3) <= $q1_pgs) {
                        $extra_pgs = $q2_pgs;
                        $extra_pgs -= ceil(($cur_pg - $q1_pgs - 1) * 3 / 4);
                        $q2_pgs = ceil(($cur_pg - $q1_pgs - 1) * 3 / 4);
                        $q3_pgs += ceil($extra_pgs / 2);
                        $q4_pgs += floor($extra_pgs / 2);
                        /* Adjust if the fourth quarter contains the current page. */
                    } else {
                        if ($cur_pg + $q4_pgs >= $tot_pgs) {
                            $extra_pgs = $q4_pgs - ($tot_pgs - $cur_pg) + $q3_pgs;
                            $q3_pgs = 0;
                            $q4_pgs = $tot_pgs - $cur_pg;
                            $q1_pgs += floor($extra_pgs / 2);
                            $q2_pgs += ceil($extra_pgs / 2);
                            /* Adjust if the third and fourth quarter intersect. */
                        } else {
                            if ($cur_pg + $q3_pgs + 1 >= $tot_pgs - $q4_pgs + 1) {
                                $extra_pgs = $q3_pgs;
                                $extra_pgs -= ceil(($tot_pgs - $cur_pg - $q4_pgs) * 3 / 4);
                                $q3_pgs = ceil(($tot_pgs - $cur_pg - $q4_pgs) * 3 / 4);
                                $q1_pgs += floor($extra_pgs / 2);
                                $q2_pgs += ceil($extra_pgs / 2);
                            }
                        }
                    }
                }
            }
            /*
             * I am leaving this debug code here, commented out, because
             * it is a really nice way to see what the above code is doing.
             * echo "qts =  $q1_pgs/$q2_pgs/$q3_pgs/$q4_pgs = "
             *    . ($q1_pgs + $q2_pgs + $q3_pgs + $q4_pgs) . '<br />';
             */
            /* Print out the page links from the compute page quarters. */
            /* Start with the first quarter. */
            if ($q1_pgs == 0 && $cur_pg > 1) {
                $pg_str .= "...{$nbsp}";
            } else {
                for ($pg = 1; $pg <= $q1_pgs; ++$pg) {
                    $start = ($pg - 1) * $iLimit + 1;
                    $pg_str .= get_paginator_link($box, $start, $pg) . $nbsp;
                }
                if ($cur_pg - $q2_pgs - $q1_pgs > 1) {
                    $pg_str .= "...{$nbsp}";
                }
            }
            /* Continue with the second quarter. */
            for ($pg = $cur_pg - $q2_pgs; $pg < $cur_pg; ++$pg) {
                $start = ($pg - 1) * $iLimit + 1;
                $pg_str .= get_paginator_link($box, $start, $pg) . $nbsp;
            }
            /* Now print the current page. */
            $pg_str .= $cur_pg . $nbsp;
            /* Next comes the third quarter. */
            for ($pg = $cur_pg + 1; $pg <= $cur_pg + $q3_pgs; ++$pg) {
                $start = ($pg - 1) * $iLimit + 1;
                $pg_str .= get_paginator_link($box, $start, $pg) . $nbsp;
            }
            /* And last, print the forth quarter page links. */
            if ($q4_pgs == 0 && $cur_pg < $tot_pgs) {
                $pg_str .= "...{$nbsp}";
            } else {
                if ($tot_pgs - $q4_pgs > $cur_pg + $q3_pgs) {
                    $pg_str .= "...{$nbsp}";
                }
                for ($pg = $tot_pgs - $q4_pgs + 1; $pg <= $tot_pgs; ++$pg) {
                    $start = ($pg - 1) * $iLimit + 1;
                    $pg_str .= get_paginator_link($box, $start, $pg) . $nbsp;
                }
            }
            $last_grp = ($tot_pgs - 1) * $iLimit + 1;
        }
    } else {
        global $accesskey_mailbox_all_paginate;
        $pg_str = create_hyperlink("{$php_self}?showall=0&amp;startMessage=1&amp;mailbox={$box}" . (strpos($php_self, 'src/search.php') ? '&amp;smtoken=' . sm_generate_security_token() : ''), _("Paginate"), '', '', '', '', '', $accesskeys_constructed ? array() : array('accesskey' => $accesskey_mailbox_all_paginate));
    }
    /* Put all the pieces of the paginator string together. */
    /**
     * Hairy code... But let's leave it like it is since I am not certain
     * a different approach would be any easier to read. ;)
     */
    $result = '';
    if ($prv_str || $nxt_str) {
        /* Compute the 'show all' string. */
        global $accesskey_mailbox_all_paginate;
        $all_str = create_hyperlink("{$php_self}?showall=1&amp;startMessage=1&amp;mailbox={$box}" . (strpos($php_self, 'src/search.php') ? '&amp;smtoken=' . sm_generate_security_token() : ''), _("Show All"), '', '', '', '', '', $accesskeys_constructed ? array() : array('accesskey' => $accesskey_mailbox_all_paginate));
        $result .= '[';
        $result .= $prv_str != '' ? $prv_str . $nbsp . $sep . $nbsp : '';
        $result .= $nxt_str != '' ? $nxt_str : '';
        $result .= ']' . $nbsp;
    }
    $result .= $pg_str != '' ? $nbsp . '[' . $nbsp . $pg_str . ']' . $nbsp : '';
    $result .= $all_str != '' ? $nbsp . '[' . $all_str . ']' . $nbsp . $nbsp : '';
    /* If the resulting string is blank, return a non-breaking space. */
    if ($result == '') {
        $result = $nbsp;
    }
    $accesskeys_constructed = TRUE;
    /* Return our final magical compact paginator string. */
    return $result;
}
Esempio n. 5
0
/**
 * Make a <form> start-tag.
 *
 * @param string  $sAction   form handler URL
 * @param string  $sMethod   http method used to submit form data. 'get' or 'post'
 * @param string  $sName     form name used for identification (used for backward 
 *                           compatibility). Use of id is recommended instead.
 * @param string  $sEnctype  content type that is used to submit data. html 4.01 
 *                           defaults to 'application/x-www-form-urlencoded'. Form 
 *                           with file field needs 'multipart/form-data' encoding type.
 * @param string  $sCharset  charset that is used for submitted data
 * @param array   $aAttribs  (since 1.5.1) extra attributes
 * @param boolean $bAddToken (since 1.5.2) When given as a string or as boolean TRUE,
 *                           a hidden input is also added to the form containing a
 *                           security token.  When given as TRUE, the input name is
 *                           "smtoken"; otherwise the name is the string that is
 *                           given for this parameter.  When FALSE, no hidden token
 *                           input field is added.  (OPTIONAL; default not used)
 *
 * @return string html formated form start string
 *
 */
function addForm($sAction, $sMethod = 'post', $sName = '', $sEnctype = '', $sCharset = '', $aAttribs = array(), $bAddToken = FALSE)
{
    global $oTemplate;
    //FIXME: all the values in the $aAttribs list as well as $charset used to go thru sm_encode_html_special_chars()... I would propose that most everything that is assigned to the template should go thru that *in the template class* on its way between here and the actual template file.  Otherwise we have to do something like:  foreach ($aAttribs as $key => $value) $aAttribs[$key] = sm_encode_html_special_chars($value); $sCharset = sm_encode_html_special_chars($sCharset);
    $oTemplate->assign('aAttribs', $aAttribs);
    $oTemplate->assign('name', $sName);
    $oTemplate->assign('method', $sMethod);
    $oTemplate->assign('action', $sAction);
    $oTemplate->assign('enctype', $sEnctype);
    $oTemplate->assign('charset', $sCharset);
    $sForm = $oTemplate->fetch('form.tpl');
    if ($bAddToken) {
        $sForm .= addHidden(is_string($bAddToken) ? $bAddToken : 'smtoken', sm_generate_security_token());
    }
    return $sForm;
}
Esempio n. 6
0
/**
 * This function loops through a group of messages in the mailbox
 * and shows them to the user.
 *
 * @param resource $imapConnection
 * @param array    $aMailbox associative array with mailbox related vars
 * @param array    $aProps
 * @param int      $iError error code, 0 is no error
 */
function showMessagesForMailbox($imapConnection, &$aMailbox, $aProps, &$iError)
{
    global $PHP_SELF;
    global $boxes, $show_copy_buttons;
    $highlight_list = isset($aProps['config']['highlight_list']) ? $aProps['config']['highlight_list'] : false;
    $fancy_index_highlite = isset($aProps['config']['fancy_index_highlite']) ? $aProps['config']['fancy_index_highlite'] : true;
    $aColumnsDesc = isset($aProps['columns']) ? $aProps['columns'] : false;
    $iAccount = isset($aProps['account']) ? (int) $aProps['account'] : 0;
    $sMailbox = isset($aProps['mailbox']) ? $aProps['mailbox'] : false;
    $sTargetModule = isset($aProps['module']) ? $aProps['module'] : 'read_body';
    $show_flag_buttons = isset($aProps['config']['show_flag_buttons']) ? $aProps['config']['show_flag_buttons'] : true;
    /* allows to control copy button in function call. If array key is not set, code follows user preferences */
    if (isset($aProps['config']['show_copy_buttons'])) {
        $show_copy_buttons = $aProps['config']['show_copy_buttons'];
    }
    $lastTargetMailbox = isset($aProps['config']['lastTargetMailbox']) ? $aProps['config']['lastTargetMailbox'] : '';
    $aOrder = array_keys($aProps['columns']);
    $trash_folder = isset($aProps['config']['trash_folder']) && $aProps['config']['trash_folder'] ? $aProps['config']['trash_folder'] : false;
    $sent_folder = isset($aProps['config']['sent_folder']) && $aProps['config']['sent_folder'] ? $aProps['config']['sent_folder'] : false;
    $draft_folder = isset($aProps['config']['draft_folder']) && $aProps['config']['draft_folder'] ? $aProps['config']['draft_folder'] : false;
    $page_selector = isset($aProps['config']['page_selector']) ? $aProps['config']['page_selector'] : false;
    $page_selector_max = isset($aProps['config']['page_selector_max']) ? $aProps['config']['page_selector_max'] : 10;
    $color = $aProps['config']['color'];
    /*
     * Form ID
     */
    static $iFormId;
    if (!isset($iFormId)) {
        $iFormId = 1;
    } else {
        ++$iFormId;
    }
    // store the columns to fetch so we can pick them up in read_body
    // where we validate the cache.
    calcFetchColumns($aMailbox, $aProps);
    $iError = fetchMessageHeaders($imapConnection, $aMailbox);
    if ($iError) {
        return array();
    } else {
        $aMessages = prepareMessageList($aMailbox, $aProps);
    }
    $iSetIndx = $aMailbox['SETINDEX'];
    $iLimit = $aMailbox['SHOWALL'][$iSetIndx] ? $aMailbox['EXISTS'] : $aMailbox['LIMIT'];
    $iEnd = $aMailbox['PAGEOFFSET'] + ($iLimit - 1) < $aMailbox['EXISTS'] ? $aMailbox['PAGEOFFSET'] + $iLimit - 1 : $aMailbox['EXISTS'];
    $iNumberOfMessages = $aMailbox['TOTAL'][$iSetIndx];
    $iEnd = min($iEnd, $iNumberOfMessages);
    $php_self = $PHP_SELF;
    $urlMailbox = urlencode($aMailbox['NAME']);
    if (preg_match('/^(.+)\\?.+$/', $php_self, $regs)) {
        $source_url = $regs[1];
    } else {
        $source_url = $php_self;
    }
    $baseurl = $source_url . '?mailbox=' . urlencode($aMailbox['NAME']) . '&amp;account=' . $aMailbox['ACCOUNT'] . (strpos($source_url, 'src/search.php') ? '&amp;smtoken=' . sm_generate_security_token() : '');
    $where = urlencode($aMailbox['SEARCH'][$iSetIndx][0]);
    $what = urlencode($aMailbox['SEARCH'][$iSetIndx][1]);
    $baseurl .= '&amp;where=' . $where . '&amp;what=' . $what;
    /* build thread sorting links */
    $newsort = $aMailbox['SORT'];
    if (sqimap_capability($imapConnection, 'THREAD')) {
        if ($aMailbox['SORT'] & SQSORT_THREAD) {
            $newsort -= SQSORT_THREAD;
            $thread_name = _("Unthread View");
        } else {
            $thread_name = _("Thread View");
            $newsort = $aMailbox['SORT'] + SQSORT_THREAD;
        }
        $thread_link_uri = $baseurl . '&amp;srt=' . $newsort . '&amp;startMessage=1';
    } else {
        $thread_link_uri = '';
        $thread_name = '';
    }
    $sort = $aMailbox['SORT'];
    /* FIX ME ADD CHECKBOX CONTROL. No checkbox => no buttons */
    /* future admin control over displayable buttons */
    $aAdminControl = array('markFlagged' => 1, 'markUnflagged' => 1, 'markRead' => 1, 'markUnread' => 1, 'forward' => 1, 'delete' => 1, 'undeleteButton' => 1, 'bypass_trash' => 1, 'expungeButton' => 1, 'moveButton' => 1, 'copyButton' => 1);
    /* user prefs control */
    $aUserControl = array('markFlagged' => $show_flag_buttons, 'markUnflagged' => $show_flag_buttons, 'markRead' => 1, 'markUnread' => 1, 'forward' => 1, 'delete' => 1, 'undeleteButton' => 1, 'bypass_trash' => 1, 'expungeButton' => 1, 'moveButton' => 1, 'copyButton' => $show_copy_buttons);
    $showDelete = $aMailbox['RIGHTS'] != 'READ-ONLY' && in_array('\\deleted', $aMailbox['PERMANENTFLAGS'], true) ? true : false;
    $showByPassTrash = $aMailbox['AUTO_EXPUNGE'] && $aMailbox['RIGHTS'] != 'READ-ONLY' && in_array('\\deleted', $aMailbox['PERMANENTFLAGS'], true) && $trash_folder ? true : false;
    //
    $showUndelete = !$aMailbox['AUTO_EXPUNGE'] && $aMailbox['RIGHTS'] != 'READ-ONLY' && in_array('\\deleted', $aMailbox['PERMANENTFLAGS'], true) ? true : false;
    $showMove = $aMailbox['RIGHTS'] != 'READ-ONLY' ? true : false;
    $showExpunge = !$aMailbox['AUTO_EXPUNGE'] && $aMailbox['RIGHTS'] != 'READ-ONLY' && in_array('\\deleted', $aMailbox['PERMANENTFLAGS'], true) ? true : false;
    /* Button options that depend on IMAP server and selected folder */
    $aImapControl = array('markUnflagged' => in_array('\\flagged', $aMailbox['PERMANENTFLAGS'], true), 'markFlagged' => in_array('\\flagged', $aMailbox['PERMANENTFLAGS'], true), 'markRead' => in_array('\\seen', $aMailbox['PERMANENTFLAGS'], true), 'markUnread' => in_array('\\seen', $aMailbox['PERMANENTFLAGS'], true), 'forward' => 1, 'delete' => $showDelete, 'undeleteButton' => $showUndelete, 'bypass_trash' => $showByPassTrash, 'expungeButton' => $showExpunge, 'moveButton' => $showMove, 'copyButton' => 1);
    /* Button strings */
    $aButtonStrings = array('markFlagged' => _("Flag"), 'markUnflagged' => _("Unflag"), 'markRead' => _("Read"), 'markUnread' => _("Unread"), 'forward' => _("Forward"), 'delete' => _("Delete"), 'undeleteButton' => _("Undelete"), 'bypass_trash' => _("Bypass Trash"), 'expungeButton' => _("Expunge"), 'moveButton' => _("Move"), 'copyButton' => _("Copy"));
    /* Button access keys */
    global $accesskey_mailbox_flag, $accesskey_mailbox_unflag, $accesskey_mailbox_read, $accesskey_mailbox_unread, $accesskey_mailbox_forward, $accesskey_mailbox_delete, $accesskey_mailbox_undelete, $accesskey_mailbox_bypass_trash, $accesskey_mailbox_expunge, $accesskey_mailbox_move, $accesskey_mailbox_copy, $accesskey_mailbox_move_to;
    $aButtonAccessKeys = array('markFlagged' => $accesskey_mailbox_flag, 'markUnflagged' => $accesskey_mailbox_unflag, 'markRead' => $accesskey_mailbox_read, 'markUnread' => $accesskey_mailbox_unread, 'forward' => $accesskey_mailbox_forward, 'delete' => $accesskey_mailbox_delete, 'undeleteButton' => $accesskey_mailbox_undelete, 'bypass_trash' => $accesskey_mailbox_bypass_trash, 'expungeButton' => $accesskey_mailbox_expunge, 'moveButton' => $accesskey_mailbox_move, 'copyButton' => $accesskey_mailbox_copy);
    /**
     * Register buttons in order to an array
     * The key is the "name", the first element of the value array is the "value", second argument is the type.
     */
    $aFormElements = array();
    foreach ($aAdminControl as $k => $v) {
        if ($v & $aUserControl[$k] & $aImapControl[$k]) {
            switch ($k) {
                case 'markFlagged':
                case 'markUnflagged':
                case 'markRead':
                case 'markUnread':
                case 'delete':
                case 'undeleteButton':
                case 'expungeButton':
                case 'forward':
                    $aFormElements[$k] = array('value' => $aButtonStrings[$k], 'type' => 'submit', 'accesskey' => isset($aButtonAccessKeys[$k]) ? $aButtonAccessKeys[$k] : 'NONE');
                    break;
                case 'bypass_trash':
                    $aFormElements[$k] = array('value' => $aButtonStrings[$k], 'type' => 'checkbox', 'accesskey' => isset($aButtonAccessKeys[$k]) ? $aButtonAccessKeys[$k] : 'NONE');
                    break;
                case 'moveButton':
                case 'copyButton':
                    $aFormElements['targetMailbox'] = array('options_list' => sqimap_mailbox_option_list($imapConnection, array(strtolower($lastTargetMailbox)), 0, $boxes), 'type' => 'select', 'accesskey' => $accesskey_mailbox_move_to);
                    $aFormElements['mailbox'] = array('value' => $aMailbox['NAME'], 'type' => 'hidden');
                    $aFormElements['startMessage'] = array('value' => $aMailbox['PAGEOFFSET'], 'type' => 'hidden');
                    $aFormElements[$k] = array('value' => $aButtonStrings[$k], 'type' => 'submit', 'accesskey' => isset($aButtonAccessKeys[$k]) ? $aButtonAccessKeys[$k] : 'NONE');
                    break;
            }
        }
        $aFormElements['account'] = array('value' => $iAccount, 'type' => 'hidden');
    }
    do_hook('message_list_controls', $aFormElements);
    /*
     * This is the beginning of the message list table.
     * It wraps around all messages
     */
    $safe_name = preg_replace("/[^0-9A-Za-z_]/", '_', $aMailbox['NAME']);
    $form_name = "FormMsgs" . $safe_name;
    //if (!sqgetGlobalVar('align',$align,SQ_SESSION)) {
    $align = array('left' => 'left', 'right' => 'right');
    //}
    //sm_print_r($align);
    /* finally set the template vars */
    // FIXME, before we support multiple templates we must review the names of the vars
    // BUMP!
    $aTemplate['color'] = $color;
    $aTemplate['form_name'] = "FormMsgs" . $safe_name;
    $aTemplate['form_id'] = 'mbx_' . $iFormId;
    $aTemplate['page_selector'] = $page_selector;
    $aTemplate['page_selector_max'] = $page_selector_max;
    $aTemplate['messagesPerPage'] = $aMailbox['LIMIT'];
    $aTemplate['showall'] = $aMailbox['SHOWALL'][$iSetIndx];
    $aTemplate['end_msg'] = $iEnd;
    $aTemplate['align'] = $align;
    $aTemplate['iNumberOfMessages'] = $iNumberOfMessages;
    $aTemplate['aOrder'] = $aOrder;
    $aTemplate['aFormElements'] = $aFormElements;
    $aTemplate['sort'] = $sort;
    $aTemplate['pageOffset'] = $aMailbox['PAGEOFFSET'];
    $aTemplate['baseurl'] = $baseurl;
    $aTemplate['aMessages'] =& $aMessages;
    $aTemplate['trash_folder'] = $trash_folder;
    $aTemplate['sent_folder'] = $sent_folder;
    $aTemplate['draft_folder'] = $draft_folder;
    $aTemplate['thread_link_uri'] = $thread_link_uri;
    $aTemplate['thread_name'] = $thread_name;
    $aTemplate['php_self'] = str_replace('&', '&amp;', $php_self);
    $aTemplate['mailbox'] = $sMailbox;
    //FIXME: javascript_on is always assigned to the template object in places like init.php; is there some reason to reassign it here?  is there some chance that it was changed?  if not, please remove this line!
    $aTemplate['javascript_on'] = isset($aProps['config']['javascript_on']) ? $aProps['config']['javascript_on'] : false;
    $aTemplate['enablesort'] = isset($aProps['config']['enablesort']) ? $aProps['config']['enablesort'] : false;
    $aTemplate['icon_theme'] = isset($aProps['config']['icon_theme']) ? $aProps['config']['icon_theme'] : false;
    $aTemplate['use_icons'] = isset($aProps['config']['use_icons']) ? $aProps['config']['use_icons'] : false;
    $aTemplate['alt_index_colors'] = isset($aProps['config']['alt_index_colors']) ? $aProps['config']['alt_index_colors'] : false;
    $aTemplate['fancy_index_highlite'] = $fancy_index_highlite;
    /**
     * Set up sort possibilities; one could argue that this is best
     * placed in the template, but most template authors won't understand
     * or need to understand it, so some advanced templates can override 
     * it if they do something different.
     */
    if (!($aTemplate['sort'] & SQSORT_THREAD) && $aTemplate['enablesort']) {
        $aTemplate['aSortSupported'] = array(SQM_COL_SUBJ => array(SQSORT_SUBJ_ASC, SQSORT_SUBJ_DESC), SQM_COL_DATE => array(SQSORT_DATE_DESC, SQSORT_DATE_ASC), SQM_COL_INT_DATE => array(SQSORT_INT_DATE_DESC, SQSORT_INT_DATE_ASC), SQM_COL_FROM => array(SQSORT_FROM_ASC, SQSORT_FROM_DESC), SQM_COL_TO => array(SQSORT_TO_ASC, SQSORT_TO_DESC), SQM_COL_CC => array(SQSORT_CC_ASC, SQSORT_CC_DESC), SQM_COL_SIZE => array(SQSORT_SIZE_ASC, SQSORT_SIZE_DESC));
    } else {
        $aTemplate['aSortSupported'] = array();
    }
    /**
     * Figure out which columns should serve as labels for checkbox:
     * we try to grab the two columns before and after the checkbox,
     * except the subject column, since it is the link that opens
     * the message view
     *
     * if $javascript_on is set, then the highlighting code takes
     * care of this; just skip it
     *
     * This code also might be more appropriate in a template file, but
     * we are moving this complex stuff out of the way of template 
     * authors; advanced template sets are always free to override
     * the resultant values.
     *
     */
    $show_label_columns = array();
    $index_order_part = array();
    if (!($aTemplate['javascript_on'] && $aTemplate['fancy_index_highlite'])) {
        $get_next_two = 0;
        $last_order_part = 0;
        $last_last_order_part = 0;
        foreach ($aTemplate['aOrder'] as $index_order_part) {
            if ($index_order_part == SQM_COL_CHECK) {
                $get_next_two = 1;
                if ($last_last_order_part != SQM_COL_SUBJ) {
                    $show_label_columns[] = $last_last_order_part;
                }
                if ($last_order_part != SQM_COL_SUBJ) {
                    $show_label_columns[] = $last_order_part;
                }
            } else {
                if ($get_next_two > 0 && $get_next_two < 3 && $index_order_part != SQM_COL_SUBJ) {
                    $show_label_columns[] = $index_order_part;
                    $get_next_two++;
                }
            }
            $last_last_order_part = $last_order_part;
            $last_order_part = $index_order_part;
        }
    }
    $aTemplate['show_label_columns'] = $show_label_columns;
    return $aTemplate;
}
    $a['Email'] = sm_encode_html_special_chars($ident['email_address']);
    $a['ReplyTo'] = sm_encode_html_special_chars($ident['reply_to']);
    $a['Signature'] = sm_encode_html_special_chars($ident['signature']);
    $i[$key] = $a;
}
$a = array();
$a['Title'] = _("Add New Identity");
$a['New'] = true;
$a['Default'] = false;
$a['FullName'] = '';
$a['Email'] = '';
$a['ReplyTo'] = '';
$a['Signature'] = '';
$i[count($i)] = $a;
//FIXME: NO HTML IN THE CORE
echo '<form name="f" action="options_identities.php" method="post">' . "\n" . addHidden('smtoken', sm_generate_security_token()) . "\n";
$oTemplate->assign('identities', $i);
$oTemplate->display('options_advidentity_list.tpl');
//FIXME: NO HTML IN THE CORE
echo "</form>\n";
$oTemplate->display('footer.tpl');
/**
 * The functions below should not be needed with the additions of templates,
 * however they will remain in case plugins use them.
 */
/**
 * Returns html formated identity form fields
 *
 * Contains options_identities_buttons and options_identities_table hooks.
 * Before 1.4.5/1.5.1 hooks were placed in ShowTableInfo() function.
 * In 1.1.3-1.4.1 they were called in do_hook function with two or
Esempio n. 8
0
function showInputForm($session, $values = false)
{
    global $send_to, $send_to_cc, $send_to_bcc, $body, $startMessage, $action, $attachments, $use_signature, $signature, $prefix_sig, $session_expired, $editor_size, $editor_height, $subject, $newmail, $use_javascript_addr_book, $passed_id, $mailbox, $fwduid, $from_htmladdr_search, $location_of_buttons, $attachment_dir, $username, $data_dir, $identity, $idents, $delete_draft, $mailprio, $compose_new_win, $saved_draft, $mail_sent, $sig_first, $composeMessage, $composesession, $default_charset, $compose_onsubmit, $oTemplate, $oErrorHandler;
    if (checkForJavascript()) {
        $onfocus = ' onfocus="alreadyFocused=true;"';
        $onfocus_array = array('onfocus' => 'alreadyFocused=true;');
    } else {
        $onfocus = '';
        $onfocus_array = array();
    }
    if ($values) {
        $send_to = $values['send_to'];
        $send_to_cc = $values['send_to_cc'];
        $send_to_bcc = $values['send_to_bcc'];
        $subject = $values['subject'];
        $mailprio = $values['mailprio'];
        $body = $values['body'];
        $identity = (int) $values['identity'];
    } else {
        $send_to = decodeHeader($send_to, true, false);
        $send_to_cc = decodeHeader($send_to_cc, true, false);
        $send_to_bcc = decodeHeader($send_to_bcc, true, false);
    }
    if ($use_javascript_addr_book) {
        //FIXME: NO HTML IN CORE!
        echo "\n" . '<script type="text/javascript">' . "\n<!--\n" . 'function open_abook() { ' . "\n" . '  var nwin = window.open("addrbook_popup.php","abookpopup",' . '"width=670,height=300,resizable=yes,scrollbars=yes");' . "\n" . '  if((!nwin.opener) && (document.windows != null))' . "\n" . '    nwin.opener = document.windows;' . "\n" . "}\n" . "// -->\n</script>\n\n";
    }
    //FIXME: NO HTML IN CORE!
    echo "\n" . '<form name="compose" action="compose.php" method="post" ' . 'enctype="multipart/form-data"';
    $compose_onsubmit = array();
    global $null;
    do_hook('compose_form', $null);
    // Plugins that use compose_form hook can add an array entry
    // to the globally scoped $compose_onsubmit; we add them up
    // here and format the form tag's full onsubmit handler.
    // Each plugin should use "return false" if they need to
    // stop form submission but otherwise should NOT use "return
    // true" to give other plugins the chance to do what they need
    // to do; SquirrelMail itself will add the final "return true".
    // Onsubmit text is enclosed inside of double quotes, so plugins
    // need to quote accordingly.
    //
    // Also, plugin authors should try to retain compatibility with
    // the Compose Extras plugin by resetting its compose submit
    // counter when preventing form submit.  Use this code:
    // if (your-code-here) { submit_count = 0; return false; }
    //
    if (checkForJavascript()) {
        if (empty($compose_onsubmit)) {
            $compose_onsubmit = array();
        } else {
            if (!is_array($compose_onsubmit)) {
                $compose_onsubmit = array($compose_onsubmit);
            }
        }
        $onsubmit_text = '';
        foreach ($compose_onsubmit as $text) {
            $text = trim($text);
            if (!empty($text)) {
                if (substr($text, -1) != ';' && substr($text, -1) != '}') {
                    $text .= '; ';
                }
                $onsubmit_text .= $text;
            }
        }
        if (!empty($onsubmit_text)) {
            //FIXME: DON'T ECHO HTML FROM CORE!
            echo ' onsubmit="' . $onsubmit_text . ' return true;"';
        }
    }
    //FIXME: NO HTML IN CORE!
    echo ">\n";
    //FIXME: DON'T ECHO HTML FROM CORE!
    echo addHidden('smtoken', sm_generate_security_token());
    //FIXME: DON'T ECHO HTML FROM CORE!
    echo addHidden('startMessage', $startMessage);
    if ($action == 'draft') {
        //FIXME: DON'T ECHO HTML FROM CORE!
        echo addHidden('delete_draft', $passed_id);
    }
    if (isset($delete_draft)) {
        //FIXME: DON'T ECHO HTML FROM CORE!
        echo addHidden('delete_draft', $delete_draft);
    }
    if (isset($session)) {
        //FIXME: DON'T ECHO HTML FROM CORE!
        echo addHidden('session', $session);
    }
    if (isset($passed_id)) {
        //FIXME: DON'T ECHO HTML FROM CORE!
        echo addHidden('passed_id', $passed_id);
    }
    if (isset($fwduid)) {
        //FIXME: DON'T ECHO HTML FROM CORE!
        echo addHidden('fwduid', $fwduid);
    }
    if ($saved_draft == 'yes') {
        $oTemplate->assign('note', _("Your draft has been saved."));
        $oTemplate->display('note.tpl');
    }
    if ($mail_sent == 'yes') {
        $oTemplate->assign('note', _("Your mail has been sent."));
        $oTemplate->display('note.tpl');
    }
    if ($compose_new_win == '1') {
        $oTemplate->display('compose_newwin_close.tpl');
    }
    if ($location_of_buttons == 'top') {
        //FIXME: DON'T ECHO HTML FROM CORE!
        showComposeButtonRow();
    }
    $identities = array();
    if (count($idents) > 1) {
        reset($idents);
        foreach ($idents as $id => $data) {
            $identities[$id] = $data['full_name'] . ' &lt;' . $data['email_address'] . '&gt;';
        }
    }
    $oTemplate->assign('identities', $identities);
    $oTemplate->assign('identity_def', $identity);
    $oTemplate->assign('input_onfocus', 'onfocus="' . join(' ', $onfocus_array) . '"');
    $oTemplate->assign('to', sm_encode_html_special_chars($send_to));
    $oTemplate->assign('cc', sm_encode_html_special_chars($send_to_cc));
    $oTemplate->assign('bcc', sm_encode_html_special_chars($send_to_bcc));
    $oTemplate->assign('subject', sm_encode_html_special_chars($subject));
    // access keys...
    //
    global $accesskey_compose_to, $accesskey_compose_cc, $accesskey_compose_identity, $accesskey_compose_bcc, $accesskey_compose_subject;
    $oTemplate->assign('accesskey_compose_identity', $accesskey_compose_identity);
    $oTemplate->assign('accesskey_compose_to', $accesskey_compose_to);
    $oTemplate->assign('accesskey_compose_cc', $accesskey_compose_cc);
    $oTemplate->assign('accesskey_compose_bcc', $accesskey_compose_bcc);
    $oTemplate->assign('accesskey_compose_subject', $accesskey_compose_subject);
    $oTemplate->display('compose_header.tpl');
    if ($location_of_buttons == 'between') {
        //FIXME: DON'T ECHO HTML FROM CORE!
        showComposeButtonRow();
    }
    $body_str = '';
    if ($use_signature == true && $newmail == true && !isset($from_htmladdr_search)) {
        $signature = $idents[$identity]['signature'];
        if ($sig_first == '1') {
            /*
             * FIXME: test is specific to ja_JP translation implementation.
             * This test might apply incorrect conversion to other translations, but
             * use of 7bit iso-2022-jp charset in other translations might have other
             * issues too.
             */
            if ($default_charset == 'iso-2022-jp') {
                $body_str = "\n\n" . ($prefix_sig == true ? "-- \n" : '') . mb_convert_encoding($signature, 'EUC-JP');
            } else {
                $body_str = "\n\n" . ($prefix_sig == true ? "-- \n" : '') . decodeHeader($signature, false, false);
            }
            $body_str .= "\n\n" . sm_encode_html_special_chars(decodeHeader($body, false, false));
        } else {
            $body_str = "\n\n" . sm_encode_html_special_chars(decodeHeader($body, false, false));
            // FIXME: test is specific to ja_JP translation implementation. See above comments.
            if ($default_charset == 'iso-2022-jp') {
                $body_str .= "\n\n" . ($prefix_sig == true ? "-- \n" : '') . mb_convert_encoding($signature, 'EUC-JP');
            } else {
                $body_str .= "\n\n" . ($prefix_sig == true ? "-- \n" : '') . decodeHeader($signature, false, false);
            }
        }
    } else {
        $body_str = sm_encode_html_special_chars(decodeHeader($body, false, false));
    }
    $oTemplate->assign('editor_width', (int) $editor_size);
    $oTemplate->assign('editor_height', (int) $editor_height);
    $oTemplate->assign('input_onfocus', 'onfocus="' . join(' ', $onfocus_array) . '"');
    $oTemplate->assign('body', $body_str);
    $oTemplate->assign('show_bottom_send', $location_of_buttons != 'bottom');
    // access keys...
    //
    global $accesskey_compose_body, $accesskey_compose_send;
    $oTemplate->assign('accesskey_compose_body', $accesskey_compose_body);
    $oTemplate->assign('accesskey_compose_send', $accesskey_compose_send);
    $oTemplate->display('compose_body.tpl');
    if ($location_of_buttons == 'bottom') {
        //FIXME: DON'T ECHO HTML FROM CORE!
        showComposeButtonRow();
    }
    // composeMessage can be empty when coming from a restored session
    if (is_object($composeMessage) && $composeMessage->entities) {
        $attach_array = $composeMessage->entities;
    }
    if ($session_expired && !empty($attachments) && is_array($attachments)) {
        $attach_array = $attachments;
    }
    /* This code is for attachments */
    if ((bool) ini_get('file_uploads')) {
        /* Calculate the max size for an uploaded file.
         * This is advisory for the user because we can't actually prevent
         * people to upload too large files. */
        $sizes = array();
        /* php.ini vars which influence the max for uploads */
        $configvars = array('post_max_size', 'memory_limit', 'upload_max_filesize');
        foreach ($configvars as $var) {
            /* skip 0 or empty values, and -1 which means 'unlimited' */
            if ($size = getByteSize(ini_get($var))) {
                if ($size != '-1') {
                    $sizes[] = $size;
                }
            }
        }
        $attach = array();
        global $username, $attachment_dir;
        $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
        if (!empty($attach_array)) {
            foreach ($attach_array as $key => $attachment) {
                $attached_file = $attachment->att_local_name;
                if ($attachment->att_local_name || $attachment->body_part) {
                    $attached_filename = decodeHeader($attachment->mime_header->getParameter('name'));
                    $type = $attachment->mime_header->type0 . '/' . $attachment->mime_header->type1;
                    $a = array();
                    $a['Key'] = $key;
                    $a['FileName'] = $attached_filename;
                    $a['ContentType'] = $type;
                    $a['Size'] = filesize($hashed_attachment_dir . '/' . $attached_file);
                    $attach[$key] = $a;
                }
            }
        }
        $max = min($sizes);
        $oTemplate->assign('max_file_size', empty($max) ? -1 : $max);
        $oTemplate->assign('attachments', $attach);
        // access keys...
        //
        global $accesskey_compose_attach_browse, $accesskey_compose_attach, $accesskey_compose_delete_attach;
        $oTemplate->assign('accesskey_compose_attach_browse', $accesskey_compose_attach_browse);
        $oTemplate->assign('accesskey_compose_attach', $accesskey_compose_attach);
        $oTemplate->assign('accesskey_compose_delete_attach', $accesskey_compose_delete_attach);
        $oTemplate->display('compose_attachments.tpl');
    }
    // End of file_uploads if-block
    /* End of attachment code */
    $oTemplate->assign('username', $username);
    $oTemplate->assign('smaction', $action);
    $oTemplate->assign('mailbox', $mailbox);
    sqgetGlobalVar('QUERY_STRING', $queryString, SQ_SERVER);
    $oTemplate->assign('querystring', $queryString);
    $oTemplate->assign('composesession', $composesession);
    $oTemplate->assign('send_button_count', unique_widget_name('send', TRUE));
    if (!empty($attach_array)) {
        $oTemplate->assign('attachments', urlencode(serialize($attach_array)));
    }
    $aUserNotices = array();
    // File uploads are off, so we didn't show that part of the form.
    // To avoid bogus bug reports, tell the user why.
    if (!(bool) ini_get('file_uploads')) {
        $aUserNotices[] = _("Because PHP file uploads are turned off, you can not attach files to this message. Please see your system administrator for details.");
    }
    $oTemplate->assign('user_notices', $aUserNotices);
    $oTemplate->display('compose_form_close.tpl');
    if ($compose_new_win == '1') {
        $oTemplate->display('compose_newwin_close.tpl');
    }
    $oErrorHandler->setDelayedErrors(false);
    $oTemplate->display('footer.tpl');
}
Esempio n. 9
0
/** Print the basic search form
 * @param stream $imapConnection
 * @param array $boxes
 * @param array $mailbox_array
 * @param array $biop_array
 * @param array $unop_array
 * @param array $where_array
 * @param array $what_array
 * @param array $exclude_array
 * @param array $sub_array
 * @since 1.5.1
 * @private
 */
function asearch_print_form_basic($imapConnection, &$boxes, $mailbox_array, $biop_array, $unop_array, $where_array, $what_array, $exclude_array, $sub_array)
{
    global $allow_advanced_search, $search_advanced, $oTemplate, $imap_asearch_unops, $imap_asearch_options;
    $row_num = 0;
    $mailbox = asearch_nz($mailbox_array[$row_num]);
    $biop = strip_tags(asearch_nz($biop_array[$row_num]));
    $unop = strip_tags(asearch_nz($unop_array[$row_num]));
    $where = strip_tags(asearch_nz($where_array[$row_num]));
    $what = asearch_nz($what_array[$row_num]);
    $exclude = strip_tags(asearch_nz($exclude_array[$row_num]));
    $sub = strip_tags(asearch_nz($sub_array[$row_num]));
    # Build the mailbox array
    $a = array();
    if ($mailbox != 'All Folders' && !asearch_mailbox_exists($mailbox, $boxes)) {
        $a[$mailbox] = '[' . _("Missing") . '] ' . sm_encode_html_special_chars(asearch_get_mailbox_display($mailbox));
    }
    $a['All Folders'] = '[' . asearch_get_mailbox_display('All Folders') . ']';
    $a = array_merge($a, sqimap_mailbox_option_array($imapConnection, 0, $boxes, NULL));
    if ($allow_advanced_search > 1) {
        $link = '../src/search.php?advanced=' . ($search_advanced ? 0 : 1);
        $txt = $search_advanced ? _("Standard Search") : _("Advanced search");
    } else {
        $link = NULL;
        $txt = NULL;
    }
    $oTemplate->assign('allow_advanced_search', $allow_advanced_search > 1);
    $oTemplate->assign('adv_toggle_text', $txt);
    $oTemplate->assign('adv_toggle_link', $link);
    $oTemplate->assign('mailbox_options', $a);
    $oTemplate->assign('unary_options', $imap_asearch_unops);
    $oTemplate->assign('where_options', $imap_asearch_options);
    $oTemplate->assign('mailbox_sel', strtolower(sm_encode_html_special_chars($mailbox)));
    $oTemplate->assign('unary_sel', $unop);
    $oTemplate->assign('where_sel', $where);
    $oTemplate->assign('what_val', $what);
    echo '<form action="../src/search.php" name="form_asearch">' . "\n" . addHidden('smtoken', sm_generate_security_token()) . "\n";
    $oTemplate->display('search.tpl');
    echo "</form>\n";
}
Esempio n. 10
0
/**
 * Format message toolbar
 *
 * @param array   $aMailbox      Current mailbox information array
 * @param int     $passed_id     UID of current message
 * @param int     $passed_ent_id Id of entity within message
 * @param object  $message       Current message object
 * @param void    $removedVar    This parameter is no longer used, but remains
 *                               so as not to break this function's prototype
 *                               (OPTIONAL)
 * @param boolean $nav_on_top    When TRUE, the menubar is being constructed
 *                               for use at the top of the page, otherwise it
 *                               will be used for page bottom (OPTIONAL;
 *                               default = TRUE)
 */
function formatMenubar($aMailbox, $passed_id, $passed_ent_id, $message, $removedVar = FALSE, $nav_on_top = TRUE)
{
    global $base_uri, $draft_folder, $where, $what, $sort, $startMessage, $PHP_SELF, $save_as_draft, $enable_forward_as_attachment, $imapConnection, $lastTargetMailbox, $delete_prev_next_display, $show_copy_buttons, $compose_new_win, $compose_width, $compose_height, $oTemplate;
    //FIXME cleanup argument list, use $aMailbox where possible
    $mailbox = $aMailbox['NAME'];
    $urlMailbox = urlencode($mailbox);
    // Create Prev & Next links
    // Handle nested entities first (i.e. Mime Attach parts)
    $prev_href = $next_href = $up_href = $del_href = $del_prev_href = $del_next_href = '';
    $msg_list_href = $search_href = $view_msg_href = '';
    if (isset($passed_ent_id) && $passed_ent_id) {
        // code for navigating through attached message/rfc822 messages
        $url = set_url_var($PHP_SELF, 'passed_ent_id', 0);
        $entities = array();
        $entity_count = array();
        $c = 0;
        foreach ($message->parent->entities as $ent) {
            if ($ent->type0 == 'message' && $ent->type1 == 'rfc822') {
                $c++;
                $entity_count[$c] = $ent->entity_id;
                $entities[$ent->entity_id] = $c;
            }
        }
        if (isset($entities[$passed_ent_id]) && $entities[$passed_ent_id] > 1) {
            $prev_ent_id = $entity_count[$entities[$passed_ent_id] - 1];
            $prev_href = set_url_var($PHP_SELF, 'passed_ent_id', $prev_ent_id);
        }
        if (isset($entities[$passed_ent_id]) && $entities[$passed_ent_id] < $c) {
            $next_ent_id = $entity_count[$entities[$passed_ent_id] + 1];
            $next_href = set_url_var($PHP_SELF, 'passed_ent_id', $next_ent_id);
        }
        $par_ent_id = $message->parent->entity_id;
        if ($par_ent_id) {
            $par_ent_id = substr($par_ent_id, 0, -2);
            if ($par_ent_id != 0) {
                $up_href = set_url_var($PHP_SELF, 'passed_ent_id', $par_ent_id);
            }
        }
        $view_msg_href = $url;
        // Prev/Next links for regular messages
    } else {
        if (true) {
            //!(isset($where) && isset($what)) ) {
            $prev = findPreviousMessage($aMailbox['UIDSET'][$what], $passed_id);
            $next = findNextMessage($aMailbox['UIDSET'][$what], $passed_id);
            if ($prev >= 0) {
                $prev_href = $base_uri . 'src/read_body.php?passed_id=' . $prev . '&amp;mailbox=' . $urlMailbox . '&amp;sort=' . $sort . "&amp;where={$where}&amp;what={$what}" . '&amp;startMessage=' . $startMessage . '&amp;show_more=0';
            }
            if ($next >= 0) {
                $next_href = $base_uri . 'src/read_body.php?passed_id=' . $next . '&amp;mailbox=' . $urlMailbox . '&amp;sort=' . $sort . "&amp;where={$where}&amp;what={$what}" . '&amp;startMessage=' . $startMessage . '&amp;show_more=0';
            }
            // Only bother with Delete & Prev and Delete & Next IF
            // top display is enabled.
            if ($delete_prev_next_display == 1 && in_array('\\deleted', $aMailbox['PERMANENTFLAGS'], true)) {
                if ($prev >= 0) {
                    $del_prev_href = $base_uri . 'src/read_body.php?passed_id=' . $prev . '&amp;mailbox=' . $urlMailbox . '&amp;sort=' . $sort . '&amp;startMessage=' . $startMessage . '&amp;show_more=0' . "&amp;where={$where}&amp;what={$what}" . '&amp;delete_id=' . $passed_id . '&amp;smtoken=' . sm_generate_security_token();
                }
                if ($next >= 0) {
                    $del_next_href = $base_uri . 'src/read_body.php?passed_id=' . $next . '&amp;mailbox=' . $urlMailbox . '&amp;sort=' . $sort . '&amp;startMessage=' . $startMessage . '&amp;show_more=0' . "&amp;where={$where}&amp;what={$what}" . '&amp;delete_id=' . $passed_id . '&amp;smtoken=' . sm_generate_security_token();
                }
            }
        }
    }
    $msg_list_href = get_message_list_uri($aMailbox['NAME'], $startMessage, $what);
    if ($where == 'search.php') {
        $search_href = str_replace('read_body.php', 'search.php', $msg_list_href);
    } else {
        $search_href = '';
    }
    $comp_uri = $base_uri . 'src/compose.php' . '?passed_id=' . $passed_id . '&amp;mailbox=' . $urlMailbox . '&amp;startMessage=' . $startMessage . (isset($passed_ent_id) ? '&amp;passed_ent_id=' . $passed_ent_id : '');
    // Start form for reply/reply all/forward..
    $target = '';
    $on_click = '';
    $method = 'post';
    $onsubmit = '';
    if ($compose_new_win == '1') {
        if (!preg_match("/^[0-9]{3,4}\$/", $compose_width)) {
            $compose_width = '640';
        }
        if (!preg_match("/^[0-9]{3,4}\$/", $compose_height)) {
            $compose_height = '550';
        }
        if (checkForJavascript()) {
            $on_click = 'comp_in_new_form(\'' . $comp_uri . '\', this, this.form,' . $compose_width . ',' . $compose_height . ')';
            $comp_uri = 'javascript:void(0)';
            $method = 'get';
            $onsubmit = 'return false';
        } else {
            $target = '_blank';
        }
    }
    $oTemplate->assign('nav_on_top', $nav_on_top);
    $oTemplate->assign('prev_href', $prev_href);
    $oTemplate->assign('up_href', $up_href);
    $oTemplate->assign('next_href', $next_href);
    $oTemplate->assign('del_prev_href', $del_prev_href);
    $oTemplate->assign('del_next_href', $del_next_href);
    $oTemplate->assign('view_msg_href', $view_msg_href);
    $oTemplate->assign('message_list_href', $msg_list_href);
    $oTemplate->assign('search_href', $search_href);
    $oTemplate->assign('form_extra', '');
    $oTemplate->assign('form_method', $method);
    $oTemplate->assign('form_target', $target);
    $oTemplate->assign('form_onsubmit', $onsubmit);
    $oTemplate->assign('compose_href', $comp_uri);
    $oTemplate->assign('button_onclick', $on_click);
    $oTemplate->assign('forward_as_attachment_enabled', $enable_forward_as_attachment == 1);
    //FIXME: I am surprised these aren't already given to the template; probably needs to be given at a higher level, so I have NO IDEA if this is the right place to do this...  adding them so template can construct its own API calls... we can build those herein too if preferrable
    $oTemplate->assign('mailbox', $aMailbox['NAME']);
    $oTemplate->assign('passed_id', $passed_id);
    $oTemplate->assign('what', $what);
    // If Draft folder - create Resume link
    $resume_draft = $edit_as_new = false;
    if (isDraftMailbox($mailbox) && $save_as_draft) {
        $resume_draft = true;
    } else {
        if (handleAsSent($mailbox)) {
            $edit_as_new = true;
        }
    }
    $oTemplate->assign('can_resume_draft', $resume_draft);
    $oTemplate->assign('can_edit_as_new', $edit_as_new);
    $oTemplate->assign('mailboxes', sqimap_mailbox_option_array($imapConnection));
    if (in_array('\\deleted', $aMailbox['PERMANENTFLAGS'], true)) {
        $delete_url = $base_uri . "src/{$where}";
        $oTemplate->assign('can_be_deleted', true);
        $oTemplate->assign('move_delete_form_action', $base_uri . 'src/' . $where);
        $oTemplate->assign('delete_form_extra', addHidden('mailbox', $aMailbox['NAME']) . "\n" . addHidden('msg[0]', $passed_id) . "\n" . addHidden('startMessage', $startMessage) . "\n");
        if (!(isset($passed_ent_id) && $passed_ent_id)) {
            $oTemplate->assign('can_be_moved', true);
            $oTemplate->assign('move_form_extra', addHidden('mailbox', $aMailbox['NAME']) . "\n" . addHidden('msg[0]', $passed_id) . "\n");
            $oTemplate->assign('last_move_target', isset($lastTargetMailbox) && !empty($lastTargetMailbox) ? $lastTargetMailbox : '');
            $oTemplate->assign('can_be_copied', $show_copy_buttons == 1);
        } else {
            $oTemplate->assign('can_be_moved', false);
            $oTemplate->assign('move_form_extra', '');
            $oTemplate->assign('last_move_target', '');
            $oTemplate->assign('can_be_copied', false);
        }
    } else {
        $oTemplate->assign('can_be_deleted', false);
        $oTemplate->assign('move_delete_form_action', '');
        $oTemplate->assign('delete_form_extra', '');
        $oTemplate->assign('can_be_moved', false);
        $oTemplate->assign('move_form_extra', '');
        $oTemplate->assign('last_move_target', '');
        $oTemplate->assign('can_be_copied', false);
    }
    // access keys... only add to the top menubar, because adding
    // them twice makes them less functional (press access key, *then*
    // press <enter> to make it work)
    //
    if ($nav_on_top) {
        global $accesskey_read_msg_reply, $accesskey_read_msg_reply_all, $accesskey_read_msg_forward, $accesskey_read_msg_as_attach, $accesskey_read_msg_delete, $accesskey_read_msg_bypass_trash, $accesskey_read_msg_move, $accesskey_read_msg_move_to, $accesskey_read_msg_copy;
    } else {
        $accesskey_read_msg_reply = $accesskey_read_msg_reply_all = $accesskey_read_msg_forward = $accesskey_read_msg_as_attach = $accesskey_read_msg_delete = $accesskey_read_msg_bypass_trash = $accesskey_read_msg_move = $accesskey_read_msg_move_to = $accesskey_read_msg_copy = 'NONE';
    }
    $oTemplate->assign('accesskey_read_msg_reply', $accesskey_read_msg_reply);
    $oTemplate->assign('accesskey_read_msg_reply_all', $accesskey_read_msg_reply_all);
    $oTemplate->assign('accesskey_read_msg_forward', $accesskey_read_msg_forward);
    $oTemplate->assign('accesskey_read_msg_as_attach', $accesskey_read_msg_as_attach);
    $oTemplate->assign('accesskey_read_msg_delete', $accesskey_read_msg_delete);
    $oTemplate->assign('accesskey_read_msg_bypass_trash', $accesskey_read_msg_bypass_trash);
    $oTemplate->assign('accesskey_read_msg_move_to', $accesskey_read_msg_move_to);
    $oTemplate->assign('accesskey_read_msg_move', $accesskey_read_msg_move);
    $oTemplate->assign('accesskey_read_msg_copy', $accesskey_read_msg_copy);
    global $null;
    do_hook('read_body_menu', $null);
    if ($nav_on_top) {
        $oTemplate->display('read_menubar_nav.tpl');
        $oTemplate->display('read_menubar_buttons.tpl');
    } else {
        $oTemplate->display('read_menubar_buttons.tpl');
        $oTemplate->display('read_menubar_nav.tpl');
    }
}
Esempio n. 11
0
            echo 'selected="selected" ';
        }
        echo 'value="(userfile)">' . _("uploaded media file") . "</option>\n";
        // end of local file option
    }
    // Set media file name
    if ($newmail_media == '(none)') {
        $media_output = _("none");
    } elseif ($newmail_media == '(userfile)') {
        $media_output = basename($newmail_userfile_name);
    } elseif (preg_match("/^mmedia_+/", $newmail_media)) {
        $media_output = preg_replace("/^mmedia_/", '', $newmail_media);
    } else {
        $media_output = basename($newmail_media);
    }
    echo '</select>' . '<input type="submit" value="' . _("Try") . '" name="test" onclick="' . "window.open('testsound.php?sound='+media_sel.options[media_sel.selectedIndex].value, 'TestSound'," . "'width=150,height=30,scrollbars=no');" . 'return false;' . '" /></td></tr>';
    if ($newmail_uploadsounds) {
        // upload form
        echo html_tag('tr') . html_tag('td', _("Upload Media File:"), 'right', '', 'style="white-space: nowrap;"') . html_tag('td', '<input type="file" size="40" name="media_file" />') . "</tr>\n";
        // display currently uploaded file information
        echo html_tag('tr') . html_tag('td', _("Uploaded Media File:"), 'right', '', 'style="white-space: nowrap;"') . html_tag('td', $newmail_userfile_name != '' ? sm_encode_html_special_chars($newmail_userfile_name) : _("unavailable")) . "</tr>\n";
        if ($newmail_userfile_name != '') {
            echo '<tr>' . '<td colspan="2" align="center">' . sprintf(_("Media file %s will be removed, if you upload other media file."), basename($newmail_userfile_name)) . '</td></tr>';
        }
    }
    echo html_tag('tr', "\n" . html_tag('td', _("Current File:"), 'right', '', 'style="white-space: nowrap;"') . html_tag('td', '<input type="hidden" value="' . sm_encode_html_special_chars($newmail_media) . '" name="media_default" />' . sm_encode_html_special_chars($media_output) . '', 'left')) . "\n";
}
echo html_tag('tr', "\n" . html_tag('td', '&nbsp;') . html_tag('td', '<input type="hidden" name="optmode" value="submit" />' . '<input type="hidden" name="optpage" value="newmail" />' . '<input type="hidden" name="smtoken" value="' . sm_generate_security_token() . '" />' . '<input type="submit" value="' . _("Submit") . '" name="submit_newmail" />', 'left')) . "\n";
?>
</table></form></td></tr></table></td></tr></table></body></html>