}
         }
         resync_pm($view_user_id);
     }
 }
 // set the page title and include the page header
 $page_title = _lang('Private_Messaging');
 if (!defined('IN_PCP')) {
     include $phpbb_root_path . 'includes/page_header.' . $phpEx;
 }
 // template name
 $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('&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);
     }
 }
 // set the page title and include the page header
 $page_title = _lang('Search_pm');
 if (!defined('IN_PCP')) {
     include $phpbb_root_path . 'includes/page_header.' . $phpEx;
 }
 // template name
 $template->set_filenames(array('body' => 'privmsga_body.tpl'));
 // send header
 privmsg_header($view_user_id, $folder_id);
 // send list
 $select = false;
 $mark_ids = array();
 $detailed = true;
 privmsg_list($privmsg_rowset, $recips, $folder_id, $select, $mark_ids, $detailed);
 // pagination
 $page_list = generate_pagination("{$main_pgm}&pmmode=search&amp;folder={$folder_id}&amp;search_folder={$search_folder}&amp;submit_search=1&amp;" . POST_USERS_URL . "={$view_user_id}&amp;username="******"&amp;words=" . urlencode($words), $count, $board_config['topics_per_page'], $pm_start);
 $page_number = sprintf(_lang('Page_of'), floor($pm_start / $board_config['topics_per_page']) + 1, ceil($count / $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);
 // save some values
 _hide('pmmode', $pmmode);
 _hide('folder', $folder_id);
 _hide(POST_USERS_URL, $view_user_id);
 _hide('sid', $userdata['session_id']);
 _hide('start', $pm_start);
 _hide('submit_search', true);
 _hide('search_folder', $search_folder);
 if (!empty($username)) {
     _hide('username', str_replace("''", "'", $username));
     $sql = "SELECT pr.privmsg_id, pr.privmsg_recip_id, pr.privmsg_user_id, ur.username AS privmsg_to_username\n                    FROM " . PRIVMSGA_RECIPS_TABLE . " pr, " . USERS_TABLE . " ur\n                    WHERE pr.privmsg_user_id = {$view_user_id} AND pr.privmsg_direct = 1\n                        AND pr.privmsg_id IN ({$s_privmsg_ids})\n                        AND ur.user_id = pr.privmsg_user_id\n                    ORDER BY pr.privmsg_id, ur.username, pr.privmsg_recip_id";
     if (!($result = $db->sql_query($sql))) {
         message_die(GENERAL_ERROR, 'Can\'t read recipients', '', __LINE__, __FILE__, $sql);
     }
     while ($row = $db->sql_fetchrow($result)) {
         if (count($recips[$row['privmsg_id']]) <= $cfg_max_userlist) {
             $recips['data'][$row['privmsg_id']][] = $row;
         } else {
             $recips['over'][$row['privmsg_id']] = true;
         }
     }
 }
 // save template state
 $sav_tpl = $template->_tpldata;
 // build list
 privmsg_list($privmsg_rowset, $recips, INBOX);
 // transfert to a var
 $res = $template->vars['PRIVMSGA_BOX'];
 // restore template saved state
 $template->_tpldata = $sav_tpl;
 // init right part of the home panel
 if (!$right_part) {
     $template->assign_block_vars('right_part', array());
     $right_part = true;
 }
 // send result to template
 $template->assign_block_vars('right_part.box', array('BOX' => $res));
 // hidden fields
 $s_hidden_fields .= '<input type="hidden" name="privmsgs_start" value="' . $privmsg_start . '" />';
 // fix pagination display bug
 if ($privmsg_total == 0) {