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!")); } } }
} 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; if (!($message_folder = pm_message_get_folder($mid))) { $message_folder = PM_FOLDER_INBOX; } } else { if (isset($_POST['mid']) && is_numeric($_POST['mid'])) { $mid = $_POST['mid'] > 0 ? $_POST['mid'] : 0; if (!($message_folder = pm_message_get_folder($mid))) { $message_folder = PM_FOLDER_INBOX; } } else { $mid = 0; $message_folder = PM_FOLDER_INBOX; } } $current_folder = $message_folder; 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 {
function pm_export_csv($messages_array, &$zip_file, $options_array = array()) { if (!is_array($messages_array)) { return false; } if (!is_object($zip_file)) { return false; } if (!is_array($options_array)) { $options_array = array(); } if (!isset($options_array['PM_EXPORT_FILE'])) { $options_array['PM_EXPORT_FILE'] = session::get_value('PM_EXPORT_FILE'); } if (!isset($options_array['PM_EXPORT_ATTACHMENTS'])) { $options_array['PM_EXPORT_ATTACHMENTS'] = session::get_value('PM_EXPORT_ATTACHMENTS'); } if (!isset($options_array['PM_EXPORT_WORDFILTER'])) { $options_array['PM_EXPORT_WORDFILTER'] = session::get_value('PM_EXPORT_WORDFILTER'); } if (sizeof($messages_array) == 0) { return false; } $pm_csv_export = fopen('php://temp', 'w'); $pm_csv_header = array('MID', 'TYPE', 'FROM_UID', 'TO_UID', 'SUBJECT', 'RECIPIENTS', 'CREATED', 'FLOGON', 'TLOGON', 'FNICK', 'TNICK', 'FOLDER', 'CONTENT'); if (!fputcsv($pm_csv_export, $pm_csv_header)) { return false; } foreach ($messages_array as $mid) { if (!($message = pm_message_get($mid))) { return false; } if (isset($message['AID']) && $options_array['PM_EXPORT_ATTACHMENTS'] == 'Y') { pm_export_attachments($message['AID'], $message['FROM_UID'], $zip_file); } $message['FOLDER'] = pm_message_get_folder($message['MID']); $message['CONTENT'] = preg_replace("[\r\n|\r|\n]", '\\n', pm_get_content($message['MID'])); $message['CREATED'] = date('Y-m-d H:i:s', $message['CREATED']); if ($options_array['PM_EXPORT_WORDFILTER'] == 'Y') { $message = array_map('pm_export_word_filter_apply', $message); } unset($message['AID']); if (!fputcsv($pm_csv_export, $message)) { return false; } if ($options_array['PM_EXPORT_FILE'] == PM_EXPORT_MANY) { rewind($pm_csv_export); $pm_csv_contents = ''; while (!feof($pm_csv_export)) { $pm_csv_contents .= fgets($pm_csv_export); } $zip_file->add_file($pm_csv_contents, sprintf("message_%s.csv", $message['MID'])); fclose($pm_csv_export); $pm_csv_export = fopen('php://temp', 'r+'); if (!fputcsv($pm_csv_export, $pm_csv_header)) { return false; } } } if ($options_array['PM_EXPORT_FILE'] == PM_EXPORT_SINGLE) { rewind($pm_csv_export); $pm_csv_contents = ''; while (!feof($pm_csv_export)) { $pm_csv_contents .= fgets($pm_csv_export); } $zip_file->add_file($pm_csv_contents, 'messages.csv'); } fclose($pm_csv_export); return true; }