Beispiel #1
0
 /**
  * Create folder selection box
  *
  * @param boolean $multiple_select When TRUE, the select widget 
  *                                 will allow multiple selections
  *                                 (OPTIONAL; default is FALSE 
  *                                 (single select list))
  *
  * @return string html formated selection box
  *
  */
 function createWidget_FolderList($multiple_select = FALSE)
 {
     switch ($this->size) {
         //FIXME: not sure about these sizes... seems like we could add another on the "large" side...
         case SMOPT_SIZE_TINY:
             $height = 3;
             break;
         case SMOPT_SIZE_SMALL:
             $height = 8;
             break;
         case SMOPT_SIZE_LARGE:
             $height = 15;
             break;
         case SMOPT_SIZE_HUGE:
             $height = 25;
             break;
         case SMOPT_SIZE_NORMAL:
         default:
             $height = 5;
     }
     // possible values might include a nested array of
     // possible values (list of folders)
     //
     $option_list = array();
     foreach ($this->possible_values as $value => $text) {
         // list of folders (boxes array)
         //
         if (is_array($text)) {
             $option_list = array_merge($option_list, sqimap_mailbox_option_array(0, 0, $text, $this->folder_filter));
             // just one option here
             //
         } else {
             $option_list = array_merge($option_list, array($value => $text));
         }
     }
     if (empty($option_list)) {
         $option_list = array('ignore' => _("unavailable"));
     }
     return addSelect('new_' . $this->name, $option_list, $this->value, TRUE, $this->aExtraAttribs, $multiple_select, $height) . sm_encode_html_special_chars($this->trailing_text);
 }
Beispiel #2
0
/**
 * Returns list of options (to be echoed into select statement
 * based on available mailboxes and separators
 * Caller should surround options with <select ...> </select> and
 * any formatting.
 * @param stream $imap_stream imap connection resource to query for mailboxes
 * @param array $show_selected array containing list of mailboxes to pre-select (0 if none)
 * @param array $folder_skip array of folders to keep out of option list (compared in lower)
 * @param $boxes list of already fetched boxes (for places like folder panel, where
 *            you know these options will be shown 3 times in a row.. (most often unset).
 * @param string $flag (since 1.4.1) flag to check for in mailbox flags, used to filter out mailboxes.
 *           'noselect' by default to remove unselectable mailboxes.
 *           'noinferiors' used to filter out folders that can not contain subfolders.
 *           NULL to avoid flag check entirely.
 *           NOTE: noselect and noiferiors are used internally. The IMAP representation is
 *                 \NoSelect and \NoInferiors
 * @param boolean $use_long_format (since 1.4.1) override folder display preference and always show full folder name.
 * @return string html formated mailbox selection options
 * @since 1.3.2
 */
function sqimap_mailbox_option_list($imap_stream, $show_selected = 0, $folder_skip = 0, $boxes = 0, $flag = 'noselect', $use_long_format = false)
{
    global $username, $data_dir, $translate_special_folders, $sent_folder, $trash_folder, $draft_folder;
    $boxes = sqimap_mailbox_option_array($imap_stream, $folder_skip, $boxes, $flag, $use_long_format);
    $str = '';
    foreach ($boxes as $value => $option) {
        $lowerbox = strtolower(sm_encode_html_special_chars($value));
        $sel = false;
        if ($show_selected != 0) {
            reset($show_selected);
            while (!$sel && (list($x, $val) = each($show_selected))) {
                if (strtolower($value) == strtolower(sm_encode_html_special_chars($val))) {
                    $sel = true;
                }
            }
        }
        $str .= '<option value="' . $value . '"' . ($sel ? ' selected="selected"' : '') . '>' . $option . "</option>\n";
    }
    return $str;
}
Beispiel #3
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";
}
Beispiel #4
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');
    }
}