FluxBB PHP Cross Reference Discussion Forums

Source: /admin_groups.php - 645 lines - 37461 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['Mod promote users label'] ?></th>
 146                                      <td>
 147                                          <label class="conl"><input type="radio" name="mod_promote_users" value="1"<?php if ($group['g_mod_promote_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_promote_users" value="0"<?php if ($group['g_mod_promote_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['Mod promote users help'] ?></span>
 150                                      </td>
 151                                  </tr>
 152                                  <tr>
 153                                      <th scope="row"><?php echo $lang_admin_groups['Ban users label'] ?></th>
 154                                      <td>
 155                                          <label class="conl"><input type="radio" name="mod_ban_users" value="1"<?php if ($group['g_mod_ban_users'] == '1') echo ' checked="checked"' ?> tabindex="15" />&#160;<strong><?php echo $lang_admin_common['Yes'] ?></strong></label>
 156                                          <label class="conl"><input type="radio" name="mod_ban_users" value="0"<?php if ($group['g_mod_ban_users'] == '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['Ban users help'] ?></span>
 158                                      </td>
 159                                  </tr>
 160  <?php endif; endif; ?>                                <tr>
 161                                      <th scope="row"><?php echo $lang_admin_groups['Read board label'] ?></th>
 162                                      <td>
 163                                          <label class="conl"><input type="radio" name="read_board" value="1"<?php if ($group['g_read_board'] == '1') echo ' checked="checked"' ?> tabindex="17" />&#160;<strong><?php echo $lang_admin_common['Yes'] ?></strong></label>
 164                                          <label class="conl"><input type="radio" name="read_board" value="0"<?php if ($group['g_read_board'] == '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['Read board help'] ?></span>
 166                                      </td>
 167                                  </tr>
 168                                  <tr>
 169                                      <th scope="row"><?php echo $lang_admin_groups['View user info label'] ?></th>
 170                                      <td>
 171                                          <label class="conl"><input type="radio" name="view_users" value="1"<?php if ($group['g_view_users'] == '1') echo ' checked="checked"' ?> tabindex="19" />&#160;<strong><?php echo $lang_admin_common['Yes'] ?></strong></label>
 172                                          <label class="conl"><input type="radio" name="view_users" value="0"<?php if ($group['g_view_users'] == '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['View user info help'] ?></span>
 174                                      </td>
 175                                  </tr>
 176                                  <tr>
 177                                      <th scope="row"><?php echo $lang_admin_groups['Post replies label'] ?></th>
 178                                      <td>
 179                                          <label class="conl"><input type="radio" name="post_replies" value="1"<?php if ($group['g_post_replies'] == '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_replies" value="0"<?php if ($group['g_post_replies'] == '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 replies help'] ?></span>
 182                                      </td>
 183                                  </tr>
 184                                  <tr>
 185                                      <th scope="row"><?php echo $lang_admin_groups['Post topics label'] ?></th>
 186                                      <td>
 187                                          <label class="conl"><input type="radio" name="post_topics" value="1"<?php if ($group['g_post_topics'] == '1') echo ' checked="checked"' ?> tabindex="23" />&#160;<strong><?php echo $lang_admin_common['Yes'] ?></strong></label>
 188                                          <label class="conl"><input type="radio" name="post_topics" value="0"<?php if ($group['g_post_topics'] == '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['Post topics help'] ?></span>
 190                                      </td>
 191                                  </tr>
 192  <?php if ($group['g_id'] != PUN_GUEST): ?>                                <tr>
 193                                      <th scope="row"><?php echo $lang_admin_groups['Edit posts label'] ?></th>
 194                                      <td>
 195                                          <label class="conl"><input type="radio" name="edit_posts" value="1"<?php if ($group['g_edit_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="edit_posts" value="0"<?php if ($group['g_edit_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['Edit posts help'] ?></span>
 198                                      </td>
 199                                  </tr>
 200                                  <tr>
 201                                      <th scope="row"><?php echo $lang_admin_groups['Delete posts label'] ?></th>
 202                                      <td>
 203                                          <label class="conl"><input type="radio" name="delete_posts" value="1"<?php if ($group['g_delete_posts'] == '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_posts" value="0"<?php if ($group['g_delete_posts'] == '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 posts help'] ?></span>
 206                                      </td>
 207                                  </tr>
 208                                  <tr>
 209                                      <th scope="row"><?php echo $lang_admin_groups['Delete topics label'] ?></th>
 210                                      <td>
 211                                          <label class="conl"><input type="radio" name="delete_topics" value="1"<?php if ($group['g_delete_topics'] == '1') echo ' checked="checked"' ?> tabindex="29" />&#160;<strong><?php echo $lang_admin_common['Yes'] ?></strong></label>
 212                                          <label class="conl"><input type="radio" name="delete_topics" value="0"<?php if ($group['g_delete_topics'] == '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['Delete topics help'] ?></span>
 214                                      </td>
 215                                  </tr>
 216  <?php endif; ?>                                <tr>
 217                                      <th scope="row"><?php echo $lang_admin_groups['Post links label'] ?></th>
 218                                      <td>
 219                                          <label class="conl"><input type="radio" name="post_links" value="1"<?php if ($group['g_post_links'] == '1') echo ' checked="checked"' ?> tabindex="31" />&#160;<strong><?php echo $lang_admin_common['Yes'] ?></strong></label>
 220                                          <label class="conl"><input type="radio" name="post_links" value="0"<?php if ($group['g_post_links'] == '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['Post links help'] ?></span>
 222                                      </td>
 223                                  </tr>
 224  <?php if ($group['g_id'] != PUN_GUEST): ?>                                <tr>
 225                                      <th scope="row"><?php echo $lang_admin_groups['Set own title label'] ?></th>
 226                                      <td>
 227                                          <label class="conl"><input type="radio" name="set_title" value="1"<?php if ($group['g_set_title'] == '1') echo ' checked="checked"' ?> tabindex="33" />&#160;<strong><?php echo $lang_admin_common['Yes'] ?></strong></label>
 228                                          <label class="conl"><input type="radio" name="set_title" value="0"<?php if ($group['g_set_title'] == '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['Set own title help'] ?></span>
 230                                      </td>
 231                                  </tr>
 232  <?php endif; ?>                                <tr>
 233                                      <th scope="row"><?php echo $lang_admin_groups['User search label'] ?></th>
 234                                      <td>
 235                                          <label class="conl"><input type="radio" name="search" value="1"<?php if ($group['g_search'] == '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" value="0"<?php if ($group['g_search'] == '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 search help'] ?></span>
 238                                      </td>
 239                                  </tr>
 240                                  <tr>
 241                                      <th scope="row"><?php echo $lang_admin_groups['User list search label'] ?></th>
 242                                      <td>
 243                                          <label class="conl"><input type="radio" name="search_users" value="1"<?php if ($group['g_search_users'] == '1') echo ' checked="checked"' ?> tabindex="37" />&#160;<strong><?php echo $lang_admin_common['Yes'] ?></strong></label>
 244                                          <label class="conl"><input type="radio" name="search_users" value="0"<?php if ($group['g_search_users'] == '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['User list search help'] ?></span>
 246                                      </td>
 247                                  </tr>
 248  <?php if ($group['g_id'] != PUN_GUEST): ?>                                <tr>
 249                                      <th scope="row"><?php echo $lang_admin_groups['Send e-mails label'] ?></th>
 250                                      <td>
 251                                          <label class="conl"><input type="radio" name="send_email" value="1"<?php if ($group['g_send_email'] == '1') echo ' checked="checked"' ?> tabindex="39" />&#160;<strong><?php echo $lang_admin_common['Yes'] ?></strong></label>
 252                                          <label class="conl"><input type="radio" name="send_email" value="0"<?php if ($group['g_send_email'] == '0') echo ' checked="checked"' ?> tabindex="40" />&#160;<strong><?php echo $lang_admin_common['No'] ?></strong></label>
 253                                          <span class="clearb"><?php echo $lang_admin_groups['Send e-mails help'] ?></span>
 254                                      </td>
 255                                  </tr>
 256  <?php endif; ?>                                <tr>
 257                                      <th scope="row"><?php echo $lang_admin_groups['Post flood label'] ?></th>
 258                                      <td>
 259                                          <input type="text" name="post_flood" size="5" maxlength="4" value="<?php echo $group['g_post_flood'] ?>" tabindex="41" />
 260                                          <span><?php echo $lang_admin_groups['Post flood help'] ?></span>
 261                                      </td>
 262                                  </tr>
 263                                  <tr>
 264                                      <th scope="row"><?php echo $lang_admin_groups['Search flood label'] ?></th>
 265                                      <td>
 266                                          <input type="text" name="search_flood" size="5" maxlength="4" value="<?php echo $group['g_search_flood'] ?>" tabindex="42" />
 267                                          <span><?php echo $lang_admin_groups['Search flood help'] ?></span>
 268                                      </td>
 269                                  </tr>
 270  <?php if ($group['g_id'] != PUN_GUEST): ?>                                <tr>
 271                                      <th scope="row"><?php echo $lang_admin_groups['E-mail flood label'] ?></th>
 272                                      <td>
 273                                          <input type="text" name="email_flood" size="5" maxlength="4" value="<?php echo $group['g_email_flood'] ?>" tabindex="43" />
 274                                          <span><?php echo $lang_admin_groups['E-mail flood help'] ?></span>
 275                                      </td>
 276                                  </tr>
 277                                  <tr>
 278                                      <th scope="row"><?php echo $lang_admin_groups['Report flood label'] ?></th>
 279                                      <td>
 280                                          <input type="text" name="report_flood" size="5" maxlength="4" value="<?php echo $group['g_report_flood'] ?>" tabindex="44" />
 281                                          <span><?php echo $lang_admin_groups['Report flood help'] ?></span>
 282                                      </td>
 283                                  </tr>
 284  <?php endif; endif; ?>                            </table>
 285  <?php if ($group['g_moderator'] == '1' ): ?>                            <p class="warntext"><?php echo $lang_admin_groups['Moderator info'] ?></p>
 286  <?php endif; ?>                        </div>
 287                      </fieldset>
 288                  </div>
 289                  <p class="submitend"><input type="submit" name="add_edit_group" value="<?php echo $lang_admin_common['Save'] ?>" tabindex="45" /></p>
 290              </form>
 291          </div>
 292      </div>
 293      <div class="clearer"></div>
 294  </div>
 295  <?php
 296  
 297      require  PUN_ROOT.'footer.php';
 298  }
 299  
 300  
 301  // Add/edit a group (stage 2)
 302  else if (isset($_POST['add_edit_group']))
 303  {
 304      confirm_referrer('admin_groups.php');
 305  
 306      // Is this the admin group? (special rules apply)
 307      $is_admin_group = (isset($_POST['group_id']) && $_POST['group_id'] == PUN_ADMIN) ? true : false;
 308  
 309      $title = pun_trim($_POST['req_title']);
 310      $user_title = pun_trim($_POST['user_title']);
 311  
 312      $promote_min_posts = isset($_POST['promote_min_posts']) ? intval($_POST['promote_min_posts']) : '0';
 313      if (isset($_POST['promote_next_group']) &&
 314              isset($groups[$_POST['promote_next_group']]) &&
 315              !in_array($_POST['promote_next_group'], array(PUN_ADMIN, PUN_GUEST)) &&
 316              (!isset($_POST['group_id']) || $_POST['promote_next_group'] != $_POST['group_id']))
 317          $promote_next_group = $_POST['promote_next_group'];
 318      else
 319          $promote_next_group = '0';
 320  
 321      $moderator = isset($_POST['moderator']) && $_POST['moderator'] == '1' ? '1' : '0';
 322      $mod_edit_users = $moderator == '1' && isset($_POST['mod_edit_users']) && $_POST['mod_edit_users'] == '1' ? '1' : '0';
 323      $mod_rename_users = $moderator == '1' && isset($_POST['mod_rename_users']) && $_POST['mod_rename_users'] == '1' ? '1' : '0';
 324      $mod_change_passwords = $moderator == '1' && isset($_POST['mod_change_passwords']) && $_POST['mod_change_passwords'] == '1' ? '1' : '0';
 325      $mod_ban_users = $moderator == '1' && isset($_POST['mod_ban_users']) && $_POST['mod_ban_users'] == '1' ? '1' : '0';
 326      $mod_promote_users = $moderator == '1' && isset($_POST['mod_promote_users']) && $_POST['mod_promote_users'] == '1' ? '1' : '0';
 327      $read_board = isset($_POST['read_board']) ? intval($_POST['read_board']) : '1';
 328      $view_users = (isset($_POST['view_users']) && $_POST['view_users'] == '1') || $is_admin_group ? '1' : '0';
 329      $post_replies = isset($_POST['post_replies']) ? intval($_POST['post_replies']) : '1';
 330      $post_topics = isset($_POST['post_topics']) ? intval($_POST['post_topics']) : '1';
 331      $edit_posts = isset($_POST['edit_posts']) ? intval($_POST['edit_posts']) : ($is_admin_group) ? '1' : '0';
 332      $delete_posts = isset($_POST['delete_posts']) ? intval($_POST['delete_posts']) : ($is_admin_group) ? '1' : '0';
 333      $delete_topics = isset($_POST['delete_topics']) ? intval($_POST['delete_topics']) : ($is_admin_group) ? '1' : '0';
 334      $post_links = isset($_POST['post_links']) ? intval($_POST['post_links']) : '1';
 335      $set_title = isset($_POST['set_title']) ? intval($_POST['set_title']) : ($is_admin_group) ? '1' : '0';
 336      $search = isset($_POST['search']) ? intval($_POST['search']) : '1';
 337      $search_users = isset($_POST['search_users']) ? intval($_POST['search_users']) : '1';
 338      $send_email = (isset($_POST['send_email']) && $_POST['send_email'] == '1') || $is_admin_group ? '1' : '0';
 339      $post_flood = (isset($_POST['post_flood']) && $_POST['post_flood'] >= 0) ? intval($_POST['post_flood']) : '0';
 340      $search_flood = (isset($_POST['search_flood']) && $_POST['search_flood'] >= 0) ? intval($_POST['search_flood']) : '0';
 341      $email_flood = (isset($_POST['email_flood']) && $_POST['email_flood'] >= 0) ? intval($_POST['email_flood']) : '0';
 342      $report_flood = (isset($_POST['report_flood']) && $_POST['report_flood'] >= 0) ? intval($_POST['report_flood']) : '0';
 343  
 344      if ($title == '')
 345          message($lang_admin_groups['Must enter title message']);
 346  
 347      $user_title = ($user_title != '') ? '\''.$db->escape($user_title).'\'' : 'NULL';
 348  
 349      if ($_POST['mode'] == 'add')
 350      {
 351          $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());
 352          if ($db->num_rows($result))
 353              message(sprintf($lang_admin_groups['Title already exists message'], pun_htmlspecialchars($title)));
 354  
 355          $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_mod_promote_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.', '.$mod_promote_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());
 356          $new_group_id = $db->insert_id();
 357  
 358          // Now lets copy the forum specific permissions from the group which this group is based on
 359          $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());
 360          while ($cur_forum_perm = $db->fetch_assoc($result))
 361              $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());
 362      }
 363      else
 364      {
 365          $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());
 366          if ($db->num_rows($result))
 367              message(sprintf($lang_admin_groups['Title already exists message'], pun_htmlspecialchars($title)));
 368  
 369          $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_mod_promote_users='.$mod_promote_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());
 370  
 371          // Promote all users who would be promoted to this group on their next post
 372          if ($promote_next_group)
 373              $db->query('UPDATE '.$db->prefix.'users SET group_id = '.$promote_next_group.' WHERE group_id = '.intval($_POST['group_id']).' AND num_posts >= '.$promote_min_posts) or error('Unable to auto-promote existing users', __FILE__, __LINE__, $db->error());
 374      }
 375  
 376      // Regenerate the quick jump cache
 377      if (!defined('FORUM_CACHE_FUNCTIONS_LOADED'))
 378          require  PUN_ROOT.'include/cache.php';
 379  
 380      $group_id = $_POST['mode'] == 'add' ? $new_group_id : intval($_POST['group_id']);
 381      generate_quickjump_cache($group_id);
 382  
 383      if ($_POST['mode'] == 'edit')
 384          redirect('admin_groups.php', $lang_admin_groups['Group edited redirect']);
 385      else
 386          redirect('admin_groups.php', $lang_admin_groups['Group added redirect']);
 387  }
 388  
 389  
 390  // Set default group
 391  else if (isset($_POST['set_default_group']))
 392  {
 393      confirm_referrer('admin_groups.php');
 394  
 395      $group_id = intval($_POST['default_group']);
 396  
 397      // Make sure it's not the admin or guest groups
 398      if ($group_id == PUN_ADMIN || $group_id == PUN_GUEST)
 399          message($lang_common['Bad request'], false, '404 Not Found');
 400  
 401      // Make sure it's not a moderator group
 402      if ($groups[$group_id]['g_moderator'] != 0)
 403          message($lang_common['Bad request'], false, '404 Not Found');
 404  
 405      $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());
 406  
 407      // Regenerate the config cache
 408      if (!defined('FORUM_CACHE_FUNCTIONS_LOADED'))
 409          require  PUN_ROOT.'include/cache.php';
 410  
 411      generate_config_cache();
 412  
 413      redirect('admin_groups.php', $lang_admin_groups['Default group redirect']);
 414  }
 415  
 416  
 417  // Remove a group
 418  else if (isset($_GET['del_group']))
 419  {
 420      confirm_referrer('admin_groups.php');
 421  
 422      $group_id = isset($_POST['group_to_delete']) ? intval($_POST['group_to_delete']) : intval($_GET['del_group']);
 423      if ($group_id < 5)
 424          message($lang_common['Bad request'], false, '404 Not Found');
 425  
 426      // Make sure we don't remove the default group
 427      if ($group_id == $pun_config['o_default_user_group'])
 428          message($lang_admin_groups['Cannot remove default message']);
 429  
 430      // Check if this group has any members
 431      $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());
 432  
 433      // If the group doesn't have any members or if we've already selected a group to move the members to
 434      if (!$db->num_rows($result) || isset($_POST['del_group']))
 435      {
 436          if (isset($_POST['del_group_comply']) || isset($_POST['del_group']))
 437          {
 438              if (isset($_POST['del_group']))
 439              {
 440                  $move_to_group = intval($_POST['move_to_group']);
 441                  $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());
 442              }
 443  
 444              // Delete the group and any forum specific permissions
 445              $db->query('DELETE FROM '.$db->prefix.'groups WHERE g_id='.$group_id) or error('Unable to delete group', __FILE__, __LINE__, $db->error());
 446              $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());
 447  
 448              // Don't let users be promoted to this group
 449              $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());
 450  
 451              redirect('admin_groups.php', $lang_admin_groups['Group removed redirect']);
 452          }
 453          else
 454          {
 455              $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());
 456              $group_title = $db->result($result);
 457  
 458              $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['User groups']);
 459              define('PUN_ACTIVE_PAGE', 'admin');
 460              require  PUN_ROOT.'header.php';
 461  
 462              generate_admin_menu('groups');
 463  
 464  ?>
 465      <div class="blockform">
 466          <h2><span><?php echo $lang_admin_groups['Group delete head'] ?></span></h2>
 467          <div class="box">
 468              <form method="post" action="admin_groups.php?del_group=<?php echo $group_id ?>">
 469                  <div class="inform">
 470                  <input type="hidden" name="group_to_delete" value="<?php echo $group_id ?>" />
 471                      <fieldset>
 472                          <legend><?php echo $lang_admin_groups['Confirm delete subhead'] ?></legend>
 473                          <div class="infldset">
 474                              <p><?php printf($lang_admin_groups['Confirm delete info'], pun_htmlspecialchars($group_title)) ?></p>
 475                              <p class="warntext"><?php echo $lang_admin_groups['Confirm delete warn'] ?></p>
 476                          </div>
 477                      </fieldset>
 478                  </div>
 479                  <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>
 480              </form>
 481          </div>
 482      </div>
 483      <div class="clearer"></div>
 484  </div>
 485  <?php
 486  
 487              require  PUN_ROOT.'footer.php';
 488          }
 489      }
 490  
 491      list($group_title, $group_members) = $db->fetch_row($result);
 492  
 493      $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['User groups']);
 494      define('PUN_ACTIVE_PAGE', 'admin');
 495      require  PUN_ROOT.'header.php';
 496  
 497      generate_admin_menu('groups');
 498  
 499  ?>
 500      <div class="blockform">
 501          <h2><span><?php echo $lang_admin_groups['Delete group head'] ?></span></h2>
 502          <div class="box">
 503              <form id="groups" method="post" action="admin_groups.php?del_group=<?php echo $group_id ?>">
 504                  <div class="inform">
 505                      <fieldset>
 506                          <legend><?php echo $lang_admin_groups['Move users subhead'] ?></legend>
 507                          <div class="infldset">
 508                              <p><?php printf($lang_admin_groups['Move users info'], pun_htmlspecialchars($group_title), forum_number_format($group_members)) ?></p>
 509                              <label><?php echo $lang_admin_groups['Move users label'] ?>
 510                              <select name="move_to_group">
 511  <?php
 512  
 513      $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());
 514  
 515      while ($cur_group = $db->fetch_assoc($result))
 516      {
 517          if ($cur_group['g_id'] == PUN_MEMBER) // Pre-select the pre-defined Members group
 518              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";
 519          else
 520              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";
 521      }
 522  
 523  ?>
 524                              </select>
 525                              <br /></label>
 526                          </div>
 527                      </fieldset>
 528                  </div>
 529                  <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>
 530              </form>
 531          </div>
 532      </div>
 533      <div class="clearer"></div>
 534  </div>
 535  <?php
 536  
 537      require  PUN_ROOT.'footer.php';
 538  }
 539  
 540  
 541  $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['User groups']);
 542  define('PUN_ACTIVE_PAGE', 'admin');
 543  require  PUN_ROOT.'header.php';
 544  
 545  generate_admin_menu('groups');
 546  
 547  ?>
 548      <div class="blockform">
 549          <h2><span><?php echo $lang_admin_groups['Add groups head'] ?></span></h2>
 550          <div class="box">
 551              <form id="groups" method="post" action="admin_groups.php">
 552                  <div class="inform">
 553                      <fieldset>
 554                          <legend><?php echo $lang_admin_groups['Add group subhead'] ?></legend>
 555                          <div class="infldset">
 556                              <table class="aligntop">
 557                                  <tr>
 558                                      <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>
 559                                      <td>
 560                                          <select id="base_group" name="base_group" tabindex="1">
 561  <?php
 562  
 563  foreach ($groups as $cur_group)
 564  {
 565      if ($cur_group['g_id'] != PUN_ADMIN && $cur_group['g_id'] != PUN_GUEST)
 566      {
 567          if ($cur_group['g_id'] == $pun_config['o_default_user_group'])
 568              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";
 569          else
 570              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";
 571      }
 572  }
 573  
 574  ?>
 575                                          </select>
 576                                          <span><?php echo $lang_admin_groups['New group help'] ?></span>
 577                                      </td>
 578                                  </tr>
 579                              </table>
 580                          </div>
 581                      </fieldset>
 582                  </div>
 583                  <div class="inform">
 584                      <fieldset>
 585                          <legend><?php echo $lang_admin_groups['Default group subhead'] ?></legend>
 586                          <div class="infldset">
 587                              <table class="aligntop">
 588                                  <tr>
 589                                      <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>
 590                                      <td>
 591                                          <select id="default_group" name="default_group" tabindex="3">
 592  <?php
 593  
 594  foreach ($groups as $cur_group)
 595  {
 596      if ($cur_group['g_id'] > PUN_GUEST && $cur_group['g_moderator'] == 0)
 597      {
 598          if ($cur_group['g_id'] == $pun_config['o_default_user_group'])
 599              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";
 600          else
 601              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";
 602      }
 603  }
 604  
 605  ?>
 606                                          </select>
 607                                          <span><?php echo $lang_admin_groups['Default group help'] ?></span>
 608                                      </td>
 609                                  </tr>
 610                              </table>
 611                          </div>
 612                      </fieldset>
 613                  </div>
 614              </form>
 615          </div>
 616  
 617          <h2 class="block2"><span><?php echo $lang_admin_groups['Existing groups head'] ?></span></h2>
 618          <div class="box">
 619              <div class="fakeform">
 620                  <div class="inform">
 621                      <fieldset>
 622                          <legend><?php echo $lang_admin_groups['Edit groups subhead'] ?></legend>
 623                          <div class="infldset">
 624                              <p><?php echo $lang_admin_groups['Edit groups info'] ?></p>
 625                              <table>
 626  <?php
 627  
 628  $cur_index = 5;
 629  
 630  foreach ($groups as $cur_group)
 631      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";
 632  
 633  ?>
 634                              </table>
 635                          </div>
 636                      </fieldset>
 637                  </div>
 638              </div>
 639          </div>
 640      </div>
 641      <div class="clearer"></div>
 642  </div>
 643  <?php
 644  
 645  require  PUN_ROOT.'footer.php';

title

Description

title

Description

title

Description

title

title

Body