Beehive PHP Cross Reference Discussion Forums

Source: /admin_folder_add.php - 272 lines - 12977 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 . 'session.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  // Check we have Admin / Moderator access
  44  if (!(session::check_perm(USER_PERM_ADMIN_TOOLS, 0))) {
  45      html_draw_error(gettext("You do not have permission to use this section."));
  46  }
  47  
  48  // Perform additional admin login.
  49  admin_check_credentials();
  50  
  51  $t_name = null;
  52  $t_description = null;
  53  $t_prefix = null;
  54  $t_allowed_types = null;
  55  
  56  if (isset($_GET['page']) && is_numeric($_GET['page'])) {
  57      $page = ($_GET['page'] > 0) ? $_GET['page'] : 1;
  58  } else if (isset($_POST['page']) && is_numeric($_POST['page'])) {
  59      $page = ($_POST['page'] > 0) ? $_POST['page'] : 1;
  60  } else {
  61      $page = 1;
  62  }
  63  
  64  if (isset($_POST['cancel'])) {
  65  
  66      header_redirect("admin_folders.php?webtag=$webtag&page=$page");
  67      exit;
  68  }
  69  
  70  if (isset($_POST['add'])) {
  71  
  72      $valid = true;
  73  
  74      if (isset($_POST['t_name']) && strlen(trim($_POST['t_name'])) > 0) {
  75          $t_name = trim($_POST['t_name']);
  76      } else {
  77          $error_msg_array[] = gettext("You must enter a folder name");
  78          $valid = false;
  79      }
  80  
  81      if (isset($_POST['t_description']) && strlen(trim($_POST['t_description'])) > 0) {
  82          $t_description = trim($_POST['t_description']);
  83      } else {
  84          $t_description = "";
  85      }
  86  
  87      if (isset($_POST['t_prefix']) && strlen(trim($_POST['t_prefix'])) > 0) {
  88          $t_prefix = trim($_POST['t_prefix']);
  89      } else {
  90          $t_prefix = "";
  91      }
  92  
  93      if (isset($_POST['t_allowed_types']) && is_numeric($_POST['t_allowed_types'])) {
  94          $t_allowed_types = $_POST['t_allowed_types'];
  95      } else {
  96          $t_allowed_types = FOLDER_ALLOW_ALL_THREAD;
  97      }
  98  
  99      $t_post_read = (double)(isset($_POST['t_post_read'])) ? $_POST['t_post_read'] : 0;
 100      $t_post_create = (double)(isset($_POST['t_post_create'])) ? $_POST['t_post_create'] : 0;
 101      $t_thread_create = (double)(isset($_POST['t_thread_create'])) ? $_POST['t_thread_create'] : 0;
 102      $t_post_edit = (double)(isset($_POST['t_post_edit'])) ? $_POST['t_post_edit'] : 0;
 103      $t_post_delete = (double)(isset($_POST['t_post_delete'])) ? $_POST['t_post_delete'] : 0;
 104      $t_post_attach = (double)(isset($_POST['t_post_attach'])) ? $_POST['t_post_attach'] : 0;
 105      $t_post_html = (double)(isset($_POST['t_post_html'])) ? $_POST['t_post_html'] : 0;
 106      $t_post_sig = (double)(isset($_POST['t_post_sig'])) ? $_POST['t_post_sig'] : 0;
 107      $t_guest_access = (double)(isset($_POST['t_guest_access'])) ? $_POST['t_guest_access'] : 0;
 108      $t_post_approval = (double)(isset($_POST['t_post_approval'])) ? $_POST['t_post_approval'] : 0;
 109      $t_thread_move = (double)(isset($_POST['t_thread_move'])) ? $_POST['t_thread_move'] : 0;
 110  
 111      // We need a double / float here because we're storing a high bit value
 112      $t_permissions = (double)$t_post_read | $t_post_create | $t_thread_create;
 113      $t_permissions = (double)$t_permissions | $t_post_edit | $t_post_delete | $t_post_attach;
 114      $t_permissions = (double)$t_permissions | $t_post_html | $t_post_sig | $t_guest_access;
 115      $t_permissions = (double)$t_permissions | $t_post_approval | $t_thread_move;
 116  
 117      if ($valid) {
 118  
 119          if (($new_fid = folder_create($t_name, $t_description, $t_prefix, $t_allowed_types, $t_permissions)) !== false) {
 120  
 121              admin_add_log_entry(CREATE_FOLDER, array($t_name));
 122              header_redirect("admin_folders.php?webtag=$webtag&added=true&page=$page");
 123              exit;
 124  
 125          } else {
 126  
 127              $error_msg_array = gettext("Failed to create new folder");
 128              $valid = false;
 129          }
 130      }
 131  }
 132  
 133  // Make the arrays for the allow post types dropdown
 134  $allowed_post_types = array(
 135      FOLDER_ALLOW_NORMAL_THREAD => gettext("Normal threads only"),
 136      FOLDER_ALLOW_POLL_THREAD => gettext("Poll threads only"),
 137      FOLDER_ALLOW_ALL_THREAD => gettext("Both thread types")
 138  );
 139  
 140  html_draw_top(sprintf("title=%s", gettext("Admin - Manage Folders - Add a new folder")), 'class=window_title', 'main_css=admin.css');
 141  
 142  echo "<h1>", gettext("Admin"), "<img src=\"", html_style_image('separator.png'), "\" alt=\"\" border=\"0\" />", gettext("Manage Folders"), "<img src=\"", html_style_image('separator.png'), "\" alt=\"\" border=\"0\" />", gettext("Add a new folder"), "</h1>\n";
 143  
 144  if (isset($error_msg_array) && sizeof($error_msg_array) > 0) {
 145      html_display_error_array($error_msg_array, '800', 'center');
 146  }
 147  
 148  echo "<br />\n";
 149  echo "<div align=\"center\">\n";
 150  echo "  <form accept-charset=\"utf-8\" name=\"thread_options\" action=\"admin_folder_add.php\" method=\"post\" target=\"_self\">\n";
 151  echo "  ", form_input_hidden('webtag', htmlentities_array($webtag)), "\n";
 152  echo "  ", form_input_hidden('page', htmlentities_array($page)), "\n";
 153  echo "  <table cellpadding=\"0\" cellspacing=\"0\" width=\"800\">\n";
 154  echo "    <tr>\n";
 155  echo "      <td align=\"left\">\n";
 156  echo "        <table class=\"box\" width=\"100%\">\n";
 157  echo "          <tr>\n";
 158  echo "            <td align=\"left\" class=\"posthead\">\n";
 159  echo "              <table class=\"posthead\" width=\"100%\">\n";
 160  echo "                <tr>\n";
 161  echo "                  <td align=\"left\" class=\"subhead\" colspan=\"2\">", gettext("Name and Description"), "</td>\n";
 162  echo "                </tr>\n";
 163  echo "                <tr>\n";
 164  echo "                  <td align=\"center\">\n";
 165  echo "                    <table class=\"posthead\" width=\"95%\">\n";
 166  echo "                      <tr>\n";
 167  echo "                        <td align=\"left\" width=\"200\" class=\"posthead\">", gettext("Name"), ":</td>\n";
 168  echo "                        <td align=\"left\">" . form_input_text("t_name", (isset($t_name) ? htmlentities_array($t_name) : ""), 30, 32) . "</td>\n";
 169  echo "                      </tr>\n";
 170  echo "                      <tr>\n";
 171  echo "                        <td align=\"left\" width=\"200\" class=\"posthead\">", gettext("Description"), ":</td>\n";
 172  echo "                        <td align=\"left\">" . form_input_text("t_description", (isset($t_description) ? htmlentities_array($t_description) : ""), 30, 255) . "</td>\n";
 173  echo "                      </tr>\n";
 174  echo "                      <tr>\n";
 175  echo "                        <td align=\"left\" width=\"200\" class=\"posthead\">", gettext("Thread Title Prefix"), ":</td>\n";
 176  echo "                        <td align=\"left\">" . form_input_text("t_prefix", (isset($t_prefix) ? htmlentities_array($t_prefix) : ""), 30, 16) . "</td>\n";
 177  echo "                      </tr>\n";
 178  echo "                      <tr>\n";
 179  echo "                        <td align=\"left\">&nbsp;</td>\n";
 180  echo "                        <td align=\"left\">&nbsp;</td>\n";
 181  echo "                      </tr>\n";
 182  echo "                    </table>\n";
 183  echo "                  </td>\n";
 184  echo "                </tr>\n";
 185  echo "              </table>\n";
 186  echo "            </td>\n";
 187  echo "          </tr>\n";
 188  echo "        </table>\n";
 189  echo "        <br />\n";
 190  echo "        <table class=\"box\" width=\"100%\">\n";
 191  echo "          <tr>\n";
 192  echo "            <td align=\"left\" class=\"posthead\">\n";
 193  echo "              <table class=\"posthead\" width=\"100%\">\n";
 194  echo "                <tr>\n";
 195  echo "                  <td align=\"left\" class=\"subhead\">", gettext("Permissions"), "</td>\n";
 196  echo "                </tr>\n";
 197  echo "                <tr>\n";
 198  echo "                  <td align=\"center\">\n";
 199  echo "                    <table class=\"posthead\" width=\"95%\">\n";
 200  echo "                      <tr>\n";
 201  echo "                        <td align=\"left\">", form_checkbox("t_post_read", USER_PERM_POST_READ, gettext("Read Posts")), "</td>\n";
 202  echo "                        <td align=\"left\">", form_checkbox("t_post_create", USER_PERM_POST_CREATE, gettext("Reply to threads")), "</td>\n";
 203  echo "                      </tr>\n";
 204  echo "                      <tr>\n";
 205  echo "                        <td align=\"left\">", form_checkbox("t_thread_create", USER_PERM_THREAD_CREATE, gettext("Create new threads")), "</td>\n";
 206  echo "                        <td align=\"left\">", form_checkbox("t_post_edit", USER_PERM_POST_EDIT, gettext("Edit posts")), "</td>\n";
 207  echo "                      </tr>\n";
 208  echo "                      <tr>\n";
 209  echo "                        <td align=\"left\">", form_checkbox("t_post_delete", USER_PERM_POST_DELETE, gettext("Delete posts")), "</td>\n";
 210  echo "                        <td align=\"left\">", form_checkbox("t_post_attach", USER_PERM_POST_ATTACHMENTS, gettext("Upload attachments")), "</td>\n";
 211  echo "                      </tr>\n";
 212  echo "                      <tr>\n";
 213  echo "                        <td align=\"left\">", form_checkbox("t_post_html", USER_PERM_HTML_POSTING, gettext("Post in HTML")), "</td>\n";
 214  echo "                        <td align=\"left\">", form_checkbox("t_post_sig", USER_PERM_SIGNATURE, gettext("Post a signature")), "</td>\n";
 215  echo "                      </tr>\n";
 216  echo "                      <tr>\n";
 217  echo "                        <td align=\"left\">", form_checkbox("t_guest_access", USER_PERM_GUEST_ACCESS, gettext("Allow Guest Access")), "</td>\n";
 218  echo "                        <td align=\"left\">", form_checkbox("t_post_approval", USER_PERM_POST_APPROVAL, gettext("Require Post Approval")), "</td>\n";
 219  echo "                      </tr>\n";
 220  echo "                      <tr>\n";
 221  echo "                        <td align=\"left\">", form_checkbox("t_thread_move", USER_PERM_THREAD_MOVE, gettext("Move threads to folder")), "</td>\n";
 222  echo "                        <td align=\"left\">&nbsp;</td>\n";
 223  echo "                      </tr>\n";
 224  echo "                    </table>\n";
 225  echo "                  </td>\n";
 226  echo "                </tr>\n";
 227  echo "                <tr>\n";
 228  echo "                  <td align=\"left\">&nbsp;</td>\n";
 229  echo "                </tr>\n";
 230  echo "              </table>\n";
 231  echo "            </td>\n";
 232  echo "          </tr>\n";
 233  echo "        </table>\n";
 234  echo "        <br />\n";
 235  echo "        <table class=\"box\" width=\"100%\">\n";
 236  echo "          <tr>\n";
 237  echo "            <td align=\"left\" class=\"posthead\">\n";
 238  echo "              <table class=\"posthead\" width=\"100%\">\n";
 239  echo "                <tr>\n";
 240  echo "                  <td align=\"left\" class=\"subhead\" colspan=\"2\">", gettext("Allow"), "</td>\n";
 241  echo "                </tr>\n";
 242  echo "                <tr>\n";
 243  echo "                  <td align=\"center\">\n";
 244  echo "                    <table class=\"posthead\" width=\"95%\">\n";
 245  echo "                      <tr>\n";
 246  echo "                        <td align=\"left\" width=\"200\" class=\"posthead\">", gettext("Allow folder to contain"), ":</td>\n";
 247  echo "                        <td align=\"left\">", form_dropdown_array("t_allowed_types", $allowed_post_types, (isset($t_allowed_types) ? $t_allowed_types : FOLDER_ALLOW_ALL_THREAD)), "</td>\n";
 248  echo "                      </tr>\n";
 249  echo "                      <tr>\n";
 250  echo "                        <td align=\"left\">&nbsp;</td>\n";
 251  echo "                        <td align=\"left\">&nbsp;</td>\n";
 252  echo "                      </tr>\n";
 253  echo "                    </table>\n";
 254  echo "                  </td>\n";
 255  echo "                </tr>\n";
 256  echo "              </table>\n";
 257  echo "            </td>\n";
 258  echo "          </tr>\n";
 259  echo "        </table>\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 "    <tr>\n";
 266  echo "      <td align=\"center\">", form_submit("add", gettext("Add")), "&nbsp;", form_submit("cancel", gettext("Cancel")), "</td>\n";
 267  echo "    </tr>\n";
 268  echo "  </table>\n";
 269  echo "  </form>\n";
 270  echo "</div>\n";
 271  
 272  html_draw_bottom();

title

Description

title

Description

title

Description

title

title

Body