Beehive PHP Cross Reference Discussion Forums

Source: /edit_subscriptions.php - 277 lines - 10745 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 . 'header.inc.php';
  32  require_once  BH_INCLUDE_PATH . 'html.inc.php';
  33  require_once  BH_INCLUDE_PATH . 'session.inc.php';
  34  require_once  BH_INCLUDE_PATH . 'thread.inc.php';
  35  require_once  BH_INCLUDE_PATH . 'threads.inc.php';
  36  require_once  BH_INCLUDE_PATH . 'word_filter.inc.php';
  37  // End Required includes
  38  
  39  // Check we're logged in correctly
  40  if (!session::logged_in()) {
  41      html_guest_error();
  42  }
  43  
  44  $error_msg_array = array();
  45  
  46  if (isset($_POST['save'])) {
  47  
  48      $valid = true;
  49  
  50      if (isset($_POST['set_interest']) && is_array($_POST['set_interest'])) {
  51  
  52          foreach ($_POST['set_interest'] as $thread) {
  53  
  54              if ($valid && is_numeric($thread)) {
  55  
  56                  if (!thread_set_interest($thread, 0)) {
  57  
  58                      $thread_title = thread_get_title($thread);
  59                      $error_msg_array[] = sprintf(gettext("Could not update interest on thread '%s'"), $thread_title);
  60                      $valid = false;
  61                  }
  62              }
  63          }
  64  
  65          if ($valid) {
  66  
  67              header_redirect("edit_subscriptions.php?webtag=$webtag&updated=true");
  68              exit;
  69          }
  70      }
  71  }
  72  
  73  if (isset($_GET['page']) && is_numeric($_GET['page'])) {
  74      $page = $_GET['page'];
  75  } else if (isset($_POST['page']) && is_numeric($_POST['page'])) {
  76      $page = $_POST['page'];
  77  } else {
  78      $page = 1;
  79  }
  80  
  81  if (isset($_GET['view']) && is_numeric($_GET['view'])) {
  82      $view = $_GET['view'];
  83  } else if (isset($_POST['view']) && is_numeric($_POST['view'])) {
  84      $view = $_POST['view'];
  85  } else {
  86      $view = THREAD_INTERESTED;
  87  }
  88  
  89  if (isset($_POST['search_keyword']) && strlen(trim($_POST['search_keyword'])) > 0) {
  90  
  91      $page = 1;
  92  
  93      $search_keyword = trim($_POST['search_keyword']);
  94  
  95  } else if (isset($_GET['search_keyword']) && strlen(trim($_GET['search_keyword'])) > 0) {
  96  
  97      $search_keyword = trim($_GET['search_keyword']);
  98  
  99  } else {
 100  
 101      $search_keyword = '';
 102  }
 103  
 104  if (isset($_POST['clear'])) {
 105      $search_keyword = "";
 106  }
 107  
 108  $header_text_array = array(
 109      THREAD_IGNORED => gettext("Ignored Threads"),
 110      THREAD_INTERESTED => gettext("High Interest Threads"),
 111      THREAD_SUBSCRIBED => gettext("Subscribed Threads")
 112  );
 113  
 114  $interest_level_array = array(
 115      THREAD_IGNORED => gettext("Ignored"),
 116      THREAD_INTERESTED => gettext("Interested"),
 117      THREAD_SUBSCRIBED => gettext("Subscribe")
 118  );
 119  
 120  if (isset($search_keyword) && strlen(trim($search_keyword)) > 0) {
 121      $thread_subscriptions = threads_search_user_subscriptions($search_keyword, $view, $page);
 122  } else {
 123      $thread_subscriptions = threads_get_user_subscriptions($view, $page);
 124  }
 125  
 126  html_draw_top(sprintf('title=%s', gettext("My Controls - Thread Subscriptions")), "js/edit_subscriptions.js", 'class=window_title');
 127  
 128  echo "<h1>", gettext("Thread Subscriptions"), "<img src=\"", html_style_image('separator.png'), "\" alt=\"\" border=\"0\" />{$header_text_array[$view]}</h1>\n";
 129  
 130  if (isset($error_msg_array) && sizeof($error_msg_array) > 0) {
 131  
 132      html_display_error_array($error_msg_array, '700', 'left');
 133  
 134  } else if (isset($_GET['updated'])) {
 135  
 136      html_display_success_msg(gettext("Thread interests updated successfully"), '700', 'left');
 137  
 138  } else if (sizeof($thread_subscriptions['thread_array']) < 1) {
 139  
 140      if (isset($search_keyword) && strlen(trim($search_keyword)) > 0) {
 141  
 142          html_display_warning_msg(gettext("Search Returned No Results"), '700', 'left');
 143  
 144      } else if ($view == THREAD_IGNORED) {
 145  
 146          html_display_warning_msg(gettext("You are not ignoring any threads."), '700', 'left');
 147  
 148      } else if ($view == THREAD_INTERESTED) {
 149  
 150          html_display_warning_msg(gettext("You have no high interest threads."), '700', 'left');
 151  
 152      } else {
 153  
 154          html_display_warning_msg(gettext("You are not subscribed to any threads."), '700', 'left');
 155      }
 156  }
 157  
 158  echo "<br />\n";
 159  echo "<form accept-charset=\"utf-8\" name=\"subscriptions\" action=\"edit_subscriptions.php\" method=\"post\" target=\"_self\">\n";
 160  echo "  ", form_input_hidden('webtag', htmlentities_array($webtag)), "\n";
 161  echo "  ", form_input_hidden("page", htmlentities_array($page)), "\n";
 162  echo "  ", form_input_hidden("search_keyword", htmlentities_array($search_keyword)), "\n";
 163  echo "  <table cellpadding=\"0\" cellspacing=\"0\" width=\"700\">\n";
 164  echo "    <tr>\n";
 165  echo "      <td align=\"left\" colspan=\"3\">\n";
 166  echo "        <table class=\"box\" width=\"100%\">\n";
 167  echo "          <tr>\n";
 168  echo "            <td align=\"left\" class=\"posthead\">\n";
 169  echo "              <table class=\"posthead\" width=\"100%\">\n";
 170  
 171  if (sizeof($thread_subscriptions['thread_array']) > 0) {
 172  
 173      echo "                <tr>\n";
 174      echo "                  <td align=\"center\" class=\"subhead_checkbox\" width=\"1%\">", form_checkbox("toggle_all", "toggle_all"), "</td>\n";
 175      echo "                  <td align=\"left\" class=\"subhead\" width=\"450\">", gettext("Thread title"), "</td>\n";
 176      echo "                  <td align=\"center\" class=\"subhead\" width=\"150\">", gettext("Current Interest"), "</td>\n";
 177      echo "                </tr>\n";
 178  
 179      foreach ($thread_subscriptions['thread_array'] as $thread) {
 180  
 181          echo "                <tr>\n";
 182          echo "                  <td align=\"center\" style=\"white-space: nowrap\">", form_checkbox('set_interest[]', $thread['TID'], null), "</td>\n";
 183          echo "                  <td align=\"left\"><a href=\"index.php?webtag=$webtag&amp;msg={$thread['TID']}.1\" target=\"_blank\">", word_filter_add_ob_tags($thread['TITLE'], true), "</a></td>\n";
 184  
 185          if (isset($interest_level_array[$thread['INTEREST']])) {
 186              echo "                  <td align=\"center\">{$interest_level_array[$thread['INTEREST']]}</td>\n";
 187          } else {
 188              echo "                  <td align=\"center\">", gettext("none"), "</td>\n";
 189          }
 190  
 191          echo "                </tr>\n";
 192      }
 193  
 194  } else {
 195  
 196      echo "                <tr>\n";
 197      echo "                  <td align=\"left\" class=\"subhead\" width=\"20\">&nbsp;</td>\n";
 198      echo "                  <td align=\"left\" class=\"subhead\" width=\"450\">", gettext("Thread title"), "</td>\n";
 199      echo "                  <td align=\"center\" class=\"subhead\" width=\"150\">", gettext("Current Interest"), "</td>\n";
 200      echo "                </tr>\n";
 201  }
 202  
 203  echo "                <tr>\n";
 204  echo "                  <td align=\"left\">&nbsp;</td>\n";
 205  echo "                </tr>\n";
 206  echo "              </table>\n";
 207  echo "            </td>\n";
 208  echo "          </tr>\n";
 209  echo "        </table>\n";
 210  echo "      </td>\n";
 211  echo "    </tr>\n";
 212  echo "    <tr>\n";
 213  echo "      <td align=\"left\">&nbsp;</td>\n";
 214  echo "    </tr>\n";
 215  echo "    <tr>\n";
 216  echo "      <td align=\"left\" width=\"33%\">&nbsp;</td>\n";
 217  echo "      <td class=\"postbody\" align=\"center\">";
 218  
 219  html_page_links("edit_subscriptions.php?webtag=$webtag&search_keyword=$search_keyword&view=$view", $page, $thread_subscriptions['thread_count'], 20, "page");
 220  
 221  echo "      </td>\n";
 222  echo "      <td align=\"right\" width=\"33%\">", gettext("View"), ":&nbsp;", form_dropdown_array('view', array(THREAD_IGNORED => gettext("Ignored"), THREAD_INTERESTED => gettext("Interested"), THREAD_SUBSCRIBED => gettext("Subscribed")), $view), "&nbsp;", form_submit("view_submit", gettext("Go!")), "</td>\n";
 223  echo "    </tr>\n";
 224  
 225  if (sizeof($thread_subscriptions['thread_array']) > 0) {
 226  
 227      echo "    <tr>\n";
 228      echo "      <td align=\"left\">&nbsp;</td>\n";
 229      echo "    </tr>\n";
 230      echo "    <tr>\n";
 231      echo "      <td align=\"center\" colspan=\"3\">", form_submit("save", gettext("Reset Selected")), "</td>\n";
 232      echo "    </tr>\n";
 233  }
 234  
 235  echo "  </table>\n";
 236  echo "</form>\n";
 237  echo "<br />\n";
 238  echo "<form accept-charset=\"utf-8\" method=\"post\" action=\"edit_subscriptions.php\" target=\"_self\">\n";
 239  echo "  ", form_input_hidden('webtag', htmlentities_array($webtag)), "\n";
 240  echo "  ", form_input_hidden("page", htmlentities_array($page)), "\n";
 241  echo "  ", form_input_hidden("view", htmlentities_array($view)), "\n";
 242  echo "  <table cellpadding=\"0\" cellspacing=\"0\" width=\"700\">\n";
 243  echo "    <tr>\n";
 244  echo "      <td align=\"left\" class=\"posthead\">\n";
 245  echo "        <table class=\"box\" width=\"100%\">\n";
 246  echo "          <tr>\n";
 247  echo "            <td align=\"left\" class=\"posthead\">\n";
 248  echo "              <table class=\"posthead\" width=\"100%\">\n";
 249  echo "                <tr>\n";
 250  echo "                  <td class=\"subhead\" align=\"left\">", gettext("Search"), "</td>\n";
 251  echo "                </tr>\n";
 252  echo "              </table>\n";
 253  echo "              <table class=\"posthead\" width=\"100%\">\n";
 254  echo "                <tr>\n";
 255  echo "                  <td align=\"center\">\n";
 256  echo "                    <table class=\"posthead\" width=\"95%\">\n";
 257  echo "                      <tr>\n";
 258  echo "                        <td class=\"posthead\" align=\"left\">\n";
 259  echo "                          ", gettext("Thread title"), ": ", form_input_text("search_keyword", isset($search_keyword) ? htmlentities_array($search_keyword) : "", 30, 64), " ", form_submit('search', gettext("Search")), "&nbsp;", form_submit('clear', gettext("Clear")), "\n";
 260  echo "                        </td>\n";
 261  echo "                      </tr>\n";
 262  echo "                      <tr>\n";
 263  echo "                        <td align=\"left\">&nbsp;</td>\n";
 264  echo "                      </tr>\n";
 265  echo "                    </table>\n";
 266  echo "                  </td>\n";
 267  echo "                </tr>\n";
 268  echo "              </table>\n";
 269  echo "            </td>\n";
 270  echo "          </tr>\n";
 271  echo "        </table>\n";
 272  echo "      </td>\n";
 273  echo "    </tr>\n";
 274  echo "  </table>\n";
 275  echo "</form>\n";
 276  
 277  html_draw_bottom();

title

Description

title

Description

title

Description

title

title

Body