function privmsg_list($privmsg_rowset, $recips, $folder_id, $select = false, $mark_ids = array(), $detailed = false)
{
    global $template, $userdata;
    global $lang, $images, $board_config, $phpEx, $phpbb_root_path;
    global $folders;
    global $main_pgm, $from_to_separator;
    global $all_marked, $marked_on_this_page;
    global $msg_days;
    global $nav_separator;
    global $icones;
    // is the post icon mod installed ?
    $mod_post_icon = function_exists('get_icon_title');
    // censor word
    $orig_word = array();
    $replacement_word = array();
    obtain_word_list($orig_word, $replacement_word);
    // get main folder
    $folder_main = $folder_id;
    if (!empty($folders['main'][$folder_id])) {
        $folder_main = $folders['main'][$folder_id];
    }
    // author/recip
    $from_to = '';
    switch ($folder_main) {
        case INBOX:
            $from_to = _lang('From');
            break;
        case OUTBOX:
            $from_to = _lang('To');
            break;
        case SENTBOX:
            $from_to = _lang('To');
            break;
        case SAVEBOX:
            $from_to = _lang('From') . $from_to_separator . _lang('To');
            break;
    }
    // get save sub-folder list
    $s_move_folder = '';
    if ($folder_main != SAVEBOX) {
        $s_move_folder = get_folders_list($folder_id);
    }
    $s_move_folder .= get_folders_list(SAVEBOX);
    // template name
    $template->set_filenames(array('privmsga_box' => 'privmsga_box.tpl'));
    $span = 4;
    if ($mod_post_icon) {
        $span++;
    }
    if ($select) {
        $span++;
    }
    // Header
    $template->assign_vars(array('L_DISPLAY_MESSAGES' => _lang('Display_messages'), 'S_SELECT_MSG_DAYS' => get_days_list($msg_days), 'L_GO' => _lang('Go'), 'L_CANCEL' => _lang('Cancel'), 'L_FLAG' => _lang('Flag'), 'L_SUBJECT' => $select ? _lang('Subject') : _lang('Private_Messages'), 'L_FROM_OR_TO' => $from_to, 'L_DATE' => _lang('Date'), 'L_MARK' => _lang('Mark'), 'L_NO_MESSAGES' => _lang('No_messages_folder'), 'L_DELETE_MARKED' => _lang('Delete_marked'), 'L_DELETE_ALL' => _lang('Delete_all'), 'L_MOVE_MARKED' => _lang('Move_marked'), 'L_SAVE_TO_MAIL' => _lang('Save_to_mail_message'), 'S_SELECT_MOVE' => $s_move_folder, 'SPAN_ALL' => $span, 'SPAN_SUBJECT' => $mod_post_icon ? 2 : 1));
    // process the display
    $all_marked = !empty($privmsg_rowset);
    $marked_on_this_page = array();
    $color = false;
    for ($i = 0; $i < count($privmsg_rowset); $i++) {
        $color = !$color;
        $privmsg_id = $privmsg_rowset[$i]['privmsg_id'];
        $privmsg_recip_id = $privmsg_rowset[$i]['selected_pm_id'];
        // get flag
        $read_icon_flag = _images('pm_readmsg');
        $read_icon_flag_alt = _lang('Read_message');
        $unread_icon_flag = _images('pm_unreadmsg');
        $unread_icon_flag_alt = _lang('Unread_message');
        $new_icon_flag = _images('pm_newmsg');
        $new_icon_flag_alt = _lang('New_message');
        // choose the good icon
        switch ($privmsg_rowset[$i]['selected_read']) {
            case NEW_MAIL:
                $icon_flag = $new_icon_flag;
                $icon_flag_alt = $new_icon_flag_alt;
                break;
            case UNREAD_MAIL:
                $icon_flag = $unread_icon_flag;
                $icon_flag_alt = $unread_icon_flag_alt;
                break;
            case READ_MAIL:
                $icon_flag = $read_icon_flag;
                $icon_flag_alt = $read_icon_flag_alt;
                break;
        }
        // get the status of the "select all" checkbox
        $marked = !empty($mark_ids) && in_array($privmsg_recip_id, $mark_ids);
        if (!$marked) {
            $all_marked = false;
        } else {
            $marked_on_this_page[] = $privmsg_recip_id;
        }
        // user display is the sender
        $a_in = true;
        $a_out = false;
        $w_from_to = array();
        if ($detailed) {
            $w_from_to = array($a_in, $a_out);
        } else {
            switch ($folder_main) {
                case INBOX:
                    $w_from_to = array($a_in);
                    break;
                case OUTBOX:
                    $w_from_to = array($a_out);
                    break;
                case SENTBOX:
                    $w_from_to = array($a_out);
                    break;
                case SAVEBOX:
                    $w_from_to = array($a_in, $a_out);
                    break;
                default:
                    message_die(GENERAL_ERROR, _lang('No_such_folder'), '', __LINE__, __FILE__);
                    break;
            }
        }
        $s_username = '';
        for ($k = 0; $k < count($w_from_to); $k++) {
            $from = $w_from_to[$k];
            if ($from) {
                $temp_url = empty($privmsg_rowset[$i]['privmsg_user_id']) ? append_sid("./index.{$phpEx}") : append_sid("./profile.{$phpEx}?mode=viewprofile&" . POST_USERS_URL . '=' . $privmsg_rowset[$i]['privmsg_user_id']);
                $temp_lib = empty($privmsg_rowset[$i]['privmsg_user_id']) ? $board_config['sitename'] : $privmsg_rowset[$i]['privmsg_from_username'];
                $s_username .= (empty($s_username) ? '' : ($j == 0 ? $from_to_separator : ', ')) . '<a href="' . $temp_url . '" class="' . $userclass . '">' . $temp_lib . '</a>';
            } else {
                for ($j = 0; $j < count($recips['data'][$privmsg_id]); $j++) {
                    $temp_url = empty($recips['data'][$privmsg_id][$j]['privmsg_user_id']) ? append_sid("./index.{$phpEx}") : append_sid("./profile.{$phpEx}?mode=viewprofile&" . POST_USERS_URL . '=' . $recips['data'][$privmsg_id][$j]['privmsg_user_id']);
                    $temp_lib = empty($recips['data'][$privmsg_id][$j]['privmsg_user_id']) ? $board_config['sitename'] : $recips['data'][$privmsg_id][$j]['privmsg_to_username'];
                    $s_username .= (empty($s_username) ? '' : ($j == 0 ? $from_to_separator : ', ')) . '<a href="' . $temp_url . '" class="' . $userclass . '">' . $temp_lib . '</a>';
                }
            }
            // add '...' if required
            if ($recips['over'][$privmsg_id]) {
                $s_username .= (empty($s_username) ? '' : ', ') . '...';
            }
        }
        $subject = preg_replace($orig_word, $replacement_word, $privmsg_rowset[$i]['privmsg_subject']);
        // nav sentence
        if ($detailed) {
            $w_folder_id = $privmsg_rowset[$i]['privmsg_folder_id'];
            $w_folder_main = $w_folder_id;
            if (!empty($folders['main'][$w_folder_id])) {
                $w_folder_main = $folders['main'][$w_folder_id];
            }
            $u_main = append_sid("{$main_pgm}&folder={$w_folder_main}");
            $l_main = _lang($folders['data'][$w_folder_main]['folder_name']);
            $u_subf = append_sid("{$main_pgm}&folder={$w_folder_id}");
            $l_subf = _lang($folders['data'][$w_folder_id]['folder_name']);
            if ($w_folder_main == $w_folder_id) {
                $u_main = $u_subf;
                $l_main = $l_subf;
                $u_subf = '';
                $l_subf = '';
            }
        }
        // post icons mod installed
        $post_icon = '';
        if ($mod_post_icon) {
            $topic_type = POST_NORMAL;
            $post_icon = get_icon_title($privmsg_rowset[$i]['privmsg_icon'], 1, $topic_type);
        }
        // display
        $template->assign_block_vars('pm_row', array('COLOR' => $color ? 'row1' : 'row2', 'FOLDER_IMG' => $icon_flag, 'L_FOLDER_ALT' => $icon_flag_alt, 'ICON' => $post_icon, 'SUBJECT' => $subject, 'U_SUBJECT' => append_sid("{$main_pgm}&pmmode=view&start={$pm_start}&folder={$folder_id}&" . POST_POST_URL . "={$privmsg_recip_id}"), 'S_USERNAME' => $s_username, 'DATE' => create_date($userdata['user_dateformat'], $privmsg_rowset[$i]['privmsg_time'], $userdata['user_timezone']), 'CHECKED' => $marked ? 'checked="checked"' : '', 'S_MARK_ID' => $privmsg_recip_id, 'U_FOLDER' => $u_main, 'L_FOLDER' => $l_main, 'U_SUBFOLDER' => $u_subf, 'L_SUBFOLDER' => $l_subf));
        // post icon mod installed
        if ($mod_post_icon) {
            $template->assign_block_vars('pm_row.switch_icon', array());
        } else {
            $template->assign_block_vars('pm_row.switch_icon_no', array());
        }
        // selection available
        if ($select) {
            $template->assign_block_vars('pm_row.privmsg_select', array());
        } else {
            $template->assign_block_vars('pm_row.privmsg_no_select', array());
        }
        // folder nav link asked
        if ($detailed) {
            $template->assign_block_vars('pm_row.detailed', array());
            if (!empty($u_subf)) {
                $template->assign_block_vars('pm_row.detailed.sub', array());
            } else {
                $template->assign_block_vars('pm_row.detailed.no_sub', array());
            }
        } else {
            $template->assign_block_vars('pm_row.not_detailed', array());
        }
    }
    // general marked
    $template->assign_vars(array('CHECKED' => $all_marked ? 'checked="checked"' : ''));
    // nothing to display
    if (count($privmsg_rowset) == 0) {
        $template->assign_block_vars('pm_empty', array());
    }
    // post icon nod installed
    if ($mod_post_icon) {
        $template->assign_block_vars('switch_icon', array());
    } else {
        $template->assign_block_vars('switch_icon_no', array());
    }
    // selection of pms available
    if ($select) {
        $template->assign_block_vars('privmsg_select', array());
        // save button : appears always for save box when we're not in savebox
        if ($folder_main != SAVEBOX || !empty($folders['sub'][$folder_main])) {
            $template->assign_block_vars('privmsg_select.switch_move', array());
        }
        // delete button
        $template->assign_block_vars('privmsg_select.switch_delete', array());
        // save to mail
        $template->assign_block_vars('privmsg_select.switch_savetomail', array());
    } else {
        if ($detailed) {
            $template->assign_block_vars('switch_cancel', array());
        } else {
            $template->assign_block_vars('privmsg_no_select', array());
        }
    }
    $template->assign_var_from_handle('PRIVMSGA_BOX', 'privmsga_box');
}
Пример #2
0
function privmsg_review($view_user_id, $privmsg_recip_id, $is_inline_review)
{
    global $db, $board_config, $template, $lang, $images, $theme, $phpEx, $phpbb_root_path;
    global $userdata, $user_ip;
    global $orig_word, $replacement_word;
    global $starttime;
    global $admin_level, $level_prior, $bbcode_parse;
    global $icones;
    include_once $phpbb_root_path . './includes/functions_messages.' . $phpEx;
    // fix parameters
    $privmsg_recip_id = intval($privmsg_recip_id);
    $view_user_id = intval($view_user_id);
    // check if exists and belongs to the user
    $sql = "SELECT privmsg_id\n                FROM " . PRIVMSGA_RECIPS_TABLE . "\n                WHERE privmsg_user_id = {$view_user_id}\n                    AND privmsg_recip_id = {$privmsg_recip_id}";
    if (!($result = $db->sql_query($sql))) {
        message_die(GENERAL_ERROR, 'Could not obtain private message information', '', __LINE__, __FILE__, $sql);
    }
    if (!($row = $db->sql_fetchrow($result))) {
        message_die(GENERAL_MESSAGE, 'No_post_id');
    }
    $privmsg_id = intval($row['privmsg_id']);
    if (!$is_inline_review) {
        //
        // Start session management
        //
        $userdata = session_pagestart($user_ip, $forum_id);
        init_userprefs($userdata);
        //
        // End session management
        //
        $sql = "SELECT *\n                    FROM " . USERS_TABLE . "\n                    WHERE user_id = {$view_user_id}";
        if (!($result = $db->sql_query($sql))) {
            message_die(GENERAL_ERROR, 'Could not read user information', '', __LINE__, __FILE__, $sql);
        }
        if (!($view_userdata = $db->sql_fetchrow($result))) {
            message_die(GENERAL_MESSAGE, 'User_not_exist');
        }
        check_user($view_userdata);
    }
    //
    // Define censored word matches
    //
    if (empty($orig_word) && empty($replacement_word)) {
        $orig_word = array();
        $replacement_word = array();
        obtain_word_list($orig_word, $replacement_word);
    }
    //
    // Dump out the page header and load viewtopic body template
    //
    if (!$is_inline_review) {
        $gen_simple_header = true;
        $page_title = _lang('Topic_review');
        include $phpbb_root_path . 'includes/page_header.' . $phpEx;
    }
    $template->set_filenames(array('reviewbody' => 'posting_topic_review.tpl'));
    // Read the message id
    $sql = "SELECT p.*, pa.*, u.username AS privmsg_from_username\n                FROM " . PRIVMSGA_TABLE . " p, " . PRIVMSGA_RECIPS_TABLE . " pa, " . USERS_TABLE . " u\n                WHERE p.privmsg_id = {$privmsg_id}\n                    AND pa.privmsg_id = p.privmsg_id AND pa.privmsg_direct = 0\n                    AND ( (pa.privmsg_user_id <> 0 AND u.user_id = pa.privmsg_user_id) OR (pa.privmsg_user_id = 0 AND u.user_id = " . ANONYMOUS . ") )";
    if (!($result = $db->sql_query($sql))) {
        message_die(GENERAL_ERROR, 'Could not obtain post/user information', '', __LINE__, __FILE__, $sql);
    }
    if ($row = $db->sql_fetchrow($result)) {
        $poster_id = $row['privmsg_user_id'];
        $poster = empty($poster_id) ? $board_config['sitename'] : $poster_id == ANONYMOUS ? _lang('Guest') : $row['privmsg_from_username'];
        $post_date = create_date($userdata['user_dateformat'], $row['privmsg_time'], $userdata['user_timezone']);
        $post_subject = empty($row['privmsg_subject']) ? '' : $row['privmsg_subject'];
        $message = $row['privmsg_text'];
        $bbcode_uid = $row['privmsg_bbcode_uid'];
        //
        // If the board has HTML off but the post has HTML
        // on then we process it, else leave it alone
        //
        if (!$board_config['allow_html'] && $row['privmsg_enable_html']) {
            $message = preg_replace('#(<)([\\/]?.*?)(>)#is', '&lt;\\2&gt;', $message);
        }
        if (!empty($bbcode_uid)) {
            $message = $board_config['allow_bbcode'] ? $bbcode_parse->bbencode_second_pass($message, $bbcode_uid) : preg_replace('/\\:[0-9a-z\\:]+\\]/si', ']', $message);
        }
        $message = $bbcode_parse->make_clickable($message);
        if (count($orig_word)) {
            $post_subject = preg_replace($orig_word, $replacement_word, $post_subject);
            $message = preg_replace($orig_word, $replacement_word, $message);
        }
        if ($board_config['allow_smilies'] && $row['enable_smilies']) {
            $message = $bbcode_parse->smilies_pass($message);
        }
        $message = str_replace("\n", '<br />', $message);
        $message = $bbcode_parse->acronym_pass($message);
        $message = $bbcode_parse->smart_pass($message);
        if (function_exists('get_icon_title')) {
            $post_subject = get_icon_title($row['post_icon']) . '&nbsp;' . $post_subject;
        }
        // just for the template : no signification here
        $mini_post_img = _images('icon_minipost');
        $mini_post_alt = _lang('Post');
        //
        // Again this will be handled by the templating
        // code at some point
        //
        $color = true;
        $row_color = $color ? $theme['td_color1'] : $theme['td_color2'];
        $row_class = $color ? $theme['td_class1'] : $theme['td_class2'];
        $template->assign_block_vars('postrow', array('ROW_COLOR' => '#' . $row_color, 'ROW_CLASS' => $row_class, 'MINI_POST_IMG' => $mini_post_img, 'POSTER_NAME' => $poster, 'POST_DATE' => $post_date, 'POST_SUBJECT' => $post_subject, 'MESSAGE' => $message, 'L_MINI_POST_ALT' => $mini_post_alt));
    } else {
        message_die(GENERAL_MESSAGE, 'No_post_id', '', __LINE__, __FILE__, $sql);
    }
    $template->assign_vars(array('L_AUTHOR' => _lang('Author'), 'L_MESSAGE' => _lang('Message'), 'L_POSTED' => _lang('Posted'), 'L_POST_SUBJECT' => _lang('Post_subject'), 'L_TOPIC_REVIEW' => _lang('Topic_review')));
    if (!$is_inline_review) {
        $template->pparse('reviewbody');
        include $phpbb_root_path . 'includes/page_tail.' . $phpEx;
    }
}
Пример #3
0
         $temp_url = 'http://wwp.icq.com/scripts/search.dll?to=' . $privmsg['user_icq'] . '';
         $icq_img = $privmsg['user_icq'] ? '<a href="' . $temp_url . '"><img src="' . _images('icon_icq') . '" alt="' . _lang('ICQ') . '" title="' . _lang('ICQ') . '" border="0" /></a>' : '';
         $icq_status_img = $privmsg['user_icq'] ? '<a href="http://wwp.icq.com/' . $privmsg['user_icq'] . '#pager"><img src="http://web.icq.com/whitepages/online?icq=' . $privmsg['user_icq'] . '&img=5" width="18" height="18" border="0" /></a>' : '';
         $icq = $privmsg['user_icq'] ? '<a href="' . $temp_url . '">' . _lang('ICQ') . '</a>' : '';
         $temp_url = 'aim:goim?screenname=' . $privmsg['user_aim'] . '&amp;message=Hello+Are+you+there?';
         $aim_img = $privmsg['user_aim'] ? '<a href="' . $temp_url . '"><img src="' . _images('icon_aim') . '" alt="' . _lang('AIM') . '" title="' . _lang('AIM') . '" border="0" /></a>' : '';
         $aim = $privmsg['user_aim'] ? '<a href="' . $temp_url . '">' . _lang('AIM') . '</a>' : '';
         $temp_url = append_sid("./profile.{$phpEx}?mode=viewprofile&amp;" . POST_USERS_URL . "={$poster_id}");
         $msn_img = $privmsg['user_msnm'] ? '<a href="' . $temp_url . '"><img src="' . _images('icon_msnm') . '" alt="' . _lang('MSNM') . '" title="' . _lang('MSNM') . '" border="0" /></a>' : '';
         $msn = $privmsg['user_msnm'] ? '<a href="' . $temp_url . '">' . _lang('MSNM') . '</a>' : '';
         $temp_url = 'http://edit.yahoo.com/config/send_webmesg?.target=' . $privmsg['user_yim'] . '&amp;.src=pg';
         $yim_img = $privmsg['user_yim'] ? '<a href="' . $temp_url . '"><img src="' . _images('icon_yim') . '" alt="' . _lang('YIM') . '" title="' . _lang('YIM') . '" border="0" /></a>' : '';
         $yim = $privmsg['user_yim'] ? '<a href="' . $temp_url . '">' . _lang('YIM') . '</a>' : '';
         // search
         $temp_url = append_sid("./search.{$phpEx}?search_author=" . urlencode($privmsg['username']) . "&amp;showresults=posts");
         $search_img = '<a href="' . $temp_url . '"><img src="' . _images('icon_search') . '" alt="' . _lang('Search_user_posts') . '" title="' . _lang('Search_user_posts') . '" border="0" /></a>';
         $search = '<a href="' . $temp_url . '">' . _lang('Search_user_posts') . '</a>';
     }
     //
     // Dump it to the templating engine
     //
     $template->assign_vars(array('PROFILE_IMG' => $profile_img, 'PROFILE' => $profile, 'SEARCH_IMG' => $search_img, 'SEARCH' => $search, 'EMAIL_IMG' => $email_img, 'EMAIL' => $email, 'WWW_IMG' => $www_img, 'WWW' => $www, 'ICQ_STATUS_IMG' => $icq_status_img, 'ICQ_IMG' => $icq_img, 'ICQ' => $icq, 'AIM_IMG' => $aim_img, 'AIM' => $aim, 'MSN_IMG' => $msn_img, 'MSN' => $msn, 'YIM_IMG' => $yim_img, 'YIM' => $yim));
 }
 // PCP process
 if (defined('IN_PCP')) {
     // get user relational status
     $sql = "SELECT *\n                    FROM " . BUDDYS_TABLE . "\n                    WHERE user_id = " . intval($privmsg['user_id']) . "\n                        AND buddy_id = " . intval($userdata['user_id']);
     if (!($result = $db->sql_query($sql))) {
         message_die(GENERAL_ERROR, 'Could not read from user buddy info', '', __LINE__, __FILE__, $sql);
     }
     $buddys = $db->sql_fetchrow($result);