plugins/admin/GroupManager.php
author Dan
Sat, 19 Dec 2009 16:06:27 -0500
changeset 1190 fa306d7af9ce
parent 1081 745200a9cc2a
child 1227 bdac73ed481e
permissions -rw-r--r--
Detagged 1.1.7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
347
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
     1
<?php
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
     2
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
     3
/*
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
     4
 * Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between
1081
745200a9cc2a Fixed some upgrade bugs; added support for choosing one's own date/time formats; rebrand as 1.1.7
Dan
parents: 801
diff changeset
     5
 * Copyright (C) 2006-2009 Dan Fuhry
347
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
     6
 *
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
     7
 * This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
     8
 * as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
     9
 *
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    10
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    11
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    12
 */
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    13
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    14
// Usergroup editor
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    15
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    16
function page_Admin_GroupManager()
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    17
{
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    18
  global $db, $session, $paths, $template, $plugins; // Common objects
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    19
  global $lang;
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    20
  if ( $session->auth_level < USER_LEVEL_ADMIN || $session->user_level < USER_LEVEL_ADMIN )
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    21
  {
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    22
    $login_link = makeUrlNS('Special', 'Login/' . $paths->nslist['Special'] . 'Administration', 'level=' . USER_LEVEL_ADMIN, true);
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    23
    echo '<h3>' . $lang->get('adm_err_not_auth_title') . '</h3>';
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    24
    echo '<p>' . $lang->get('adm_err_not_auth_body', array( 'login_link' => $login_link )) . '</p>';
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    25
    return;
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    26
  }
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    27
  
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    28
  if(isset($_POST['do_create_stage1']))
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    29
  {
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    30
    if(!preg_match('/^([A-z0-9 -]+)$/', $_POST['create_group_name']))
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    31
    {
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    32
      echo '<p>' . $lang->get('acpug_err_group_name_invalid') . '</p>';
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    33
      return;
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    34
    }
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    35
    echo '<form action="'.makeUrl($paths->nslist['Special'].'Administration', 'module='.$paths->cpage['module']).'" method="post" onsubmit="if(!submitAuthorized) return false;" enctype="multipart/form-data">';
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    36
    echo '<div class="tblholder">
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    37
          <table border="0" style="width:100%;" cellspacing="1" cellpadding="4">
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    38
          <tr><th colspan="2">' . $lang->get('acpug_heading_creating_group') . ' '.htmlspecialchars($_POST['create_group_name']).'</th></tr>
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    39
          <tr>
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    40
            <td class="row1">' . $lang->get('acpug_field_group_mod') . '</td><td class="row1">' . $template->username_field('group_mod') . '</td>
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    41
          </tr>
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    42
          <tr><td class="row2">' . $lang->get('acpug_field_group_type') . '</td><td class="row2">
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    43
            <label><input type="radio" name="group_status" value="'.GROUP_CLOSED.'" checked="checked" /> ' . $lang->get('groupcp_type_hidden') . '</label><br />
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    44
            <label><input type="radio" name="group_status" value="'.GROUP_REQUEST.'" /> ' . $lang->get('groupcp_type_closed') . '</label><br />
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    45
            <label><input type="radio" name="group_status" value="'.GROUP_OPEN.'" /> ' . $lang->get('groupcp_type_request') . '</label><br />
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    46
            <label><input type="radio" name="group_status" value="'.GROUP_HIDDEN.'" /> ' . $lang->get('groupcp_type_open') . '</label>
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    47
          </td></tr>
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    48
          <tr>
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    49
            <th class="subhead" colspan="2">
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    50
              <input type="hidden" name="create_group_name" value="'.htmlspecialchars($_POST['create_group_name']).'" />
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    51
              <input type="submit" name="do_create_stage2" value="' . $lang->get('acpug_btn_create_stage2') . '" />
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    52
            </th>
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    53
          </tr>
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    54
          </table>
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    55
          </div>';
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    56
    echo '</form>';
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    57
    return;
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    58
  }
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    59
  elseif(isset($_POST['do_create_stage2']))
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    60
  {
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    61
    if(!preg_match('/^([A-z0-9 -]+)$/', $_POST['create_group_name']))
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    62
    {
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    63
      echo '<p>' . $lang->get('acpug_err_group_name_invalid') . '</p>';
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    64
      return;
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    65
    }
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    66
    if(!in_array(intval($_POST['group_status']), Array(GROUP_CLOSED, GROUP_OPEN, GROUP_HIDDEN, GROUP_REQUEST)))
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    67
    {
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    68
      echo '<p>Hacking attempt</p>';
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    69
      return;
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    70
    }
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    71
    $e = $db->sql_query('SELECT group_id FROM '.table_prefix.'groups WHERE group_name=\''.$db->escape($_POST['create_group_name']).'\';');
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    72
    if(!$e)
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    73
    {
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    74
      echo $db->get_error();
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    75
      return;
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    76
    }
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    77
    if($db->numrows() > 0)
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    78
    {
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    79
      echo '<p>' . $lang->get('acpug_err_already_exist') . '</p>';
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    80
      return;
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    81
    }
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    82
    $db->free_result();
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    83
    $q = $db->sql_query('INSERT INTO '.table_prefix.'groups(group_name,group_type) VALUES( \''.$db->escape($_POST['create_group_name']).'\', ' . intval($_POST['group_status']) . ' )');
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    84
    if(!$q)
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    85
    {
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    86
      echo $db->get_error();
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    87
      return;
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    88
    }
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    89
    $e = $db->sql_query('SELECT user_id FROM '.table_prefix.'users WHERE username=\''.$db->escape($_POST['group_mod']).'\';');
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    90
    if(!$e)
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    91
    {
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    92
      echo $db->get_error();
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    93
      return;
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    94
    }
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    95
    if($db->numrows() < 1)
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    96
    {
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    97
      echo '<p>' . $lang->get('acpug_err_bad_username') . '</p>';
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    98
      return;
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
    99
    }
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   100
    $row = $db->fetchrow();
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   101
    $id = $row['user_id'];
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   102
    $db->free_result();
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   103
    $e = $db->sql_query('SELECT group_id FROM '.table_prefix.'groups WHERE group_name=\''.$db->escape($_POST['create_group_name']).'\';');
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   104
    if(!$e)
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   105
    {
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   106
      echo $db->get_error();
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   107
      return;
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   108
    }
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   109
    if($db->numrows() < 1)
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   110
    {
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   111
      echo '<p>' . $lang->get('acpug_err_bad_insert_id') . '</p>';
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   112
      return;
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   113
    }
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   114
    $row = $db->fetchrow();
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   115
    $gid = $row['group_id'];
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   116
    $db->free_result();
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   117
    $e = $db->sql_query('INSERT INTO '.table_prefix.'group_members(group_id,user_id,is_mod) VALUES('.$gid.', '.$id.', 1);');
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   118
    if(!$e)
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   119
    {
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   120
      echo $db->get_error();
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   121
      return;
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   122
    }
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   123
    $g_name = htmlspecialchars($_POST['create_group_name']);
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   124
    echo "<div class='info-box'>
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   125
            <b>" . $lang->get('acpug_heading_info') . "</b><br />
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   126
            " . $lang->get('acpug_msg_create_success', array('g_name' => $g_name)) . "
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   127
          </div>";
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   128
  }
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   129
  if(isset($_POST['do_edit']) || isset($_POST['edit_do']))
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   130
  {
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   131
    // Fetch the group name
631
f4f4146d8b6c Added group_rank option in admin group manager and user_title option in admin user manager
Dan
parents: 573
diff changeset
   132
    $q = $db->sql_query('SELECT group_name,system_group,group_rank FROM '.table_prefix.'groups WHERE group_id='.intval($_POST['group_edit_id']).';');
347
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   133
    if(!$q)
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   134
    {
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   135
      echo $db->get_error();
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   136
      return;
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   137
    }
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   138
    if($db->numrows() < 1)
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   139
    {
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   140
      echo '<p>Error: couldn\'t look up group name</p>';
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   141
    }
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   142
    $row = $db->fetchrow();
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   143
    $name = htmlspecialchars($row['group_name']);
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   144
    $db->free_result();
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   145
    if(isset($_POST['edit_do']))
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   146
    {
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   147
      if(isset($_POST['edit_do']['del_group']))
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   148
      {
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   149
        if ( $row['system_group'] == 1 )
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   150
        {
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   151
          echo '<div class="error-box">' . $lang->get('acpug_err_nodelete_system_group', array('g_name' => $name)) . '</div>';
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   152
        }
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   153
        else
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   154
        {
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   155
          $q = $db->sql_query('DELETE FROM '.table_prefix.'group_members WHERE group_id='.intval($_POST['group_edit_id']).';');
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   156
          if(!$q)
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   157
          {
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   158
            echo $db->get_error();
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   159
            return;
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   160
          }
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   161
          $q = $db->sql_query('DELETE FROM '.table_prefix.'groups WHERE group_id='.intval($_POST['group_edit_id']).';');
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   162
          if(!$q)
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   163
          {
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   164
            echo $db->get_error();
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   165
            return;
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   166
          }
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   167
          echo '<div class="info-box">' . $lang->get('acpug_msg_delete_success', array('g_name' => $name, 'a_flags' => 'href="javascript:ajaxPage(\'' . $paths->nslist['Admin'] . 'GroupManager\');"')) . '</div>';
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   168
          return;
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   169
        }
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   170
      }
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   171
      if(isset($_POST['edit_do']['save_name']))
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   172
      {
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   173
        if(!preg_match('/^([A-z0-9 -]+)$/', $_POST['group_name']))
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   174
        {
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   175
          echo '<p>' . $lang->get('acpug_err_group_name_invalid') . '</p>';
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   176
          return;
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   177
        }
631
f4f4146d8b6c Added group_rank option in admin group manager and user_title option in admin user manager
Dan
parents: 573
diff changeset
   178
        // determine rank
f4f4146d8b6c Added group_rank option in admin group manager and user_title option in admin user manager
Dan
parents: 573
diff changeset
   179
        $group_rank =& $_POST['group_rank'];
f4f4146d8b6c Added group_rank option in admin group manager and user_title option in admin user manager
Dan
parents: 573
diff changeset
   180
        if ( $_POST['group_rank'] !== 'NULL' )
f4f4146d8b6c Added group_rank option in admin group manager and user_title option in admin user manager
Dan
parents: 573
diff changeset
   181
        {
f4f4146d8b6c Added group_rank option in admin group manager and user_title option in admin user manager
Dan
parents: 573
diff changeset
   182
          $group_rank = intval($group_rank);
f4f4146d8b6c Added group_rank option in admin group manager and user_title option in admin user manager
Dan
parents: 573
diff changeset
   183
          if ( empty($group_rank) )
f4f4146d8b6c Added group_rank option in admin group manager and user_title option in admin user manager
Dan
parents: 573
diff changeset
   184
          {
f4f4146d8b6c Added group_rank option in admin group manager and user_title option in admin user manager
Dan
parents: 573
diff changeset
   185
            echo '<p>Hacked rank ID</p>';
f4f4146d8b6c Added group_rank option in admin group manager and user_title option in admin user manager
Dan
parents: 573
diff changeset
   186
            return;
f4f4146d8b6c Added group_rank option in admin group manager and user_title option in admin user manager
Dan
parents: 573
diff changeset
   187
          }
f4f4146d8b6c Added group_rank option in admin group manager and user_title option in admin user manager
Dan
parents: 573
diff changeset
   188
        }
f4f4146d8b6c Added group_rank option in admin group manager and user_title option in admin user manager
Dan
parents: 573
diff changeset
   189
        $row['group_rank'] = $group_rank;
f4f4146d8b6c Added group_rank option in admin group manager and user_title option in admin user manager
Dan
parents: 573
diff changeset
   190
        $q = $db->sql_query('UPDATE '.table_prefix.'groups SET group_name=\''.$db->escape($_POST['group_name']).'\',group_rank = ' . $group_rank . '
347
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   191
            WHERE group_id='.intval($_POST['group_edit_id']).';');
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   192
        if(!$q)
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   193
        {
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   194
          echo $db->get_error();
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   195
          return;
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   196
        }
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   197
        else
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   198
        {
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   199
          echo '<div class="info-box" style="margin: 0 0 10px 0;"">
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   200
                  ' . $lang->get('acpug_msg_name_update_success') . '
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   201
                </div>';
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   202
        }
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   203
        $name = htmlspecialchars($_POST['group_name']);
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   204
        
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   205
      }
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   206
      $q = $db->sql_query('SELECT member_id FROM '.table_prefix.'group_members
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   207
                             WHERE group_id='.intval($_POST['group_edit_id']).';');
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   208
      if(!$q)
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   209
      {
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   210
        echo $db->get_error();
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   211
        return;
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   212
      }
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   213
      if($db->numrows() > 0)
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   214
      {
631
f4f4146d8b6c Added group_rank option in admin group manager and user_title option in admin user manager
Dan
parents: 573
diff changeset
   215
        while($delrow = $db->fetchrow($q))
347
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   216
        {
631
f4f4146d8b6c Added group_rank option in admin group manager and user_title option in admin user manager
Dan
parents: 573
diff changeset
   217
          if(isset($_POST['edit_do']['del_' . $delrow['member_id']]))
347
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   218
          {
631
f4f4146d8b6c Added group_rank option in admin group manager and user_title option in admin user manager
Dan
parents: 573
diff changeset
   219
            $e = $db->sql_query('DELETE FROM '.table_prefix.'group_members WHERE member_id='.$delrow['member_id']);
347
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   220
            if(!$e)
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   221
            {
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   222
              echo $db->get_error();
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   223
              return;
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   224
            }
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   225
          }
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   226
        }
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   227
      }
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   228
      $db->free_result();
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   229
      if(isset($_POST['edit_do']['add_member']))
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   230
      {
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   231
        $q = $db->sql_query('SELECT user_id FROM '.table_prefix.'users WHERE username=\''.$db->escape($_POST['edit_add_username']).'\';');
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   232
        if(!$q)
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   233
        {
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   234
          echo $db->get_error();
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   235
          return;
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   236
        }
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   237
        if($db->numrows() > 0)
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   238
        {
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   239
          $row = $db->fetchrow();
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   240
          $user_id = $row['user_id'];
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   241
          $is_mod = ( isset( $_POST['add_mod'] ) ) ? '1' : '0';
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   242
          $q = $db->sql_query('INSERT INTO '.table_prefix.'group_members(group_id,user_id,is_mod) VALUES('.intval($_POST['group_edit_id']).','.$user_id.','.$is_mod.');');
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   243
          if(!$q)
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   244
          {
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   245
            echo $db->get_error();
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   246
            return;
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   247
          }
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   248
          else
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   249
          {
541
acb7e23b6ffa Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents: 536
diff changeset
   250
            
347
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   251
            echo '<div class="info-box" style="margin: 0 0 10px 0;"">
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   252
                    ' . $lang->get('acpug_msg_user_added', array('username' => htmlspecialchars($_POST['edit_add_username']))) . '
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   253
                  </div>';
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   254
          }
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   255
        }
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   256
        else
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   257
          echo '<div class="warning-box">' . $lang->get('acpug_err_username_not_exist', array('username' => htmlspecialchars($_POST['edit_add_username']))) . '</div>';
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   258
      }
573
43e7254afdb4 Renamed some functions (that were new in this release anyway) due to compatibility broken with PunBB bridge
Dan
parents: 541
diff changeset
   259
      generate_cache_userranks();
347
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   260
    }
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   261
    $sg_disabled = ( $row['system_group'] == 1 ) ?
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   262
             ' value="' . $lang->get('acpug_btn_cant_delete') . '" disabled="disabled" style="color: #FF9773" ' :
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   263
             ' value="' . $lang->get('acpug_btn_delete_group') . '" style="color: #FF3713" ';
631
f4f4146d8b6c Added group_rank option in admin group manager and user_title option in admin user manager
Dan
parents: 573
diff changeset
   264
    
f4f4146d8b6c Added group_rank option in admin group manager and user_title option in admin user manager
Dan
parents: 573
diff changeset
   265
    // build rank list
f4f4146d8b6c Added group_rank option in admin group manager and user_title option in admin user manager
Dan
parents: 573
diff changeset
   266
    $q = $db->sql_query('SELECT rank_id, rank_title FROM ' . table_prefix . 'ranks');
f4f4146d8b6c Added group_rank option in admin group manager and user_title option in admin user manager
Dan
parents: 573
diff changeset
   267
    if ( !$q )
f4f4146d8b6c Added group_rank option in admin group manager and user_title option in admin user manager
Dan
parents: 573
diff changeset
   268
      $db->_die();
f4f4146d8b6c Added group_rank option in admin group manager and user_title option in admin user manager
Dan
parents: 573
diff changeset
   269
    $rank_list = '<option value="NULL"' . ( $row['group_rank'] === NULL ? ' selected="selected"' : '' ) . '>--</option>' . "\n";
f4f4146d8b6c Added group_rank option in admin group manager and user_title option in admin user manager
Dan
parents: 573
diff changeset
   270
    while ( $rank_row = $db->fetchrow() )
f4f4146d8b6c Added group_rank option in admin group manager and user_title option in admin user manager
Dan
parents: 573
diff changeset
   271
    {
f4f4146d8b6c Added group_rank option in admin group manager and user_title option in admin user manager
Dan
parents: 573
diff changeset
   272
      $rank_list .= '<option value="' . $rank_row['rank_id'] . '"' . ( $rank_row['rank_id'] == $row['group_rank'] ? ' selected="selected"' : '' ) . '>' . htmlspecialchars($lang->get($rank_row['rank_title'])) . '</option>' . "\n";
f4f4146d8b6c Added group_rank option in admin group manager and user_title option in admin user manager
Dan
parents: 573
diff changeset
   273
    }
f4f4146d8b6c Added group_rank option in admin group manager and user_title option in admin user manager
Dan
parents: 573
diff changeset
   274
             
347
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   275
    echo '<form action="'.makeUrl($paths->nslist['Special'].'Administration', 'module='.$paths->cpage['module']).'" method="post" onsubmit="if(!submitAuthorized) return false;" enctype="multipart/form-data">';
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   276
    echo '<div class="tblholder">
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   277
          <table border="0" style="width:100%;" cellspacing="1" cellpadding="4">
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   278
          <tr><th>' . $lang->get('acpug_heading_edit_name') . '</th></tr>
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   279
          <tr>
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   280
            <td class="row1">
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   281
              ' . $lang->get('acpug_field_group_name') . ' <input type="text" name="group_name" value="'.$name.'" />
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   282
            </td>
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   283
          </tr>
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   284
          <tr>
631
f4f4146d8b6c Added group_rank option in admin group manager and user_title option in admin user manager
Dan
parents: 573
diff changeset
   285
            <td class="row1">
f4f4146d8b6c Added group_rank option in admin group manager and user_title option in admin user manager
Dan
parents: 573
diff changeset
   286
              ' . $lang->get('acpug_field_group_rank') . ' <select name="group_rank" />' . $rank_list . '</select>
f4f4146d8b6c Added group_rank option in admin group manager and user_title option in admin user manager
Dan
parents: 573
diff changeset
   287
            </td>
f4f4146d8b6c Added group_rank option in admin group manager and user_title option in admin user manager
Dan
parents: 573
diff changeset
   288
          </tr>
f4f4146d8b6c Added group_rank option in admin group manager and user_title option in admin user manager
Dan
parents: 573
diff changeset
   289
          <tr>
347
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   290
            <th class="subhead">
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   291
              <input type="submit" name="edit_do[save_name]" value="' . $lang->get('acpug_btn_save_name') . '" />
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   292
              <input type="submit" name="edit_do[del_group]" '.$sg_disabled.' />
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   293
            </th>
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   294
          </tr>
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   295
          </table>
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   296
          </div>
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   297
          <input type="hidden" name="group_edit_id" value="'.htmlspecialchars($_POST['group_edit_id']).'" />';
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   298
    echo '</form>';
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   299
    echo '<form action="'.makeUrl($paths->nslist['Special'].'Administration', 'module='.$paths->cpage['module']).'" method="post" onsubmit="if(!submitAuthorized) return false;" enctype="multipart/form-data">';
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   300
    echo '<div class="tblholder">
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   301
          <table border="0" style="width:100%;" cellspacing="1" cellpadding="4">
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   302
          <tr><th colspan="3">' . $lang->get('acpug_heading_edit_members') . '</th></tr>';
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   303
    $q = $db->sql_query('SELECT m.member_id,m.is_mod,u.username FROM '.table_prefix.'group_members AS m
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   304
                           LEFT JOIN '.table_prefix.'users AS u
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   305
                             ON u.user_id=m.user_id
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   306
                             WHERE m.group_id='.intval($_POST['group_edit_id']).'
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   307
                           ORDER BY m.is_mod DESC, u.username ASC;');
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   308
    if(!$q)
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   309
    {
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   310
      echo $db->get_error();
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   311
      return;
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   312
    }
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   313
    if($db->numrows() < 1)
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   314
    {
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   315
      echo '<tr><td colspan="3" class="row1">' . $lang->get('acpug_msg_no_members') . '</td></tr>';
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   316
    }
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   317
    else
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   318
    {
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   319
      $cls = 'row2';
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   320
      while($row = $db->fetchrow())
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   321
      {
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   322
        $cls = ( $cls == 'row1' ) ? 'row2' : 'row1';
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   323
        $mod = ( $row['is_mod'] == 1 ) ? $lang->get('acpug_lbl_member_mod') : '';
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   324
        echo '<tr>
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   325
                <td class="'.$cls.'" style="width: 100%;">
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   326
                  ' . $row['username'] . '
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   327
                </td>
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   328
                <td class="'.$cls.'">
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   329
                  '.$mod.'
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   330
                </td>
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   331
                <td class="'.$cls.'">
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   332
                  <input type="submit" name="edit_do[del_'.$row['member_id'].']" value="' . $lang->get('acpug_btn_remove_member') . '" />
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   333
                </td>
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   334
              </tr>';
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   335
      }
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   336
    }
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   337
    $db->free_result();
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   338
    echo '</table>
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   339
          </div>
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   340
          <input type="hidden" name="group_edit_id" value="'.htmlspecialchars($_POST['group_edit_id']).'" />';
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   341
    echo '</form>';
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   342
    echo '<form action="'.makeUrl($paths->nslist['Special'].'Administration', 'module='.$paths->cpage['module']).'" method="post" onsubmit="if(!submitAuthorized) return false;" enctype="multipart/form-data">';
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   343
    echo '<div class="tblholder">
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   344
          <table border="0" style="width:100%;" cellspacing="1" cellpadding="4">
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   345
            <tr>
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   346
              <th>' . $lang->get('acpug_heading_add_member') . '</th>
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   347
            </tr>
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   348
            <tr>
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   349
              <td class="row1">
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   350
                ' . $lang->get('acpug_field_username') . ' ' . $template->username_field('edit_add_username') . '
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   351
              </td>
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   352
            </tr>
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   353
            <tr>
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   354
              <td class="row2">
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   355
                <label><input type="checkbox" name="add_mod" /> ' . $lang->get('acpug_field_make_mod') . '</label>
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   356
                ' . $lang->get('acpug_field_make_mod_hint') . '
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   357
              </td>
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   358
            </tr>
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   359
            <tr>
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   360
              <th class="subhead">
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   361
                <input type="submit" name="edit_do[add_member]" value="' . $lang->get('acpug_btn_add_user') . '" />
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   362
              </th>
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   363
            </tr>
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   364
          </table>
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   365
          </div>
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   366
          <input type="hidden" name="group_edit_id" value="'.htmlspecialchars($_POST['group_edit_id']).'" />';
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   367
    echo '</form>';
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   368
    return;
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   369
  }
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   370
  echo '<h3>' . $lang->get('acpug_heading_main') . '</h3>';
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   371
  echo '<form action="'.makeUrl($paths->nslist['Special'].'Administration', 'module='.$paths->cpage['module']).'" method="post" onsubmit="if(!submitAuthorized) return false;" enctype="multipart/form-data">';
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   372
  $q = $db->sql_query('SELECT group_id,group_name FROM '.table_prefix.'groups ORDER BY group_name ASC;');
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   373
  if(!$q)
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   374
  {
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   375
    echo $db->get_error();
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   376
  }
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   377
  else
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   378
  {
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   379
    echo '<div class="tblholder">
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   380
          <table border="0" cellspacing="1" cellpadding="4" style="width: 100%;">
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   381
          <tr>
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   382
          <th>' . $lang->get('acpug_heading_edit_existing') . '</th>
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   383
          </tr>';
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   384
    echo '<tr><td class="row2"><select name="group_edit_id">';
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   385
    while ( $row = $db->fetchrow() )
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   386
    {
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   387
      if ( $row['group_name'] != 'Everyone' )
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   388
      {
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   389
        echo '<option value="' . $row['group_id'] . '">' . htmlspecialchars( $row['group_name'] ) . '</option>';
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   390
      }
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   391
    }
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   392
    $db->free_result();
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   393
    echo '</select></td></tr>';
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   394
    echo '<tr><td class="row1" style="text-align: center;"><input type="submit" name="do_edit" value="' . $lang->get('acpug_btn_edit_stage1') . '" /></td></tr>
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   395
          </table>
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   396
          </div>
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   397
          </form><br />';
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   398
  }
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   399
  echo '<form action="'.makeUrl($paths->nslist['Special'].'Administration', 'module='.$paths->cpage['module']).'" method="post" onsubmit="if(!submitAuthorized) return false;" enctype="multipart/form-data">';
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   400
  echo '<div class="tblholder">
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   401
        <table border="0" cellspacing="1" cellpadding="4" style="width: 100%;">
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   402
        <tr>
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   403
        <th colspan="2">' . $lang->get('acpug_heading_create_new') . '</th>
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   404
        </tr>';
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   405
  echo '<tr><td class="row2">' . $lang->get('acpug_field_group_name') . '</td><td class="row2"><input type="text" name="create_group_name" /></td></tr>';
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   406
  echo '<tr><td colspan="2" class="row1" style="text-align: center;"><input type="submit" name="do_create_stage1" value="' . $lang->get('acpug_btn_create_stage1') . ' &raquo;" /></td></tr>
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   407
        </table>
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   408
        </div>';
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   409
  echo '</form>';
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   410
}
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   411
299a90e28abc Localized and separated Admin:GroupManager
Dan
parents:
diff changeset
   412
?>