Beehive PHP Cross Reference Discussion Forums

Source: /admin_folders.php - 324 lines - 13790 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 . 'admin.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 . 'form.inc.php';
  32  require_once  BH_INCLUDE_PATH . 'format.inc.php';
  33  require_once  BH_INCLUDE_PATH . 'header.inc.php';
  34  require_once  BH_INCLUDE_PATH . 'html.inc.php';
  35  require_once  BH_INCLUDE_PATH . 'perm.inc.php';
  36  require_once  BH_INCLUDE_PATH . 'session.inc.php';
  37  require_once  BH_INCLUDE_PATH . 'word_filter.inc.php';
  38  // End Required includes
  39  
  40  // Check we're logged in correctly
  41  if (!session::logged_in()) {
  42      html_guest_error();
  43  }
  44  
  45  // Check we have Admin / Moderator access
  46  if (!(session::check_perm(USER_PERM_ADMIN_TOOLS, 0))) {
  47      html_draw_error(gettext("You do not have permission to use this section."));
  48  }
  49  
  50  // Perform additional admin login.
  51  admin_check_credentials();
  52  
  53  if (isset($_GET['page']) && is_numeric($_GET['page'])) {
  54      $page = ($_GET['page'] > 0) ? $_GET['page'] : 1;
  55  } else if (isset($_POST['page']) && is_numeric($_POST['page'])) {
  56      $page = ($_POST['page'] > 0) ? $_POST['page'] : 1;
  57  } else {
  58      $page = 1;
  59  }
  60  
  61  // Array to hold error messages
  62  $error_msg_array = array();
  63  
  64  // Delete folders.
  65  if (isset($_POST['delete'])) {
  66  
  67      $valid = true;
  68  
  69      if (isset($_POST['t_delete']) && is_array($_POST['t_delete'])) {
  70  
  71          foreach ($_POST['t_delete'] as $fid => $delete_folder) {
  72  
  73              if ($valid && $delete_folder == "Y" && $folder_data = folder_get($fid)) {
  74  
  75                  if ($folder_data['THREAD_COUNT'] < 1) {
  76  
  77                      if (folder_delete($fid)) {
  78  
  79                          admin_add_log_entry(DELETE_FOLDER, array($folder_data['TITLE']));
  80  
  81                      } else {
  82  
  83                          $error_msg_array[] = gettext("Failed to delete folder.");
  84                          $valid = false;
  85                      }
  86  
  87                  } else {
  88  
  89                      $error_msg_array[] = gettext("Cannot delete folders that still contain threads.");
  90                      $valid = false;
  91                  }
  92              }
  93          }
  94  
  95          if ($valid) {
  96  
  97              header_redirect("admin_folders.php?webtag=$webtag&page=$page&deleted=true");
  98              exit;
  99          }
 100      }
 101  
 102  }
 103  
 104  if (isset($_POST['addnew'])) {
 105  
 106      header_redirect("admin_folder_add.php?webtag=$webtag&page=$page");
 107      exit;
 108  }
 109  
 110  if (isset($_POST['move_up']) && is_array($_POST['move_up'])) {
 111  
 112      list($fid) = array_keys($_POST['move_up']);
 113  
 114      if (folder_move_up($fid)) {
 115  
 116          header_redirect("admin_folders.php?webtag=$webtag&page=$page");
 117          exit;
 118      }
 119  }
 120  
 121  if (isset($_POST['move_down']) && is_array($_POST['move_down'])) {
 122  
 123      list($fid) = array_keys($_POST['move_down']);
 124  
 125      if (folder_move_down($fid)) {
 126  
 127          header_redirect("admin_folders.php?webtag=$webtag&page=$page");
 128          exit;
 129      }
 130  }
 131  
 132  if (isset($_POST['move_up_disabled']) || isset($_POST['move_down_disabled'])) {
 133  
 134      header_redirect("admin_folders.php?webtag=$webtag&page=$page");
 135      exit;
 136  }
 137  
 138  html_draw_top(sprintf('title=%s', gettext("Admin - Manage Folders")), 'class=window_title', 'main_css=admin.css');
 139  
 140  $folder_array = folder_get_all_by_page($page);
 141  
 142  echo "<h1>", gettext("Admin"), "<img src=\"", html_style_image('separator.png'), "\" alt=\"\" border=\"0\" />", gettext("Manage Folders"), "</h1>\n";
 143  
 144  if (isset($error_msg_array) && sizeof($error_msg_array) > 0) {
 145  
 146      html_display_error_array($error_msg_array, '86%', 'center');
 147  
 148  } else if (isset($_GET['added'])) {
 149  
 150      html_display_success_msg(gettext("Successfully added new folder"), '86%', 'center');
 151  
 152  } else if (isset($_GET['edited'])) {
 153  
 154      html_display_success_msg(gettext("Successfully edited folder"), '86%', 'center');
 155  
 156  } else if (isset($_GET['deleted'])) {
 157  
 158      html_display_success_msg(gettext("Successfully removed selected folders"), '86%', 'center');
 159  
 160  } else if (sizeof($folder_array['folder_array']) < 1) {
 161  
 162      html_display_warning_msg(gettext("No existing folders found. To add a folder click the 'Add New' button below."), '86%', 'center');
 163  
 164  } else {
 165  
 166      html_display_warning_msg(gettext("Folder order only applies when user has enabled 'Sort Thread List by folders' in Forum Options."), '86%', 'center');
 167  }
 168  
 169  echo "<br />\n";
 170  echo "<div align=\"center\">\n";
 171  echo "<form accept-charset=\"utf-8\" name=\"f_folders\" action=\"admin_folders.php\" method=\"post\">\n";
 172  echo "  ", form_input_hidden('webtag', htmlentities_array($webtag)), "\n";
 173  echo "  ", form_input_hidden('page', htmlentities_array($page)), "\n";
 174  echo "  <table cellpadding=\"0\" cellspacing=\"0\" width=\"86%\">\n";
 175  echo "    <tr>\n";
 176  echo "      <td align=\"left\">\n";
 177  echo "        <table class=\"box\" width=\"100%\">\n";
 178  echo "          <tr>\n";
 179  echo "            <td align=\"left\" class=\"posthead\">\n";
 180  echo "              <table class=\"posthead\" width=\"100%\">\n";
 181  echo "                <tr>\n";
 182  echo "                  <td class=\"subhead\" align=\"left\" style=\"white-space: nowrap\">&nbsp;</td>\n";
 183  echo "                  <td class=\"subhead\" align=\"left\" style=\"white-space: nowrap\">", gettext("Folder name"), "</td>\n";
 184  echo "                  <td class=\"subhead\" align=\"left\" style=\"white-space: nowrap\">&nbsp;</td>\n";
 185  echo "                  <td class=\"subhead\" align=\"center\" style=\"white-space: nowrap\">", gettext("Thread Count"), "</td>\n";
 186  echo "                  <td class=\"subhead\" align=\"left\" style=\"white-space: nowrap\">", gettext("Permissions"), "</td>\n";
 187  echo "                </tr>\n";
 188  
 189  if (sizeof($folder_array['folder_array']) > 0) {
 190  
 191      foreach ($folder_array['folder_array'] as $key => $folder) {
 192  
 193          echo "                <tr>\n";
 194          echo "                  <td valign=\"top\" align=\"center\" width=\"1%\">", form_checkbox("t_delete[{$folder['FID']}]", "Y"), "</td>\n";
 195          echo "                  <td align=\"left\"><a href=\"admin_folder_edit.php?webtag=$webtag&amp;page=$page&amp;fid={$folder['FID']}\" title=\"", gettext("Click To Edit Folder"), "\">", word_filter_add_ob_tags($folder['TITLE'], true), "</a></td>\n";
 196          echo "                  <td align=\"right\" width=\"40\" style=\"white-space: nowrap\">", form_submit_image('move_up.png', "move_up[{$folder['FID']}]", "Move Up", "title=\"Move Up\"", "move_up_ctrl"), form_submit_image('move_down.png', "move_down[{$folder['FID']}]", "Move Down", "title=\"Move Down\"", "move_down_ctrl"), "</td>\n";
 197  
 198          if (isset($folder['THREAD_COUNT']) && $folder['THREAD_COUNT'] > 0) {
 199              echo "                  <td align=\"center\" width=\"15%\">{$folder['THREAD_COUNT']}</td>\n";
 200          } else {
 201              echo "                  <td align=\"center\" width=\"15%\">0</td>\n";
 202          }
 203  
 204          if (isset($folder['FOLDER_PERMS']) && $folder['FOLDER_PERMS'] > 0) {
 205              echo "                  <td align=\"left\" width=\"25%\" style=\"white-space: nowrap\">", perm_display_list($folder['FOLDER_PERMS']), "</td>\n";
 206          } else {
 207              echo "                  <td align=\"left\" width=\"25%\" style=\"white-space: nowrap\">", gettext("none"), "</td>\n";
 208          }
 209  
 210          echo "                </tr>\n";
 211      }
 212  }
 213  
 214  echo "                <tr>\n";
 215  echo "                  <td align=\"left\" colspan=\"8\">&nbsp;</td>\n";
 216  echo "                </tr>\n";
 217  echo "              </table>\n";
 218  echo "            </td>\n";
 219  echo "          </tr>\n";
 220  echo "        </table>\n";
 221  echo "      </td>\n";
 222  echo "    </tr>\n";
 223  echo "    <tr>\n";
 224  echo "      <td align=\"left\">&nbsp;</td>\n";
 225  echo "    </tr>\n";
 226  echo "    <tr>\n";
 227  echo "      <td class=\"postbody\" align=\"center\">";
 228  
 229  html_page_links("admin_folders.php?webtag=$webtag", $page, $folder_array['folder_count'], 10);
 230  
 231  echo "      </td>\n";
 232  echo "    </tr>\n";
 233  echo "    <tr>\n";
 234  echo "      <td align=\"left\">&nbsp;</td>\n";
 235  echo "    </tr>\n";
 236  echo "    <tr>\n";
 237  echo "      <td align=\"center\">", form_submit("addnew", gettext("Add New")), "&nbsp;", form_submit("delete", gettext("Delete Selected")), "</td>\n";
 238  echo "    </tr>\n";
 239  echo "  </table>\n";
 240  echo "</form>\n";
 241  echo "<br />\n";
 242  echo "<table cellpadding=\"0\" cellspacing=\"0\" width=\"86%\">\n";
 243  echo "  <tr>\n";
 244  echo "    <td align=\"left\">\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 colspan=\"4\" class=\"subhead\" align=\"left\" style=\"white-space: nowrap\">Permissions Key</td>\n";
 251  echo "              </tr>\n";
 252  echo "              <tr>\n";
 253  echo "                <td align=\"center\">\n";
 254  echo "                  <table width=\"95%\">\n";
 255  echo "                    <tr>\n";
 256  echo "                      <td align=\"left\" valign=\"top\" width=\"50%\">\n";
 257  echo "                        <table width=\"100%\">\n";
 258  echo "                          <tr>\n";
 259  echo "                            <td align=\"left\" class=\"postbody\"><b>PR</b></td>\n";
 260  echo "                            <td align=\"left\" class=\"postbody\">", gettext("Post Reading allowed"), "</td>\n";
 261  echo "                          </tr>\n";
 262  echo "                          <tr>\n";
 263  echo "                            <td align=\"left\" class=\"postbody\"><b>TC</b></td>\n";
 264  echo "                            <td align=\"left\" class=\"postbody\">", gettext("Thread Creation allowed"), "</td>\n";
 265  echo "                          </tr>\n";
 266  echo "                          <tr>\n";
 267  echo "                            <td align=\"left\" class=\"postbody\"><b>PD</b></td>\n";
 268  echo "                            <td align=\"left\" class=\"postbody\">", gettext("Post Deletion allowed"), "</td>\n";
 269  echo "                          </tr>\n";
 270  echo "                          <tr>\n";
 271  echo "                            <td align=\"left\" class=\"postbody\"><b>HP</b></td>\n";
 272  echo "                            <td align=\"left\" class=\"postbody\">", gettext("HTML Posting allowed"), "</td>\n";
 273  echo "                          </tr>\n";
 274  echo "                          <tr>\n";
 275  echo "                            <td align=\"left\" class=\"postbody\"><b>GA</b></td>\n";
 276  echo "                            <td align=\"left\" class=\"postbody\">", gettext("Guest Access allowed"), "</td>\n";
 277  echo "                          </tr>\n";
 278  echo "                          <tr>\n";
 279  echo "                            <td align=\"left\" class=\"postbody\"><b>TM</b></td>\n";
 280  echo "                            <td align=\"left\" class=\"postbody\">", gettext("Move threads to folder"), "</td>\n";
 281  echo "                          </tr>\n";
 282  echo "                        </table>\n";
 283  echo "                      </td>\n";
 284  echo "                      <td align=\"left\" valign=\"top\" width=\"50%\">\n";
 285  echo "                        <table width=\"100%\">\n";
 286  echo "                          <tr>\n";
 287  echo "                            <td align=\"left\" class=\"postbody\"><b>PC</b></td>\n";
 288  echo "                            <td align=\"left\" class=\"postbody\">", gettext("Post Creation allowed"), "</td>\n";
 289  echo "                          </tr>\n";
 290  echo "                          <tr>\n";
 291  echo "                            <td align=\"left\" class=\"postbody\"><b>PE</b></td>\n";
 292  echo "                            <td align=\"left\" class=\"postbody\">", gettext("Post Editing allowed"), "</td>\n";
 293  echo "                          </tr>\n";
 294  echo "                          <tr>\n";
 295  echo "                            <td align=\"left\" class=\"postbody\"><b>UA</b></td>\n";
 296  echo "                            <td align=\"left\" class=\"postbody\">", gettext("Uploading Attachments allowed"), "</td>\n";
 297  echo "                          </tr>\n";
 298  echo "                          <tr>\n";
 299  echo "                            <td align=\"left\" class=\"postbody\"><b>US</b></td>\n";
 300  echo "                            <td align=\"left\" class=\"postbody\">", gettext("User Signature allowed"), "</td>\n";
 301  echo "                          </tr>\n";
 302  echo "                          <tr>\n";
 303  echo "                            <td align=\"left\" class=\"postbody\"><b>PA</b></td>\n";
 304  echo "                            <td align=\"left\" class=\"postbody\">", gettext("Post Approval required"), "</td>\n";
 305  echo "                          </tr>\n";
 306  echo "                        </table>\n";
 307  echo "                      </td>\n";
 308  echo "                    </tr>\n";
 309  echo "                  </table>\n";
 310  echo "                </td>\n";
 311  echo "              </tr>\n";
 312  echo "              <tr>\n";
 313  echo "                <td align=\"left\" colspan=\"8\">&nbsp;</td>\n";
 314  echo "              </tr>\n";
 315  echo "            </table>\n";
 316  echo "          </td>\n";
 317  echo "        </tr>\n";
 318  echo "      </table>\n";
 319  echo "    </td>\n";
 320  echo "  </tr>\n";
 321  echo "</table>\n";
 322  echo "</div>\n";
 323  
 324  html_draw_bottom();

title

Description

title

Description

title

Description

title

title

Body