function light_draw_pm_inbox() { $webtag = get_webtag(); forum_check_webtag_available($webtag); $new_count = 0; $outbox_count = 0; $unread_count = 0; $current_folder = PM_FOLDER_INBOX; pm_get_message_count($new_count, $outbox_count, $unread_count); if (!($folder_names_array = pm_get_folder_names())) { $folder_names_array = array(PM_FOLDER_INBOX => gettext("Inbox"), PM_FOLDER_SENT => gettext("Sent Items"), PM_FOLDER_OUTBOX => gettext("Outbox"), PM_FOLDER_SAVED => gettext("Saved Items"), PM_FOLDER_DRAFTS => gettext("Drafts")); } if (isset($_GET['page']) && is_numeric($_GET['page'])) { $page = $_GET['page'] > 0 ? $_GET['page'] : 1; } else { if (isset($_POST['page']) && is_numeric($_POST['page'])) { $page = $_POST['page'] > 0 ? $_POST['page'] : 1; } else { $page = 1; } } if (isset($_GET['mid']) && is_numeric($_GET['mid'])) { $mid = $_GET['mid'] > 0 ? $_GET['mid'] : 0; } else { if (isset($_POST['mid']) && is_numeric($_POST['mid'])) { $mid = $_POST['mid'] > 0 ? $_POST['mid'] : 0; } else { $mid = null; } } if (isset($_GET['folder'])) { if ($_GET['folder'] == PM_FOLDER_INBOX) { $current_folder = PM_FOLDER_INBOX; } else { if ($_GET['folder'] == PM_FOLDER_SENT) { $current_folder = PM_FOLDER_SENT; } else { if ($_GET['folder'] == PM_FOLDER_OUTBOX) { $current_folder = PM_FOLDER_OUTBOX; } else { if ($_GET['folder'] == PM_FOLDER_SAVED) { $current_folder = PM_FOLDER_SAVED; } else { if ($_GET['folder'] == PM_FOLDER_DRAFTS) { $current_folder = PM_FOLDER_DRAFTS; } else { if ($_GET['folder'] == PM_SEARCH_RESULTS) { $current_folder = PM_SEARCH_RESULTS; } } } } } } } else { if (isset($_POST['folder'])) { if ($_POST['folder'] == PM_FOLDER_INBOX) { $current_folder = PM_FOLDER_INBOX; } else { if ($_POST['folder'] == PM_FOLDER_SENT) { $current_folder = PM_FOLDER_SENT; } else { if ($_POST['folder'] == PM_FOLDER_OUTBOX) { $current_folder = PM_FOLDER_OUTBOX; } else { if ($_POST['folder'] == PM_FOLDER_SAVED) { $current_folder = PM_FOLDER_SAVED; } else { if ($_POST['folder'] == PM_FOLDER_DRAFTS) { $current_folder = PM_FOLDER_DRAFTS; } else { if ($_POST['folder'] == PM_SEARCH_RESULTS) { $current_folder = PM_SEARCH_RESULTS; } } } } } } } } if (isset($_GET['delete_msg']) && is_numeric($_GET['delete_msg']) && ($message_data = pm_message_get($_GET['delete_msg']))) { $delete_mid = $_GET['delete_msg']; $type = pm_get_folder_type($current_folder); $message_data['CONTENT'] = pm_get_content($delete_mid); if (isset($_POST['pm_delete_confirm'])) { if (pm_delete_message($delete_mid)) { header_redirect("lpm.php?webtag={$webtag}&folder={$current_folder}&deleted=true"); exit; } } else { if (isset($_POST['cancel'])) { header_redirect("lpm.php?webtag={$webtag}&folder={$current_folder}&mid={$delete_mid}"); exit; } } echo "<form method=\"post\" action=\"lpm.php?delete_msg={$delete_mid}&folder={$current_folder}\">"; echo form_csrf_token_field(); light_pm_display($message_data, true); echo "<div class=\"post_buttons\">"; echo light_form_submit("pm_delete_confirm", gettext("Delete")); echo light_form_submit("cancel", gettext("Cancel")); echo "</div>\n"; return; } if (isset($mid) && is_numeric($mid) && $mid > 0) { if (!($message_data = pm_message_get($mid))) { light_html_display_error_msg(gettext("Message not found. Check that it hasn't been deleted.")); } else { if (isset($_GET['message_sent'])) { light_html_display_success_msg(gettext("Message sent successfully.")); } else { if (isset($_GET['deleted'])) { light_html_display_success_msg(gettext("Successfully deleted selected messages")); } else { if (isset($_GET['message_saved'])) { light_html_display_success_msg(gettext("Message was successfully saved to 'Drafts' folder")); } } } $message_data['CONTENT'] = pm_get_content($mid); light_pm_display($message_data); if ($current_folder == PM_FOLDER_INBOX && $message_data['TYPE'] == PM_UNREAD) { pm_mark_as_read($mid); } } } else { if (isset($_GET['message_sent'])) { light_html_display_success_msg(gettext("Message sent successfully.")); } else { if (isset($_GET['deleted'])) { light_html_display_success_msg(gettext("Successfully deleted selected messages")); } else { if (isset($_GET['message_saved'])) { light_html_display_success_msg(gettext("Message was successfully saved to 'Drafts' folder")); } } } $message_count_array = pm_get_folder_message_counts(); echo "<div id=\"folder_view\">\n"; echo "<form accept-charset=\"utf-8\" method=\"get\" action=\"lpm.php\">\n"; echo "<ul>\n"; echo "<li>", light_form_dropdown_array("folder", $folder_names_array, $current_folder), "</li>\n"; echo "<li class=\"right_col\">", light_form_submit("go", gettext("Go!")), "</li>\n"; echo "</ul>\n"; echo "</form>\n"; echo "</div>\n"; if (isset($message_count_array[$current_folder]) && is_numeric($message_count_array[$current_folder])) { echo "<div class=\"folder\">"; echo " <h3>", html_style_image('folder'), "{$folder_names_array[$current_folder]}</h3>\n"; echo " <div class=\"folder_inner\">\n"; echo " <div class=\"folder_info\">{$message_count_array[$current_folder]} ", gettext("Messages"), "</div>\n"; if ($current_folder == PM_FOLDER_INBOX) { $messages_array = pm_get_inbox(false, false, $page, 20); } else { if ($current_folder == PM_FOLDER_SENT) { $messages_array = pm_get_sent(false, false, $page, 20); } else { if ($current_folder == PM_FOLDER_OUTBOX) { $messages_array = pm_get_outbox(false, false, $page, 20); } else { if ($current_folder == PM_FOLDER_SAVED) { $messages_array = pm_get_saved_items(false, false, $page, 20); } else { if ($current_folder == PM_FOLDER_DRAFTS) { $messages_array = pm_get_drafts(false, false, $page, 20); } } } } } if (isset($messages_array['message_array']) && sizeof($messages_array['message_array']) > 0) { if ($page > 1) { echo "<div class=\"folder_pagination\"><a href=\"lpm.php?webtag={$webtag}&folder={$current_folder}&page=", $page - 1, "\">", gettext("Previous"), "</a></div>\n"; } echo "<ul>\n"; foreach ($messages_array['message_array'] as $message) { echo "<li>"; echo "<span class=\"pm_icon\">"; if ($message['TYPE'] == PM_UNREAD) { echo html_style_image('pm_unread'); } else { echo html_style_image('pm_read'); } echo "</span><span class=\"pm_title\">"; echo "<a href=\"lpm.php?webtag={$webtag}&folder={$current_folder}&mid={$message['MID']}\">{$message['SUBJECT']}</a>"; echo "</span>"; echo "<span class=\"pm_time\">", format_date_time($message['CREATED']), "</span>"; echo "</li>\n"; } echo "</ul>\n"; $more_messages = $message_count_array[$current_folder] - $page - 1; if ($more_messages > 0) { echo "<div class=\"folder_pagination\"><a href=\"lpm.php?webtag={$webtag}&folder={$current_folder}&page=", $page + 1, "\">", gettext("Next"), "</a></div>\n"; } } echo " </div>\n"; echo "</div>\n"; } $free_space = pm_get_free_space($_SESSION['UID']); $max_user_messages = forum_get_setting('pm_max_user_messages', null, 100); $used_percent = 100 / $max_user_messages * ($max_user_messages - $free_space); echo "<div class=\"pm_bar\">\n"; echo "<div class=\"pm_bar_inner\" style=\"width: {$used_percent}%\"></div>\n"; echo "</div>\n"; echo "<div class=\"pm_folder_usage\">", sprintf(gettext("Your PM folders are %s full"), "{$used_percent}%"), "</div>\n"; if (pm_auto_prune_enabled()) { light_html_display_warning_msg(gettext("PM Folder pruning is enabled!")); } } }
echo " </td>\n"; echo " </tr>\n"; echo " </table>\n"; echo " <table width=\"90%\" border=\"0\" cellpadding=\"2\" cellspacing=\"0\">\n"; echo " <tr>\n"; echo " <td align=\"left\">\n"; echo " <table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n"; echo " <tr>\n"; echo " <td align=\"left\" class=\"foldername\">", html_style_image('export', gettext("Export Private Messages")), " <a href=\"pm_export.php?webtag={$webtag}\" title=\"", gettext("Export Private Messages"), "\">", gettext("Export Private Messages"), "</a></td>\n"; echo " </tr>\n"; echo " </table>\n"; echo " </td>\n"; echo " </tr>\n"; echo " </table>\n"; // Fetch the free PM space and calculate it as a percentage. $pm_free_space = pm_get_free_space($_SESSION['UID']); $pm_max_user_messages = forum_get_setting('pm_max_user_messages', 'is_numeric', 100); $pm_used_percent = 100 / $pm_max_user_messages * ($pm_max_user_messages - $pm_free_space); echo " <br />\n"; echo " <table width=\"90%\" border=\"0\">\n"; echo " <tr>\n"; echo " <td align=\"left\">\n"; echo " <table cellpadding=\"2\" cellspacing=\"0\" width=\"75%\">\n"; echo " <tr>\n"; echo " <td align=\"left\">\n"; echo " <table cellpadding=\"0\" cellspacing=\"0\" class=\"pmbar_container\">\n"; echo " <tr>\n"; echo " <td align=\"left\" title=\"{$pm_used_percent}% ", gettext("Used"), "\">\n"; echo " <table cellpadding=\"0\" cellspacing=\"0\" class=\"pmbar\" style=\"width: {$pm_used_percent}%\">\n"; echo " <tr>\n"; echo " <td></td>\n";
$t_new_recipient_array['TO_UID'] = array(); $t_new_recipient_array['LOGON'] = array(); $t_new_recipient_array['NICK'] = array(); foreach ($t_recipient_array as $key => $t_recipient) { $to_logon = trim($t_recipient); if ($to_user = user_get_by_logon($to_logon)) { $peer_relationship = user_get_peer_relationship($to_user['UID'], $uid); if (!in_array($to_user['UID'], $t_new_recipient_array['TO_UID'])) { $t_new_recipient_array['TO_UID'][] = $to_user['UID']; $t_new_recipient_array['LOGON'][] = $to_user['LOGON']; $t_new_recipient_array['NICK'][] = $to_user['NICKNAME']; } if ($to_radio == 'others') { if ($peer_relationship ^ USER_BLOCK_PM && user_allow_pm($to_user['UID']) || session::check_perm(USER_PERM_FOLDER_MODERATE, 0)) { pm_user_prune_folders(); if (pm_get_free_space($uid) < sizeof($t_new_recipient_array['TO_UID'])) { $error_msg_array[] = gettext("You do not have enough free space to send this message."); $valid = false; } } else { $error_msg_array[] = sprintf(gettext("%s has opted out of receiving personal messages"), $to_logon); $valid = false; } } } else { $error_msg_array[] = sprintf(gettext("User %s not found"), $to_logon); $valid = false; } } $t_to_uid_others = implode('; ', $t_new_recipient_array['LOGON']); if ($to_radio == 'others') {
function pm_get_message_count(&$pm_new_count, &$pm_outbox_count, &$pm_unread_count) { // Default the variables to return 0 even on error. $pm_new_count = 0; $pm_outbox_count = 0; $pm_unread_count = 0; // Connect to the database. if (!($db = db::get())) { return false; } // Check the user UID. if (!isset($_SESSION['UID']) || !is_numeric($_SESSION['UID'])) { return false; } // PM folder types we'll be using. $pm_unread = PM_UNREAD; $pm_outbox = PM_OUTBOX; // Get the user's free space. $pm_free_space = pm_get_free_space($_SESSION['UID']); // Get a list of messages we have received. if (($message_array = pm_get_new_messages($pm_free_space)) !== false) { // Convert the array keys into a comma separated list. $mid_list = implode(',', array_filter(array_keys($message_array), 'is_numeric')); // Mark the selected messages as unread and notified. $sql = "UPDATE LOW_PRIORITY PM_TYPE INNER JOIN PM_RECIPIENT "; $sql .= "ON (PM_TYPE.MID = PM_RECIPIENT.MID AND PM_TYPE.UID = PM_RECIPIENT.TO_UID) "; $sql .= "SET PM_TYPE.TYPE = '{$pm_unread}', PM_RECIPIENT.NOTIFIED = 'Y' "; $sql .= "WHERE PM_TYPE.MID in ({$mid_list}) AND PM_TYPE.UID = '{$_SESSION['UID']}' "; $sql .= "AND (PM_TYPE.TYPE & {$pm_outbox}) "; if (!($result = $db->query($sql))) { return false; } // Number of new messages we've received for popup. $pm_new_count = sizeof($message_array); } // Unread message count. $sql = "SELECT COUNT(MID) FROM PM_TYPE WHERE (TYPE & {$pm_unread}) "; $sql .= "AND UID = '{$_SESSION['UID']}'"; if (!($result = $db->query($sql))) { return false; } list($pm_unread_count) = $result->fetch_row(); // Check for any undelivered messages waiting for the user. $sql = "SELECT COUNT(MID) AS OUTBOX_COUNT FROM PM_TYPE "; $sql .= "WHERE (TYPE & {$pm_outbox}) AND UID = '{$_SESSION['UID']}' "; if (!($result = $db->query($sql))) { return false; } list($pm_outbox_count) = $result->fetch_row(); return true; }
function light_draw_pm_inbox() { $webtag = get_webtag(); // Default values $pm_new_count = 0; $pm_outbox_count = 0; $pm_unread_count = 0; // Check for new PMs pm_get_message_count($pm_new_count, $pm_outbox_count, $pm_unread_count); if (!($pm_folder_names_array = pm_get_folder_names())) { $pm_folder_names_array = array(PM_FOLDER_INBOX => gettext("Inbox"), PM_FOLDER_SENT => gettext("Sent Items"), PM_FOLDER_OUTBOX => gettext("Outbox"), PM_FOLDER_SAVED => gettext("Saved Items"), PM_FOLDER_DRAFTS => gettext("Drafts")); } // Check to see which page we should be on if (isset($_GET['page']) && is_numeric($_GET['page'])) { $page = $_GET['page']; } else { if (isset($_POST['page']) && is_numeric($_POST['page'])) { $page = $_POST['page']; } else { $page = 1; } } if (isset($_GET['mid']) && is_numeric($_GET['mid'])) { $mid = $_GET['mid'] > 0 ? $_GET['mid'] : 0; } else { if (isset($_GET['pmid']) && is_numeric($_GET['pmid'])) { $mid = $_GET['pmid'] > 0 ? $_GET['pmid'] : 0; } else { if (isset($_POST['mid']) && is_numeric($_POST['mid'])) { $mid = $_POST['mid'] > 0 ? $_POST['mid'] : 0; } } } $folder = PM_FOLDER_INBOX; if (isset($_GET['folder'])) { if ($_GET['folder'] == PM_FOLDER_INBOX) { $folder = PM_FOLDER_INBOX; } else { if ($_GET['folder'] == PM_FOLDER_SENT) { $folder = PM_FOLDER_SENT; } else { if ($_GET['folder'] == PM_FOLDER_OUTBOX) { $folder = PM_FOLDER_OUTBOX; } else { if ($_GET['folder'] == PM_FOLDER_SAVED) { $folder = PM_FOLDER_SAVED; } else { if ($_GET['folder'] == PM_FOLDER_DRAFTS) { $folder = PM_FOLDER_DRAFTS; } } } } } } else { if (isset($_POST['folder'])) { if ($_POST['folder'] == PM_FOLDER_INBOX) { $folder = PM_FOLDER_INBOX; } else { if ($_POST['folder'] == PM_FOLDER_SENT) { $folder = PM_FOLDER_SENT; } else { if ($_POST['folder'] == PM_FOLDER_OUTBOX) { $folder = PM_FOLDER_OUTBOX; } else { if ($_POST['folder'] == PM_FOLDER_SAVED) { $folder = PM_FOLDER_SAVED; } else { if ($_POST['folder'] == PM_FOLDER_DRAFTS) { $folder = PM_FOLDER_DRAFTS; } } } } } } } if (isset($_GET['deletemsg']) && is_numeric($_GET['deletemsg']) && ($pm_message_array = pm_message_get($_GET['deletemsg']))) { $delete_mid = $_GET['deletemsg']; $pm_message_array['CONTENT'] = pm_get_content($delete_mid); if (isset($_POST['pm_delete_confirm'])) { if (pm_delete_message($delete_mid)) { header_redirect("lpm.php?webtag={$webtag}&folder={$folder}&deleted=true"); exit; } } else { if (isset($_POST['cancel'])) { header_redirect("lpm.php?webtag={$webtag}&folder={$folder}&mid={$delete_mid}"); exit; } } echo "<form method=\"post\" action=\"lpm.php?deletemsg={$delete_mid}&folder={$folder}\">"; light_pm_display($pm_message_array, $folder, true); echo "<div class=\"post_buttons\">"; echo light_form_submit("pm_delete_confirm", gettext("Delete")); echo light_form_submit("cancel", gettext("Cancel")); echo "</div>\n"; return; } if (isset($mid) && is_numeric($mid)) { if (!($folder = pm_message_get_folder($mid))) { light_html_display_error_msg(gettext("Message not found in selected folder. Check that it hasn't been moved or deleted.")); return; } if (!($pm_message_array = pm_message_get($mid))) { light_html_display_error_msg(gettext("Message not found. Check that it hasn't been deleted.")); return; } if (isset($_GET['message_sent'])) { light_html_display_success_msg(gettext("Message sent successfully.")); } else { if (isset($_GET['deleted'])) { light_html_display_success_msg(gettext("Successfully deleted selected messages")); } else { if (isset($_GET['message_saved'])) { light_html_display_success_msg(gettext("Message was successfully saved to 'Drafts' folder")); } } } $pm_message_array['CONTENT'] = pm_get_content($mid); light_pm_display($pm_message_array, $folder); echo "<a href=\"lpm.php?webtag={$webtag}&folder={$folder}\" class=\"folder_list_link\">", gettext("Back to folder list"), "</a>"; } else { if (isset($_GET['message_sent'])) { light_html_display_success_msg(gettext("Message sent successfully.")); } else { if (isset($_GET['deleted'])) { light_html_display_success_msg(gettext("Successfully deleted selected messages")); } else { if (isset($_GET['message_saved'])) { light_html_display_success_msg(gettext("Message was successfully saved to 'Drafts' folder")); } } } $pm_message_count_array = pm_get_folder_message_counts(); echo "<div id=\"folder_view\">\n"; echo "<form accept-charset=\"utf-8\" method=\"get\" action=\"lpm.php\">\n"; echo "<ul>\n"; echo "<li>", light_form_dropdown_array("folder", $pm_folder_names_array, $folder), "</li>\n"; echo "<li class=\"right_col\">", light_form_submit("go", gettext("Go!")), "</li>\n"; echo "</ul>\n"; echo "</form>\n"; echo "</div>\n"; if (isset($pm_message_count_array[$folder]) && is_numeric($pm_message_count_array[$folder])) { echo "<div class=\"folder\">"; echo " <h3>{$pm_folder_names_array[$folder]}</h3>\n"; echo " <div class=\"folder_inner\">\n"; echo " <div class=\"folder_info\">{$pm_message_count_array[$folder]} ", gettext("Messages"), "</div>\n"; if ($folder == PM_FOLDER_INBOX) { $pm_messages_array = pm_get_inbox(false, false, $page, 20); } else { if ($folder == PM_FOLDER_SENT) { $pm_messages_array = pm_get_sent(false, false, $page, 20); } else { if ($folder == PM_FOLDER_OUTBOX) { $pm_messages_array = pm_get_outbox(false, false, $page, 20); } else { if ($folder == PM_FOLDER_SAVED) { $pm_messages_array = pm_get_saved_items(false, false, $page, 20); } else { if ($folder == PM_FOLDER_DRAFTS) { $pm_messages_array = pm_get_drafts(false, false, $page, 20); } } } } } if (isset($pm_messages_array['message_array']) && sizeof($pm_messages_array['message_array']) > 0) { if ($page > 1) { echo "<div class=\"folder_pagination\"><a href=\"lpm.php?webtag={$webtag}&folder={$folder}&page=", $page - 1, "\">", gettext("Previous"), "</a></div>\n"; } echo "<ul>\n"; foreach ($pm_messages_array['message_array'] as $message) { if ($message['TYPE'] == PM_UNREAD) { echo "<li class=\"pm_unread\">"; } else { echo "<li class=\"pm_read\">"; } echo "<span class=\"pm_title\">"; echo "<a href=\"lpm.php?webtag={$webtag}&folder={$folder}&mid={$message['MID']}\">{$message['SUBJECT']}</a>"; echo "</span>"; echo "<span class=\"pm_time\">", format_time($message['CREATED']), "</span>"; echo "</li>\n"; } echo "</ul>\n"; $more_messages = $pm_message_count_array[$folder] - $page - 1; if ($more_messages > 0) { echo "<div class=\"folder_pagination\"><a href=\"lpm.php?webtag={$webtag}&folder={$folder}&page=", $page + 1, "\">", gettext("Next"), "</a></div>\n"; } } echo " </div>\n"; echo "</div>\n"; } echo "<a href=\"lpm_write.php?webtag={$webtag}\" class=\"pm_send_new\">", gettext("Send New PM"), "</a>\n"; // Fetch the free PM space and calculate it as a percentage. $pm_free_space = pm_get_free_space(); $pm_max_user_messages = forum_get_setting('pm_max_user_messages', null, 100); $pm_used_percent = 100 / $pm_max_user_messages * ($pm_max_user_messages - $pm_free_space); echo "<div class=\"pm_bar\">\n"; echo "<div class=\"pm_bar_inner\" style=\"width: {$pm_used_percent}%\"></div>\n"; echo "</div>\n"; echo "<div class=\"pm_folder_usage\">", sprintf(gettext("Your PM folders are %s full"), "{$pm_used_percent}%"), "</div>\n"; if (pm_auto_prune_enabled()) { light_html_display_warning_msg(gettext("PM Folder pruning is enabled!")); } } }
html_draw_bottom(); exit; } } if (isset($_POST['to_logon']) && strlen(trim($_POST['to_logon'])) > 0) { $to_logon_array = preg_split('/,\\s*/u', trim($_POST['to_logon'], ', ')); $to_logon_array = array_filter(array_map('trim', $to_logon_array), 'strlen'); foreach ($to_logon_array as $key => $recipient) { $to_logon = trim($recipient); unset($to_logon_array[$key]); if (($to_user = user_get_by_logon($to_logon)) !== false) { $peer_relationship = user_get_peer_relationship($to_user['UID'], $_SESSION['UID']); $to_logon_array[$to_user['UID']] = array('UID' => $to_user['UID'], 'LOGON' => $to_user['LOGON'], 'NICKNAME' => $to_user['NICKNAME']); if (($peer_relationship & USER_BLOCK_PM) == 0 && user_allow_pm($to_user['UID']) || session::check_perm(USER_PERM_FOLDER_MODERATE, 0)) { pm_user_prune_folders($_SESSION['UID']); if (pm_get_free_space($_SESSION['UID']) < sizeof($to_logon_array)) { $error_msg_array[] = gettext("You do not have enough free space to send this message."); $valid = false; } } else { $error_msg_array[] = sprintf(gettext("%s has opted out of receiving personal messages"), htmlentities_array($to_logon)); $valid = false; } } else { $error_msg_array[] = sprintf(gettext("User %s not found"), htmlentities_array($to_logon)); $valid = false; } } $to_logon = implode(', ', array_map('user_get_logon_callback', $to_logon_array)); if ($valid && sizeof($to_logon_array) > 10) { $error_msg_array[] = gettext("There is a limit of 10 recipients per message. Please amend your recipient list.");
function pm_get_message_count(&$pm_new_count, &$pm_outbox_count, &$pm_unread_count) { // Default the variables to return 0 even on error. $pm_new_count = 0; $pm_outbox_count = 0; $pm_unread_count = 0; // Connect to the database. if (!($db = db::get())) { return false; } // Check the user UID. if (($uid = session::get_value('UID')) === false) { return false; } // PM folder types we'll be using. $pm_unread = PM_UNREAD; $pm_outbox = PM_OUTBOX; $pm_sent_item = PM_SENT; // Get the user's free space. $pm_free_space = pm_get_free_space($uid); // Get a list of messages we have received. if ($messages_array = pm_get_new_messages($pm_free_space)) { // Convert the array keys into a comma separated list. $mid_list = implode(',', array_filter(array_keys($messages_array), 'is_numeric')); // Mark the selected messages as unread / received and make the // sent items visible to the sender. $sql = "UPDATE LOW_PRIORITY PM SET TYPE = '{$pm_unread}' WHERE MID in ({$mid_list}) "; $sql .= "AND TO_UID = '{$uid}'"; if (!($result = $db->query($sql))) { return false; } $sql = "UPDATE LOW_PRIORITY PM SET SMID = 0 WHERE SMID IN ({$mid_list}) "; $sql .= "AND TYPE = '{$pm_sent_item}' AND TO_UID = '{$uid}'"; if (!($result = $db->query($sql))) { return false; } // Number of new messages we've received for popup. $pm_new_count = sizeof($messages_array); } // Unread message count. $sql = "SELECT COUNT(MID) FROM PM WHERE (TYPE & {$pm_unread} > 0) "; $sql .= "AND TO_UID = '{$uid}'"; if (!($result = $db->query($sql))) { return false; } list($pm_unread_count) = $result->fetch_row(); // Check for any undelivered messages waiting for the user. $sql = "SELECT COUNT(MID) AS OUTBOX_COUNT FROM PM "; $sql .= "WHERE TYPE = '{$pm_outbox}' AND TO_UID = '{$uid}'"; if (!($result = $db->query($sql))) { return false; } list($pm_outbox_count) = $result->fetch_row(); return true; }
echo " </td>\n"; echo " </tr>\n"; echo " </table>\n"; echo " <table width=\"90%\" border=\"0\" cellpadding=\"2\" cellspacing=\"0\">\n"; echo " <tr>\n"; echo " <td align=\"left\">\n"; echo " <table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n"; echo " <tr>\n"; echo " <td align=\"left\" class=\"foldername\"><img src=\"", html_style_image('export.png'), "\" alt=\"", gettext("Export Private Messages"), "\" title=\"", gettext("Export Private Messages"), "\" /> <a href=\"pm_export.php?webtag={$webtag}\" title=\"", gettext("Export Private Messages"), "\">", gettext("Export Private Messages"), "</a></td>\n"; echo " </tr>\n"; echo " </table>\n"; echo " </td>\n"; echo " </tr>\n"; echo " </table>\n"; // Fetch the free PM space and calculate it as a percentage. $pm_free_space = pm_get_free_space(); $pm_max_user_messages = forum_get_setting('pm_max_user_messages', null, 100); $pm_used_percent = 100 / $pm_max_user_messages * ($pm_max_user_messages - $pm_free_space); echo " <br />\n"; echo " <table width=\"90%\" border=\"0\">\n"; echo " <tr>\n"; echo " <td align=\"left\">\n"; echo " <table cellpadding=\"0\" cellspacing=\"0\" width=\"75%\">\n"; echo " <tr>\n"; echo " <td align=\"left\">\n"; echo " <table cellpadding=\"0\" cellspacing=\"0\" class=\"pmbar_container\">\n"; echo " <tr>\n"; echo " <td align=\"left\" title=\"{$pm_used_percent}% ", gettext("Used"), "\">\n"; echo " <table cellpadding=\"0\" cellspacing=\"0\" class=\"pmbar\" style=\"width: {$pm_used_percent}%\">\n"; echo " <tr>\n"; echo " <td></td>\n";