echo form_submit('pm_save_messages', gettext("Save"), sprintf('title="%s"', gettext("Save Selected Messages"))), " "; } echo form_submit('pm_delete_messages', gettext("Delete")), " "; echo "</span></td>\n"; } else { echo " <td align=\"left\"> </td>\n"; } echo " </tr>\n"; echo " <tr>\n"; echo " <td align=\"left\"> </td>\n"; echo " </tr>\n"; echo " </table>\n"; if (isset($message_data) && is_array($message_data)) { $message_data['CONTENT'] = pm_get_content($mid); if ($current_folder == PM_FOLDER_INBOX && $message_data['TYPE'] == PM_UNREAD) { pm_mark_as_read($mid); } echo " <a name=\"message\"></a>\n"; echo " <br />\n"; echo " <table cellpadding=\"0\" cellspacing=\"0\" width=\"96%\">\n"; echo " <tr>\n"; echo " <td>\n"; echo " <table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\n"; echo " <tr>\n"; echo " <td align=\"left\">"; pm_display($message_data); echo " </td>\n"; echo " </tr>\n"; echo " </table>\n"; echo " </td>\n"; echo " </tr>\n";
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!")); } } }
function pm_message_get($mid) { if (!($db = db::get())) { return false; } if (($uid = session::get_value('UID')) === false) { return false; } if (!is_numeric($mid)) { return false; } $pm_inbox_items = PM_INBOX_ITEMS; $pm_sent_items = PM_SENT_ITEMS; $pm_outbox_items = PM_OUTBOX_ITEMS; $pm_saved_out = PM_SAVED_OUT; $pm_saved_in = PM_SAVED_IN; $pm_draft_items = PM_DRAFT_ITEMS; $sql = "SELECT PM.MID, PM.TYPE, PM.FROM_UID, PM.TO_UID, PM.SUBJECT, "; $sql .= "PM.RECIPIENTS, UNIX_TIMESTAMP(PM.CREATED) AS CREATED, FUSER.LOGON AS FLOGON, "; $sql .= "TUSER.LOGON AS TLOGON, FUSER.NICKNAME AS FNICK, "; $sql .= "TUSER.NICKNAME AS TNICK FROM PM PM "; $sql .= "LEFT JOIN USER FUSER ON (PM.FROM_UID = FUSER.UID) "; $sql .= "LEFT JOIN USER TUSER ON (PM.TO_UID = TUSER.UID) "; $sql .= "WHERE (((PM.TYPE & {$pm_inbox_items} > 0) AND PM.TO_UID = '{$uid}') "; $sql .= "OR ((PM.TYPE & {$pm_sent_items} > 0) AND PM.FROM_UID = '{$uid}' AND PM.SMID = 0) "; $sql .= "OR ((PM.TYPE & {$pm_outbox_items} > 0) AND PM.FROM_UID = '{$uid}') "; $sql .= "OR ((PM.TYPE & {$pm_saved_out} > 0) AND PM.FROM_UID = '{$uid}') "; $sql .= "OR ((PM.TYPE & {$pm_saved_in} > 0) AND PM.TO_UID = '{$uid}') "; $sql .= "OR ((PM.TYPE & {$pm_draft_items} > 0) AND PM.FROM_UID = '{$uid}')) "; $sql .= "AND PM.MID = '{$mid}' LIMIT 0, 1"; if (!($result = $db->query($sql))) { return false; } if ($result->num_rows == 0) { return false; } if (!($pm_message_array = $result->fetch_assoc())) { return false; } if (!($folder = pm_message_get_folder($mid, $pm_message_array['TYPE']))) { return false; } if ($pm_message_array['TO_UID'] == $uid && $pm_message_array['TYPE'] == PM_UNREAD && $folder == PM_FOLDER_INBOX) { pm_mark_as_read($mid); } if ($aid = pm_has_attachments($mid)) { $pm_message_array['AID'] = $aid; } return $pm_message_array; }