FluxBB PHP Cross Reference Discussion Forums

Source: /admin_groups.php - 632 lines - 36145 bytes - Summary - Text - Print

Description: Copyright (C) 2008-2012 FluxBB based on code by Rickard Andersson copyright (C) 2002-2008 PunBB License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher

   1  <?php
   2  
   3  /**
   4   * Copyright (C) 2008-2012 FluxBB
   5   * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB
   6   * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
   7   */
   8  
   9  // Tell header.php to use the admin template
  10  define('PUN_ADMIN_CONSOLE', 1);
  11  
  12  define('PUN_ROOT', dirname(__FILE__).'/');
  13  require  PUN_ROOT.'include/common.php';
  14  require  PUN_ROOT.'include/common_admin.php';
  15  
  16  
  17  if ($pun_user['g_id'] != PUN_ADMIN)
  18      message($lang_common['No permission'], false, '403 Forbidden');
  19  
  20  // Load the admin_censoring.php language file
  21  require PUN_ROOT.'lang/'.$admin_language.'/admin_groups.php';
  22  
  23  
  24  // Fetch all groups
  25  $result = $db->query('SELECT * FROM '.$db->prefix.'groups ORDER BY g_id') or error('Unable to fetch user groups', __FILE__, __LINE__, $db->error());
  26  $groups = array();
  27  while ($cur_group = $db->fetch_assoc($result))
  28      $groups[$cur_group['g_id']] = $cur_group;
  29  
  30  // Add/edit a group (stage 1)
  31  if (isset($_POST['add_group']) || isset($_GET['edit_group']))
  32  {
  33      if (isset($_POST['add_group']))
  34      {
  35          $base_group = intval($_POST['base_group']);
  36          $group = $groups[$base_group];
  37  
  38          $mode = 'add';
  39      }
  40      else // We are editing a group
  41      {
  42          $group_id = intval($_GET['edit_group']);
  43          if ($group_id < 1 || !isset($groups[$group_id]))
  44              message($lang_common['Bad request'], false, '404 Not Found');
  45  
  46          $group = $groups[$group_id];
  47  
  48          $mode = 'edit';
  49      }
  50  
  51  
  52      $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['User groups']);
  53      $required_fields = array('req_title' => $lang_admin_groups['Group title label']);
  54      $focus_element = array('groups2', 'req_title');
  55      define('PUN_ACTIVE_PAGE', 'admin');
  56      require  PUN_ROOT.'header.php';
  57  
  58      generate_admin_menu('groups');
  59  
  60  ?>
  61      <div class="blockform">
  62          <h2><span><?php echo $lang_admin_groups['Group settings head'] ?></span></h2>
  63          <div class="box">
  64              <form id="groups2" method="post" action="admin_groups.php" onsubmit="return process_form(this)">
  65                  <p class="submittop"><input type="submit" name="add_edit_group" value="<?php echo $lang_admin_common['Save'] ?>" /></p>
  66                  <div class="inform">
  67                      <input type="hidden" name="mode" value="<?php echo $mode ?>" />
  68  <?php if ($mode == 'edit'): ?>                    <input type="hidden" name="group_id" value="<?php echo $group_id ?>" />
  69  <?php endif; ?><?php if ($mode == 'add'): ?>                    <input type="hidden" name="base_group" value="<?php echo $base_group ?>" />
  70  <?php endif; ?>                    <fieldset>
  71                          <legend><?php echo $lang_admin_groups['Group settings subhead'] ?></legend>
  72                          <div class="infldset">
  73                              <p><?php echo $lang_admin_groups['Group settings info'] ?></p>
  74                              <table class="aligntop">
  75                                  <tr>
  76                                      <th scope="row"><?php echo $lang_admin_groups['Group title label'] ?></th>
  77                                      <td>
  78                                          <input type="text" name="req_title" size="25" maxlength="50" value="<?php if ($mode == 'edit') echo pun_htmlspecialchars($group['g_title']); ?>" tabindex="1" />
  79                                      </td>
  80                                  </tr>
  81                                  <tr>
  82                                      <th scope="row"><?php echo $lang_admin_groups['User title label'] ?></th>
  83                                      <td>
  84                                          <input type="text" name="user_title" size="25" maxlength="50" value="<?php echo pun_htmlspecialchars($group['g_user_title']) ?>" tabindex="2" />
  85                                          <span><?php printf($lang_admin_groups['User title help'], ($group['g_id'] != PUN_GUEST ? $lang_common['Member'] : $lang_common['Guest'])) ?></span>
  86                                      </td>
  87                                  </tr>
  88  <?php if ($group['g_id'] != PUN_ADMIN): if ($group['g_id'] != PUN_GUEST): ?>                                <tr>
  89                                      <th scope="row"><?php echo $lang_admin_groups['Promote users label'] ?></th>
  90                                      <td>
  91                                          <select name="promote_next_group" tabindex="3">
  92                                              <option value="0"><?php echo $lang_admin_groups['Disable promotion'] ?></option>
  93  <?php
  94  
  95  foreach ($groups as $cur_group)
  96  {
  97      if (($cur_group['g_id'] != $group['g_id'] || $mode == 'add') && $cur_group['g_id'] != PUN_ADMIN && $cur_group['g_id'] != PUN_GUEST)
  98      {
  99          if ($cur_group['g_id'] == $group['g_promote_next_group'])
 100              echo "\t\t\t\t\t\t\t\t\t\t\t".'<option value="'.$cur_group['g_id'].'" selected="selected">'.pun_htmlspecialchars($cur_group['g_title']).'</option>'."\n";
 101          else
 102              echo "\t\t\t\t\t\t\t\t\t\t\t".'<option value="'.$cur_group['g_id'].'">'.pun_htmlspecialchars($cur_group['g_title']).'</option>'."\n";
 103      }
 104  }
 105  
 106  ?>
 107                                          </select>
 108                                          <input type="text" name="promote_min_posts" size="5" maxlength="10" value="<?php echo pun_htmlspecialchars($group['g_promote_min_posts']) ?>" tabindex="4" />
 109                                          <span><?php printf($lang_admin_groups['Promote users help'], $lang_admin_groups['Disable promotion']) ?></span>
 110                                      </td>
 111                                  </tr>
 112  <?php if ($mode != 'edit' || $pun_config['o_default_user_group'] != $group['g_id']): ?>                                <tr>
 113                                      <th scope="row"> <?php echo $lang_admin_groups['Mod privileges label'] ?></th>
 114                                      <td>
 115                                          <label class="conl"><input type="radio" name="moderator" value="1"<?php if ($group['g_moderator'] == '1') echo ' checked="checked"' ?> tabindex="5" />&#160;<strong><?php echo $lang_admin_common['Yes'] ?></strong></label>
 116                                          <label class="conl"><input type="radio" name="moderator" value="0"<?php if ($group['g_moderator'] == '0') echo ' checked="checked"' ?> tabindex="6" />&#160;<strong><?php echo $lang_admin_common['No'] ?></strong></label>
 117                                          <span class="clearb"><?php echo $lang_admin_groups['Mod privileges help'] ?></span>
 118                                      </td>
 119                                  </tr>
 120                                  <tr>
 121                                      <th scope="row"><?php echo $lang_admin_groups['Edit profile label'] ?></th>
 122                                      <td>
 123                                          <label class="conl"><input type="radio" name="mod_edit_users" value="1"<?php if ($group['g_mod_edit_users'] == '1') echo ' checked="checked"' ?> tabindex="7" />&#160;<strong><?php echo $lang_admin_common['Yes'] ?></strong></label>
 124                                          <label class="conl"><input type="radio" name="mod_edit_users" value="0"<?php if ($group['g_mod_edit_users'] == '0') echo ' checked="checked"' ?> tabindex="8" />&#160;<strong><?php echo $lang_admin_common['No'] ?></strong></label>
 125                                          <span class="clearb"><?php echo $lang_admin_groups['Edit profile help'] ?></span>
 126                                      </td>
 127                                  </tr>
 128                                  <tr>
 129                                      <th scope="row"><?php echo $lang_admin_groups['Rename users label'] ?></th>
 130                                      <td>
 131                                          <label class="conl"><input type="radio" name="mod_rename_users" value="1"<?php if ($group['g_mod_rename_users'] == '1') echo ' checked="checked"' ?> tabindex="9" />&#160;<strong><?php echo $lang_admin_common['Yes'] ?></strong></label>
 132                                          <label class="conl"><input type="radio" name="mod_rename_users" value="0"<?php if ($group['g_mod_rename_users'] == '0') echo ' checked="checked"' ?> tabindex="10" />&#160;<strong><?php echo $lang_admin_common['No'] ?></strong></label>
 133                                          <span class="clearb"><?php echo $lang_admin_groups['Rename users help'] ?></span>
 134                                      </td>
 135                                  </tr>
 136                                  <tr>
 137                                      <th scope="row"><?php echo $lang_admin_groups['Change passwords label'] ?></th>
 138                                      <td>
 139                                          <label class="conl"><input type="radio" name="mod_change_passwords" value="1"<?php if ($group['g_mod_change_passwords'] == '1') echo ' checked="checked"' ?> tabindex="11" />&#160;<strong><?php echo $lang_admin_common['Yes'] ?></strong></label>
 140                                          <label class="conl"><input type="radio" name="mod_change_passwords" value="0"<?php if ($group['g_mod_change_passwords'] == '0') echo ' checked="checked"' ?> tabindex="12" />&#160;<strong><?php echo $lang_admin_common['No'] ?></strong></label>
 141                                          <span class="clearb"><?php echo $lang_admin_groups['Change passwords help'] ?></span>
 142                                      </td>
 143                                  </tr>
 144                                  <tr>
 145                                      <th scope="row"><?php echo $lang_admin_groups['Ban users label'] ?></th>
 146                                      <td>
 147                                          <label class="conl"><input type="radio" name="mod_ban_users" value="1"<?php if ($group['g_mod_ban_users'] == '1') echo ' checked="checked"' ?> tabindex="13" />&#160;<strong><?php echo $lang_admin_common['Yes'] ?></strong></label>
 148                                          <label class="conl"><input type="radio" name="mod_ban_users" value="0"<?php if ($group['g_mod_ban_users'] == '0') echo ' checked="checked"' ?> tabindex="14" />&#160;<strong><?php echo $lang_admin_common['No'] ?></strong></label>
 149                                          <span class="clearb"><?php echo $lang_admin_groups['Ban users help'] ?></span>
 150                                      </td>
 151                                  </tr>
 152  <?php endif; endif; ?>                                <tr>
 153                                      <th scope="row"><?php echo $lang_admin_groups['Read board label'] ?></th>
 154                                      <td>
 155                                          <label class="conl"><input type="radio" name="read_board" value="1"<?php if ($group['g_read_board'] == '1') echo ' checked="checked"' ?> tabindex="15" />&#160;<strong><?php echo $lang_admin_common['Yes'] ?></strong></label>
 156                                          <label class="conl"><input type="radio" name="read_board" value="0"<?php if ($group['g_read_board'] == '0') echo ' checked="checked"' ?> tabindex="16" />&#160;<strong><?php echo $lang_admin_common['No'] ?></strong></label>
 157                                          <span class="clearb"><?php echo $lang_admin_groups['Read board help'] ?></span>
 158                                      </td>
 159                                  </tr>
 160                                  <tr>
 161                                      <th scope="row"><?php echo $lang_admin_groups['View user info label'] ?></th>
 162                                      <td>
 163                                          <label class="conl"><input type="radio" name="view_users" value="1"<?php if ($group['g_view_users'] == '1') echo ' checked="checked"' ?> tabindex="17" />&#160;<strong><?php echo $lang_admin_common['Yes'] ?></strong></label>
 164                                          <label class="conl"><input type="radio" name="view_users" value="0"<?php if ($group['g_view_users'] == '0') echo ' checked="checked"' ?> tabindex="18" />&#160;<strong><?php echo $lang_admin_common['No'] ?></strong></label>
 165                                          <span class="clearb"><?php echo $lang_admin_groups['View user info help'] ?></span>
 166                                      </td>
 167                                  </tr>
 168                                  <tr>
 169                                      <th scope="row"><?php echo $lang_admin_groups['Post replies label'] ?></th>
 170                                      <td>
 171                                          <label class="conl"><input type="radio" name="post_replies" value="1"<?php if ($group['g_post_replies'] == '1') echo ' checked="checked"' ?> tabindex="19" />&#160;<strong><?php echo $lang_admin_common['Yes'] ?></strong></label>
 172                                          <label class="conl"><input type="radio" name="post_replies" value="0"<?php if ($group['g_post_replies'] == '0') echo ' checked="checked"' ?> tabindex="20" />&#160;<strong><?php echo $lang_admin_common['No'] ?></strong></label>
 173                                          <span class="clearb"><?php echo $lang_admin_groups['Post replies help'] ?></span>
 174                                      </td>
 175                                  </tr>
 176                                  <tr>
 177                                      <th scope="row"><?php echo $lang_admin_groups['Post topics label'] ?></th>
 178                                      <td>
 179                                          <label class="conl"><input type="radio" name="post_topics" value="1"<?php if ($group['g_post_topics'] == '1') echo ' checked="checked"' ?> tabindex="21" />&#160;<strong><?php echo $lang_admin_common['Yes'] ?></strong></label>
 180                                          <label class="conl"><input type="radio" name="post_topics" value="0"<?php if ($group['g_post_topics'] == '0') echo ' checked="checked"' ?> tabindex="22" />&#160;<strong><?php echo $lang_admin_common['No'] ?></strong></label>
 181                                          <span class="clearb"><?php echo $lang_admin_groups['Post topics help'] ?></span>
 182                                      </td>
 183                                  </tr>
 184  <?php if ($group['g_id'] != PUN_GUEST): ?>                                <tr>
 185                                      <th scope="row"><?php echo $lang_admin_groups['Edit posts label'] ?></th>
 186                                      <td>
 187                                          <label class="conl"><input type="radio" name="edit_posts" value="1"<?php if ($group['g_edit_posts'] == '1') echo ' checked="checked"' ?> tabindex="23" />&#160;<strong><?php echo $lang_admin_common['Yes'] ?></strong></label>
 188                                          <label class="conl"><input type="radio" name="edit_posts" value="0"<?php if ($group['g_edit_posts'] == '0') echo ' checked="checked"' ?> tabindex="24" />&#160;<strong><?php echo $lang_admin_common['No'] ?></strong></label>
 189                                          <span class="clearb"><?php echo $lang_admin_groups['Edit posts help'] ?></span>
 190                                      </td>
 191                                  </tr>
 192                                  <tr>
 193                                      <th scope="row"><?php echo $lang_admin_groups['Delete posts label'] ?></th>
 194                                      <td>
 195                                          <label class="conl"><input type="radio" name="delete_posts" value="1"<?php if ($group['g_delete_posts'] == '1') echo ' checked="checked"' ?> tabindex="25" />&#160;<strong><?php echo $lang_admin_common['Yes'] ?></strong></label>
 196                                          <label class="conl"><input type="radio" name="delete_posts" value="0"<?php if ($group['g_delete_posts'] == '0') echo ' checked="checked"' ?> tabindex="26" />&#160;<strong><?php echo $lang_admin_common['No'] ?></strong></label>
 197                                          <span class="clearb"><?php echo $lang_admin_groups['Delete posts help'] ?></span>
 198                                      </td>
 199                                  </tr>
 200                                  <tr>
 201                                      <th scope="row"><?php echo $lang_admin_groups['Delete topics label'] ?></th>
 202                                      <td>
 203                                          <label class="conl"><input type="radio" name="delete_topics" value="1"<?php if ($group['g_delete_topics'] == '1') echo ' checked="checked"' ?> tabindex="27" />&#160;<strong><?php echo $lang_admin_common['Yes'] ?></strong></label>
 204                                          <label class="conl"><input type="radio" name="delete_topics" value="0"<?php if ($group['g_delete_topics'] == '0') echo ' checked="checked"' ?> tabindex="28" />&#160;<strong><?php echo $lang_admin_common['No'] ?></strong></label>
 205                                          <span class="clearb"><?php echo $lang_admin_groups['Delete topics help'] ?></span>
 206                                      </td>
 207                                  </tr>
 208  <?php endif; ?>                                <tr>
 209                                      <th scope="row"><?php echo $lang_admin_groups['Post links label'] ?></th>
 210                                      <td>
 211                                          <label class="conl"><input type="radio" name="post_links" value="1"<?php if ($group['g_post_links'] == '1') echo ' checked="checked"' ?> tabindex="29" />&#160;<strong><?php echo $lang_admin_common['Yes'] ?></strong></label>
 212                                          <label class="conl"><input type="radio" name="post_links" value="0"<?php if ($group['g_post_links'] == '0') echo ' checked="checked"' ?> tabindex="30" />&#160;<strong><?php echo $lang_admin_common['No'] ?></strong></label>
 213                                          <span class="clearb"><?php echo $lang_admin_groups['Post links help'] ?></span>
 214                                      </td>
 215                                  </tr>
 216  <?php if ($group['g_id'] != PUN_GUEST): ?>                                <tr>
 217                                      <th scope="row"><?php echo $lang_admin_groups['Set own title label'] ?></th>
 218                                      <td>
 219                                          <label class="conl"><input type="radio" name="set_title" value="1"<?php if ($group['g_set_title'] == '1') echo ' checked="checked"' ?> tabindex="31" />&#160;<strong><?php echo $lang_admin_common['Yes'] ?></strong></label>
 220                                          <label class="conl"><input type="radio" name="set_title" value="0"<?php if ($group['g_set_title'] == '0') echo ' checked="checked"' ?> tabindex="32" />&#160;<strong><?php echo $lang_admin_common['No'] ?></strong></label>
 221                                          <span class="clearb"><?php echo $lang_admin_groups['Set own title help'] ?></span>
 222                                      </td>
 223                                  </tr>
 224  <?php endif; ?>                                <tr>
 225                                      <th scope="row"><?php echo $lang_admin_groups['User search label'] ?></th>
 226                                      <td>
 227                                          <label class="conl"><input type="radio" name="search" value="1"<?php if ($group['g_search'] == '1') echo ' checked="checked"' ?> tabindex="33" />&#160;<strong><?php echo $lang_admin_common['Yes'] ?></strong></label>
 228                                          <label class="conl"><input type="radio" name="search" value="0"<?php if ($group['g_search'] == '0') echo ' checked="checked"' ?> tabindex="34" />&#160;<strong><?php echo $lang_admin_common['No'] ?></strong></label>
 229                                          <span class="clearb"><?php echo $lang_admin_groups['User search help'] ?></span>
 230                                      </td>
 231                                  </tr>
 232                                  <tr>
 233                                      <th scope="row"><?php echo $lang_admin_groups['User list search label'] ?></th>
 234                                      <td>
 235                                          <label class="conl"><input type="radio" name="search_users" value="1"<?php if ($group['g_search_users'] == '1') echo ' checked="checked"' ?> tabindex="35" />&#160;<strong><?php echo $lang_admin_common['Yes'] ?></strong></label>
 236                                          <label class="conl"><input type="radio" name="search_users" value="0"<?php if ($group['g_search_users'] == '0') echo ' checked="checked"' ?> tabindex="36" />&#160;<strong><?php echo $lang_admin_common['No'] ?></strong></label>
 237                                          <span class="clearb"><?php echo $lang_admin_groups['User list search help'] ?></span>
 238                                      </td>
 239                                  </tr>
 240  <?php if ($group['g_id'] != PUN_GUEST): ?>                                <tr>
 241                                      <th scope="row"><?php echo $lang_admin_groups['Send e-mails label'] ?></th>
 242                                      <td>
 243                                          <label class="conl"><input type="radio" name="send_email" value="1"<?php if ($group['g_send_email'] == '1') echo ' checked="checked"' ?> tabindex="37" />&#160;<strong><?php echo $lang_admin_common['Yes'] ?></strong></label>
 244                                          <label class="conl"><input type="radio" name="send_email" value="0"<?php if ($group['g_send_email'] == '0') echo ' checked="checked"' ?> tabindex="38" />&#160;<strong><?php echo $lang_admin_common['No'] ?></strong></label>
 245                                          <span class="clearb"><?php echo $lang_admin_groups['Send e-mails help'] ?></span>
 246                                      </td>
 247                                  </tr>
 248  <?php endif; ?>                                <tr>
 249                                      <th scope="row"><?php echo $lang_admin_groups['Post flood label'] ?></th>
 250                                      <td>
 251                                          <input type="text" name="post_flood" size="5" maxlength="4" value="<?php echo $group['g_post_flood'] ?>" tabindex="39" />
 252                                          <span><?php echo $lang_admin_groups['Post flood help'] ?></span>
 253                                      </td>
 254                                  </tr>
 255                                  <tr>
 256                                      <th scope="row"><?php echo $lang_admin_groups['Search flood label'] ?></th>
 257                                      <td>
 258                                          <input type="text" name="search_flood" size="5" maxlength="4" value="<?php echo $group['g_search_flood'] ?>" tabindex="40" />
 259                                          <span><?php echo $lang_admin_groups['Search flood help'] ?></span>
 260                                      </td>
 261                                  </tr>
 262  <?php if ($group['g_id'] != PUN_GUEST): ?>                                <tr>
 263                                      <th scope="row"><?php echo $lang_admin_groups['E-mail flood label'] ?></th>
 264                                      <td>
 265                                          <input type="text" name="email_flood" size="5" maxlength="4" value="<?php echo $group['g_email_flood'] ?>" tabindex="41" />
 266                                          <span><?php echo $lang_admin_groups['E-mail flood help'] ?></span>
 267                                      </td>
 268                                  </tr>
 269                                  <tr>
 270                                      <th scope="row"><?php echo $lang_admin_groups['Report flood label'] ?></th>
 271                                      <td>
 272                                          <input type="text" name="report_flood" size="5" maxlength="4" value="<?php echo $group['g_report_flood'] ?>" tabindex="42" />
 273                                          <span><?php echo $lang_admin_groups['Report flood help'] ?></span>
 274                                      </td>
 275                                  </tr>
 276  <?php endif; endif; ?>                            </table>
 277  <?php if ($group['g_moderator'] == '1' ): ?>                            <p class="warntext"><?php echo $lang_admin_groups['Moderator info'] ?></p>
 278  <?php endif; ?>                        </div>
 279                      </fieldset>
 280                  </div>
 281                  <p class="submitend"><input type="submit" name="add_edit_group" value="<?php echo $lang_admin_common['Save'] ?>" tabindex="43" /></p>
 282              </form>
 283          </div>
 284      </div>
 285      <div class="clearer"></div>
 286  </div>
 287  <?php
 288  
 289      require  PUN_ROOT.'footer.php';
 290  }
 291  
 292  
 293  // Add/edit a group (stage 2)
 294  else if (isset($_POST['add_edit_group']))
 295  {
 296      confirm_referrer('admin_groups.php');
 297  
 298      // Is this the admin group? (special rules apply)
 299      $is_admin_group = (isset($_POST['group_id']) && $_POST['group_id'] == PUN_ADMIN) ? true : false;
 300  
 301      $title = pun_trim($_POST['req_title']);
 302      $user_title = pun_trim($_POST['user_title']);
 303  
 304      $promote_min_posts = isset($_POST['promote_min_posts']) ? intval($_POST['promote_min_posts']) : '0';
 305      if (isset($_POST['promote_next_group']) &&
 306              isset($groups[$_POST['promote_next_group']]) &&
 307              !in_array($_POST['promote_next_group'], array(PUN_ADMIN, PUN_GUEST)) &&
 308              (!isset($_POST['group_id']) || $_POST['promote_next_group'] != $_POST['group_id']))
 309          $promote_next_group = $_POST['promote_next_group'];
 310      else
 311          $promote_next_group = '0';
 312  
 313      $moderator = isset($_POST['moderator']) && $_POST['moderator'] == '1' ? '1' : '0';
 314      $mod_edit_users = $moderator == '1' && isset($_POST['mod_edit_users']) && $_POST['mod_edit_users'] == '1' ? '1' : '0';
 315      $mod_rename_users = $moderator == '1' && isset($_POST['mod_rename_users']) && $_POST['mod_rename_users'] == '1' ? '1' : '0';
 316      $mod_change_passwords = $moderator == '1' && isset($_POST['mod_change_passwords']) && $_POST['mod_change_passwords'] == '1' ? '1' : '0';
 317      $mod_ban_users = $moderator == '1' && isset($_POST['mod_ban_users']) && $_POST['mod_ban_users'] == '1' ? '1' : '0';
 318      $read_board = isset($_POST['read_board']) ? intval($_POST['read_board']) : '1';
 319      $view_users = (isset($_POST['view_users']) && $_POST['view_users'] == '1') || $is_admin_group ? '1' : '0';
 320      $post_replies = isset($_POST['post_replies']) ? intval($_POST['post_replies']) : '1';
 321      $post_topics = isset($_POST['post_topics']) ? intval($_POST['post_topics']) : '1';
 322      $edit_posts = isset($_POST['edit_posts']) ? intval($_POST['edit_posts']) : ($is_admin_group) ? '1' : '0';
 323      $delete_posts = isset($_POST['delete_posts']) ? intval($_POST['delete_posts']) : ($is_admin_group) ? '1' : '0';
 324      $delete_topics = isset($_POST['delete_topics']) ? intval($_POST['delete_topics']) : ($is_admin_group) ? '1' : '0';
 325      $post_links = isset($_POST['post_links']) ? intval($_POST['post_links']) : '1';
 326      $set_title = isset($_POST['set_title']) ? intval($_POST['set_title']) : ($is_admin_group) ? '1' : '0';
 327      $search = isset($_POST['search']) ? intval($_POST['search']) : '1';
 328      $search_users = isset($_POST['search_users']) ? intval($_POST['search_users']) : '1';
 329      $send_email = (isset($_POST['send_email']) && $_POST['send_email'] == '1') || $is_admin_group ? '1' : '0';
 330      $post_flood = (isset($_POST['post_flood']) && $_POST['post_flood'] >= 0) ? intval($_POST['post_flood']) : '0';
 331      $search_flood = (isset($_POST['search_flood']) && $_POST['search_flood'] >= 0) ? intval($_POST['search_flood']) : '0';
 332      $email_flood = (isset($_POST['email_flood']) && $_POST['email_flood'] >= 0) ? intval($_POST['email_flood']) : '0';
 333      $report_flood = (isset($_POST['report_flood']) && $_POST['report_flood'] >= 0) ? intval($_POST['report_flood']) : '0';
 334  
 335      if ($title == '')
 336          message($lang_admin_groups['Must enter title message']);
 337  
 338      $user_title = ($user_title != '') ? '\''.$db->escape($user_title).'\'' : 'NULL';
 339  
 340      if ($_POST['mode'] == 'add')
 341      {
 342          $result = $db->query('SELECT 1 FROM '.$db->prefix.'groups WHERE g_title=\''.$db->escape($title).'\'') or error('Unable to check group title collision', __FILE__, __LINE__, $db->error());
 343          if ($db->num_rows($result))
 344              message(sprintf($lang_admin_groups['Title already exists message'], pun_htmlspecialchars($title)));
 345  
 346          $db->query('INSERT INTO '.$db->prefix.'groups (g_title, g_user_title, g_promote_min_posts, g_promote_next_group, g_moderator, g_mod_edit_users, g_mod_rename_users, g_mod_change_passwords, g_mod_ban_users, g_read_board, g_view_users, g_post_replies, g_post_topics, g_edit_posts, g_delete_posts, g_delete_topics, g_post_links, g_set_title, g_search, g_search_users, g_send_email, g_post_flood, g_search_flood, g_email_flood, g_report_flood) VALUES(\''.$db->escape($title).'\', '.$user_title.', '.$promote_min_posts.', '.$promote_next_group.', '.$moderator.', '.$mod_edit_users.', '.$mod_rename_users.', '.$mod_change_passwords.', '.$mod_ban_users.', '.$read_board.', '.$view_users.', '.$post_replies.', '.$post_topics.', '.$edit_posts.', '.$delete_posts.', '.$delete_topics.', '.$post_links.', '.$set_title.', '.$search.', '.$search_users.', '.$send_email.', '.$post_flood.', '.$search_flood.', '.$email_flood.', '.$report_flood.')') or error('Unable to add group', __FILE__, __LINE__, $db->error());
 347          $new_group_id = $db->insert_id();
 348  
 349          // Now lets copy the forum specific permissions from the group which this group is based on
 350          $result = $db->query('SELECT forum_id, read_forum, post_replies, post_topics FROM '.$db->prefix.'forum_perms WHERE group_id='.intval($_POST['base_group'])) or error('Unable to fetch group forum permission list', __FILE__, __LINE__, $db->error());
 351          while ($cur_forum_perm = $db->fetch_assoc($result))
 352              $db->query('INSERT INTO '.$db->prefix.'forum_perms (group_id, forum_id, read_forum, post_replies, post_topics) VALUES('.$new_group_id.', '.$cur_forum_perm['forum_id'].', '.$cur_forum_perm['read_forum'].', '.$cur_forum_perm['post_replies'].', '.$cur_forum_perm['post_topics'].')') or error('Unable to insert group forum permissions', __FILE__, __LINE__, $db->error());
 353      }
 354      else
 355      {
 356          $result = $db->query('SELECT 1 FROM '.$db->prefix.'groups WHERE g_title=\''.$db->escape($title).'\' AND g_id!='.intval($_POST['group_id'])) or error('Unable to check group title collision', __FILE__, __LINE__, $db->error());
 357          if ($db->num_rows($result))
 358              message(sprintf($lang_admin_groups['Title already exists message'], pun_htmlspecialchars($title)));
 359  
 360          $db->query('UPDATE '.$db->prefix.'groups SET g_title=\''.$db->escape($title).'\', g_user_title='.$user_title.', g_promote_min_posts='.$promote_min_posts.', g_promote_next_group='.$promote_next_group.', g_moderator='.$moderator.', g_mod_edit_users='.$mod_edit_users.', g_mod_rename_users='.$mod_rename_users.', g_mod_change_passwords='.$mod_change_passwords.', g_mod_ban_users='.$mod_ban_users.', g_read_board='.$read_board.', g_view_users='.$view_users.', g_post_replies='.$post_replies.', g_post_topics='.$post_topics.', g_edit_posts='.$edit_posts.', g_delete_posts='.$delete_posts.', g_delete_topics='.$delete_topics.', g_post_links='.$post_links.', g_set_title='.$set_title.', g_search='.$search.', g_search_users='.$search_users.', g_send_email='.$send_email.', g_post_flood='.$post_flood.', g_search_flood='.$search_flood.', g_email_flood='.$email_flood.', g_report_flood='.$report_flood.' WHERE g_id='.intval($_POST['group_id'])) or error('Unable to update group', __FILE__, __LINE__, $db->error());
 361      }
 362  
 363      // Regenerate the quick jump cache
 364      if (!defined('FORUM_CACHE_FUNCTIONS_LOADED'))
 365          require  PUN_ROOT.'include/cache.php';
 366  
 367      $group_id = $_POST['mode'] == 'add' ? $new_group_id : intval($_POST['group_id']);
 368      generate_quickjump_cache($group_id);
 369  
 370      if ($_POST['mode'] == 'edit')
 371          redirect('admin_groups.php', $lang_admin_groups['Group edited redirect']);
 372      else
 373          redirect('admin_groups.php', $lang_admin_groups['Group added redirect']);
 374  }
 375  
 376  
 377  // Set default group
 378  else if (isset($_POST['set_default_group']))
 379  {
 380      confirm_referrer('admin_groups.php');
 381  
 382      $group_id = intval($_POST['default_group']);
 383  
 384      // Make sure it's not the admin or guest groups
 385      if ($group_id == PUN_ADMIN || $group_id == PUN_GUEST)
 386          message($lang_common['Bad request'], false, '404 Not Found');
 387  
 388      // Make sure it's not a moderator group
 389      if ($groups[$group_id]['g_moderator'] != 0)
 390          message($lang_common['Bad request'], false, '404 Not Found');
 391  
 392      $db->query('UPDATE '.$db->prefix.'config SET conf_value='.$group_id.' WHERE conf_name=\'o_default_user_group\'') or error('Unable to update board config', __FILE__, __LINE__, $db->error());
 393  
 394      // Regenerate the config cache
 395      if (!defined('FORUM_CACHE_FUNCTIONS_LOADED'))
 396          require  PUN_ROOT.'include/cache.php';
 397  
 398      generate_config_cache();
 399  
 400      redirect('admin_groups.php', $lang_admin_groups['Default group redirect']);
 401  }
 402  
 403  
 404  // Remove a group
 405  else if (isset($_GET['del_group']))
 406  {
 407      confirm_referrer('admin_groups.php');
 408  
 409      $group_id = isset($_POST['group_to_delete']) ? intval($_POST['group_to_delete']) : intval($_GET['del_group']);
 410      if ($group_id < 5)
 411          message($lang_common['Bad request'], false, '404 Not Found');
 412  
 413      // Make sure we don't remove the default group
 414      if ($group_id == $pun_config['o_default_user_group'])
 415          message($lang_admin_groups['Cannot remove default message']);
 416  
 417      // Check if this group has any members
 418      $result = $db->query('SELECT g.g_title, COUNT(u.id) FROM '.$db->prefix.'groups AS g INNER JOIN '.$db->prefix.'users AS u ON g.g_id=u.group_id WHERE g.g_id='.$group_id.' GROUP BY g.g_id, g_title') or error('Unable to fetch group info', __FILE__, __LINE__, $db->error());
 419  
 420      // If the group doesn't have any members or if we've already selected a group to move the members to
 421      if (!$db->num_rows($result) || isset($_POST['del_group']))
 422      {
 423          if (isset($_POST['del_group_comply']) || isset($_POST['del_group']))
 424          {
 425              if (isset($_POST['del_group']))
 426              {
 427                  $move_to_group = intval($_POST['move_to_group']);
 428                  $db->query('UPDATE '.$db->prefix.'users SET group_id='.$move_to_group.' WHERE group_id='.$group_id) or error('Unable to move users into group', __FILE__, __LINE__, $db->error());
 429              }
 430  
 431              // Delete the group and any forum specific permissions
 432              $db->query('DELETE FROM '.$db->prefix.'groups WHERE g_id='.$group_id) or error('Unable to delete group', __FILE__, __LINE__, $db->error());
 433              $db->query('DELETE FROM '.$db->prefix.'forum_perms WHERE group_id='.$group_id) or error('Unable to delete group forum permissions', __FILE__, __LINE__, $db->error());
 434  
 435              // Don't let users be promoted to this group
 436              $db->query('UPDATE '.$db->prefix.'groups SET g_promote_next_group=0 WHERE g_promote_next_group='.$group_id) or error('Unable to remove group as promotion target', __FILE__, __LINE__, $db->error());
 437  
 438              redirect('admin_groups.php', $lang_admin_groups['Group removed redirect']);
 439          }
 440          else
 441          {
 442              $result = $db->query('SELECT g_title FROM '.$db->prefix.'groups WHERE g_id='.$group_id) or error('Unable to fetch group title', __FILE__, __LINE__, $db->error());
 443              $group_title = $db->result($result);
 444  
 445              $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['User groups']);
 446              define('PUN_ACTIVE_PAGE', 'admin');
 447              require  PUN_ROOT.'header.php';
 448  
 449              generate_admin_menu('groups');
 450  
 451  ?>
 452      <div class="blockform">
 453          <h2><span><?php echo $lang_admin_groups['Group delete head'] ?></span></h2>
 454          <div class="box">
 455              <form method="post" action="admin_groups.php?del_group=<?php echo $group_id ?>">
 456                  <div class="inform">
 457                  <input type="hidden" name="group_to_delete" value="<?php echo $group_id ?>" />
 458                      <fieldset>
 459                          <legend><?php echo $lang_admin_groups['Confirm delete subhead'] ?></legend>
 460                          <div class="infldset">
 461                              <p><?php printf($lang_admin_groups['Confirm delete info'], pun_htmlspecialchars($group_title)) ?></p>
 462                              <p class="warntext"><?php echo $lang_admin_groups['Confirm delete warn'] ?></p>
 463                          </div>
 464                      </fieldset>
 465                  </div>
 466                  <p class="buttons"><input type="submit" name="del_group_comply" value="<?php echo $lang_admin_common['Delete'] ?>" tabindex="1" /><a href="javascript:history.go(-1)" tabindex="2"><?php echo $lang_admin_common['Go back'] ?></a></p>
 467              </form>
 468          </div>
 469      </div>
 470      <div class="clearer"></div>
 471  </div>
 472  <?php
 473  
 474              require  PUN_ROOT.'footer.php';
 475          }
 476      }
 477  
 478      list($group_title, $group_members) = $db->fetch_row($result);
 479  
 480      $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['User groups']);
 481      define('PUN_ACTIVE_PAGE', 'admin');
 482      require  PUN_ROOT.'header.php';
 483  
 484      generate_admin_menu('groups');
 485  
 486  ?>
 487      <div class="blockform">
 488          <h2><span><?php echo $lang_admin_groups['Delete group head'] ?></span></h2>
 489          <div class="box">
 490              <form id="groups" method="post" action="admin_groups.php?del_group=<?php echo $group_id ?>">
 491                  <div class="inform">
 492                      <fieldset>
 493                          <legend><?php echo $lang_admin_groups['Move users subhead'] ?></legend>
 494                          <div class="infldset">
 495                              <p><?php printf($lang_admin_groups['Move users info'], pun_htmlspecialchars($group_title), forum_number_format($group_members)) ?></p>
 496                              <label><?php echo $lang_admin_groups['Move users label'] ?>
 497                              <select name="move_to_group">
 498  <?php
 499  
 500      $result = $db->query('SELECT g_id, g_title FROM '.$db->prefix.'groups WHERE g_id!='.PUN_GUEST.' AND g_id!='.$group_id.' ORDER BY g_title') or error('Unable to fetch user group list', __FILE__, __LINE__, $db->error());
 501  
 502      while ($cur_group = $db->fetch_assoc($result))
 503      {
 504          if ($cur_group['g_id'] == PUN_MEMBER) // Pre-select the pre-defined Members group
 505              echo "\t\t\t\t\t\t\t\t\t\t".'<option value="'.$cur_group['g_id'].'" selected="selected">'.pun_htmlspecialchars($cur_group['g_title']).'</option>'."\n";
 506          else
 507              echo "\t\t\t\t\t\t\t\t\t\t".'<option value="'.$cur_group['g_id'].'">'.pun_htmlspecialchars($cur_group['g_title']).'</option>'."\n";
 508      }
 509  
 510  ?>
 511                              </select>
 512                              <br /></label>
 513                          </div>
 514                      </fieldset>
 515                  </div>
 516                  <p class="buttons"><input type="submit" name="del_group" value="<?php echo $lang_admin_groups['Delete group'] ?>" /><a href="javascript:history.go(-1)"><?php echo $lang_admin_common['Go back'] ?></a></p>
 517              </form>
 518          </div>
 519      </div>
 520      <div class="clearer"></div>
 521  </div>
 522  <?php
 523  
 524      require  PUN_ROOT.'footer.php';
 525  }
 526  
 527  
 528  $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['User groups']);
 529  define('PUN_ACTIVE_PAGE', 'admin');
 530  require  PUN_ROOT.'header.php';
 531  
 532  generate_admin_menu('groups');
 533  
 534  ?>
 535      <div class="blockform">
 536          <h2><span><?php echo $lang_admin_groups['Add groups head'] ?></span></h2>
 537          <div class="box">
 538              <form id="groups" method="post" action="admin_groups.php">
 539                  <div class="inform">
 540                      <fieldset>
 541                          <legend><?php echo $lang_admin_groups['Add group subhead'] ?></legend>
 542                          <div class="infldset">
 543                              <table class="aligntop">
 544                                  <tr>
 545                                      <th scope="row"><?php echo $lang_admin_groups['New group label'] ?><div><input type="submit" name="add_group" value="<?php echo $lang_admin_common['Add'] ?>" tabindex="2" /></div></th>
 546                                      <td>
 547                                          <select id="base_group" name="base_group" tabindex="1">
 548  <?php
 549  
 550  foreach ($groups as $cur_group)
 551  {
 552      if ($cur_group['g_id'] != PUN_ADMIN && $cur_group['g_id'] != PUN_GUEST)
 553      {
 554          if ($cur_group['g_id'] == $pun_config['o_default_user_group'])
 555              echo "\t\t\t\t\t\t\t\t\t\t\t".'<option value="'.$cur_group['g_id'].'" selected="selected">'.pun_htmlspecialchars($cur_group['g_title']).'</option>'."\n";
 556          else
 557              echo "\t\t\t\t\t\t\t\t\t\t\t".'<option value="'.$cur_group['g_id'].'">'.pun_htmlspecialchars($cur_group['g_title']).'</option>'."\n";
 558      }
 559  }
 560  
 561  ?>
 562                                          </select>
 563                                          <span><?php echo $lang_admin_groups['New group help'] ?></span>
 564                                      </td>
 565                                  </tr>
 566                              </table>
 567                          </div>
 568                      </fieldset>
 569                  </div>
 570                  <div class="inform">
 571                      <fieldset>
 572                          <legend><?php echo $lang_admin_groups['Default group subhead'] ?></legend>
 573                          <div class="infldset">
 574                              <table class="aligntop">
 575                                  <tr>
 576                                      <th scope="row"><?php echo $lang_admin_groups['Default group label'] ?><div><input type="submit" name="set_default_group" value="<?php echo $lang_admin_common['Save'] ?>" tabindex="4" /></div></th>
 577                                      <td>
 578                                          <select id="default_group" name="default_group" tabindex="3">
 579  <?php
 580  
 581  foreach ($groups as $cur_group)
 582  {
 583      if ($cur_group['g_id'] > PUN_GUEST && $cur_group['g_moderator'] == 0)
 584      {
 585          if ($cur_group['g_id'] == $pun_config['o_default_user_group'])
 586              echo "\t\t\t\t\t\t\t\t\t\t\t".'<option value="'.$cur_group['g_id'].'" selected="selected">'.pun_htmlspecialchars($cur_group['g_title']).'</option>'."\n";
 587          else
 588              echo "\t\t\t\t\t\t\t\t\t\t\t".'<option value="'.$cur_group['g_id'].'">'.pun_htmlspecialchars($cur_group['g_title']).'</option>'."\n";
 589      }
 590  }
 591  
 592  ?>
 593                                          </select>
 594                                          <span><?php echo $lang_admin_groups['Default group help'] ?></span>
 595                                      </td>
 596                                  </tr>
 597                              </table>
 598                          </div>
 599                      </fieldset>
 600                  </div>
 601              </form>
 602          </div>
 603  
 604          <h2 class="block2"><span><?php echo $lang_admin_groups['Existing groups head'] ?></span></h2>
 605          <div class="box">
 606              <div class="fakeform">
 607                  <div class="inform">
 608                      <fieldset>
 609                          <legend><?php echo $lang_admin_groups['Edit groups subhead'] ?></legend>
 610                          <div class="infldset">
 611                              <p><?php echo $lang_admin_groups['Edit groups info'] ?></p>
 612                              <table>
 613  <?php
 614  
 615  $cur_index = 5;
 616  
 617  foreach ($groups as $cur_group)
 618      echo "\t\t\t\t\t\t\t\t".'<tr><th scope="row"><a href="admin_groups.php?edit_group='.$cur_group['g_id'].'" tabindex="'.$cur_index++.'">'.$lang_admin_groups['Edit link'].'</a>'.(($cur_group['g_id'] > PUN_MEMBER) ? ' | <a href="admin_groups.php?del_group='.$cur_group['g_id'].'" tabindex="'.$cur_index++.'">'.$lang_admin_groups['Delete link'].'</a>' : '').'</th><td>'.pun_htmlspecialchars($cur_group['g_title']).'</td></tr>'."\n";
 619  
 620  ?>
 621                              </table>
 622                          </div>
 623                      </fieldset>
 624                  </div>
 625              </div>
 626          </div>
 627      </div>
 628      <div class="clearer"></div>
 629  </div>
 630  <?php
 631  
 632  require  PUN_ROOT.'footer.php';

title

Description

title

Description

title

Description

title

title

Body