plugins/SpecialGroups.php
changeset 334 c72b545f1304
parent 322 5f1cd51bf1be
child 343 eefe9ab7fe7c
equal deleted inserted replaced
333:32429702305e 334:c72b545f1304
    18  *
    18  *
    19  * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
    19  * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
    20  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
    20  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
    21  */
    21  */
    22 
    22 
    23 $plugins->attachHook('base_classes_initted', '
    23 $plugins->attachHook('session_started', '
    24   global $paths;
    24   global $paths;
    25     $paths->add_page(Array(
    25     $paths->add_page(Array(
    26       \'name\'=>\'Group Membership\',
    26       \'name\'=>\'specialpage_groupcp\',
    27       \'urlname\'=>\'Usergroups\',
    27       \'urlname\'=>\'Usergroups\',
    28       \'namespace\'=>\'Special\',
    28       \'namespace\'=>\'Special\',
    29       \'special\'=>0,\'visible\'=>1,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\',
    29       \'special\'=>0,\'visible\'=>1,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\',
    30       ));
    30       ));
    31     ');
    31     ');
    32 
    32 
    33 function page_Special_Usergroups()
    33 function page_Special_Usergroups()
    34 {
    34 {
    35   global $db, $session, $paths, $template, $plugins; // Common objects
    35   global $db, $session, $paths, $template, $plugins; // Common objects
    36   global $email; // Import e-mail encryption functions
    36   global $email; // Import e-mail encryption functions
       
    37   global $lang;
    37   
    38   
    38   if ( !$session->user_logged_in )
    39   if ( !$session->user_logged_in )
    39   {
    40   {
    40     header('Location: ' . makeUrlComplete('Special', 'Login/' . $paths->page));
    41     header('Location: ' . makeUrlComplete('Special', 'Login/' . $paths->page));
    41     $db->close();
    42     $db->close();
    42     exit;
    43     exit;
    43   }
    44   }
    44   
    45   
    45   $template->header();
    46   $template->header();
       
    47   userprefs_show_menu();
    46   if ( isset($_POST['do_view']) || isset($_POST['do_view_n']) || ( isset($_GET['act']) && isset($_POST['group_id']) ) )
    48   if ( isset($_POST['do_view']) || isset($_POST['do_view_n']) || ( isset($_GET['act']) && isset($_POST['group_id']) ) )
    47   {
    49   {
    48     $gid = ( isset ( $_POST['do_view_n'] ) ) ? intval($_POST['group_id_n']) : intval($_POST['group_id']);
    50     $gid = ( isset ( $_POST['do_view_n'] ) ) ? intval($_POST['group_id_n']) : intval($_POST['group_id']);
    49     if ( empty($gid) || $gid < 1 )
    51     if ( empty($gid) || $gid < 1 )
    50     {
    52     {
   100         }
   102         }
   101       }
   103       }
   102     }
   104     }
   103     
   105     
   104     $status = ( $is_member && $is_mod )
   106     $status = ( $is_member && $is_mod )
   105       ? 'You are a moderator of this group.'
   107       ? $lang->get('groupcp_status_mod')
   106       : ( ( $is_member && !$is_mod ) 
   108       : ( ( $is_member && !$is_mod ) 
   107         ? 'You are a member of this group.'
   109         ? $lang->get('groupcp_status_member')
   108         : 'You are not a member of this group.'
   110         : $lang->get('groupcp_status_not_member')
   109         );
   111         );
   110       
   112       
   111     $can_do_admin_stuff = ( $is_mod || $session->user_level >= USER_LEVEL_ADMIN );
   113     $can_do_admin_stuff = ( $is_mod || $session->user_level >= USER_LEVEL_ADMIN );
   112       
   114       
   113     switch ( $row['group_type'] )
   115     switch ( $row['group_type'] )
   114     {
   116     {
   115       case GROUP_HIDDEN:  $g_state = 'Hidden group';                break;
   117       case GROUP_HIDDEN:  $g_state = $lang->get('groupcp_type_hidden'); break;
   116       case GROUP_CLOSED:  $g_state = 'Closed group';                break;
   118       case GROUP_CLOSED:  $g_state = $lang->get('groupcp_type_closed'); break;
   117       case GROUP_REQUEST: $g_state = 'Members can request to join'; break;
   119       case GROUP_REQUEST: $g_state = $lang->get('groupcp_type_request'); break;
   118       case GROUP_OPEN:    $g_state = 'Anyone can join';             break;
   120       case GROUP_OPEN:    $g_state = $lang->get('groupcp_type_open'); break;
   119     }
   121     }
   120     
   122     
   121     if ( isset($_GET['act']) && $can_do_admin_stuff )
   123     if ( isset($_GET['act']) && $can_do_admin_stuff )
   122     {
   124     {
   123       switch($_GET['act'])
   125       switch($_GET['act'])
   137             $error = true;
   139             $error = true;
   138           }
   140           }
   139           $r = $db->fetchrow();
   141           $r = $db->fetchrow();
   140           if ( $r['system_group'] == 1 && ( intval($_POST['group_state']) == GROUP_OPEN || intval($_POST['group_state']) == GROUP_REQUEST ) )
   142           if ( $r['system_group'] == 1 && ( intval($_POST['group_state']) == GROUP_OPEN || intval($_POST['group_state']) == GROUP_REQUEST ) )
   141           {
   143           {
   142             echo '<div class="error-box" style="margin-left: 0;">Because this is a system group, you can\'t make it open or allow membership requests.</div>';
   144             echo '<div class="error-box" style="margin-left: 0;">' . $lang->get('groupcp_err_state_system_group') . '</div>';
   143             $error = true;
   145             $error = true;
   144           }
   146           }
   145           if ( !$error )
   147           if ( !$error )
   146           {
   148           {
   147             $q = $db->sql_query('UPDATE '.table_prefix.'groups SET group_type=' . intval($_POST['group_state']) . ' WHERE group_id=' . intval( $_POST['group_id']) . ';');
   149             $q = $db->sql_query('UPDATE '.table_prefix.'groups SET group_type=' . intval($_POST['group_state']) . ' WHERE group_id=' . intval( $_POST['group_id']) . ';');
   148             if (!$q)
   150             if (!$q)
   149               $db->_die('SpecialGroups.php, line ' . __LINE__);
   151               $db->_die('SpecialGroups.php, line ' . __LINE__);
   150             $row['group_type'] = $_POST['group_state'];
   152             $row['group_type'] = $_POST['group_state'];
   151             echo '<div class="info-box" style="margin-left: 0;">The group state was updated.</div>';
   153             echo '<div class="info-box" style="margin-left: 0;">' . $lang->get('groupcp_msg_state_updated') . '</div>';
   152           }
   154           }
   153           break;
   155           break;
   154         case 'adduser':
   156         case 'adduser':
   155           $username = $_POST['add_username'];
   157           $username = $_POST['add_username'];
   156           $mod = ( isset($_POST['add_mod']) ) ? '1' : '0';
   158           $mod = ( isset($_POST['add_mod']) ) ? '1' : '0';
   158           $q = $db->sql_query('SELECT user_id FROM '.table_prefix.'users WHERE username=\'' . $db->escape($username) . '\';');
   160           $q = $db->sql_query('SELECT user_id FROM '.table_prefix.'users WHERE username=\'' . $db->escape($username) . '\';');
   159           if (!$q)
   161           if (!$q)
   160             $db->_die('SpecialGroups.php, line ' . __LINE__);
   162             $db->_die('SpecialGroups.php, line ' . __LINE__);
   161           if ($db->numrows() < 1)
   163           if ($db->numrows() < 1)
   162           {
   164           {
   163             echo '<div class="error-box">The username you entered could not be found.</div>';
   165             echo '<div class="error-box">' . $lang->get('groupcp_err_user_not_found') . '</div>';
   164             break;
   166             break;
   165           }
   167           }
   166           $r = $db->fetchrow();
   168           $r = $db->fetchrow();
   167           $db->free_result();
   169           $db->free_result();
   168           $uid = intval($r['user_id']);
   170           $uid = intval($r['user_id']);
   182               foreach ( $members as $i => $member )
   184               foreach ( $members as $i => $member )
   183               {
   185               {
   184                 if ( $member['member_id'] == $r['member_id'] )
   186                 if ( $member['member_id'] == $r['member_id'] )
   185                   $members[$i]['is_mod'] = (int)$mod;
   187                   $members[$i]['is_mod'] = (int)$mod;
   186               }
   188               }
   187               echo '<div class="info-box">The user "' . $username . '" is already in this group, so their moderator status was updated.</div>';
   189               echo '<div class="info-box">' . $lang->get('groupcp_msg_user_already_in_mod_updated', array('username' => $username)) . '</div>';
   188             }
   190             }
   189             else
   191             else
   190             {
   192             {
   191               echo '<div class="info-box">The user "' . $username . '" is already in this group.</div>';
   193               echo '<div class="info-box">' . $lang->get('groupcp_msg_user_already_in', array('username' => $username)) . '</div>';
   192             }
   194             }
   193             break;
   195             break;
   194           }
   196           }
   195           
   197           
   196           $db->free_result();
   198           $db->free_result();
   197           
   199           
   198           $q = $db->sql_query('INSERT INTO '.table_prefix.'group_members(group_id,user_id,is_mod) VALUES(' . intval($_POST['group_id']) . ', ' . $uid . ', ' . $mod . ');');
   200           $q = $db->sql_query('INSERT INTO '.table_prefix.'group_members(group_id,user_id,is_mod) VALUES(' . intval($_POST['group_id']) . ', ' . $uid . ', ' . $mod . ');');
   199           if (!$q)
   201           if (!$q)
   200             $db->_die('SpecialGroups.php, line ' . __LINE__);
   202             $db->_die('SpecialGroups.php, line ' . __LINE__);
   201           echo '<div class="info-box">The user "' . $username . '" has been added to this usergroup.</div>';
   203           echo '<div class="info-box">' . $lang->get('groupcp_msg_user_added', array('username' => $username)) . '</div>';
   202           
   204           
   203           $q = $db->sql_query('SELECT u.username,u.email,u.reg_time,m.member_id,m.user_id,m.is_mod,COUNT(c.comment_id) AS num_comments
   205           $q = $db->sql_query('SELECT u.username,u.email,u.reg_time,m.member_id,m.user_id,m.is_mod,COUNT(c.comment_id) AS num_comments
   204                                  FROM '.table_prefix.'users AS u
   206                                  FROM '.table_prefix.'users AS u
   205                                  LEFT JOIN '.table_prefix.'group_members AS m
   207                                  LEFT JOIN '.table_prefix.'group_members AS m
   206                                    ON ( m.user_id = u.user_id )
   208                                    ON ( m.user_id = u.user_id )
   253                   $db->_die('SpecialGroups.php, line ' . __LINE__);
   255                   $db->_die('SpecialGroups.php, line ' . __LINE__);
   254                 unset($pending[$i]);
   256                 unset($pending[$i]);
   255               }
   257               }
   256             }
   258             }
   257           }
   259           }
   258           echo '<div class="info-box">Pending members status updated successfully.</div>';
   260           echo '<div class="info-box">' . $lang->get('groupcp_msg_pending_updated') . '</div>';
   259           break;
   261           break;
   260       }
   262       }
   261     }
   263     }
   262     
   264     
   263     if ( isset($_GET['act']) && $_GET['act'] == 'update' && !$is_member && $row['group_type'] == GROUP_OPEN )
   265     if ( isset($_GET['act']) && $_GET['act'] == 'update' && !$is_member && $row['group_type'] == GROUP_OPEN && !$can_do_admin_stuff )
   264     {
   266     {
   265       $q = $db->sql_query('INSERT INTO '.table_prefix.'group_members(group_id,user_id) VALUES(' . $gid . ', ' . $session->user_id . ');');
   267       $q = $db->sql_query('INSERT INTO '.table_prefix.'group_members(group_id,user_id) VALUES(' . $gid . ', ' . $session->user_id . ');');
   266       if (!$q)
   268       if (!$q)
   267         $db->_die('SpecialGroups.php, line ' . __LINE__);
   269         $db->_die('SpecialGroups.php, line ' . __LINE__);
   268       echo '<div class="info-box">You have been added to this group.</div>';
   270       echo '<div class="info-box">' . $lang->get('groupcp_msg_self_added') . '</div>';
   269       
   271       
   270       $q = $db->sql_query('SELECT u.username,u.email,u.reg_time,m.member_id,m.user_id,m.is_mod,COUNT(c.comment_id) AS num_comments
   272       $q = $db->sql_query('SELECT u.username,u.email,u.reg_time,m.member_id,m.user_id,m.is_mod,COUNT(c.comment_id) AS num_comments
   271                              FROM '.table_prefix.'users AS u
   273                              FROM '.table_prefix.'users AS u
   272                              LEFT JOIN '.table_prefix.'group_members AS m
   274                              LEFT JOIN '.table_prefix.'group_members AS m
   273                                ON ( m.user_id = u.user_id )
   275                                ON ( m.user_id = u.user_id )
   286       $members[] = $r;
   288       $members[] = $r;
   287       $db->free_result();
   289       $db->free_result();
   288       
   290       
   289     }
   291     }
   290     
   292     
   291     if ( isset($_GET['act']) && $_GET['act'] == 'update' && !$is_member && $row['group_type'] == GROUP_REQUEST && !$is_pending )
   293     if ( isset($_GET['act']) && $_GET['act'] == 'update' && !$is_member && $row['group_type'] == GROUP_REQUEST && !$is_pending && !$can_do_admin_stuff )
   292     {
   294     {
   293       $q = $db->sql_query('INSERT INTO '.table_prefix.'group_members(group_id,user_id,pending) VALUES(' . $gid . ', ' . $session->user_id . ', 1);');
   295       $q = $db->sql_query('INSERT INTO '.table_prefix.'group_members(group_id,user_id,pending) VALUES(' . $gid . ', ' . $session->user_id . ', 1);');
   294       if (!$q)
   296       if (!$q)
   295         $db->_die('SpecialGroups.php, line ' . __LINE__);
   297         $db->_die('SpecialGroups.php, line ' . __LINE__);
   296       echo '<div class="info-box">A request has been sent to the moderator(s) of this group to add you.</div>';
   298       echo '<div class="info-box">' . $lang->get('groupcp_msg_membership_requested') . '</div>';
   297     }
   299     }
   298     
   300     
   299     $state_btns = ( $can_do_admin_stuff ) ?
   301     $state_btns = ( $can_do_admin_stuff ) ?
   300                   '<label><input type="radio" name="group_state" value="' . GROUP_HIDDEN . '" ' . (( $row['group_type'] == GROUP_HIDDEN ) ? 'checked="checked"' : '' ) . ' /> Hidden group</label>
   302                   '<label><input type="radio" name="group_state" value="' . GROUP_HIDDEN . '" ' . (( $row['group_type'] == GROUP_HIDDEN ) ? 'checked="checked"' : '' ) . ' /> ' . $lang->get('groupcp_type_hidden') . '</label>
   301                    <label><input type="radio" name="group_state" value="' . GROUP_CLOSED . '" ' . (( $row['group_type'] == GROUP_CLOSED ) ? 'checked="checked"' : '' ) . ' /> Closed group</label>
   303                    <label><input type="radio" name="group_state" value="' . GROUP_CLOSED . '" ' . (( $row['group_type'] == GROUP_CLOSED ) ? 'checked="checked"' : '' ) . ' /> ' . $lang->get('groupcp_type_closed') . '</label>
   302                    <label><input type="radio" name="group_state" value="' . GROUP_REQUEST. '" ' . (( $row['group_type'] == GROUP_REQUEST) ? 'checked="checked"' : '' ) . ' /> Members can request to join</label>
   304                    <label><input type="radio" name="group_state" value="' . GROUP_REQUEST. '" ' . (( $row['group_type'] == GROUP_REQUEST) ? 'checked="checked"' : '' ) . ' /> ' . $lang->get('groupcp_type_request') . '</label>
   303                    <label><input type="radio" name="group_state" value="' . GROUP_OPEN   . '" ' . (( $row['group_type'] == GROUP_OPEN   ) ? 'checked="checked"' : '' ) . ' /> Anybody can join</label>'
   305                    <label><input type="radio" name="group_state" value="' . GROUP_OPEN   . '" ' . (( $row['group_type'] == GROUP_OPEN   ) ? 'checked="checked"' : '' ) . ' /> ' . $lang->get('groupcp_type_open') . '</label>'
   304                    : $g_state;
   306                    : $g_state;
   305     if ( !$can_do_admin_stuff && $row['group_type'] == GROUP_REQUEST && !$is_member )
   307     if ( !$can_do_admin_stuff && $row['group_type'] == GROUP_REQUEST && !$is_member )
   306     {
   308     {
   307       if ( $is_pending )
   309       if ( $is_pending )
   308         $state_btns .= ' (Your request to join is awaiting approval)';
   310         $state_btns .= ' ' . $lang->get('groupcp_msg_status_pending');
   309       else
   311       else
   310         $state_btns .= ' <input type="submit" value="Request membership" />';
   312         $state_btns .= ' <input type="submit" value="' . $lang->get('groupcp_btn_request_join') . '" />';
   311     }
   313     }
   312     
   314     
   313     if ( !$can_do_admin_stuff && $row['group_type'] == GROUP_OPEN && !$is_member )
   315     if ( !$can_do_admin_stuff && $row['group_type'] == GROUP_OPEN && !$is_member )
   314     {
   316     {
   315       $state_btns .= ' <input type="submit" value="Join this group" />';
   317       $state_btns .= ' <input type="submit" value="' . $lang->get('groupcp_btn_join') . '" />';
   316     }
   318     }
       
   319     
       
   320     $g_name_local = 'groupcp_grp_' . strtolower($row['group_name']);
       
   321     $str = $lang->get($g_name_local);
       
   322     if ( $str != $g_name_local )
       
   323       $row['group_name'] = $str;
   317     
   324     
   318     echo '<form action="' . makeUrl($paths->page, 'act=update') . '" method="post" enctype="multipart/form-data">
   325     echo '<form action="' . makeUrl($paths->page, 'act=update') . '" method="post" enctype="multipart/form-data">
   319           <div class="tblholder">
   326           <div class="tblholder">
   320             <table border="0" cellspacing="1" cellpadding="4">
   327             <table border="0" cellspacing="1" cellpadding="4">
   321               <tr>
   328               <tr>
   322                 <th colspan="2">Group information</th>
   329                 <th colspan="2">' . $lang->get('groupcp_th_group_info') . '</th>
   323               </tr>
   330               </tr>
   324               <tr>
   331               <tr>
   325                 <td class="row2">Group name:</td>
   332                 <td class="row2">' . $lang->get('groupcp_lbl_group_name') . '</td>
   326                 <td class="row1">' . $row['group_name'] . ( $row['system_group'] == 1 ? ' (system group)' : '' ) . '</td>
   333                 <td class="row1">' . $row['group_name'] . ( $row['system_group'] == 1 ? ' ' . $lang->get('groupcp_msg_system_group') : '' ) . '</td>
   327               </tr>
   334               </tr>
   328               <tr>
   335               <tr>
   329                 <td class="row2">Membership status:</td>
   336                 <td class="row2">' . $lang->get('groupcp_lbl_status') . '</td>
   330                 <td class="row1">' . $status . '</td>
   337                 <td class="row1">' . $status . '</td>
   331               </tr>
   338               </tr>
   332               <tr>
   339               <tr>
   333                 <td class="row2">Group state:</td>
   340                 <td class="row2">' . $lang->get('groupcp_lbl_state') . '</td>
   334                 <td class="row1">' . $state_btns . '</td>
   341                 <td class="row1">' . $state_btns . '</td>
   335               </tr>   
   342               </tr>   
   336               ' . ( ( $is_mod || $session->user_level >= USER_LEVEL_ADMIN ) ? '
   343               ' . ( ( $is_mod || $session->user_level >= USER_LEVEL_ADMIN ) ? '
   337               <tr>
   344               <tr>
   338                 <th class="subhead" colspan="2">
   345                 <th class="subhead" colspan="2">
   339                   <input type="submit" value="Save changes" />
   346                   <input type="submit" value="' . $lang->get('etc_save_changes') . '" />
   340                 </th>
   347                 </th>
   341               </tr>
   348               </tr>
   342               ' : '' ) . '
   349               ' : '' ) . '
   343             </table>
   350             </table>
   344           </div>
   351           </div>
   346           </form>';
   353           </form>';
   347     if ( sizeof ( $pending ) > 0 && $can_do_admin_stuff )
   354     if ( sizeof ( $pending ) > 0 && $can_do_admin_stuff )
   348     {
   355     {
   349       echo '<form action="' . makeUrl($paths->page, 'act=pending') . '" method="post" enctype="multipart/form-data">
   356       echo '<form action="' . makeUrl($paths->page, 'act=pending') . '" method="post" enctype="multipart/form-data">
   350             <input name="group_id" value="' . $gid . '" type="hidden" />
   357             <input name="group_id" value="' . $gid . '" type="hidden" />
   351             <h2>Pending memberships</h2>
   358             <h2>' . $lang->get('groupcp_th_pending_memberships') . '</h2>
   352             <div class="tblholder">
   359             <div class="tblholder">
   353             <table border="0" cellspacing="1" cellpadding="4">
   360             <table border="0" cellspacing="1" cellpadding="4">
   354               <tr>
   361               <tr>
   355                 <th>Username</th>
   362                 <th>' . $lang->get('groupcp_th_username') . '</th>
   356                 <th>E-mail</th>
   363                 <th>' . $lang->get('groupcp_th_email') . '</th>
   357                 <th>Registered</th>
   364                 <th>' . $lang->get('groupcp_th_reg_time') . '</th>
   358                 <th>Total comments</th>
   365                 <th>' . $lang->get('groupcp_th_comments') . '</th>
   359                 <th>Select</th>
   366                 <th>' . $lang->get('groupcp_th_select') . '</th>
   360               </tr>';
   367               </tr>';
   361       $cls = 'row2';
   368       $cls = 'row2';
   362       foreach ( $pending as $member )
   369       foreach ( $pending as $member )
   363       {
   370       {
   364         
   371         
   376       }
   383       }
   377       echo '</table>
   384       echo '</table>
   378             </div>
   385             </div>
   379             <div style="margin: 10px 0 0 auto;">
   386             <div style="margin: 10px 0 0 auto;">
   380               With selected: 
   387               With selected: 
   381               <input type="submit" name="do_appr_pending" value="Approve membership" />
   388               <input type="submit" name="do_appr_pending" value="' . $lang->get('groupcp_btn_approve_pending') . '" />
   382               <input type="submit" name="do_reject_pending" value="Reject membership" />
   389               <input type="submit" name="do_reject_pending" value="' . $lang->get('groupcp_btn_reject_pending') . '" />
   383             </div>
   390             </div>
   384             </form>';
   391             </form>';
   385     }
   392     }
   386     echo '<form action="' . makeUrl($paths->page, 'act=del_users') . '" method="post" enctype="multipart/form-data">
   393     echo '<form action="' . makeUrl($paths->page, 'act=del_users') . '" method="post" enctype="multipart/form-data">
   387           <h2>Group members</h2>
   394           <h2>' . $lang->get('groupcp_th_group_members') . '</h2>
   388           <div class="tblholder">
   395           <div class="tblholder">
   389             <table border="0" cellspacing="1" cellpadding="4">
   396             <table border="0" cellspacing="1" cellpadding="4">
   390               <tr>
   397               <tr>
   391                 <th>Username</th>
   398                 <th>' . $lang->get('groupcp_th_username') . '</th>
   392                 <th>E-mail</th>
   399                 <th>' . $lang->get('groupcp_th_email') . '</th>
   393                 <th>Registered</th>
   400                 <th>' . $lang->get('groupcp_th_reg_time') . '</th>
   394                 <th>Total comments</th>
   401                 <th>' . $lang->get('groupcp_th_comments') . '</th>
   395                 ' . ( ( $can_do_admin_stuff ) ? "
   402                 ' . ( ( $can_do_admin_stuff ) ? '
   396                 <th>Remove?</th>
   403                 <th>' . $lang->get('groupcp_th_remove') . '</th>
   397                 " : '' ) . '
   404                 ' : '' ) . '
   398               </tr>
   405               </tr>
   399               <tr>
   406               <tr>
   400                 <th colspan="5" class="subhead">Group moderators</th>
   407                 <th colspan="5" class="subhead">' . $lang->get('groupcp_th_group_mods') . '</th>
   401               </tr>';
   408               </tr>';
   402     $mod_printed = false;
   409     $mod_printed = false;
   403     $mem_printed = false;
   410     $mem_printed = false;
   404     $cls = 'row2';
   411     $cls = 'row2';
   405     
   412     
   423               <td class='{$cls}' style='text-align: center;'><input type='checkbox' name='del_user[{$member['member_id']}]' /></td>
   430               <td class='{$cls}' style='text-align: center;'><input type='checkbox' name='del_user[{$member['member_id']}]' /></td>
   424               " : '' ) . "
   431               " : '' ) . "
   425             </tr>";
   432             </tr>";
   426     }
   433     }
   427     if (!$mod_printed)
   434     if (!$mod_printed)
   428       echo '<tr><td class="' . $cls . '" colspan="5">This group has no moderators.</td></th>';
   435       echo '<tr><td class="' . $cls . '" colspan="5">' . $lang->get('groupcp_msg_no_mods') . '</td></th>';
   429     echo '<tr><th class="subhead" colspan="5">Group members</th></tr>';
   436     echo '<tr><th class="subhead" colspan="5">' . $lang->get('groupcp_th_group_members') . '</th></tr>';
   430     foreach ( $members as $member )
   437     foreach ( $members as $member )
   431     {
   438     {
   432       if ( $member['is_mod'] == 1 )
   439       if ( $member['is_mod'] == 1 )
   433         continue;
   440         continue;
   434       
   441       
   447               <td class='{$cls}' style='text-align: center;'><input type='checkbox' name='del_user[{$member['member_id']}]' /></td>
   454               <td class='{$cls}' style='text-align: center;'><input type='checkbox' name='del_user[{$member['member_id']}]' /></td>
   448               " : '' ) . "
   455               " : '' ) . "
   449             </tr>";
   456             </tr>";
   450     }
   457     }
   451     if (!$mem_printed)
   458     if (!$mem_printed)
   452       echo '<tr><td class="' . $cls . '" colspan="5">This group has no members.</td></th>';
   459       echo '<tr><td class="' . $cls . '" colspan="5">' . $lang->get('groupcp_msg_no_members') . '</td></th>';
   453     echo '  </table>
   460     echo '  </table>
   454           </div>';
   461           </div>';
   455     if ( $can_do_admin_stuff )
   462     if ( $can_do_admin_stuff )
   456     {
   463     {
   457       echo "<div style='margin: 10px 0 0 auto;'><input type='submit' name='do_del_user' value='Remove selected users' /></div>";
   464       echo "<div style='margin: 10px 0 0 auto;'><input type='submit' name='do_del_user' value=\"" . $lang->get('groupcp_btn_remove_selected') . "\" /></div>";
   458     }
   465     }
   459     echo '<input name="group_id" value="' . $gid . '" type="hidden" />
   466     echo '<input name="group_id" value="' . $gid . '" type="hidden" />
   460           </form>';
   467           </form>';
   461     if ( $can_do_admin_stuff )
   468     if ( $can_do_admin_stuff )
   462     {
   469     {
   463       echo '<form action="' . makeUrl($paths->page, 'act=adduser') . '" method="post" enctype="multipart/form-data" onsubmit="if(!submitAuthorized) return false;">
   470       echo '<form action="' . makeUrl($paths->page, 'act=adduser') . '" method="post" enctype="multipart/form-data" onsubmit="if(!submitAuthorized) return false;">
   464               <div class="tblholder">
   471               <div class="tblholder">
   465                 <table border="0" cellspacing="1" cellpadding="4">
   472                 <table border="0" cellspacing="1" cellpadding="4">
   466                   <tr>
   473                   <tr>
   467                     <th colspan="2">Add a new member to this group</th>
   474                     <th colspan="2">' . $lang->get('groupcp_th_add_member') . '</th>
   468                   </tr>
   475                   </tr>
   469                   <tr>
   476                   <tr>
   470                     <td class="row2">Username:</td><td class="row1">' . $template->username_field('add_username') . '</td>
   477                     <td class="row2">' . $lang->get('groupcp_lbl_username') . '</td><td class="row1">' . $template->username_field('add_username') . '</td>
   471                   </tr>
   478                   </tr>
   472                   <tr>
   479                   <tr>
   473                     <td class="row2">Group moderator:</td><td class="row1"><label><input type="checkbox" name="add_mod" /> User is a group moderator</label></td>
   480                     <td class="row2">' . $lang->get('groupcp_lbl_moderator') . '</td><td class="row1"><label><input type="checkbox" name="add_mod" /> ' . $lang->get('groupcp_lbl_make_mod') . '</label></td>
   474                   </tr>
   481                   </tr>
   475                   <tr>
   482                   <tr>
   476                     <th class="subhead" colspan="2">
   483                     <th class="subhead" colspan="2">
   477                       <input type="submit" value="Add member" />
   484                       <input type="submit" value="' . $lang->get('groupcp_btn_add_member') . '" />
   478                     </th>
   485                     </th>
   479                   </tr>
   486                   </tr>
   480                 </table>
   487                 </table>
   481               </div>
   488               </div>
   482               <input name="group_id" value="' . $gid . '" type="hidden" />
   489               <input name="group_id" value="' . $gid . '" type="hidden" />
   487   {
   494   {
   488     echo '<form action="'.makeUrlNS('Special', 'Usergroups').'" method="post" onsubmit="if(!submitAuthorized) return false;" enctype="multipart/form-data">';
   495     echo '<form action="'.makeUrlNS('Special', 'Usergroups').'" method="post" onsubmit="if(!submitAuthorized) return false;" enctype="multipart/form-data">';
   489     echo '<div class="tblholder">
   496     echo '<div class="tblholder">
   490           <table border="0" style="width: 100%;" cellspacing="1" cellpadding="4">
   497           <table border="0" style="width: 100%;" cellspacing="1" cellpadding="4">
   491             <tr>
   498             <tr>
   492               <th colspan="2">Group membership details</th>
   499               <th colspan="2">' . $lang->get('groupcp_th_select_group') . '</th>
   493             </tr>
   500             </tr>
   494             <tr>
   501             <tr>
   495               <td class="row2" style="text-align: right; width: 50%;">
   502               <td class="row2" style="text-align: right; width: 50%;">
   496                 Current group memberships:
   503                 ' . $lang->get('groupcp_lbl_current_memberships') . '
   497               </td>
   504               </td>
   498               <td class="row1" style="width: 50%;">';
   505               <td class="row1" style="width: 50%;">';
   499     $taboo = Array('Everyone');
   506     $taboo = Array('Everyone');
   500     if ( sizeof ( $session->groups ) > count($taboo) )
   507     if ( sizeof ( $session->groups ) > count($taboo) )
   501     {
   508     {
   503       foreach ( $session->groups as $id => $group )
   510       foreach ( $session->groups as $id => $group )
   504       {
   511       {
   505         $taboo[] = $group;
   512         $taboo[] = $group;
   506         if ( $group != 'Everyone' )
   513         if ( $group != 'Everyone' )
   507         {
   514         {
       
   515           $g_name_local = 'groupcp_grp_' . strtolower($group);
       
   516           $str = $lang->get($g_name_local);
       
   517           if ( $str != $g_name_local )
       
   518             $group = $str;
   508           echo '<option value="' . $id . '">' . $group . '</option>';
   519           echo '<option value="' . $id . '">' . $group . '</option>';
   509         }
   520         }
   510       }
   521       }
   511       echo '</select>
   522       echo '</select>
   512             <input type="submit" name="do_view" value="View information" />';
   523             <input type="submit" name="do_view" value="' . $lang->get('groupcp_btn_view') . '" />';
   513     }
   524     }
   514     else
   525     else
   515     {
   526     {
   516       echo 'None';
   527       echo 'None';
   517     }
   528     }
   528     }
   539     }
   529     if($db->numrows() > 0)
   540     if($db->numrows() > 0)
   530     {
   541     {
   531       echo '<tr>
   542       echo '<tr>
   532               <td class="row2" style="text-align: right;">
   543               <td class="row2" style="text-align: right;">
   533                 Non-memberships:
   544                 ' . $lang->get('groupcp_lbl_non_memberships') . '
   534               </td>
   545               </td>
   535               <td class="row1">
   546               <td class="row1">
   536               <select name="group_id_n">';
   547               <select name="group_id_n">';
   537       while ( $row = $db->fetchrow() )
   548       while ( $row = $db->fetchrow() )
   538       {
   549       {
   540         {
   551         {
   541           echo '<option value="' . $row['group_id'] . '">' . $row['group_name'] . '</option>';
   552           echo '<option value="' . $row['group_id'] . '">' . $row['group_name'] . '</option>';
   542         }
   553         }
   543       }
   554       }
   544       echo '</select>
   555       echo '</select>
   545             <input type="submit" name="do_view_n" value="View information" />
   556             <input type="submit" name="do_view_n" value="' . $lang->get('groupcp_btn_view') . '" />
   546           </td>
   557           </td>
   547         </tr>
   558         </tr>
   548       ';
   559       ';
   549     }
   560     }
   550     $db->free_result();
   561     $db->free_result();