Beehive PHP Cross Reference Discussion Forums

Source: /admin_user_groups_add.php - 354 lines - 20848 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  // Array to hold error messages
  54  $error_msg_array = array();
  55  
  56  $t_name = null;
  57  
  58  // Cancel button clicked.
  59  if (isset($_POST['cancel'])) {
  60  
  61      header_redirect("admin_user_groups.php?webtag=$webtag");
  62      exit;
  63  }
  64  
  65  // Do updates
  66  if (isset($_POST['add_group']) || isset($_POST['add_users'])) {
  67  
  68      $valid = true;
  69  
  70      if (isset($_POST['t_name']) && strlen(trim($_POST['t_name'])) > 0) {
  71  
  72          $t_name = trim($_POST['t_name']);
  73  
  74      } else {
  75  
  76          $error_msg_array[] = gettext("You must enter a group name");
  77          $valid = false;
  78      }
  79  
  80      if (isset($_POST['t_description']) && strlen(trim($_POST['t_description'])) > 0) {
  81          $t_description = trim($_POST['t_description']);
  82      } else {
  83          $t_description = "";
  84      }
  85  
  86      $t_admintools = (double)(isset($_POST['t_admintools'])) ? $_POST['t_admintools'] : 0;
  87      $t_banned = (double)(isset($_POST['t_banned'])) ? $_POST['t_banned'] : 0;
  88      $t_wormed = (double)(isset($_POST['t_wormed'])) ? $_POST['t_wormed'] : 0;
  89      $t_globalmod = (double)(isset($_POST['t_globalmod'])) ? $_POST['t_globalmod'] : 0;
  90      $t_linksmod = (double)(isset($_POST['t_linksmod'])) ? $_POST['t_linksmod'] : 0;
  91  
  92      $new_group_perms = (double)$t_banned | $t_wormed | $t_globalmod | $t_linksmod;
  93  
  94      if (session::check_perm(USER_PERM_FORUM_TOOLS, 0)) {
  95  
  96          $new_group_perms = (double)$new_group_perms | $t_admintools;
  97      }
  98  
  99      if ($valid) {
 100  
 101          if (($new_gid = perm_add_group($t_name, $t_description, $new_group_perms)) !== false) {
 102  
 103              if (isset($_POST['t_new_perms_array']) && is_array($_POST['t_new_perms_array'])) {
 104  
 105                  $t_new_perms_array = $_POST['t_new_perms_array'];
 106  
 107                  foreach ($t_new_perms_array as $fid) {
 108  
 109                      $t_post_read = (double)(isset($_POST['t_post_read'][$fid])) ? $_POST['t_post_read'][$fid] : 0;
 110                      $t_post_create = (double)(isset($_POST['t_post_create'][$fid])) ? $_POST['t_post_create'][$fid] : 0;
 111                      $t_thread_create = (double)(isset($_POST['t_thread_create'][$fid])) ? $_POST['t_thread_create'][$fid] : 0;
 112                      $t_post_edit = (double)(isset($_POST['t_post_edit'][$fid])) ? $_POST['t_post_edit'][$fid] : 0;
 113                      $t_post_delete = (double)(isset($_POST['t_post_delete'][$fid])) ? $_POST['t_post_delete'][$fid] : 0;
 114                      $t_post_attach = (double)(isset($_POST['t_post_attach'][$fid])) ? $_POST['t_post_attach'][$fid] : 0;
 115                      $t_moderator = (double)(isset($_POST['t_moderator'][$fid])) ? $_POST['t_moderator'][$fid] : 0;
 116                      $t_post_html = (double)(isset($_POST['t_post_html'][$fid])) ? $_POST['t_post_html'][$fid] : 0;
 117                      $t_post_sig = (double)(isset($_POST['t_post_sig'][$fid])) ? $_POST['t_post_sig'][$fid] : 0;
 118                      $t_post_approval = (double)(isset($_POST['t_post_approval'][$fid])) ? $_POST['t_post_approval'][$fid] : 0;
 119  
 120                      $new_group_perms = (double)$t_post_read | $t_post_create | $t_thread_create;
 121                      $new_group_perms = (double)$new_group_perms | $t_post_edit | $t_post_delete;
 122                      $new_group_perms = (double)$new_group_perms | $t_moderator | $t_post_attach;
 123                      $new_group_perms = (double)$new_group_perms | $t_post_html | $t_post_sig | $t_post_approval;
 124  
 125                      perm_update_group_folder_perms($new_gid, $fid, $new_group_perms);
 126                  }
 127              }
 128  
 129              admin_add_log_entry(CREATE_USER_GROUP, array($t_name));
 130  
 131              if (isset($_POST['add_users'])) {
 132  
 133                  header_redirect("admin_user_groups_edit_users.php?webtag=$webtag&gid=$new_gid&added=true");
 134                  exit;
 135  
 136              } else {
 137  
 138                  header_redirect("admin_user_groups.php?webtag=$webtag&added=true");
 139                  exit;
 140              }
 141          }
 142      }
 143  }
 144  
 145  html_draw_top(sprintf('title=%s', gettext("Admin - Manage User Groups - Add User Group")), 'class=window_title', 'main_css=admin.css');
 146  
 147  echo "<h1>", gettext("Admin"), "<img src=\"", html_style_image('separator.png'), "\" alt=\"\" border=\"0\" />", gettext("Manage User Groups"), "<img src=\"", html_style_image('separator.png'), "\" alt=\"\" border=\"0\" />", gettext("Add User Group"), "</h1>\n";
 148  
 149  if (isset($error_msg_array) && sizeof($error_msg_array) > 0) {
 150      html_display_error_array($error_msg_array, '800', 'center');
 151  }
 152  
 153  echo "<br />\n";
 154  echo "<div align=\"center\">\n";
 155  echo "<form accept-charset=\"utf-8\" name=\"admin_user_form\" action=\"admin_user_groups_add.php\" method=\"post\">\n";
 156  echo "  ", form_input_hidden('webtag', htmlentities_array($webtag)), "\n";
 157  echo "  <table cellpadding=\"0\" cellspacing=\"0\" width=\"800\">\n";
 158  echo "    <tr>\n";
 159  echo "      <td align=\"left\">\n";
 160  echo "        <table class=\"box\" width=\"100%\">\n";
 161  echo "          <tr>\n";
 162  echo "            <td align=\"left\" class=\"posthead\">\n";
 163  echo "              <table class=\"posthead\" width=\"100%\">\n";
 164  echo "                <tr>\n";
 165  echo "                  <td align=\"left\" class=\"subhead\" colspan=\"2\">", gettext("Name and Description"), "</td>\n";
 166  echo "                </tr>\n";
 167  echo "                <tr>\n";
 168  echo "                  <td align=\"center\">\n";
 169  echo "                    <table class=\"posthead\" width=\"95%\">\n";
 170  echo "                      <tr>\n";
 171  echo "                        <td align=\"left\" width=\"200\" class=\"posthead\">", gettext("Name"), ":</td>\n";
 172  echo "                        <td align=\"left\">" . form_input_text("t_name", (isset($t_name) ? htmlentities_array($t_name) : ""), 30, 64) . "</td>\n";
 173  echo "                      </tr>\n";
 174  echo "                      <tr>\n";
 175  echo "                        <td align=\"left\" width=\"200\" class=\"posthead\">", gettext("Description"), ":</td>\n";
 176  echo "                        <td align=\"left\">" . form_input_text("t_description", (isset($t_description) ? htmlentities_array($t_description) : ""), 30, 64) . "</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\" colspan=\"1\">", gettext("Group Status"), "</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  
 201  if (session::check_perm(USER_PERM_FORUM_TOOLS, 0)) {
 202  
 203      echo "                      <tr>\n";
 204      echo "                        <td align=\"left\">", form_checkbox("t_admintools", USER_PERM_ADMIN_TOOLS, gettext("Group can access admin tools")), "</td>\n";
 205      echo "                      </tr>\n";
 206  }
 207  
 208  echo "                      <tr>\n";
 209  echo "                        <td align=\"left\">", form_checkbox("t_globalmod", USER_PERM_FOLDER_MODERATE, gettext("Group can moderate all folders")), "</td>\n";
 210  echo "                      </tr>\n";
 211  echo "                      <tr>\n";
 212  echo "                        <td align=\"left\">", form_checkbox("t_linksmod", USER_PERM_LINKS_MODERATE, gettext("Group can moderate Links sections")), "</td>\n";
 213  echo "                      </tr>\n";
 214  echo "                      <tr>\n";
 215  echo "                        <td align=\"left\">", form_checkbox("t_banned", USER_PERM_BANNED, gettext("Group is banned")), "</td>\n";
 216  echo "                      </tr>\n";
 217  echo "                      <tr>\n";
 218  echo "                        <td align=\"left\">", form_checkbox("t_wormed", USER_PERM_WORMED, gettext("Group is wormed")), "</td>\n";
 219  echo "                      </tr>\n";
 220  echo "                      <tr>\n";
 221  echo "                        <td align=\"left\">&nbsp;</td>\n";
 222  echo "                      </tr>\n";
 223  echo "                    </table>\n";
 224  echo "                  </td>\n";
 225  echo "                </tr>\n";
 226  echo "              </table>\n";
 227  echo "            </td>\n";
 228  echo "          </tr>\n";
 229  echo "        </table>\n";
 230  echo "        <br />\n";
 231  
 232  if (($folder_array = folder_get_all()) !== false) {
 233  
 234      echo "        <table class=\"box\" width=\"100%\">\n";
 235      echo "          <tr>\n";
 236      echo "            <td align=\"left\" class=\"posthead\">\n";
 237      echo "              <table class=\"posthead\" width=\"100%\">\n";
 238      echo "                <tr>\n";
 239      echo "                  <td class=\"subhead\" align=\"left\">", gettext("Folder Access"), "</td>\n";
 240      echo "                </tr>\n";
 241      echo "                <tr>\n";
 242      echo "                  <td align=\"left\">&nbsp;</td>\n";
 243      echo "                </tr>\n";
 244      echo "                <tr>\n";
 245      echo "                  <td align=\"center\">\n";
 246      echo "                    <table class=\"box\" width=\"95%\">\n";
 247      echo "                      <tr>\n";
 248      echo "                        <td align=\"left\" class=\"posthead\">\n";
 249      echo "                          <table class=\"posthead\" width=\"100%\">\n";
 250      echo "                            <tr>\n";
 251      echo "                              <td align=\"left\" class=\"subhead\" width=\"100\">", gettext("Folders"), "</td>\n";
 252      echo "                              <td align=\"left\" class=\"subhead\">", gettext("Permissions"), "</td>\n";
 253      echo "                            </tr>\n";
 254      echo "                            <tr>\n";
 255      echo "                              <td align=\"left\" colspan=\"2\">\n";
 256      echo "                                <div class=\"admin_folder_perms\">\n";
 257  
 258      foreach ($folder_array as $folder) {
 259  
 260          if ($folder['FOLDER_PERM_COUNT'] > 0) {
 261  
 262              echo "                                  ", form_input_hidden("t_new_perms_array[]", htmlentities_array($folder['FID'])), "\n";
 263              echo "                                  <table class=\"posthead\" width=\"100%\">\n";
 264              echo "                                    <tr>\n";
 265              echo "                                      <td align=\"left\" rowspan=\"5\" width=\"100\" valign=\"top\"><a href=\"admin_folder_edit.php?webtag=$webtag&amp;fid={$folder['FID']}\" target=\"_self\">", word_filter_add_ob_tags($folder['TITLE'], true), "</a></td>\n";
 266              echo "                                      <td align=\"left\" style=\"white-space: nowrap\">", form_checkbox("t_post_read[{$folder['FID']}]", USER_PERM_POST_READ, gettext("Read Posts"), $folder['FOLDER_PERMS'] & USER_PERM_POST_READ), "</td>\n";
 267              echo "                                      <td align=\"left\" style=\"white-space: nowrap\">", form_checkbox("t_post_create[{$folder['FID']}]", USER_PERM_POST_CREATE, gettext("Reply to threads"), $folder['FOLDER_PERMS'] & USER_PERM_POST_CREATE), "</td>\n";
 268              echo "                                    </tr>\n";
 269              echo "                                    <tr>\n";
 270              echo "                                      <td align=\"left\" style=\"white-space: nowrap\">", form_checkbox("t_thread_create[{$folder['FID']}]", USER_PERM_THREAD_CREATE, gettext("Create new threads"), $folder['FOLDER_PERMS'] & USER_PERM_THREAD_CREATE), "</td>\n";
 271              echo "                                      <td align=\"left\" style=\"white-space: nowrap\">", form_checkbox("t_post_edit[{$folder['FID']}]", USER_PERM_POST_EDIT, gettext("Edit posts"), $folder['FOLDER_PERMS'] & USER_PERM_POST_EDIT), "</td>\n";
 272              echo "                                    </tr>\n";
 273              echo "                                    <tr>\n";
 274              echo "                                      <td align=\"left\" style=\"white-space: nowrap\">", form_checkbox("t_post_delete[{$folder['FID']}]", USER_PERM_POST_DELETE, gettext("Delete posts"), $folder['FOLDER_PERMS'] & USER_PERM_POST_DELETE), "</td>\n";
 275              echo "                                      <td align=\"left\" style=\"white-space: nowrap\">", form_checkbox("t_post_attach[{$folder['FID']}]", USER_PERM_POST_ATTACHMENTS, gettext("Upload attachments"), $folder['FOLDER_PERMS'] & USER_PERM_POST_ATTACHMENTS), "</td>\n";
 276              echo "                                    </tr>\n";
 277              echo "                                    <tr>\n";
 278              echo "                                      <td align=\"left\" style=\"white-space: nowrap\">", form_checkbox("t_post_html[{$folder['FID']}]", USER_PERM_HTML_POSTING, gettext("Post in HTML"), $folder['FOLDER_PERMS'] & USER_PERM_HTML_POSTING), "</td>\n";
 279              echo "                                      <td align=\"left\" style=\"white-space: nowrap\">", form_checkbox("t_post_sig[{$folder['FID']}]", USER_PERM_SIGNATURE, gettext("Post a signature"), $folder['FOLDER_PERMS'] & USER_PERM_SIGNATURE), "</td>\n";
 280              echo "                                    </tr>\n";
 281              echo "                                    <tr>\n";
 282              echo "                                      <td align=\"left\" style=\"white-space: nowrap\">", form_checkbox("t_moderator[{$folder['FID']}]", USER_PERM_FOLDER_MODERATE, gettext("Moderate folder")), "</td>\n";
 283              echo "                                      <td align=\"left\" style=\"white-space: nowrap\">", form_checkbox("t_post_approval[{$folder['FID']}]", USER_PERM_POST_APPROVAL, gettext("Require Post Approval")), "</td>\n";
 284              echo "                                    </tr>\n";
 285              echo "                                    <tr>\n";
 286              echo "                                      <td align=\"left\" colspan=\"4\">&nbsp;</td>\n";
 287              echo "                                    </tr>\n";
 288              echo "                                  </table>\n";
 289  
 290          } else {
 291  
 292              echo "                                  ", form_input_hidden("t_new_perms_array[]", htmlentities_array($folder['FID'])), "\n";
 293              echo "                                  <table class=\"posthead\" width=\"100%\">\n";
 294              echo "                                    <tr>\n";
 295              echo "                                      <td align=\"left\" rowspan=\"5\" width=\"100\" valign=\"top\"><a href=\"admin_folder_edit.php?webtag=$webtag&amp;fid={$folder['FID']}\" target=\"_self\">", word_filter_add_ob_tags($folder['TITLE'], true), "</a></td>\n";
 296              echo "                                      <td align=\"left\" style=\"white-space: nowrap\">", form_checkbox("t_post_read[{$folder['FID']}]", USER_PERM_POST_READ, gettext("Read Posts"), true), "</td>\n";
 297              echo "                                      <td align=\"left\" style=\"white-space: nowrap\">", form_checkbox("t_post_create[{$folder['FID']}]", USER_PERM_POST_CREATE, gettext("Reply to threads"), true), "</td>\n";
 298              echo "                                    </tr>\n";
 299              echo "                                    <tr>\n";
 300              echo "                                      <td align=\"left\" style=\"white-space: nowrap\">", form_checkbox("t_thread_create[{$folder['FID']}]", USER_PERM_THREAD_CREATE, gettext("Create new threads"), true), "</td>\n";
 301              echo "                                      <td align=\"left\" style=\"white-space: nowrap\">", form_checkbox("t_post_edit[{$folder['FID']}]", USER_PERM_POST_EDIT, gettext("Edit posts"), true), "</td>\n";
 302              echo "                                    </tr>\n";
 303              echo "                                    <tr>\n";
 304              echo "                                      <td align=\"left\" style=\"white-space: nowrap\">", form_checkbox("t_post_delete[{$folder['FID']}]", USER_PERM_POST_DELETE, gettext("Delete posts"), true), "</td>\n";
 305              echo "                                      <td align=\"left\" style=\"white-space: nowrap\">", form_checkbox("t_post_attach[{$folder['FID']}]", USER_PERM_POST_ATTACHMENTS, gettext("Upload attachments"), true), "</td>\n";
 306              echo "                                    </tr>\n";
 307              echo "                                    <tr>\n";
 308              echo "                                      <td align=\"left\" style=\"white-space: nowrap\">", form_checkbox("t_post_html[{$folder['FID']}]", USER_PERM_HTML_POSTING, gettext("Post in HTML"), true), "</td>\n";
 309              echo "                                      <td align=\"left\" style=\"white-space: nowrap\">", form_checkbox("t_post_sig[{$folder['FID']}]", USER_PERM_SIGNATURE, gettext("Post a signature"), true), "</td>\n";
 310              echo "                                    </tr>\n";
 311              echo "                                    <tr>\n";
 312              echo "                                      <td align=\"left\" style=\"white-space: nowrap\">", form_checkbox("t_moderator[{$folder['FID']}]", USER_PERM_FOLDER_MODERATE, gettext("Moderate folder")), "</td>\n";
 313              echo "                                      <td align=\"left\" style=\"white-space: nowrap\">", form_checkbox("t_post_approval[{$folder['FID']}]", USER_PERM_POST_APPROVAL, gettext("Require Post Approval")), "</td>\n";
 314              echo "                                    </tr>\n";
 315  
 316  
 317              echo "                                    <tr>\n";
 318              echo "                                      <td align=\"left\" colspan=\"4\">&nbsp;</td>\n";
 319              echo "                                    </tr>\n";
 320              echo "                                  </table>\n";
 321          }
 322      }
 323  
 324      echo "                                </div>\n";
 325      echo "                              </td>\n";
 326      echo "                            </tr>\n";
 327      echo "                          </table>\n";
 328      echo "                        </td>\n";
 329      echo "                      </tr>\n";
 330      echo "                    </table>\n";
 331      echo "                  </td>\n";
 332      echo "                </tr>\n";
 333      echo "                <tr>\n";
 334      echo "                  <td align=\"left\">&nbsp;</td>\n";
 335      echo "                </tr>\n";
 336      echo "              </table>\n";
 337      echo "            </td>\n";
 338      echo "          </tr>\n";
 339      echo "        </table>\n";
 340  }
 341  
 342  echo "      </td>\n";
 343  echo "    </tr>\n";
 344  echo "    <tr>\n";
 345  echo "      <td align=\"left\">&nbsp;</td>\n";
 346  echo "    </tr>\n";
 347  echo "    <tr>\n";
 348  echo "      <td align=\"center\">", form_submit("add_group", gettext("Add Empty Group")), "&nbsp;", form_submit("add_users", gettext("Add Users To Group")), "&nbsp;", form_submit("cancel", gettext("Cancel")), "</td>\n";
 349  echo "    </tr>\n";
 350  echo "  </table>\n";
 351  echo "</form>\n";
 352  echo "</div>\n";
 353  
 354  html_draw_bottom();

title

Description

title

Description

title

Description

title

title

Body