Beehive PHP Cross Reference Discussion Forums

Source: /pm_export.php - 225 lines - 9007 bytes - Summary - Text - Print

   1  <?php
   2  
   3  /*======================================================================
   4  Copyright Project Beehive Forum 2002
   5  
   6  This file is part of Beehive Forum.
   7  
   8  Beehive Forum is free software; you can redistribute it and/or modify
   9  it under the terms of the GNU General Public License as published by
  10  the Free Software Foundation; either version 3 of the License, or
  11  (at your option) any later version.
  12  
  13  Beehive Forum is distributed in the hope that it will be useful,
  14  but WITHOUT ANY WARRANTY; without even the implied warranty of
  15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16  GNU General Public License for more details.
  17  
  18  You should have received a copy of the GNU General Public License
  19  along with Beehive; if not, write to the Free Software
  20  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
  21  USA
  22  ======================================================================*/
  23  
  24  // Bootstrap
  25  require_once  'boot.php';
  26  
  27  // Required includes
  28  require_once  BH_INCLUDE_PATH . 'constants.inc.php';
  29  require_once  BH_INCLUDE_PATH . 'form.inc.php';
  30  require_once  BH_INCLUDE_PATH . 'format.inc.php';
  31  require_once  BH_INCLUDE_PATH . 'html.inc.php';
  32  require_once  BH_INCLUDE_PATH . 'pm.inc.php';
  33  require_once  BH_INCLUDE_PATH . 'session.inc.php';
  34  require_once  BH_INCLUDE_PATH . 'user.inc.php';
  35  // End Required includes
  36  
  37  // Check we're logged in correctly
  38  if (!session::logged_in()) {
  39      html_guest_error();
  40  }
  41  
  42  // Array to store error messages.
  43  $error_msg_array = array();
  44  
  45  // Check that PM system is enabled
  46  pm_enabled();
  47  
  48  // Variables to hold message counts
  49  $pm_new_count = 0;
  50  $pm_outbox_count = 0;
  51  $pm_unread_count = 0;
  52  
  53  // Check for new PMs
  54  pm_get_message_count($pm_new_count, $pm_outbox_count, $pm_unread_count);
  55  
  56  // Get custom folder names array.
  57  if (!$pm_folder_names_array = pm_get_folder_names(false)) {
  58  
  59      $pm_folder_names_array = array(
  60          PM_FOLDER_INBOX => gettext("Inbox"),
  61          PM_FOLDER_SENT => gettext("Sent Items"),
  62          PM_FOLDER_OUTBOX => gettext("Outbox"),
  63          PM_FOLDER_SAVED => gettext("Saved Items"),
  64          PM_FOLDER_DRAFTS => gettext("Drafts")
  65      );
  66  }
  67  
  68  // Submit code starts here.
  69  if (isset($_POST['export'])) {
  70  
  71      $options_array = array();
  72  
  73      $pm_folders_array = array();
  74  
  75      if (isset($_POST['pm_folders_array']) && is_array($_POST['pm_folders_array'])) {
  76  
  77          foreach ($_POST['pm_folders_array'] as $folder => $export) {
  78  
  79              if (isset($pm_folder_names_array[$folder]) && ($export == 'Y')) {
  80  
  81                  $pm_folders_array[] = $folder;
  82              }
  83          }
  84      }
  85  
  86      if (isset($_POST['pm_export_file']) && in_array($_POST['pm_export_file'], range(0, 2))) {
  87          $options_array['PM_EXPORT_FILE'] = $_POST['pm_export_file'];
  88      } else {
  89          $options_array['PM_EXPORT_FILE'] = 0;
  90      }
  91  
  92      if (isset($_POST['pm_export_type']) && in_array($_POST['pm_export_type'], range(0, 1))) {
  93          $options_array['PM_EXPORT_TYPE'] = $_POST['pm_export_type'];
  94      } else {
  95          $options_array['PM_EXPORT_TYPE'] = 0;
  96      }
  97  
  98      if (isset($_POST['pm_export_attachments']) && $_POST['pm_export_attachments'] == "Y") {
  99          $options_array['PM_EXPORT_ATTACHMENTS'] = "Y";
 100      } else {
 101          $options_array['PM_EXPORT_ATTACHMENTS'] = "N";
 102      }
 103  
 104      if (isset($_POST['pm_export_wordfilter']) && $_POST['pm_export_wordfilter'] == "Y") {
 105          $options_array['PM_EXPORT_WORDFILTER'] = "Y";
 106      } else {
 107          $options_array['PM_EXPORT_WORDFILTER'] = "N";
 108      }
 109  
 110      if (sizeof($pm_folders_array) > 0) {
 111  
 112          pm_export_folders($pm_folders_array, $options_array);
 113  
 114      } else {
 115  
 116          $error_msg_array[] = gettext("You must select some folders to export");
 117      }
 118  }
 119  
 120  // Get User Prefs
 121  $user_prefs = user_get_prefs($_SESSION['UID']);
 122  
 123  // Start output here
 124  html_draw_top(sprintf("title=%s", gettext("Export Private Messages")), "js/emoticons.js", 'class=window_title');
 125  
 126  echo "<h1>", gettext("Export Private Messages"), "</h1>\n";
 127  
 128  if (isset($error_msg_array) && sizeof($error_msg_array) > 0) {
 129  
 130      html_display_error_array($error_msg_array, '600', 'left');
 131  
 132  } else if (isset($_GET['updated'])) {
 133  
 134      html_display_success_msg(gettext("Preferences were successfully updated."), '600', 'left');
 135  }
 136  
 137  echo "<br />\n";
 138  echo "<form accept-charset=\"utf-8\" name=\"prefs\" action=\"pm_export.php\" method=\"post\" target=\"_self\">\n";
 139  echo "  ", form_input_hidden('webtag', htmlentities_array($webtag)), "\n";
 140  echo "  <table cellpadding=\"0\" cellspacing=\"0\" width=\"600\">\n";
 141  echo "    <tr>\n";
 142  echo "      <td align=\"left\">\n";
 143  echo "        <table class=\"box\" width=\"100%\">\n";
 144  echo "          <tr>\n";
 145  echo "            <td align=\"left\" class=\"posthead\">\n";
 146  echo "              <table class=\"posthead\" width=\"100%\">\n";
 147  echo "                <tr>\n";
 148  echo "                  <td align=\"left\" class=\"subhead\">", gettext("Select folders to export"), "</td>\n";
 149  echo "                </tr>\n";
 150  echo "                <tr>\n";
 151  echo "                  <td align=\"left\">\n";
 152  
 153  $pm_message_count_array = pm_get_folder_message_counts(false);
 154  
 155  foreach ($pm_folder_names_array as $folder_type => $folder_name) {
 156  
 157      if (isset($pm_message_count_array[$folder_type]) && is_numeric($pm_message_count_array[$folder_type])) {
 158  
 159          echo "  <table width=\"90%\" border=\"0\" cellpadding=\"2\" cellspacing=\"0\">\n";
 160          echo "    <tr>\n";
 161          echo "      <td align=\"left\">\n";
 162          echo "        <table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n";
 163          echo "          <tr>\n";
 164          echo "            <td align=\"left\" class=\"foldername\">", form_checkbox("pm_folders_array[$folder_type]", "Y", $folder_name), "&nbsp;<span class=\"pm_message_count\">({$pm_message_count_array[$folder_type]})</span></td>\n";
 165          echo "          </tr>\n";
 166          echo "        </table>\n";
 167          echo "      </td>\n";
 168          echo "    </tr>\n";
 169          echo "  </table>\n";
 170      }
 171  }
 172  
 173  echo "                  </td>\n";
 174  echo "                </tr>\n";
 175  echo "                <tr>\n";
 176  echo "                  <td align=\"left\" colspan=\"2\">&nbsp;</td>\n";
 177  echo "                </tr>\n";
 178  echo "              </table>\n";
 179  echo "            </td>\n";
 180  echo "          </tr>\n";
 181  echo "        </table>\n";
 182  echo "        <br />\n";
 183  echo "        <table class=\"box\" width=\"100%\">\n";
 184  echo "          <tr>\n";
 185  echo "            <td align=\"left\" class=\"posthead\">\n";
 186  echo "              <table class=\"posthead\" width=\"100%\">\n";
 187  echo "                <tr>\n";
 188  echo "                  <td align=\"left\" colspan=\"3\" class=\"subhead\">", gettext("Private Message Export Options"), "</td>\n";
 189  echo "                </tr>\n";
 190  echo "                <tr>\n";
 191  echo "                  <td align=\"left\" rowspan=\"7\" width=\"1%\">&nbsp;</td>\n";
 192  echo "                </tr>\n";
 193  echo "                <tr>\n";
 194  echo "                  <td align=\"left\" width=\"250\" style=\"white-space: nowrap\">", gettext("Export as type"), ":</td>\n";
 195  echo "                  <td align=\"left\">", form_dropdown_array("pm_export_type", array(gettext("HTML"), gettext("XML")), (isset($user_prefs['PM_EXPORT_TYPE']) && is_numeric($user_prefs['PM_EXPORT_TYPE'])) ? $user_prefs['PM_EXPORT_TYPE'] : 0), "</td>\n";
 196  echo "                </tr>\n";
 197  echo "                <tr>\n";
 198  echo "                  <td align=\"left\" width=\"250\" style=\"white-space: nowrap\">", gettext("Export messages as"), ":</td>\n";
 199  echo "                  <td align=\"left\">", form_dropdown_array("pm_export_file", array(gettext("One file for all messages"), gettext("One file per message")), (isset($user_prefs['PM_EXPORT_FILE']) && is_numeric($user_prefs['PM_EXPORT_FILE'])) ? $user_prefs['PM_EXPORT_FILE'] : 0), "</td>\n";
 200  echo "                </tr>\n";
 201  echo "                <tr>\n";
 202  echo "                  <td align=\"left\" colspan=\"2\" style=\"white-space: nowrap\">", form_checkbox("pm_export_attachments", "Y", gettext("Export attachments"), (isset($user_prefs['PM_EXPORT_ATTACHMENTS']) && $user_prefs['PM_EXPORT_ATTACHMENTS'] == "Y") ? true : false), "</td>\n";
 203  echo "                </tr>\n";
 204  echo "                <tr>\n";
 205  echo "                  <td align=\"left\" colspan=\"2\" style=\"white-space: nowrap\">", form_checkbox("pm_export_wordfilter", "Y", gettext("Apply word filter to messages"), (isset($user_prefs['PM_EXPORT_WORDFILTER']) && $user_prefs['PM_EXPORT_WORDFILTER'] == "Y") ? true : false), "</td>\n";
 206  echo "                </tr>\n";
 207  echo "                <tr>\n";
 208  echo "                  <td align=\"left\" colspan=\"2\">&nbsp;</td>\n";
 209  echo "                </tr>\n";
 210  echo "              </table>\n";
 211  echo "            </td>\n";
 212  echo "          </tr>\n";
 213  echo "        </table>\n";
 214  echo "      </td>\n";
 215  echo "    </tr>\n";
 216  echo "    <tr>\n";
 217  echo "      <td align=\"left\">&nbsp;</td>\n";
 218  echo "    </tr>\n";
 219  echo "    <tr>\n";
 220  echo "      <td align=\"center\">", form_submit("export", gettext("Export")), "</td>\n";
 221  echo "    </tr>\n";
 222  echo "  </table>\n";
 223  echo "</form>\n";
 224  
 225  html_draw_bottom();

title

Description

title

Description

title

Description

title

title

Body