// Send smilies to template // generate_smilies('inline'); $privmsg_subject = clean_title($privmsg_subject); $template->assign_vars(array('SUBJECT' => htmlCHR($privmsg_subject), 'USERNAME' => $to_username, 'MESSAGE' => $privmsg_message, 'FORUM_NAME' => $lang['PRIVATE_MESSAGE'], 'BOX_NAME' => $l_box_name, 'INBOX' => $inbox_url, 'SENTBOX' => $sentbox_url, 'OUTBOX' => $outbox_url, 'SAVEBOX' => $savebox_url, 'POSTING_TYPE_TITLE' => $post_a, 'S_HIDDEN_FORM_FIELDS' => $s_hidden_fields, 'S_POST_ACTION' => PM_URL, 'U_SEARCH_USER' => "search.php?mode=searchuser", 'U_VIEW_FORUM' => PM_URL)); } else { // // Reset PM counters // $userdata['user_new_privmsg'] = 0; $userdata['user_unread_privmsg'] = $userdata['user_new_privmsg'] + $userdata['user_unread_privmsg']; $userdata['user_last_privmsg'] = $userdata['session_start']; // // Update unread status // db_update_userdata($userdata, array('user_unread_privmsg' => 'user_unread_privmsg + user_new_privmsg', 'user_new_privmsg' => 0, 'user_last_privmsg' => $userdata['session_start'])); $sql = "UPDATE " . BB_PRIVMSGS . "\n\t\tSET privmsgs_type = " . PRIVMSGS_UNREAD_MAIL . "\n\t\tWHERE privmsgs_type = " . PRIVMSGS_NEW_MAIL . "\n\t\t\tAND privmsgs_to_userid = " . $userdata['user_id']; if (!DB()->sql_query($sql)) { bb_die('Could not update private message new / read status (2) for user'); } // // Generate page // $page_title = $lang['PRIVATE_MESSAGING']; // // Load templates // $template->set_filenames(array('body' => 'privmsgs.tpl')); $orig_word = $replacement_word = array(); obtain_word_list($orig_word, $replacement_word); //
/** * Mark read * * @param $type */ function mark_read($type) { if ($type === 'all_forums') { // Update session time DB()->query("\n\t\t\t\tUPDATE " . SESSIONS_TABLE . " SET\n\t\t\t\t\tsession_time = " . TIMENOW . "\n\t\t\t\tWHERE session_id = '{$this->data['session_id']}'\n\t\t\t\tLIMIT 1\n\t\t\t"); // Update userdata $this->data['session_time'] = TIMENOW; $this->data['user_lastvisit'] = TIMENOW; // Update lastvisit db_update_userdata($this->data, array('user_session_time' => $this->data['session_time'], 'user_lastvisit' => $this->data['user_lastvisit'])); // Delete cookies ft_setcookie(COOKIE_TOPIC, ''); ft_setcookie(COOKIE_FORUM, ''); ft_setcookie(COOKIE_MARK, ''); } }
$icon_pm = $images['pm_new_msg']; $pm_info = declension($userdata['user_new_privmsg'], $lang['NEW_PMS_DECLENSION'], $lang['NEW_PMS_FORMAT']); if ($userdata['user_last_privmsg'] > $userdata['user_lastvisit'] && defined('IN_PM')) { $userdata['user_last_privmsg'] = $userdata['user_lastvisit']; db_update_userdata($userdata, array('user_last_privmsg' => $userdata['user_lastvisit'])); $have_new_pm = $userdata['user_new_privmsg'] > 1; } } if (!$have_new_pm && $userdata['user_unread_privmsg']) { // synch unread pm count if (defined('IN_PM')) { $row = DB()->fetch_row("\n\t\t\t\tSELECT COUNT(*) AS pm_count\n\t\t\t\tFROM " . BB_PRIVMSGS . "\n\t\t\t\tWHERE privmsgs_to_userid = " . $userdata['user_id'] . "\n\t\t\t\t\tAND privmsgs_type = " . PRIVMSGS_UNREAD_MAIL . "\n\t\t\t\tGROUP BY privmsgs_to_userid\n\t\t\t"); $real_unread_pm_count = (int) $row['pm_count']; if ($userdata['user_unread_privmsg'] != $real_unread_pm_count) { $userdata['user_unread_privmsg'] = $real_unread_pm_count; db_update_userdata($userdata, array('user_unread_privmsg' => $real_unread_pm_count)); } } $pm_info = declension($userdata['user_unread_privmsg'], $lang['UNREAD_PMS_DECLENSION'], $lang['UNREAD_PMS_FORMAT']); $have_unread_pm = true; } } $template->assign_vars(array('HAVE_NEW_PM' => $have_new_pm, 'HAVE_UNREAD_PM' => $have_unread_pm)); // The following assigns all _common_ variables that may be used at any point in a template $template->assign_vars(array('SIMPLE_HEADER' => !empty($gen_simple_header), 'CONTENT_ENCODING' => $bb_cfg['lang'][$userdata['user_lang']]['encoding'], 'IN_ADMIN' => defined('IN_ADMIN'), 'SHOW_ADS' => !$logged_in || isset($bb_cfg['show_ads_users'][$user->id]) || !IS_AM && $user->show_ads, 'USER_HIDE_CAT' => BB_SCRIPT == 'index', 'USER_LANG' => $userdata['user_lang'], 'INCLUDE_BBCODE_JS' => !empty($page_cfg['include_bbcode_js']), 'USER_OPTIONS_JS' => IS_GUEST ? '{}' : Zend\Json\Json::encode($user->opt_js), 'USE_TABLESORTER' => !empty($page_cfg['use_tablesorter']), 'SITENAME' => $bb_cfg['sitename'], 'U_INDEX' => BB_ROOT . "index.php", 'T_INDEX' => sprintf($lang['FORUM_INDEX'], $bb_cfg['sitename']), 'IS_GUEST' => IS_GUEST, 'IS_USER' => IS_USER, 'IS_ADMIN' => IS_ADMIN, 'IS_MOD' => IS_MOD, 'IS_AM' => IS_AM, 'FORUM_PATH' => FORUM_PATH, 'FULL_URL' => FULL_URL, 'CURRENT_TIME' => sprintf($lang['CURRENT_TIME'], bb_date(TIMENOW, $bb_cfg['last_visit_date_format'], false)), 'S_TIMEZONE' => preg_replace('/\\(.*?\\)/', '', sprintf($lang['ALL_TIMES'], $lang['TZ'][str_replace(',', '.', floatval($bb_cfg['board_timezone']))])), 'BOARD_TIMEZONE' => $bb_cfg['board_timezone'], 'PM_INFO' => $pm_info, 'PRIVMSG_IMG' => $icon_pm, 'LOGGED_IN' => $logged_in, 'SESSION_USER_ID' => $userdata['user_id'], 'POINTS' => $userdata['user_points'], 'THIS_USER' => profile_url($userdata), 'THIS_AVATAR' => get_avatar($userdata['user_id'], $userdata['avatar_ext_id'], !bf($userdata['user_opt'], 'user_opt', 'dis_avatar')), 'SHOW_LOGIN_LINK' => !defined('IN_LOGIN'), 'AUTOLOGIN_DISABLED' => !$bb_cfg['allow_autologin'], 'S_LOGIN_ACTION' => LOGIN_URL, 'U_CUR_DOWNLOADS' => PROFILE_URL . $userdata['user_id'], 'U_FORUM' => "viewforum.php", 'U_GROUPS' => "group.php", 'U_LOGIN_LOGOUT' => $u_login_logout, 'U_MEMBERLIST' => "memberlist.php", 'U_MODCP' => "modcp.php", 'U_OPTIONS' => "profile.php?mode=editprofile", 'U_PRIVATEMSGS' => PM_URL . "?folder=inbox", 'U_PROFILE' => PROFILE_URL . $userdata['user_id'], 'U_READ_PM' => PM_URL . "?folder=inbox" . ($userdata['user_newest_pm_id'] && $userdata['user_new_privmsg'] == 1 ? "&mode=read&p={$userdata['user_newest_pm_id']}" : ''), 'U_REGISTER' => "profile.php?mode=register", 'U_SEARCH' => "search.php", 'U_SEND_PASSWORD' => "profile.php?mode=sendpassword", 'U_TERMS' => $bb_cfg['terms_and_conditions_url'], 'U_TRACKER' => "tracker.php", 'SHOW_SIDEBAR1' => !empty($page_cfg['show_sidebar1'][BB_SCRIPT]) || $bb_cfg['show_sidebar1_on_every_page'], 'SHOW_SIDEBAR2' => !empty($page_cfg['show_sidebar2'][BB_SCRIPT]) || $bb_cfg['show_sidebar2_on_every_page'], 'HTML_AGREEMENT' => LANG_DIR . 'html/user_agreement.html', 'HTML_COPYRIGHT' => LANG_DIR . 'html/copyright_holders.html', 'HTML_ADVERT' => LANG_DIR . 'html/advert.html', 'HTML_SIDEBAR_1' => LANG_DIR . 'html/sidebar1.html', 'HTML_SIDEBAR_2' => LANG_DIR . 'html/sidebar2.html', 'AVATARS_URL' => 'data/avatars', 'CAT_URL' => BB_ROOT . CAT_URL, 'DOWNLOAD_URL' => BB_ROOT . DOWNLOAD_URL, 'FORUM_URL' => BB_ROOT . FORUM_URL, 'GROUP_URL' => BB_ROOT . GROUP_URL, 'LOGIN_URL' => $bb_cfg['login_url'], 'NEWEST_URL' => '&view=newest#newest', 'PM_URL' => $bb_cfg['pm_url'], 'POST_URL' => BB_ROOT . POST_URL, 'POSTING_URL' => $bb_cfg['posting_url'], 'PROFILE_URL' => BB_ROOT . PROFILE_URL, 'TOPIC_URL' => BB_ROOT . TOPIC_URL, 'AJAX_HTML_DIR' => AJAX_HTML_DIR, 'ONLY_NEW_POSTS' => ONLY_NEW_POSTS, 'ONLY_NEW_TOPICS' => ONLY_NEW_TOPICS, 'BOT_UID' => BOT_UID, 'COOKIE_MARK' => COOKIE_MARK, 'SID' => $userdata['session_id'], 'SID_HIDDEN' => '<input type="hidden" name="sid" value="' . $userdata['session_id'] . '" />', 'CHECKED' => HTML_CHECKED, 'DISABLED' => HTML_DISABLED, 'READONLY' => HTML_READONLY, 'SELECTED' => HTML_SELECTED, 'U_SEARCH_SELF_BY_LAST' => "search.php?uid={$userdata['user_id']}&o=5", 'U_WATCHED_TOPICS' => "profile.php?mode=watch")); if (!empty($page_cfg['show_torhelp'][BB_SCRIPT]) && !empty($userdata['torhelp'])) { $ignore_time = !empty($_COOKIE['torhelp']) ? (int) $_COOKIE['torhelp'] : 0; if (TIMENOW > $ignore_time) { if ($ignore_time) { bb_setcookie('torhelp', '', COOKIE_EXPIRED); }