if (!defined('IN_PCP')) {
                include $phpbb_root_path . 'includes/page_tail.' . $phpEx;
            }
        } else {
            // display the page
            $page_title = _lang('Search_pm');
            if (!defined('IN_PCP')) {
                include $phpbb_root_path . 'includes/page_header.' . $phpEx;
            }
            $template->set_filenames(array('body' => 'privmsga_search_body.tpl'));
            privmsg_header($view_user_id, $folder_id, $privmsg_recip_id);
            // header
            $template->assign_vars(array('L_TITLE' => _lang('Search_pm'), 'L_SEARCH_FOLDER' => _lang('Search_folder'), 'L_SEARCH_FOLDER_EXPLAIN' => _lang('Search_folder_explain'), 'L_SEARCH_AUTHOR' => _lang('Search_recipient'), 'L_SEARCH_AUTHOR_EXPLAIN' => _lang('Search_recipient_explain'), 'L_SEARCH_WORDS' => _lang('Search_words'), 'L_SEARCH_WORDS_EXPLAIN' => _lang('Search_words_explain'), 'L_SUBMIT' => _lang('Submit'), 'L_CANCEL' => _lang('Cancel'), 'L_FIND_USERNAME' => _lang('Find_username'), 'U_SEARCH_USER' => append_sid("search.{$phpEx}?mode=searchuser")));
            // data
            $s_folders = '<option value="-1">' . _lang('All_folders') . '</option>' . get_folders_list(0, $folder_id);
            // vars
            $template->assign_vars(array('S_FOLDERS' => $s_folders, 'USERNAME' => empty($username) ? '' : str_replace("''", "'", $username), 'WORDS' => empty($search_words) ? '' : str_replace("''", "'", implode(', ', $search_words))));
            // system
            _hide(POST_USERS_URL, $view_user_id);
            _hide('pmmode', $pmmode);
            _hide('sid', $userdata['session_id']);
            $template->assign_vars(array('S_ACTION' => append_sid($main_pgm), 'S_HIDDEN_FIELDS' => _hidden_get()));
            // send to browser
            privmsg_footer();
            $template->pparse('body');
            if (!defined('IN_PCP')) {
                include $phpbb_root_path . 'includes/page_tail.' . $phpEx;
            }
        }
    }
}
    $template->set_filenames(array('body' => 'privmsga_body.tpl'));
    // send header
    privmsg_header($view_user_id, $folder_id);
    // send list
    privmsg_list($privmsg_rowset, $recips, $folder_id, true, $mark_ids);
    // pagination
    $page_list = generate_pagination("profile.{$phpEx}?mode=privmsg", $count_in_sub_folder, $board_config['topics_per_page'], $pm_start);
    $page_number = sprintf(_lang('Page_of'), floor($start / $board_config['topics_per_page']) + 1, ceil($count_in_sub_folder / $board_config['topics_per_page']));
    //$page_list      = str_replace('&amp;start', '&start', $page_list);
    $page_list = preg_replace("/\\&start\\=(\\d*)/", "javascript:document.post.start.value='\\1'; document.post.submit();", $page_list);
    // add marked on other pages
    for ($i = 0; $i < count($mark_ids); $i++) {
        if (empty($marked_on_this_page) || !in_array($mark_ids[$i], $marked_on_this_page)) {
            _hide('mark_ids[]', $mark_ids[$i]);
        }
    }
    _hide('start', $pm_start);
    _hide('pmmode', $pmmode);
    _hide('folder', $folder_id);
    _hide(POST_USERS_URL, $view_user_id);
    // mark as not first entrance
    _hide('refresh', true);
    // system
    $template->assign_vars(array('S_ACTION' => append_sid($main_pgm), 'S_HIDDEN_FIELDS' => _hidden_get(), 'L_GOTO_PAGE' => $count_in_sub_folder < $board_config['topics_per_page'] ? '' : _lang('Goto_page'), 'PAGINATION' => $count_in_sub_folder < $board_config['topics_per_page'] ? '' : $page_list, 'PAGE_NUMBER' => $page_number));
}
// send to browser
privmsg_footer();
$template->pparse('body');
if (!defined('IN_PCP')) {
    include $phpbb_root_path . 'includes/page_tail.' . $phpEx;
}
function privmsg_header($view_user_id, $folder_id, $privmsg_recip_id = 0)
{
    global $template, $db, $userdata;
    global $lang, $images, $board_config, $phpEx, $phpbb_root_path;
    global $folders;
    global $main_pgm;
    global $nav_separator;
    // fix the folder id
    if (!isset($folders['data'][$folder_id])) {
        $folder_id = INBOX;
    }
    $folder_main = $folder_id;
    if (!empty($folders['main'][$folder_id])) {
        $folder_main = $folders['main'][$folder_id];
    }
    $template->set_filenames(array('privmsga_header' => 'privmsga_header.tpl'));
    // start the display
    if (!defined('IN_PCP')) {
        make_jumpbox('viewforum.' . $phpEx);
    }
    // send the menu
    display_menu($view_user_id, $folder_id);
    // nav sentence
    $u_main = append_sid("{$main_pgm}&folder={$folder_main}");
    $l_main = _lang($folders['data'][$folder_main]['folder_name']);
    $u_subf = append_sid("{$main_pgm}&folder={$folder_id}");
    $l_subf = _lang($folders['data'][$folder_id]['folder_name']);
    if ($folder_main == $folder_id) {
        $u_main = $u_subf;
        $l_main = $l_subf;
        $u_subf = '';
        $l_subf = '';
    }
    // generate some command buttons and the nav sentence
    $template->assign_vars(array('U_POST_NEW_PM' => append_sid("{$main_pgm}&pmmode=post"), 'L_POST_NEW_PM' => _lang('Post_new_pm'), 'POST_IMG' => _images('pm_postmsg'), 'U_REPLY_PM' => append_sid("{$main_pgm}&pmmode=reply&" . POST_POST_URL . "={$privmsg_recip_id}"), 'L_REPLY_PM' => _lang('Post_reply_pm'), 'REPLY_IMG' => _images('pm_replymsg'), 'U_FOLDER' => $u_main, 'L_FOLDER' => $l_main, 'U_SUBFOLDER' => $u_subf, 'L_SUBFOLDER' => $l_subf));
    if (!defined('IN_PCP')) {
        $template->assign_block_vars('switch_not_in_pcp', array());
        $template->assign_block_vars('switch_nav_sentence', array());
        $template->assign_block_vars('switch_not_in_pcp.switch_nav_sentence', array());
        if (!empty($u_subf)) {
            $template->assign_block_vars('switch_nav_sentence.switch_subfolder', array());
            $template->assign_block_vars('switch_not_in_pcp.switch_nav_sentence.switch_subfolder', array());
        }
    } else {
        $template->assign_block_vars('switch_in_pcp', array());
    }
    // edit folder list
    if (!defined('IN_POSTING') && !defined('IN_FOLDERS')) {
        $template->assign_block_vars('switch_new_post', array());
        if (!defined('IN_PCP')) {
            $template->assign_block_vars('switch_not_in_pcp.switch_new_post', array());
        }
    }
    // reply button
    if (!empty($privmsg_recip_id) && $folder_main == INBOX) {
        $template->assign_block_vars('switch_reply', array());
        if (!defined('IN_PCP')) {
            $template->assign_block_vars('switch_not_in_pcp.switch_reply', array());
        }
    }
    // system
    _hide('sid', $userdata['session_id']);
    $template->assign_vars(array('NAV_SEPARATOR' => $nav_separator));
    $template->assign_var_from_handle('EXTERNAL_HEADER', 'privmsga_header');
}
        $template->assign_block_vars('switch_icon_checkbox.row', array());
        for ($j = 0; $j < $icon_per_row && $offset < count($icones_sort); $j++) {
            $icon_id = $icones_sort[$offset];
            // send to cell or cell_none
            $template->assign_block_vars('switch_icon_checkbox.row.cell', array('ICON_ID' => $icones[$icon_id]['ind'], 'ICON_CHECKED' => $post_icon == $icones[$icon_id]['ind'] ? ' checked="checked"' : '', 'ICON_IMG' => get_icon_title($icones[$icon_id]['ind'], 2)));
            $offset++;
        }
    }
}
// system
_hide(POST_USERS_URL, $view_user_id);
_hide('pmmode', $pmmode);
_hide('folder', $folder_id);
_hide('start', $pm_start);
if (!empty($privmsg_id)) {
    _hide(POST_POST_URL, $privmsg_recip_id);
}
$template->assign_vars(array('S_POST_ACTION' => append_sid($main_pgm), 'S_HIDDEN_FORM_FIELDS' => _hidden_get()));
// send to browser
privmsg_footer();
// privmsg review
if ($review) {
    include_once $phpbb_root_path . 'includes/privmsga_review.' . $phpEx;
    privmsg_review($view_user_id, $privmsg_recip_id, true);
    $template->assign_block_vars('switch_inline_mode', array());
    $template->assign_var_from_handle('TOPIC_REVIEW_BOX', 'reviewbody');
}
$template->pparse('body');
if (!defined('IN_PCP')) {
    include $phpbb_root_path . 'includes/page_tail.' . $phpEx;
}
        $ignore_buttons = pcp_output_panel('PHPBB.privmsgs.buttons.ignore', $privmsg);
        //
        // Dump it to the templating engine
        //
        $template->assign_vars(array('AUTHOR_PANEL' => !$privmsg['user_my_ignore'] ? $from_panel : $from_ignore_panel, 'DEST_PANEL' => !$privmsg['user_my_ignore'] ? $to_panel : $to_ignore_panel, 'BUTTONS_PANEL' => !$privmsg['user_my_ignore'] ? $buttons_panel : $ignore_buttons));
    }
    // post icons mod installed
    $post_icon = '';
    if ($mod_post_icon) {
        $topic_type = POST_NORMAL;
        $post_icon = get_icon_title($privmsg['privmsg_icon'], 1, $topic_type);
        $post_subject = $post_icon . '&nbsp;' . $post_subject;
    }
    //
    // Dump it to the templating engine
    //
    $template->assign_vars(array('MESSAGE_FROM' => $s_user_from, 'MESSAGE_TO' => $s_user_to, 'POST_SUBJECT' => $post_subject, 'POST_DATE' => $post_date, 'MESSAGE' => $private_message, 'SIGNATURE' => $signature, 'QUOTE_PM_IMG' => $quote_img, 'QUOTE_PM' => $quote, 'EDIT_PM_IMG' => $editpm_img, 'EDIT_PM' => $editpm, 'DELETE_PM_IMG' => $delpm_img, 'DELETE_PM' => $delpm, 'FORWARD_PM_IMG' => $forward_img, 'FORWARD_PM' => $forward, 'SAVEMAIL_PM_IMG' => $savemail_img, 'SAVEMAIL_PM' => $savemail, 'S_MOVE_FOLDER' => $s_move_folder));
    // system
    _hide(POST_POST_URL, $privmsg_recip_id);
    _hide('folder', $folder_id);
    _hide(POST_USERS_URL, $view_user_id);
    _hide('pmmode', $pmmode);
    _hide('start', $pm_start);
    $template->assign_vars(array('S_ACTION' => append_sid($main_pgm), 'S_HIDDEN_FIELDS' => _hidden_get()));
}
// send to browser
privmsg_footer();
$template->pparse('body');
if (!defined('IN_PCP')) {
    include $phpbb_root_path . 'includes/page_tail.' . $phpEx;
}