/**
 * This function adds a "Check Spelling" link to the "Compose" row
 * during message composition (internal function).
 * @since 1.5.1 (sqspell 0.5)
 * @return void
 */
function squirrelspell_setup_function()
{
    /**
     * Check if this browser is capable of displaying SquirrelSpell
     * correctly.
     */
    if (checkForJavascript()) {
        global $oTemplate, $base_uri, $nbsp;
        $output = addButton(_("Check Spelling"), 'check_spelling', array('onclick' => 'window.open(\'' . $base_uri . 'plugins/squirrelspell/sqspell_interface.php\', \'sqspell\', \'status=yes,width=550,height=370,resizable=yes\')')) . $nbsp;
        return array('compose_button_row' => $output);
    }
}
Example #2
0
/**
 * Add message details link in message view
 * @access private
 */
function show_message_details(&$links)
{
    global $passed_id, $mailbox, $passed_ent_id;
    if (strlen(trim($mailbox)) < 1) {
        $mailbox = 'INBOX';
    }
    $params = '?passed_ent_id=' . $passed_ent_id . '&mailbox=' . urlencode($mailbox) . '&passed_id=' . $passed_id;
    $url = checkForJavascript() ? 'javascript:MessageSource();' : '../plugins/message_details/message_details_main.php' . $params;
    /* Output the link. */
    $links[] = array('URL' => $url, 'Text' => _("View Message Details"));
    if (checkForJavascript()) {
        echo '<script type="text/javascript">' . "\n" . '<!--' . "\n" . "  function MessageSource() {\n" . '    window.open("' . sqm_baseuri() . 'plugins/message_details/message_details_main.php' . $params . '","MessageDetails","width=800,height=600");' . "\n" . "  }\n" . "// -->\n" . "</script>\n\n";
    }
}
Example #3
0
/**
 * This function saves the javascript detection option.
 */
function save_option_javascript_autodetect($option)
{
    global $data_dir, $username;
    save_option($option);
    checkForJavascript(TRUE);
}
$hour_format = getPref($data_dir, $username, 'hour_format', 2);
/*  compose in new window setting */
$compose_new_win = getPref($data_dir, $username, 'compose_new_win', 0);
$compose_height = getPref($data_dir, $username, 'compose_height', 550);
$compose_width = getPref($data_dir, $username, 'compose_width', 640);
/* signature placement settings */
$sig_first = getPref($data_dir, $username, 'sig_first', 0);
/* Strip signature when replying */
$strip_sigs = getPref($data_dir, $username, 'strip_sigs', 0);
/* use the internal date of the message for sorting instead of the supplied header date */
$internal_date_sort = getPref($data_dir, $username, 'internal_date_sort', SMPREF_ON);
/* if server sorting is enabled/disabled */
$sort_by_ref = getPref($data_dir, $username, 'sort_by_ref', 1);
/* Load the javascript settings. */
$javascript_setting = getPref($data_dir, $username, 'javascript_setting', SMPREF_JS_AUTODETECT);
if (checkForJavascript()) {
    $use_javascript_folder_list = getPref($data_dir, $username, 'use_javascript_folder_list');
    $use_javascript_addr_book = getPref($data_dir, $username, 'use_javascript_addr_book', $default_use_javascript_addr_book);
} else {
    $use_javascript_folder_list = false;
    $use_javascript_addr_book = false;
}
$search_memory = getPref($data_dir, $username, 'search_memory', 0);
$forward_cc = getPref($data_dir, $username, 'forward_cc', 0);
$mailbox_select_style = getPref($data_dir, $username, 'mailbox_select_style', 0);
/* Allow user to customize, and display the full date, instead of day, or time based
   on time distance from date of message */
