Beehive PHP Cross Reference Discussion Forums

Source: /lthread_list.php - 189 lines - 6250 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  'lboot.php';
  26  
  27  // Required includes
  28  require_once  BH_INCLUDE_PATH . 'cache.inc.php';
  29  require_once  BH_INCLUDE_PATH . 'constants.inc.php';
  30  require_once  BH_INCLUDE_PATH . 'folder.inc.php';
  31  require_once  BH_INCLUDE_PATH . 'header.inc.php';
  32  require_once  BH_INCLUDE_PATH . 'html.inc.php';
  33  require_once  BH_INCLUDE_PATH . 'light.inc.php';
  34  require_once  BH_INCLUDE_PATH . 'session.inc.php';
  35  require_once  BH_INCLUDE_PATH . 'threads.inc.php';
  36  // End Required includes
  37  
  38  // Check thread list cache
  39  cache_check_thread_list();
  40  
  41  // Get the folders the user can see.
  42  if (!($available_folders = folder_get_available_array())) {
  43      $available_folders = array();
  44  }
  45  
  46  // Are we viewing a specific folder only?
  47  if (isset($_REQUEST['folder']) && in_array($_REQUEST['folder'], $available_folders)) {
  48      $folder = $_REQUEST['folder'];
  49  } else {
  50      $folder = false;
  51  }
  52  
  53  // View offset.
  54  if (isset($_REQUEST['page']) && is_numeric($_REQUEST['page'])) {
  55      $page = $_REQUEST['page'];
  56  } else {
  57      $page = 1;
  58  }
  59  
  60  // View mode
  61  if (isset($_REQUEST['mode']) && is_numeric($_REQUEST['mode'])) {
  62      $mode = $_REQUEST['mode'];
  63  }
  64  
  65  // Check that required variables are set
  66  if (!session::logged_in()) {
  67  
  68      // non-logged in users can only display "All" threads
  69      // or those in the past x days, since the other options
  70      // would be impossible
  71      if (!isset($mode) || ($mode != ALL_DISCUSSIONS && $mode != TODAYS_DISCUSSIONS && $mode != TWO_DAYS_BACK && $mode != SEVEN_DAYS_BACK)) {
  72          $mode = ALL_DISCUSSIONS;
  73      }
  74  
  75  } else {
  76  
  77      $threads_any_unread = threads_any_unread();
  78  
  79      if (isset($mode) && is_numeric($mode)) {
  80  
  81          $_SESSION['THREAD_MODE'] = $mode;
  82  
  83          if ($mode == SEARCH_RESULTS) {
  84  
  85              header_redirect("lsearch.php?webtag=$webtag&page=1");
  86              exit;
  87          }
  88  
  89      } else {
  90  
  91          if (isset($_SESSION['THREAD_MODE']) && is_numeric($_SESSION['THREAD_MODE']) && ($_SESSION['THREAD_MODE'] != SEARCH_RESULTS)) {
  92              $mode = $_SESSION['THREAD_MODE'];
  93          } else {
  94              $mode = UNREAD_DISCUSSIONS;
  95          }
  96  
  97          if ($mode == UNREAD_DISCUSSIONS && !$threads_any_unread) {
  98              $mode = ALL_DISCUSSIONS;
  99          }
 100      }
 101  
 102      if (isset($_REQUEST['mark_read_submit'])) {
 103  
 104          if (isset($_REQUEST['mark_read_confirm']) && ($_REQUEST['mark_read_confirm'] == 'Y')) {
 105  
 106              if ($_REQUEST['mark_read_type'] == THREAD_MARK_READ_VISIBLE) {
 107  
 108                  if (isset($_REQUEST['mark_read_threads']) && strlen(trim($_REQUEST['mark_read_threads'])) > 0) {
 109  
 110                      $thread_data = array();
 111  
 112                      $mark_read_threads = trim($_REQUEST['mark_read_threads']);
 113  
 114                      $mark_read_threads_array = array_filter(explode(',', $mark_read_threads), 'is_numeric');
 115  
 116                      threads_get_unread_data($thread_data, $mark_read_threads_array);
 117  
 118                      if (threads_mark_read($thread_data)) {
 119  
 120                          header_redirect("lthread_list.php?webtag=$webtag&mode=$mode&folder=$folder&mark_read_success=true");
 121                          exit;
 122  
 123                      } else {
 124  
 125                          $error_msg_array[] = gettext("Failed to mark selected threads as read");
 126                          $valid = false;
 127                      }
 128                  }
 129  
 130              } else if ($_REQUEST['mark_read_type'] == THREAD_MARK_READ_ALL) {
 131  
 132                  if (threads_mark_all_read()) {
 133  
 134                      header_redirect("lthread_list.php?webtag=$webtag&mode=$mode&folder=$folder&mark_read_success=true");
 135                      exit;
 136  
 137                  } else {
 138  
 139                      $error_msg_array[] = gettext("Failed to mark selected threads as read");
 140                      $valid = false;
 141                  }
 142  
 143              } else if ($_REQUEST['mark_read_type'] == THREAD_MARK_READ_FIFTY) {
 144  
 145                  if (threads_mark_50_read()) {
 146  
 147                      header_redirect("lthread_list.php?webtag=$webtag&mode=$mode&folder=$folder&mark_read_success=true");
 148                      exit;
 149  
 150                  } else {
 151  
 152                      $error_msg_array[] = gettext("Failed to mark selected threads as read");
 153                      $valid = false;
 154                  }
 155  
 156              } else if (($_REQUEST['mark_read_type'] == THREAD_MARK_READ_FOLDER) && (isset($folder) && is_numeric($folder))) {
 157  
 158                  if (threads_mark_folder_read($folder)) {
 159  
 160                      header_redirect("lthread_list.php?webtag=$webtag&mode=$mode&folder=$folder&mark_read_success=true");
 161                      exit;
 162  
 163                  } else {
 164  
 165                      $error_msg_array[] = gettext("Failed to mark selected threads as read");
 166                      $valid = false;
 167                  }
 168              }
 169  
 170          } else {
 171  
 172              unset($_REQUEST['mark_read_submit'], $_REQUEST['mark_read_confirm']);
 173  
 174              light_html_draw_top();
 175              light_html_display_msg(gettext("Confirm"), gettext("Are you sure you want to mark the selected threads as read?"), 'lthread_list.php', 'post', array(
 176                  'mark_read_submit' => gettext("Confirm"),
 177                  'cancel' => gettext("Cancel")
 178              ), array_merge($_REQUEST, array('mark_read_confirm' => 'Y')));
 179              light_html_draw_bottom();
 180              exit;
 181          }
 182      }
 183  }
 184  
 185  light_html_draw_top('js/thread_list.js');
 186  
 187  light_draw_thread_list($mode, $folder, $page);
 188  
 189  light_html_draw_bottom();

title

Description

title

Description

title

Description

title

title

Body