Beehive PHP Cross Reference Discussion Forums

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

title

Description

title

Description

title

Description

title

title

Body