$show_full_date = getPref($data_dir, $username, 'show_full_date', 0);
/* Allow user to customize length of from field */
$truncate_sender = getPref($data_dir, $username, 'truncate_sender', 0);
/* Allow user to customize length of subject field */
Example #5
0
}
if ($aMailbox['EXISTS'] > 0) {
    $aTemplateVars = showMessagesForMailbox($imapConnection, $aMailbox, $aProps, $iError);
    if ($iError) {
    }
    foreach ($aTemplateVars as $k => $v) {
        $oTemplate->assign($k, $v);
    }
    /*
     * TODO: To many config related vars. We should move all config related vars to
     * one single associative array and assign that to the template
     */
    $oTemplate->assign('page_selector', $page_selector);
    $oTemplate->assign('page_selector_max', $page_selector_max);
    $oTemplate->assign('compact_paginator', $compact_paginator);
    $oTemplate->assign('javascript_on', checkForJavascript());
    $oTemplate->assign('base_uri', sqm_baseuri());
    $oTemplate->assign('enablesort', isset($aProps['config']['enablesort']) ? $aProps['config']['enablesort'] : false);
    $oTemplate->assign('icon_theme_path', $icon_theme_path);
    $oTemplate->assign('aOrder', array_keys($aColumns));
    $oTemplate->assign('alt_index_colors', isset($alt_index_colors) ? $alt_index_colors : false);
    $oTemplate->assign('color', $color);
    $oTemplate->assign('align', $align);
    $oTemplate->assign('checkall', $checkall);
    $oTemplate->assign('preselected', $preselected);
    global $show_personal_names;
    $oTemplate->assign('show_personal_names', $show_personal_names);
    global $accesskey_mailbox_toggle_selected, $accesskey_mailbox_thread;
    $oTemplate->assign('accesskey_mailbox_toggle_selected', $accesskey_mailbox_toggle_selected);
    $oTemplate->assign('accesskey_mailbox_thread', $accesskey_mailbox_thread);
    $oTemplate->display('message_list.tpl');
<?php

/**
 * Message Details plugin - top frame with buttons
 *
 * Plugin to view the RFC822 raw message output and the bodystructure of a message
 *
 * @author Marc Groot Koerkamp
 * @copyright 2002 Marc Groot Koerkamp, The Netherlands
 * @copyright 2002-2016 The SquirrelMail Project Team
 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
 * @version $Id$
 * @package plugins
 * @subpackage message_details
 */
/**
 * Include the SquirrelMail initialization file.
 */
require '../../include/init.php';
require SM_PATH . 'functions/forms.php';
displayHtmlHeader(_("Message Details"), "<script type=\"text/javascript\">\n" . "<!--\n" . "function printPopup() {\n" . "parent.frames[1].focus();\n" . "parent.frames[1].print();\n" . "}\n" . "-->\n" . "</script>\n", FALSE);
sqgetGlobalVar('passed_id', $passed_id, SQ_GET, NULL, SQ_TYPE_BIGINT);
if (!sqgetGlobalVar('passed_ent_id', $passed_ent_id, SQ_GET)) {
    $passed_ent_id = 0;
}
sqgetGlobalVar('mailbox', $mailbox, SQ_GET);
echo "<body text=\"{$color['8']}\" bgcolor=\"{$color['3']}\" link=\"{$color['7']}\" vlink=\"{$color['7']}\" alink=\"{$color['7']}\">\n" . '<div style="text-align: center;">' . addForm(SM_PATH . 'src/download.php', 'GET') . addHidden('mailbox', $mailbox) . addHidden('passed_id', $passed_id) . addHidden('ent_id', $passed_ent_id) . addHidden('absolute_dl', 'true') . (checkForJavascript() ? '<input type="button" value="' . _("Print") . '" onclick="printPopup()" />&nbsp;&nbsp;' . '<input type="button" value="' . _("Close Window") . '" onclick="window.parent.close()" />&nbsp;&nbsp;' : '') . addSubmit(_("Save Message")) . '</form></div>' . '</body>' . "</html>\n";
Example #7
0
if (!isset($sTemplateID)) {
    if (PAGE_NAME == 'squirrelmail_rpc') {
        $sTemplateID = Template::get_rpc_template_set();
    } else {
        $sTemplateID = Template::get_default_template_set();
    }
    $icon_theme_path = !$use_icons ? NULL : Template::calculate_template_images_directory($sTemplateID);
}
// template object may have already been constructed in load_prefs.php
//
if (empty($oTemplate)) {
    $oTemplate = Template::construct_template($sTemplateID);
}
// We want some variables to always be available to the template
//
$oTemplate->assign('javascript_on', sqGetGlobalVar('user_is_logged_in', $user_is_logged_in, SQ_SESSION) ? checkForJavascript() : 0);
$oTemplate->assign('base_uri', sqm_baseuri());
$always_include = array('sTemplateID', 'icon_theme_path');
foreach ($always_include as $var) {
    $oTemplate->assign($var, isset(${$var}) ? ${$var} : NULL);
}
// A few output elements are used often, so just get them once here
//
$nbsp = $oTemplate->fetch('non_breaking_space.tpl');
$br = $oTemplate->fetch('line_break.tpl');
/**
 * Set up the language.
 *
 * This code block corresponds to the *default* block of the switch
 * statement above, but the language cannot be set up until after the
 * template is instantiated, so we set $set_up_langage_after_template_setup
Example #8
0
sqsession_register($just_logged_in, 'just_logged_in');
/* parse the accepted content-types of the client */
$attachment_common_types = array();
$attachment_common_types_parsed = array();
sqsession_register($attachment_common_types, 'attachment_common_types');
sqsession_register($attachment_common_types_parsed, 'attachment_common_types_parsed');
if (sqgetGlobalVar('HTTP_ACCEPT', $http_accept, SQ_SERVER) && !isset($attachment_common_types_parsed[$http_accept])) {
    attachment_common_parse($http_accept);
}
// having just logged in, need to synch the template file cache
// so the right template set is displayed (per user prefs)
require SM_PATH . 'include/load_prefs.php';
global $sTemplateID;
Template::cache_template_file_hierarchy($sTemplateID, TRUE);
/* Complete autodetection of Javascript. */
checkForJavascript();
/* Compute the URL to forward the user to. */
$redirect_url = $location . '/webmail.php';
if (sqgetGlobalVar('session_expired_location', $session_expired_location, SQ_SESSION)) {
    sqsession_unregister('session_expired_location');
    if ($session_expired_location == 'compose') {
        $compose_new_win = getPref($data_dir, $username, 'compose_new_win', 0);
        if ($compose_new_win) {
            // do not prefix $location here because $session_expired_location is set to the PAGE_NAME
            // of the last page
            $redirect_url = $location . '/' . $session_expired_location . '.php';
        } else {
            $redirect_url = $location . '/webmail.php?right_frame=' . urlencode($session_expired_location . '.php');
        }
    } else {
        if ($session_expired_location != 'webmail' && $session_expired_location != 'left_main') {
Example #9
0
/**
 * This function saves the javascript detection option.
 */
function save_option_javascript_autodetect($option)
{
    save_option($option);
    checkForJavascript(TRUE);
}
Example #10
0
/**
 * Add spamcop link to read_body (internal function)
 * @since 1.5.1
 * @access private
 */
function spamcop_show_link_function(&$links)
{
    global $spamcop_enabled, $spamcop_method, $spamcop_quick_report;
    if (!$spamcop_enabled) {
        return;
    }
    /* GLOBALS */
    sqgetGlobalVar('passed_id', $passed_id, SQ_FORM, NULL, SQ_TYPE_BIGINT);
    sqgetGlobalVar('passed_ent_id', $passed_ent_id, SQ_FORM);
    sqgetGlobalVar('mailbox', $mailbox, SQ_FORM);
    if (sqgetGlobalVar('startMessage', $startMessage, SQ_FORM)) {
        $startMessage = (int) $startMessage;
    }
    /* END GLOBALS */
    // catch unset passed_ent_id
    if (!sqgetGlobalVar('passed_ent_id', $passed_ent_id, SQ_FORM)) {
        $passed_ent_id = 0;
    }
    /*
      Catch situation when user uses quick_email and does not update
      preferences. User gets web_form link. If prefs are set to
      quick_email format - they will be updated after clicking the link
    */
    if (!$spamcop_quick_report && $spamcop_method == 'quick_email') {
        $spamcop_method = 'web_form';
    }
    // FIXME: do we need this javascript and if so, fix it
    // <script type="text/javascript">
    // document.write('<a href="../plugins/spamcop/spamcop.php?passed_id=<php echo urlencode($passed_id); >&amp;js_web=1&amp;mailbox=<php echo urlencode($mailbox); >&amp;passed_ent_id=<php echo urlencode($passed_ent_id); >" target="_blank">');
    //document.write("<php echo _("Report as Spam"); >");
    //document.write("</a>");
    //</script>
    $url = '../plugins/spamcop/spamcop.php?passed_id=' . urlencode($passed_id) . '&amp;mailbox=' . urlencode($mailbox) . '&amp;startMessage=' . urlencode($startMessage) . '&amp;passed_ent_id=' . urlencode($passed_ent_id);
    if ($spamcop_method == 'web_form' && checkForJavascript()) {
        $url .= '&amp;js_web=1';
    }
    $links[] = array('URL' => $url, 'Text' => _("Report as Spam"));
}
Example #11
0
function showComposeButtonRow()
{
    global $use_javascript_addr_book, $save_as_draft, $default_use_priority, $mailprio, $default_use_mdn, $request_mdn, $request_dr, $data_dir, $username;
    global $oTemplate, $buffer_hook;
    if ($default_use_priority) {
        $priorities = array('1' => _("High"), '3' => _("Normal"), '5' => _("Low"));
        $priority = isset($mailprio) ? $mailprio : 3;
    } else {
        $priorities = array();
        $priority = NULL;
    }
    $mdn_user_support = getPref($data_dir, $username, 'mdn_user_support', $default_use_mdn);
    $address_book_button_attribs = array();
    global $accesskey_compose_addresses;
    if ($accesskey_compose_addresses != 'NONE') {
        $address_book_button_attribs['accesskey'] = $accesskey_compose_addresses;
    }
    if ($use_javascript_addr_book && checkForJavascript()) {
        $addr_book = addButton(_("Addresses"), null, array_merge($address_book_button_attribs, array('onclick' => 'javascript:open_abook();')));
    } else {
        $addr_book = addSubmit(_("Addresses"), 'html_addr_search', $address_book_button_attribs);
    }
    $oTemplate->assign('allow_priority', $default_use_priority == 1);
    $oTemplate->assign('priority_list', $priorities);
    $oTemplate->assign('current_priority', $priority);
    $oTemplate->assign('notifications_enabled', $mdn_user_support == 1);
    $oTemplate->assign('read_receipt', $request_mdn == '1');
    $oTemplate->assign('delivery_receipt', $request_dr == '1');
    $oTemplate->assign('drafts_enabled', $save_as_draft);
    $oTemplate->assign('address_book_button', $addr_book);
    // access keys...
    //
    global $accesskey_compose_priority, $accesskey_compose_on_read, $accesskey_compose_on_delivery, $accesskey_compose_signature, $accesskey_compose_save_draft, $accesskey_compose_send;
    $oTemplate->assign('accesskey_compose_priority', $accesskey_compose_priority);
    $oTemplate->assign('accesskey_compose_on_read', $accesskey_compose_on_read);
    $oTemplate->assign('accesskey_compose_on_delivery', $accesskey_compose_on_delivery);
    $oTemplate->assign('accesskey_compose_signature', $accesskey_compose_signature);
    $oTemplate->assign('accesskey_compose_save_draft', $accesskey_compose_save_draft);
    $oTemplate->assign('accesskey_compose_send', $accesskey_compose_send);
    $oTemplate->display('compose_buttons.tpl');
}
Example #12
0
/**
 * Points message targets to open in the preview pane
 * (and possibly refresh message list as well)
 */
function preview_pane_change_message_target_do($args)
{
    if (!checkForJavascript()) {
        return;
    }
    global $data_dir, $username, $target, $onclick, $PHP_SELF;
    //   sqgetGlobalVar('REQUEST_URI', $request_uri, SQ_SERVER);
    $request_uri = $PHP_SELF;
    if (getPref($data_dir, $username, 'use_previewPane', 0) == 1) {
        $pp_refresh_message_list = getPref($data_dir, $username, 'pp_refresh_message_list', 1);
        $aMsg = $args[3];
        $target = 'bottom';
        // introduce a delay so read messages actually
        // refresh after they are read, but only if they
        // have not already been seen
        //
        if ($pp_refresh_message_list && empty($aMsg['FLAGS']['\\seen'])) {
            // old code without refresh delay
            //         $onclick .= ' onclick="document.location=\'' . $request_uri . '\'; " ';
            $onclick .= ' setTimeout(\'pp_refresh()\', 500); ';
        }
    }
}
Example #13
0
/**
 * Create compose link
 *
 * Returns a link to the compose-page, taking in consideration
 * the compose_in_new and javascript settings.
 *
 * @param string $url       The URL to the compose page
 * @param string $text      The link text, default "Compose"
 * @param string $target    URL target, if any (since 1.4.3)
 * @param string $accesskey The access key to be used, if any
 *
 * @return string a link to the compose page
 *
 * @since 1.4.2
 */
function makeComposeLink($url, $text = null, $target = '', $accesskey = 'NONE')
{
    global $compose_new_win, $compose_width, $compose_height, $oTemplate;
    if (!$text) {
        $text = _("Compose");
    }
    // if not using "compose in new window", make
    // regular link and be done with it
    if ($compose_new_win != '1') {
        return makeInternalLink($url, $text, $target, $accesskey);
    }
    // build the compose in new window link...
    // if javascript is on, use onclick event to handle it
    if (checkForJavascript()) {
        sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION);
        $compuri = SM_BASE_URI . $url;
        return create_hyperlink('javascript:void(0)', $text, '', "comp_in_new('{$compuri}','{$compose_width}','{$compose_height}')", '', '', '', $accesskey == 'NONE' ? array() : array('accesskey' => $accesskey));
    }
    // otherwise, just open new window using regular HTML
    return makeInternalLink($url, $text, '_blank', $accesskey);
}
Example #14
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');
    }
}
Example #15
0
/**
 * This function checks whether the user's USER_AGENT is known to
 * be broken. If so, returns true and the plugin is invisible to the
 * offending browser.
 * *** THIS IS A TEST FOR JAVASCRIPT SUPPORT ***
 * FIXME: This function needs to have its name changed!
 *
 * @return bool whether this browser properly supports JavaScript
 */
function soupNazi()
{
    return !checkForJavascript();
}
Example #16
0
 /**
  * Creates a (non-associative) edit list
  *
  * Note that multiple layout types are supported for this widget.
  * $this->layout_type must be one of the SMOPT_EDIT_LIST_LAYOUT_*
  * constants.
  *
  * @return string html formated list of edit fields and
  *                their associated controls
  */
 function createWidget_EditList()
 {
     global $oTemplate;
     switch ($this->size) {
         case SMOPT_SIZE_TINY:
             $height = 3;
             break;
         case SMOPT_SIZE_SMALL:
             $height = 8;
             break;
         case SMOPT_SIZE_MEDIUM:
             $height = 15;
             break;
         case SMOPT_SIZE_LARGE:
             $height = 25;
             break;
         case SMOPT_SIZE_HUGE:
             $height = 40;
             break;
         case SMOPT_SIZE_NORMAL:
         default:
             $height = 5;
     }
     if (empty($this->possible_values)) {
         $this->possible_values = array();
     }
     if (!is_array($this->possible_values)) {
         $this->possible_values = array($this->possible_values);
     }
     //FIXME: $this->aExtraAttribs probably should only be used in one place
     $oTemplate->assign('input_widget', addInput('add_' . $this->name, '', 38, 0, $this->aExtraAttribs));
     $oTemplate->assign('use_input_widget', $this->use_add_widget);
     $oTemplate->assign('use_delete_widget', $this->use_delete_widget);
     $oTemplate->assign('trailing_text', $this->trailing_text);
     $oTemplate->assign('possible_values', $this->possible_values);
     $oTemplate->assign('current_value', $this->value);
     $oTemplate->assign('select_widget', addSelect('new_' . $this->name, $this->possible_values, $this->value, FALSE, !checkForJavascript() ? $this->aExtraAttribs : array_merge(array('onchange' => 'if (typeof(window.addinput_' . $this->name . ') == \'undefined\') { var f = document.forms.length; var i = 0; var pos = -1; while( pos == -1 && i < f ) { var e = document.forms[i].elements.length; var j = 0; while( pos == -1 && j < e ) { if ( document.forms[i].elements[j].type == \'text\' && document.forms[i].elements[j].name == \'add_' . $this->name . '\' ) { pos = j; i=f-1; j=e-1; } j++; } i++; } if( pos >= 0 ) { window.addinput_' . $this->name . ' = document.forms[i-1].elements[pos]; } } for (x = 0; x < this.length; x++) { if (this.options[x].selected) { window.addinput_' . $this->name . '.value = this.options[x].text; break; } }'), $this->aExtraAttribs), TRUE, $height));
     // NOTE: i=f-1; j=e-1 is in lieu of break 2
     $oTemplate->assign('checkbox_widget', addCheckBox('delete_' . $this->name, FALSE, SMPREF_YES, array_merge(array('id' => 'delete_' . $this->name), $this->aExtraAttribs)));
     $oTemplate->assign('name', $this->name);
     switch ($this->layout_type) {
         case SMOPT_EDIT_LIST_LAYOUT_SELECT:
             return $oTemplate->fetch('edit_list_widget.tpl');
         case SMOPT_EDIT_LIST_LAYOUT_LIST:
             return $oTemplate->fetch('edit_list_widget_list_style.tpl');
         default:
             error_box(sprintf(_("Edit List Layout Type '%s' Not Found"), $this->layout_type));
     }
 }
Example #17
0
/**
 * Creates an address book paginator
 *
 * @param boolean $abook_page_selector     Whether or not to show the page selector
 * @param int     $abook_page_selector_max The maximum number of page links to show
 *                                         on screen
 * @param int     $page_number             What page is being viewed - 0 if not used
 * @param int     $page_size               Maximum number of addresses to be shown
 *                                         per page
 * @param int     $total_addresses         The total count of addresses in the backend
 * @param boolean $show_all                Whether or not all addresses are being shown
 * @param array  $current_page_args        All known query string arguments
 *                                         for the current page request; structured
 *                                         as an associative array of key/value pairs
 * @param boolean $compact                 Whether or not to build a smaller, 
 *                                         "compact" paginator
 *
 * @return string The paginator, ready for output
 *
 */
function get_abook_paginator($abook_page_selector, $abook_page_selector_max, $page_number, $page_size, $total_addresses, $show_all, $current_page_args, $compact)
{
    // if showing all, just show pagination link
    //
    if ($show_all) {
        unset($current_page_args['show_all']);
        return '[' . make_abook_paginator_link(1, _("Paginate"), $current_page_args) . ']';
    }
    // if we don't have enough information to build the paginator, return nothing
    //
    if (empty($page_number) || empty($page_size) || empty($total_addresses)) {
        return '';
    }
    // calculate some values we need below
    //
    $show_elipses_before = FALSE;
    $show_elipses_after = FALSE;
    global $nbsp;
    $sep = '|';
    $paginator_string = '[';
    $total_pages = ceil($total_addresses / $page_size);
    if ($page_number > $total_pages) {
        $page_number = $total_pages;
    }
    $spacing = $compact ? $nbsp : $nbsp . $nbsp;
    // only enough addresses for one page anyway?  no pagination needed
    //
    if ($total_pages < 2) {
        return '';
    }
    // build "Show All" link
    //
    $show_all_string = '[' . make_abook_paginator_link(1, _("All"), array_merge($current_page_args, array('show_all' => 1))) . ']';
    // build next/previous links for compact paginator
    //
    if ($compact) {
        if ($page_number > 1) {
            $paginator_string .= make_abook_paginator_link(1, _("<<"), $current_page_args) . '][' . make_abook_paginator_link($page_number - 1, _("<"), $current_page_args) . '][';
        } else {
            // i18n: "<<" is for the first page in the paginator. "<" is for the previous page.
            $paginator_string .= _("<<") . '][' . _("<") . '][';
        }
        if ($page_number < $total_pages) {
            $paginator_string .= make_abook_paginator_link($page_number + 1, _(">"), $current_page_args) . '][' . make_abook_paginator_link($total_pages, _(">>"), $current_page_args) . ']';
        } else {
            // i18n: ">>" is for the last page in the paginator. ">" is for the next page.
            $paginator_string .= _(">") . '][' . _(">>") . ']';
        }
    } else {
        if ($page_number > 1) {
            $paginator_string .= make_abook_paginator_link($page_number - 1, _("Previous"), $current_page_args);
        } else {
            $paginator_string .= _("Previous");
        }
        $paginator_string .= $nbsp . $sep . $nbsp;
        if ($page_number < $total_pages) {
            $paginator_string .= make_abook_paginator_link($page_number + 1, _("Next"), $current_page_args);
        } else {
            $paginator_string .= _("Next");
        }
        $paginator_string .= ']';
    }
    // paginator is turned off - just show previous/next links
    //
    if (!$abook_page_selector) {
        return $paginator_string . $spacing . $show_all_string;
    }
    $paginator_string .= $spacing;
    if ($total_pages <= $abook_page_selector_max) {
        $start_page = 1;
        $end_page = $total_pages;
    } else {
        $pages_to_show = $abook_page_selector_max % 2 ? $abook_page_selector_max : $abook_page_selector_max - 1;
        $end_page = $page_number + floor($pages_to_show / 2);
        $start_page = $page_number - floor($pages_to_show / 2);
        if (!($abook_page_selector_max % 2)) {
            $start_page--;
        }
        if ($start_page < 1) {
            $end_page += 1 - $start_page;
            $start_page = 1;
        } else {
            if ($end_page > $total_pages) {
                $start_page -= $end_page - $total_pages;
                $end_page = $total_pages;
            }
        }
        // do we need to insert elipses?
        //
        if (1 < $start_page) {
            $start_page++;
            $show_elipses_before = TRUE;
        }
        if ($total_pages > $end_page) {
            $end_page--;
            $show_elipses_after = TRUE;
        }
    }
    // now build the actual (compact) paginator
    //
    if ($compact) {
        $aValues = array();
        for ($i = 1; $i <= $total_pages; $i++) {
            $aValues[$i] = $i . '/' . $total_pages;
        }
        $page_uri = sqm_baseuri() . 'src/addressbook.php';
        $temp_page_number = $current_page_args['page_number'];
        unset($current_page_args['page_number']);
        $page_uri = set_uri_vars($page_uri, array_diff($current_page_args, array('page_number' => 0)), FALSE);
        $current_page_args['page_number'] = $temp_page_number;
        $paginator_string .= addSelect('page_number', $aValues, $page_number, TRUE, checkForJavascript() ? array('onchange' => 'SubmitOnSelect(this, \'' . $page_uri . '&page_number=' . '\')') : array());
        // need a submit button when select widget cannot submit itself
        //
        if (!checkForJavascript()) {
            $paginator_string .= addSubmit(_("Go"), 'paginator_submit');
        }
    } else {
        $paginator_string .= '[' . $nbsp;
        if ($show_elipses_before) {
            $paginator_string .= make_abook_paginator_link(1, 1, $current_page_args) . $nbsp . '...' . $nbsp;
        }
        for ($x = $start_page; $x <= $end_page; $x++) {
            if ($x == $page_number) {
                $paginator_string .= $x . $nbsp;
            } else {
                $paginator_string .= make_abook_paginator_link($x, $x, $current_page_args) . $nbsp;
            }
        }
        if ($show_elipses_after) {
            $paginator_string .= '...' . $nbsp . make_abook_paginator_link($total_pages, $total_pages, $current_page_args) . $nbsp;
        }
        $paginator_string .= ']';
    }
    $paginator_string .= $spacing . $show_all_string;
    return $paginator_string;
}