plugins/SpecialGroups.php
changeset 1227 bdac73ed481e
parent 1081 745200a9cc2a
child 1270 bd3ee7f12bc1
equal deleted inserted replaced
1226:de56132c008d 1227:bdac73ed481e
     1 <?php
     1 <?php
     2 /**!info**
     2 /**!info**
     3 {
     3 {
     4   "Plugin Name"  : "plugin_specialgroups_title",
     4 	"Plugin Name"  : "plugin_specialgroups_title",
     5   "Plugin URI"   : "http://enanocms.org/",
     5 	"Plugin URI"   : "http://enanocms.org/",
     6   "Description"  : "plugin_specialgroups_desc",
     6 	"Description"  : "plugin_specialgroups_desc",
     7   "Author"       : "Dan Fuhry",
     7 	"Author"       : "Dan Fuhry",
     8   "Version"      : "1.1.6",
     8 	"Version"      : "1.1.6",
     9   "Author URI"   : "http://enanocms.org/"
     9 	"Author URI"   : "http://enanocms.org/"
    10 }
    10 }
    11 **!*/
    11 **!*/
    12 
    12 
    13 /*
    13 /*
    14  * Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between
    14  * Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between
    23 
    23 
    24 // $plugins->attachHook('session_started', 'SpecialGroups_paths_init();');
    24 // $plugins->attachHook('session_started', 'SpecialGroups_paths_init();');
    25 
    25 
    26 function SpecialGroups_paths_init()
    26 function SpecialGroups_paths_init()
    27 {
    27 {
    28   register_special_page('Usergroups', 'specialpage_groupcp');
    28 	register_special_page('Usergroups', 'specialpage_groupcp');
    29 }
    29 }
    30 
    30 
    31 function page_Special_Usergroups()
    31 function page_Special_Usergroups()
    32 {
    32 {
    33   global $db, $session, $paths, $template, $plugins; // Common objects
    33 	global $db, $session, $paths, $template, $plugins; // Common objects
    34   global $email; // Import e-mail encryption functions
    34 	global $email; // Import e-mail encryption functions
    35   global $lang;
    35 	global $lang;
    36   
    36 	
    37   if ( !$session->user_logged_in )
    37 	if ( !$session->user_logged_in )
    38   {
    38 	{
    39     header('Location: ' . makeUrlComplete('Special', 'Login/' . $paths->page));
    39 		header('Location: ' . makeUrlComplete('Special', 'Login/' . $paths->page));
    40     $db->close();
    40 		$db->close();
    41     exit;
    41 		exit;
    42   }
    42 	}
    43   
    43 	
    44   $template->header();
    44 	$template->header();
    45   userprefs_show_menu();
    45 	userprefs_show_menu();
    46   if ( isset($_POST['do_view']) || isset($_POST['do_view_n']) || ( isset($_GET['act']) && isset($_POST['group_id']) ) )
    46 	if ( isset($_POST['do_view']) || isset($_POST['do_view_n']) || ( isset($_GET['act']) && isset($_POST['group_id']) ) )
    47   {
    47 	{
    48     $gid = ( isset ( $_POST['do_view_n'] ) ) ? intval($_POST['group_id_n']) : intval($_POST['group_id']);
    48 		$gid = ( isset ( $_POST['do_view_n'] ) ) ? intval($_POST['group_id_n']) : intval($_POST['group_id']);
    49     if ( empty($gid) || $gid < 1 )
    49 		if ( empty($gid) || $gid < 1 )
    50     {
    50 		{
    51       die_friendly('Error', '<p>Hacking attempt</p>');
    51 			die_friendly('Error', '<p>Hacking attempt</p>');
    52     }
    52 		}
    53     $q = $db->sql_query('SELECT group_name,group_type,system_group FROM '.table_prefix.'groups WHERE group_id=' . $gid . ';');
    53 		$q = $db->sql_query('SELECT group_name,group_type,system_group FROM '.table_prefix.'groups WHERE group_id=' . $gid . ';');
    54     if ( !$q )
    54 		if ( !$q )
    55     {
    55 		{
    56       $db->_die('SpecialGroups.php, line ' . __LINE__);
    56 			$db->_die('SpecialGroups.php, line ' . __LINE__);
    57     }
    57 		}
    58     $row = $db->fetchrow();
    58 		$row = $db->fetchrow();
    59     $db->free_result();
    59 		$db->free_result();
    60     $members = array();
    60 		$members = array();
    61     $pending = array();
    61 		$pending = array();
    62     $q = $db->sql_query('SELECT u.username,u.email,u.reg_time,m.member_id,m.user_id,m.is_mod,m.pending,COUNT(c.comment_id) AS num_comments
    62 		$q = $db->sql_query('SELECT u.username,u.email,u.reg_time,m.member_id,m.user_id,m.is_mod,m.pending,COUNT(c.comment_id) AS num_comments
    63                            FROM '.table_prefix.'users AS u
    63  													FROM '.table_prefix.'users AS u
    64                            LEFT JOIN '.table_prefix.'group_members AS m
    64  													LEFT JOIN '.table_prefix.'group_members AS m
    65                              ON ( m.user_id = u.user_id )
    65  														ON ( m.user_id = u.user_id )
    66                            LEFT JOIN '.table_prefix.'comments AS c
    66  													LEFT JOIN '.table_prefix.'comments AS c
    67                              ON ( c.name = u.username )
    67  														ON ( c.name = u.username )
    68                            WHERE m.group_id=' . $gid . '
    68  													WHERE m.group_id=' . $gid . '
    69                            GROUP BY u.user_id,u.username,u.email,u.reg_time,m.member_id,m.user_id,m.is_mod,m.pending
    69  													GROUP BY u.user_id,u.username,u.email,u.reg_time,m.member_id,m.user_id,m.is_mod,m.pending
    70                            ORDER BY m.is_mod DESC,u.username ASC;');
    70  													ORDER BY m.is_mod DESC,u.username ASC;');
    71     if ( !$q )
    71 		if ( !$q )
    72     {
    72 		{
    73       $db->_die('SpecialGroups.php, line ' . __LINE__);
    73 			$db->_die('SpecialGroups.php, line ' . __LINE__);
    74     }
    74 		}
    75     
    75 		
    76     $is_member = false;
    76 		$is_member = false;
    77     $is_mod = false;
    77 		$is_mod = false;
    78     $is_pending = false;
    78 		$is_pending = false;
    79     
    79 		
    80     while ( $mr = $db->fetchrow() )
    80 		while ( $mr = $db->fetchrow() )
    81     {
    81 		{
    82       if ( $mr['pending'] == 1 )
    82 			if ( $mr['pending'] == 1 )
    83       {
    83 			{
    84         $pending[] = $mr;
    84 				$pending[] = $mr;
    85         if ( $mr['user_id'] == $session->user_id )
    85 				if ( $mr['user_id'] == $session->user_id )
    86         {
    86 				{
    87           $is_pending = true;
    87 					$is_pending = true;
    88         }
    88 				}
    89       }
    89 			}
    90       else
    90 			else
    91       {
    91 			{
    92         $members[] = $mr;
    92 				$members[] = $mr;
    93         if ( $mr['user_id'] == $session->user_id )
    93 				if ( $mr['user_id'] == $session->user_id )
    94         {
    94 				{
    95           $is_member = true;
    95 					$is_member = true;
    96           if ( $mr['is_mod'] == 1 )
    96 					if ( $mr['is_mod'] == 1 )
    97           {
    97 					{
    98             $is_mod = true;
    98 						$is_mod = true;
    99           }
    99 					}
   100         }
   100 				}
   101       }
   101 			}
   102     }
   102 		}
   103     
   103 		
   104     $status = ( $is_member && $is_mod )
   104 		$status = ( $is_member && $is_mod )
   105       ? $lang->get('groupcp_status_mod')
   105 			? $lang->get('groupcp_status_mod')
   106       : ( ( $is_member && !$is_mod ) 
   106 			: ( ( $is_member && !$is_mod ) 
   107         ? $lang->get('groupcp_status_member')
   107 				? $lang->get('groupcp_status_member')
   108         : $lang->get('groupcp_status_not_member')
   108 				: $lang->get('groupcp_status_not_member')
   109         );
   109 				);
   110       
   110 			
   111     $can_do_admin_stuff = ( $is_mod || $session->user_level >= USER_LEVEL_ADMIN );
   111 		$can_do_admin_stuff = ( $is_mod || $session->user_level >= USER_LEVEL_ADMIN );
   112       
   112 			
   113     switch ( $row['group_type'] )
   113 		switch ( $row['group_type'] )
   114     {
   114 		{
   115       case GROUP_HIDDEN:  $g_state = $lang->get('groupcp_type_hidden'); break;
   115 			case GROUP_HIDDEN:  $g_state = $lang->get('groupcp_type_hidden'); break;
   116       case GROUP_CLOSED:  $g_state = $lang->get('groupcp_type_closed'); break;
   116 			case GROUP_CLOSED:  $g_state = $lang->get('groupcp_type_closed'); break;
   117       case GROUP_REQUEST: $g_state = $lang->get('groupcp_type_request'); break;
   117 			case GROUP_REQUEST: $g_state = $lang->get('groupcp_type_request'); break;
   118       case GROUP_OPEN:    $g_state = $lang->get('groupcp_type_open'); break;
   118 			case GROUP_OPEN:    $g_state = $lang->get('groupcp_type_open'); break;
   119     }
   119 		}
   120     
   120 		
   121     if ( isset($_GET['act']) && $can_do_admin_stuff )
   121 		if ( isset($_GET['act']) && $can_do_admin_stuff )
   122     {
   122 		{
   123       switch($_GET['act'])
   123 			switch($_GET['act'])
   124       {
   124 			{
   125         case 'update':
   125 				case 'update':
   126           if(!in_array(intval($_POST['group_state']), Array(GROUP_CLOSED, GROUP_OPEN, GROUP_HIDDEN, GROUP_REQUEST)))
   126 					if(!in_array(intval($_POST['group_state']), Array(GROUP_CLOSED, GROUP_OPEN, GROUP_HIDDEN, GROUP_REQUEST)))
   127           {
   127 					{
   128             die_friendly('ERROR', '<p>Hacking attempt</p>');
   128 						die_friendly('ERROR', '<p>Hacking attempt</p>');
   129           }
   129 					}
   130           $q = $db->sql_query('SELECT group_type, system_group FROM '.table_prefix.'groups WHERE group_id=' . intval( $_POST['group_id']) . ';');
   130 					$q = $db->sql_query('SELECT group_type, system_group FROM '.table_prefix.'groups WHERE group_id=' . intval( $_POST['group_id']) . ';');
   131           if ( !$q )
   131 					if ( !$q )
   132             $db->_die('SpecialGroups.php, line ' . __LINE__);
   132 						$db->_die('SpecialGroups.php, line ' . __LINE__);
   133           $error = false;
   133 					$error = false;
   134           if ( $db->numrows() < 1 )
   134 					if ( $db->numrows() < 1 )
   135           {
   135 					{
   136             echo '<div class="error-box" style="margin-left: 0;">The group you selected does not exist.</div>';
   136 						echo '<div class="error-box" style="margin-left: 0;">The group you selected does not exist.</div>';
   137             $error = true;
   137 						$error = true;
   138           }
   138 					}
   139           $r = $db->fetchrow();
   139 					$r = $db->fetchrow();
   140           if ( $r['system_group'] == 1 && ( intval($_POST['group_state']) == GROUP_OPEN || intval($_POST['group_state']) == GROUP_REQUEST ) )
   140 					if ( $r['system_group'] == 1 && ( intval($_POST['group_state']) == GROUP_OPEN || intval($_POST['group_state']) == GROUP_REQUEST ) )
   141           {
   141 					{
   142             echo '<div class="error-box" style="margin-left: 0;">' . $lang->get('groupcp_err_state_system_group') . '</div>';
   142 						echo '<div class="error-box" style="margin-left: 0;">' . $lang->get('groupcp_err_state_system_group') . '</div>';
   143             $error = true;
   143 						$error = true;
   144           }
   144 					}
   145           if ( !$error )
   145 					if ( !$error )
   146           {
   146 					{
   147             $q = $db->sql_query('UPDATE '.table_prefix.'groups SET group_type=' . intval($_POST['group_state']) . ' WHERE group_id=' . intval( $_POST['group_id']) . ';');
   147 						$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)
   148 						if (!$q)
   149               $db->_die('SpecialGroups.php, line ' . __LINE__);
   149 							$db->_die('SpecialGroups.php, line ' . __LINE__);
   150             $row['group_type'] = $_POST['group_state'];
   150 						$row['group_type'] = $_POST['group_state'];
   151             echo '<div class="info-box" style="margin-left: 0;">' . $lang->get('groupcp_msg_state_updated') . '</div>';
   151 						echo '<div class="info-box" style="margin-left: 0;">' . $lang->get('groupcp_msg_state_updated') . '</div>';
   152           }
   152 					}
   153           break;
   153 					break;
   154         case 'adduser':
   154 				case 'adduser':
   155           $username = $_POST['add_username'];
   155 					$username = $_POST['add_username'];
   156           $mod = ( isset($_POST['add_mod']) ) ? '1' : '0';
   156 					$mod = ( isset($_POST['add_mod']) ) ? '1' : '0';
   157           
   157 					
   158           $q = $db->sql_query('SELECT user_id FROM '.table_prefix.'users WHERE username=\'' . $db->escape($username) . '\';');
   158 					$q = $db->sql_query('SELECT user_id FROM '.table_prefix.'users WHERE username=\'' . $db->escape($username) . '\';');
   159           if (!$q)
   159 					if (!$q)
   160             $db->_die('SpecialGroups.php, line ' . __LINE__);
   160 						$db->_die('SpecialGroups.php, line ' . __LINE__);
   161           if ($db->numrows() < 1)
   161 					if ($db->numrows() < 1)
   162           {
   162 					{
   163             echo '<div class="error-box">' . $lang->get('groupcp_err_user_not_found') . '</div>';
   163 						echo '<div class="error-box">' . $lang->get('groupcp_err_user_not_found') . '</div>';
   164             break;
   164 						break;
   165           }
   165 					}
   166           $r = $db->fetchrow();
   166 					$r = $db->fetchrow();
   167           $db->free_result();
   167 					$db->free_result();
   168           $uid = intval($r['user_id']);
   168 					$uid = intval($r['user_id']);
   169 
   169 
   170           // Check if the user is already in the group, and if so, only update modship
   170 					// Check if the user is already in the group, and if so, only update modship
   171           $q = $db->sql_query('SELECT member_id,is_mod FROM '.table_prefix.'group_members WHERE user_id=' . $uid . ' AND group_id=' . intval($_POST['group_id']) . ';');
   171 					$q = $db->sql_query('SELECT member_id,is_mod FROM '.table_prefix.'group_members WHERE user_id=' . $uid . ' AND group_id=' . intval($_POST['group_id']) . ';');
   172           if ( !$q )
   172 					if ( !$q )
   173             $db->_die('SpecialGroups.php, line ' . __LINE__);
   173 						$db->_die('SpecialGroups.php, line ' . __LINE__);
   174           if ( $db->numrows() > 0 )
   174 					if ( $db->numrows() > 0 )
   175           {
   175 					{
   176             $r = $db->fetchrow();
   176 						$r = $db->fetchrow();
   177             if ( (string) $r['is_mod'] != $mod )
   177 						if ( (string) $r['is_mod'] != $mod )
   178             {
   178 						{
   179               $q = $db->sql_query('UPDATE '.table_prefix.'group_members SET is_mod=' . $mod . ' WHERE member_id=' . $r['member_id'] . ';');
   179 							$q = $db->sql_query('UPDATE '.table_prefix.'group_members SET is_mod=' . $mod . ' WHERE member_id=' . $r['member_id'] . ';');
   180               if ( !$q )
   180 							if ( !$q )
   181                 $db->_die('SpecialGroups.php, line ' . __LINE__);
   181 								$db->_die('SpecialGroups.php, line ' . __LINE__);
   182               foreach ( $members as $i => $member )
   182 							foreach ( $members as $i => $member )
   183               {
   183 							{
   184                 if ( $member['member_id'] == $r['member_id'] )
   184 								if ( $member['member_id'] == $r['member_id'] )
   185                   $members[$i]['is_mod'] = (int)$mod;
   185 									$members[$i]['is_mod'] = (int)$mod;
   186               }
   186 							}
   187               echo '<div class="info-box">' . $lang->get('groupcp_msg_user_already_in_mod_updated', array('username' => $username)) . '</div>';
   187 							echo '<div class="info-box">' . $lang->get('groupcp_msg_user_already_in_mod_updated', array('username' => $username)) . '</div>';
   188             }
   188 						}
   189             else
   189 						else
   190             {
   190 						{
   191               echo '<div class="info-box">' . $lang->get('groupcp_msg_user_already_in', array('username' => $username)) . '</div>';
   191 							echo '<div class="info-box">' . $lang->get('groupcp_msg_user_already_in', array('username' => $username)) . '</div>';
   192             }
   192 						}
   193             break;
   193 						break;
   194           }
   194 					}
   195           
   195 					
   196           $db->free_result();
   196 					$db->free_result();
   197           
   197 					
   198           $q = $db->sql_query('INSERT INTO '.table_prefix.'group_members(group_id,user_id,is_mod) VALUES(' . intval($_POST['group_id']) . ', ' . $uid . ', ' . $mod . ');');
   198 					$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)
   199 					if (!$q)
   200             $db->_die('SpecialGroups.php, line ' . __LINE__);
   200 						$db->_die('SpecialGroups.php, line ' . __LINE__);
   201           echo '<div class="info-box">' . $lang->get('groupcp_msg_user_added', array('username' => $username)) . '</div>';
   201 					echo '<div class="info-box">' . $lang->get('groupcp_msg_user_added', array('username' => $username)) . '</div>';
   202           
   202 					
   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
   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
   204                                  FROM '.table_prefix.'users AS u
   204  																FROM '.table_prefix.'users AS u
   205                                  LEFT JOIN '.table_prefix.'group_members AS m
   205  																LEFT JOIN '.table_prefix.'group_members AS m
   206                                    ON ( m.user_id = u.user_id )
   206  																	ON ( m.user_id = u.user_id )
   207                                  LEFT JOIN '.table_prefix.'comments AS c
   207  																LEFT JOIN '.table_prefix.'comments AS c
   208                                    ON ( c.name = u.username )
   208  																	ON ( c.name = u.username )
   209                                  WHERE m.group_id=' . $gid . '
   209  																WHERE m.group_id=' . $gid . '
   210                                    AND m.pending!=1
   210  																	AND m.pending!=1
   211                                    AND u.user_id=' . $uid . '
   211  																	AND u.user_id=' . $uid . '
   212                                  GROUP BY u.user_id,u.username,u.email,u.reg_time,m.member_id,m.user_id,m.is_mod
   212  																GROUP BY u.user_id,u.username,u.email,u.reg_time,m.member_id,m.user_id,m.is_mod
   213                                  ORDER BY m.is_mod DESC,u.username ASC
   213  																ORDER BY m.is_mod DESC,u.username ASC
   214                                  LIMIT 1;');
   214  																LIMIT 1;');
   215           if ( !$q )
   215 					if ( !$q )
   216             $db->_die('SpecialGroups.php, line ' . __LINE__);
   216 						$db->_die('SpecialGroups.php, line ' . __LINE__);
   217           
   217 					
   218           $r = $db->fetchrow();
   218 					$r = $db->fetchrow();
   219           $members[] = $r;
   219 					$members[] = $r;
   220           $db->free_result();
   220 					$db->free_result();
   221           
   221 					
   222           // just added a user to the group, so regenerate the ranks cache
   222 					// just added a user to the group, so regenerate the ranks cache
   223           generate_cache_userranks();
   223 					generate_cache_userranks();
   224           
   224 					
   225           break;
   225 					break;
   226         case 'del_users':
   226 				case 'del_users':
   227           foreach ( $members as $i => $member )
   227 					foreach ( $members as $i => $member )
   228           {
   228 					{
   229             if ( isset($_POST['del_user'][$member['member_id']]) )
   229 						if ( isset($_POST['del_user'][$member['member_id']]) )
   230             {
   230 						{
   231               $q = $db->sql_query('DELETE FROM '.table_prefix.'group_members WHERE member_id=' . $member['member_id'] . ';');
   231 							$q = $db->sql_query('DELETE FROM '.table_prefix.'group_members WHERE member_id=' . $member['member_id'] . ';');
   232               if (!$q)
   232 							if (!$q)
   233                 $db->_die('SpecialGroups.php, line ' . __LINE__);
   233 								$db->_die('SpecialGroups.php, line ' . __LINE__);
   234               unset($members[$i]);
   234 							unset($members[$i]);
   235             }
   235 						}
   236           }
   236 					}
   237           // regenerate the ranks cache
   237 					// regenerate the ranks cache
   238           generate_cache_userranks();
   238 					generate_cache_userranks();
   239           
   239 					
   240           break;
   240 					break;
   241         case 'pending':
   241 				case 'pending':
   242           foreach ( $pending as $i => $member )
   242 					foreach ( $pending as $i => $member )
   243           {
   243 					{
   244             if ( isset( $_POST['with_user'][$member['member_id']]) )
   244 						if ( isset( $_POST['with_user'][$member['member_id']]) )
   245             {
   245 						{
   246               if ( isset ( $_POST['do_appr_pending'] ) )
   246 							if ( isset ( $_POST['do_appr_pending'] ) )
   247               {
   247 							{
   248                 $q = $db->sql_query('UPDATE '.table_prefix.'group_members SET pending=0 WHERE member_id=' . $member['member_id'] . ';');
   248 								$q = $db->sql_query('UPDATE '.table_prefix.'group_members SET pending=0 WHERE member_id=' . $member['member_id'] . ';');
   249                 if (!$q)
   249 								if (!$q)
   250                   $db->_die('SpecialGroups.php, line ' . __LINE__);
   250 									$db->_die('SpecialGroups.php, line ' . __LINE__);
   251                 $members[] = $member;
   251 								$members[] = $member;
   252                 unset($pending[$i]);
   252 								unset($pending[$i]);
   253                 continue;
   253 								continue;
   254               }
   254 							}
   255               elseif ( isset ( $_POST['do_reject_pending'] ) )
   255 							elseif ( isset ( $_POST['do_reject_pending'] ) )
   256               {
   256 							{
   257                 $q = $db->sql_query('DELETE FROM '.table_prefix.'group_members WHERE member_id=' . $member['member_id'] . ';');
   257 								$q = $db->sql_query('DELETE FROM '.table_prefix.'group_members WHERE member_id=' . $member['member_id'] . ';');
   258                 if (!$q)
   258 								if (!$q)
   259                   $db->_die('SpecialGroups.php, line ' . __LINE__);
   259 									$db->_die('SpecialGroups.php, line ' . __LINE__);
   260                 unset($pending[$i]);
   260 								unset($pending[$i]);
   261               }
   261 							}
   262             }
   262 						}
   263           }
   263 					}
   264           // memberships updated/changed, regenerate ranks cache
   264 					// memberships updated/changed, regenerate ranks cache
   265           generate_cache_userranks();
   265 					generate_cache_userranks();
   266           
   266 					
   267           echo '<div class="info-box">' . $lang->get('groupcp_msg_pending_updated') . '</div>';
   267 					echo '<div class="info-box">' . $lang->get('groupcp_msg_pending_updated') . '</div>';
   268           break;
   268 					break;
   269       }
   269 			}
   270     }
   270 		}
   271     
   271 		
   272     if ( isset($_GET['act']) && $_GET['act'] == 'update' && !$is_member && $row['group_type'] == GROUP_OPEN && !$can_do_admin_stuff )
   272 		if ( isset($_GET['act']) && $_GET['act'] == 'update' && !$is_member && $row['group_type'] == GROUP_OPEN && !$can_do_admin_stuff )
   273     {
   273 		{
   274       $q = $db->sql_query('INSERT INTO '.table_prefix.'group_members(group_id,user_id) VALUES(' . $gid . ', ' . $session->user_id . ');');
   274 			$q = $db->sql_query('INSERT INTO '.table_prefix.'group_members(group_id,user_id) VALUES(' . $gid . ', ' . $session->user_id . ');');
   275       if (!$q)
   275 			if (!$q)
   276         $db->_die('SpecialGroups.php, line ' . __LINE__);
   276 				$db->_die('SpecialGroups.php, line ' . __LINE__);
   277       echo '<div class="info-box">' . $lang->get('groupcp_msg_self_added') . '</div>';
   277 			echo '<div class="info-box">' . $lang->get('groupcp_msg_self_added') . '</div>';
   278       
   278 			
   279       $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
   279 			$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
   280                              FROM '.table_prefix.'users AS u
   280  														FROM '.table_prefix.'users AS u
   281                              LEFT JOIN '.table_prefix.'group_members AS m
   281  														LEFT JOIN '.table_prefix.'group_members AS m
   282                                ON ( m.user_id = u.user_id )
   282  															ON ( m.user_id = u.user_id )
   283                              LEFT JOIN '.table_prefix.'comments AS c
   283  														LEFT JOIN '.table_prefix.'comments AS c
   284                                ON ( c.name = u.username )
   284  															ON ( c.name = u.username )
   285                              WHERE m.group_id=' . $gid . '
   285  														WHERE m.group_id=' . $gid . '
   286                                AND m.pending!=1
   286  															AND m.pending!=1
   287                                AND u.user_id=' . $session->user_id . '
   287  															AND u.user_id=' . $session->user_id . '
   288                              GROUP BY u.user_id,u.username,u.email,u.reg_time,m.member_id,m.user_id,m.is_mod
   288  														GROUP BY u.user_id,u.username,u.email,u.reg_time,m.member_id,m.user_id,m.is_mod
   289                              ORDER BY m.is_mod DESC,u.username ASC
   289  														ORDER BY m.is_mod DESC,u.username ASC
   290                              LIMIT 1;');
   290  														LIMIT 1;');
   291       if ( !$q )
   291 			if ( !$q )
   292         $db->_die('SpecialGroups.php, line ' . __LINE__);
   292 				$db->_die('SpecialGroups.php, line ' . __LINE__);
   293       
   293 			
   294       $r = $db->fetchrow();
   294 			$r = $db->fetchrow();
   295       $members[] = $r;
   295 			$members[] = $r;
   296       $db->free_result();
   296 			$db->free_result();
   297       
   297 			
   298     }
   298 		}
   299     
   299 		
   300     if ( isset($_GET['act']) && $_GET['act'] == 'update' && !$is_member && $row['group_type'] == GROUP_REQUEST && !$is_pending && !$can_do_admin_stuff )
   300 		if ( isset($_GET['act']) && $_GET['act'] == 'update' && !$is_member && $row['group_type'] == GROUP_REQUEST && !$is_pending && !$can_do_admin_stuff )
   301     {
   301 		{
   302       $q = $db->sql_query('INSERT INTO '.table_prefix.'group_members(group_id,user_id,pending) VALUES(' . $gid . ', ' . $session->user_id . ', 1);');
   302 			$q = $db->sql_query('INSERT INTO '.table_prefix.'group_members(group_id,user_id,pending) VALUES(' . $gid . ', ' . $session->user_id . ', 1);');
   303       if (!$q)
   303 			if (!$q)
   304         $db->_die('SpecialGroups.php, line ' . __LINE__);
   304 				$db->_die('SpecialGroups.php, line ' . __LINE__);
   305       echo '<div class="info-box">' . $lang->get('groupcp_msg_membership_requested') . '</div>';
   305 			echo '<div class="info-box">' . $lang->get('groupcp_msg_membership_requested') . '</div>';
   306     }
   306 		}
   307     
   307 		
   308     $state_btns = ( $can_do_admin_stuff ) ?
   308 		$state_btns = ( $can_do_admin_stuff ) ?
   309                   '<label><input type="radio" name="group_state" value="' . GROUP_HIDDEN . '" ' . (( $row['group_type'] == GROUP_HIDDEN ) ? 'checked="checked"' : '' ) . ' /> ' . $lang->get('groupcp_type_hidden') . '</label>
   309 									'<label><input type="radio" name="group_state" value="' . GROUP_HIDDEN . '" ' . (( $row['group_type'] == GROUP_HIDDEN ) ? 'checked="checked"' : '' ) . ' /> ' . $lang->get('groupcp_type_hidden') . '</label>
   310                    <label><input type="radio" name="group_state" value="' . GROUP_CLOSED . '" ' . (( $row['group_type'] == GROUP_CLOSED ) ? 'checked="checked"' : '' ) . ' /> ' . $lang->get('groupcp_type_closed') . '</label>
   310  									<label><input type="radio" name="group_state" value="' . GROUP_CLOSED . '" ' . (( $row['group_type'] == GROUP_CLOSED ) ? 'checked="checked"' : '' ) . ' /> ' . $lang->get('groupcp_type_closed') . '</label>
   311                    <label><input type="radio" name="group_state" value="' . GROUP_REQUEST. '" ' . (( $row['group_type'] == GROUP_REQUEST) ? 'checked="checked"' : '' ) . ' /> ' . $lang->get('groupcp_type_request') . '</label>
   311  									<label><input type="radio" name="group_state" value="' . GROUP_REQUEST. '" ' . (( $row['group_type'] == GROUP_REQUEST) ? 'checked="checked"' : '' ) . ' /> ' . $lang->get('groupcp_type_request') . '</label>
   312                    <label><input type="radio" name="group_state" value="' . GROUP_OPEN   . '" ' . (( $row['group_type'] == GROUP_OPEN   ) ? 'checked="checked"' : '' ) . ' /> ' . $lang->get('groupcp_type_open') . '</label>'
   312  									<label><input type="radio" name="group_state" value="' . GROUP_OPEN   . '" ' . (( $row['group_type'] == GROUP_OPEN   ) ? 'checked="checked"' : '' ) . ' /> ' . $lang->get('groupcp_type_open') . '</label>'
   313                    : $g_state;
   313  									: $g_state;
   314     if ( !$can_do_admin_stuff && $row['group_type'] == GROUP_REQUEST && !$is_member )
   314 		if ( !$can_do_admin_stuff && $row['group_type'] == GROUP_REQUEST && !$is_member )
   315     {
   315 		{
   316       if ( $is_pending )
   316 			if ( $is_pending )
   317         $state_btns .= ' ' . $lang->get('groupcp_msg_status_pending');
   317 				$state_btns .= ' ' . $lang->get('groupcp_msg_status_pending');
   318       else
   318 			else
   319         $state_btns .= ' <input type="submit" value="' . $lang->get('groupcp_btn_request_join') . '" />';
   319 				$state_btns .= ' <input type="submit" value="' . $lang->get('groupcp_btn_request_join') . '" />';
   320     }
   320 		}
   321     
   321 		
   322     if ( !$can_do_admin_stuff && $row['group_type'] == GROUP_OPEN && !$is_member )
   322 		if ( !$can_do_admin_stuff && $row['group_type'] == GROUP_OPEN && !$is_member )
   323     {
   323 		{
   324       $state_btns .= ' <input type="submit" value="' . $lang->get('groupcp_btn_join') . '" />';
   324 			$state_btns .= ' <input type="submit" value="' . $lang->get('groupcp_btn_join') . '" />';
   325     }
   325 		}
   326     
   326 		
   327     $g_name_local = 'groupcp_grp_' . strtolower($row['group_name']);
   327 		$g_name_local = 'groupcp_grp_' . strtolower($row['group_name']);
   328     $str = $lang->get($g_name_local);
   328 		$str = $lang->get($g_name_local);
   329     if ( $str != $g_name_local )
   329 		if ( $str != $g_name_local )
   330       $row['group_name'] = $str;
   330 			$row['group_name'] = $str;
   331     
   331 		
   332     echo '<form action="' . makeUrl($paths->page, 'act=update') . '" method="post" enctype="multipart/form-data">
   332 		echo '<form action="' . makeUrl($paths->page, 'act=update') . '" method="post" enctype="multipart/form-data">
   333           <div class="tblholder">
   333 					<div class="tblholder">
   334             <table border="0" cellspacing="1" cellpadding="4">
   334 						<table border="0" cellspacing="1" cellpadding="4">
   335               <tr>
   335 							<tr>
   336                 <th colspan="2">' . $lang->get('groupcp_th_group_info') . '</th>
   336 								<th colspan="2">' . $lang->get('groupcp_th_group_info') . '</th>
   337               </tr>
   337 							</tr>
   338               <tr>
   338 							<tr>
   339                 <td class="row2">' . $lang->get('groupcp_lbl_group_name') . '</td>
   339 								<td class="row2">' . $lang->get('groupcp_lbl_group_name') . '</td>
   340                 <td class="row1">' . $row['group_name'] . ( $row['system_group'] == 1 ? ' ' . $lang->get('groupcp_msg_system_group') : '' ) . '</td>
   340 								<td class="row1">' . $row['group_name'] . ( $row['system_group'] == 1 ? ' ' . $lang->get('groupcp_msg_system_group') : '' ) . '</td>
   341               </tr>
   341 							</tr>
   342               <tr>
   342 							<tr>
   343                 <td class="row2">' . $lang->get('groupcp_lbl_status') . '</td>
   343 								<td class="row2">' . $lang->get('groupcp_lbl_status') . '</td>
   344                 <td class="row1">' . $status . '</td>
   344 								<td class="row1">' . $status . '</td>
   345               </tr>
   345 							</tr>
   346               <tr>
   346 							<tr>
   347                 <td class="row2">' . $lang->get('groupcp_lbl_state') . '</td>
   347 								<td class="row2">' . $lang->get('groupcp_lbl_state') . '</td>
   348                 <td class="row1">' . $state_btns . '</td>
   348 								<td class="row1">' . $state_btns . '</td>
   349               </tr>   
   349 							</tr>   
   350               ' . ( ( $is_mod || $session->user_level >= USER_LEVEL_ADMIN ) ? '
   350 							' . ( ( $is_mod || $session->user_level >= USER_LEVEL_ADMIN ) ? '
   351               <tr>
   351 							<tr>
   352                 <th class="subhead" colspan="2">
   352 								<th class="subhead" colspan="2">
   353                   <input type="submit" value="' . $lang->get('etc_save_changes') . '" />
   353 									<input type="submit" value="' . $lang->get('etc_save_changes') . '" />
   354                 </th>
   354 								</th>
   355               </tr>
   355 							</tr>
   356               ' : '' ) . '
   356 							' : '' ) . '
   357             </table>
   357 						</table>
   358           </div>
   358 					</div>
   359           <input name="group_id" value="' . $gid . '" type="hidden" />
   359 					<input name="group_id" value="' . $gid . '" type="hidden" />
   360           </form>';
   360 					</form>';
   361     if ( sizeof ( $pending ) > 0 && $can_do_admin_stuff )
   361 		if ( sizeof ( $pending ) > 0 && $can_do_admin_stuff )
   362     {
   362 		{
   363       echo '<form action="' . makeUrl($paths->page, 'act=pending') . '" method="post" enctype="multipart/form-data">
   363 			echo '<form action="' . makeUrl($paths->page, 'act=pending') . '" method="post" enctype="multipart/form-data">
   364             <input name="group_id" value="' . $gid . '" type="hidden" />
   364 						<input name="group_id" value="' . $gid . '" type="hidden" />
   365             <h2>' . $lang->get('groupcp_th_pending_memberships') . '</h2>
   365 						<h2>' . $lang->get('groupcp_th_pending_memberships') . '</h2>
   366             <div class="tblholder">
   366 						<div class="tblholder">
   367             <table border="0" cellspacing="1" cellpadding="4">
   367 						<table border="0" cellspacing="1" cellpadding="4">
   368               <tr>
   368 							<tr>
   369                 <th>' . $lang->get('groupcp_th_username') . '</th>
   369 								<th>' . $lang->get('groupcp_th_username') . '</th>
   370                 <th>' . $lang->get('groupcp_th_email') . '</th>
   370 								<th>' . $lang->get('groupcp_th_email') . '</th>
   371                 <th>' . $lang->get('groupcp_th_reg_time') . '</th>
   371 								<th>' . $lang->get('groupcp_th_reg_time') . '</th>
   372                 <th>' . $lang->get('groupcp_th_comments') . '</th>
   372 								<th>' . $lang->get('groupcp_th_comments') . '</th>
   373                 <th>' . $lang->get('groupcp_th_select') . '</th>
   373 								<th>' . $lang->get('groupcp_th_select') . '</th>
   374               </tr>';
   374 							</tr>';
   375       $cls = 'row2';
   375 			$cls = 'row2';
   376       foreach ( $pending as $member )
   376 			foreach ( $pending as $member )
   377       {
   377 			{
   378         
   378 				
   379         $date = enano_date(ED_DATE, $member['reg_time']);
   379 				$date = enano_date(ED_DATE, $member['reg_time']);
   380         $cls = ( $cls == 'row2' ) ? 'row1' : 'row2';
   380 				$cls = ( $cls == 'row2' ) ? 'row1' : 'row2';
   381         $addy = $email->encryptEmail($member['email']);
   381 				$addy = $email->encryptEmail($member['email']);
   382         
   382 				
   383         echo "<tr>
   383 				echo "<tr>
   384                 <td class='{$cls}'>{$member['username']}</td>
   384 								<td class='{$cls}'>{$member['username']}</td>
   385                 <td class='{$cls}'>{$addy}</td>
   385 								<td class='{$cls}'>{$addy}</td>
   386                 <td class='{$cls}'>{$date}</td>
   386 								<td class='{$cls}'>{$date}</td>
   387                 <td class='{$cls}'>{$member['num_comments']}</td>
   387 								<td class='{$cls}'>{$member['num_comments']}</td>
   388                 <td class='{$cls}' style='text-align: center;'><input type='checkbox' name='with_user[{$member['member_id']}]' /></td>
   388 								<td class='{$cls}' style='text-align: center;'><input type='checkbox' name='with_user[{$member['member_id']}]' /></td>
   389               </tr>";
   389 							</tr>";
   390       }
   390 			}
   391       echo '</table>
   391 			echo '</table>
   392             </div>
   392 						</div>
   393             <div style="margin: 10px 0 0 auto;">
   393 						<div style="margin: 10px 0 0 auto;">
   394               With selected: 
   394 							With selected: 
   395               <input type="submit" name="do_appr_pending" value="' . $lang->get('groupcp_btn_approve_pending') . '" />
   395 							<input type="submit" name="do_appr_pending" value="' . $lang->get('groupcp_btn_approve_pending') . '" />
   396               <input type="submit" name="do_reject_pending" value="' . $lang->get('groupcp_btn_reject_pending') . '" />
   396 							<input type="submit" name="do_reject_pending" value="' . $lang->get('groupcp_btn_reject_pending') . '" />
   397             </div>
   397 						</div>
   398             </form>';
   398 						</form>';
   399     }
   399 		}
   400     echo '<form action="' . makeUrl($paths->page, 'act=del_users') . '" method="post" enctype="multipart/form-data">
   400 		echo '<form action="' . makeUrl($paths->page, 'act=del_users') . '" method="post" enctype="multipart/form-data">
   401           <h2>' . $lang->get('groupcp_th_group_members') . '</h2>
   401 					<h2>' . $lang->get('groupcp_th_group_members') . '</h2>
   402           <div class="tblholder">
   402 					<div class="tblholder">
   403             <table border="0" cellspacing="1" cellpadding="4">
   403 						<table border="0" cellspacing="1" cellpadding="4">
   404               <tr>
   404 							<tr>
   405                 <th>' . $lang->get('groupcp_th_username') . '</th>
   405 								<th>' . $lang->get('groupcp_th_username') . '</th>
   406                 <th>' . $lang->get('groupcp_th_email') . '</th>
   406 								<th>' . $lang->get('groupcp_th_email') . '</th>
   407                 <th>' . $lang->get('groupcp_th_reg_time') . '</th>
   407 								<th>' . $lang->get('groupcp_th_reg_time') . '</th>
   408                 <th>' . $lang->get('groupcp_th_comments') . '</th>
   408 								<th>' . $lang->get('groupcp_th_comments') . '</th>
   409                 ' . ( ( $can_do_admin_stuff ) ? '
   409 								' . ( ( $can_do_admin_stuff ) ? '
   410                 <th>' . $lang->get('groupcp_th_remove') . '</th>
   410 								<th>' . $lang->get('groupcp_th_remove') . '</th>
   411                 ' : '' ) . '
   411 								' : '' ) . '
   412               </tr>
   412 							</tr>
   413               <tr>
   413 							<tr>
   414                 <th colspan="5" class="subhead">' . $lang->get('groupcp_th_group_mods') . '</th>
   414 								<th colspan="5" class="subhead">' . $lang->get('groupcp_th_group_mods') . '</th>
   415               </tr>';
   415 							</tr>';
   416     $mod_printed = false;
   416 		$mod_printed = false;
   417     $mem_printed = false;
   417 		$mem_printed = false;
   418     $cls = 'row2';
   418 		$cls = 'row2';
   419     
   419 		
   420     foreach ( $members as $member )
   420 		foreach ( $members as $member )
   421     {
   421 		{
   422       if ( $member['is_mod'] != 1 )
   422 			if ( $member['is_mod'] != 1 )
   423         break;
   423 				break;
   424       
   424 			
   425       $date = enano_date(ED_DATE, $member['reg_time']);
   425 			$date = enano_date(ED_DATE, $member['reg_time']);
   426       $cls = ( $cls == 'row2' ) ? 'row1' : 'row2';
   426 			$cls = ( $cls == 'row2' ) ? 'row1' : 'row2';
   427       $addy = $email->encryptEmail($member['email']);
   427 			$addy = $email->encryptEmail($member['email']);
   428       
   428 			
   429       $mod_printed = true;
   429 			$mod_printed = true;
   430       
   430 			
   431       echo "<tr>
   431 			echo "<tr>
   432               <td class='{$cls}'>{$member['username']}</td>
   432 							<td class='{$cls}'>{$member['username']}</td>
   433               <td class='{$cls}'>{$addy}</td>
   433 							<td class='{$cls}'>{$addy}</td>
   434               <td class='{$cls}'>{$date}</td>
   434 							<td class='{$cls}'>{$date}</td>
   435               <td class='{$cls}'>{$member['num_comments']}</td>
   435 							<td class='{$cls}'>{$member['num_comments']}</td>
   436               " . ( ( $can_do_admin_stuff ) ? "
   436 							" . ( ( $can_do_admin_stuff ) ? "
   437               <td class='{$cls}' style='text-align: center;'><input type='checkbox' name='del_user[{$member['member_id']}]' /></td>
   437 							<td class='{$cls}' style='text-align: center;'><input type='checkbox' name='del_user[{$member['member_id']}]' /></td>
   438               " : '' ) . "
   438 							" : '' ) . "
   439             </tr>";
   439 						</tr>";
   440     }
   440 		}
   441     if (!$mod_printed)
   441 		if (!$mod_printed)
   442       echo '<tr><td class="' . $cls . '" colspan="5">' . $lang->get('groupcp_msg_no_mods') . '</td></th>';
   442 			echo '<tr><td class="' . $cls . '" colspan="5">' . $lang->get('groupcp_msg_no_mods') . '</td></th>';
   443     echo '<tr><th class="subhead" colspan="5">' . $lang->get('groupcp_th_group_members') . '</th></tr>';
   443 		echo '<tr><th class="subhead" colspan="5">' . $lang->get('groupcp_th_group_members') . '</th></tr>';
   444     foreach ( $members as $member )
   444 		foreach ( $members as $member )
   445     {
   445 		{
   446       if ( $member['is_mod'] == 1 )
   446 			if ( $member['is_mod'] == 1 )
   447         continue;
   447 				continue;
   448       
   448 			
   449       $date = enano_date(ED_DATE, $member['reg_time']);
   449 			$date = enano_date(ED_DATE, $member['reg_time']);
   450       $cls = ( $cls == 'row2' ) ? 'row1' : 'row2';
   450 			$cls = ( $cls == 'row2' ) ? 'row1' : 'row2';
   451       $addy = $email->encryptEmail($member['email']);
   451 			$addy = $email->encryptEmail($member['email']);
   452       
   452 			
   453       $mem_printed = true;
   453 			$mem_printed = true;
   454       
   454 			
   455       echo "<tr>
   455 			echo "<tr>
   456               <td class='{$cls}'>{$member['username']}</td>
   456 							<td class='{$cls}'>{$member['username']}</td>
   457               <td class='{$cls}'>{$addy}</td>
   457 							<td class='{$cls}'>{$addy}</td>
   458               <td class='{$cls}'>{$date}</td>
   458 							<td class='{$cls}'>{$date}</td>
   459               <td class='{$cls}'>{$member['num_comments']}</td>
   459 							<td class='{$cls}'>{$member['num_comments']}</td>
   460               " . ( ( $can_do_admin_stuff ) ? "
   460 							" . ( ( $can_do_admin_stuff ) ? "
   461               <td class='{$cls}' style='text-align: center;'><input type='checkbox' name='del_user[{$member['member_id']}]' /></td>
   461 							<td class='{$cls}' style='text-align: center;'><input type='checkbox' name='del_user[{$member['member_id']}]' /></td>
   462               " : '' ) . "
   462 							" : '' ) . "
   463             </tr>";
   463 						</tr>";
   464     }
   464 		}
   465     if (!$mem_printed)
   465 		if (!$mem_printed)
   466       echo '<tr><td class="' . $cls . '" colspan="5">' . $lang->get('groupcp_msg_no_members') . '</td></th>';
   466 			echo '<tr><td class="' . $cls . '" colspan="5">' . $lang->get('groupcp_msg_no_members') . '</td></th>';
   467     echo '  </table>
   467 		echo '  </table>
   468           </div>';
   468 					</div>';
   469     if ( $can_do_admin_stuff )
   469 		if ( $can_do_admin_stuff )
   470     {
   470 		{
   471       echo "<div style='margin: 10px 0 0 auto;'><input type='submit' name='do_del_user' value=\"" . $lang->get('groupcp_btn_remove_selected') . "\" /></div>";
   471 			echo "<div style='margin: 10px 0 0 auto;'><input type='submit' name='do_del_user' value=\"" . $lang->get('groupcp_btn_remove_selected') . "\" /></div>";
   472     }
   472 		}
   473     echo '<input name="group_id" value="' . $gid . '" type="hidden" />
   473 		echo '<input name="group_id" value="' . $gid . '" type="hidden" />
   474           </form>';
   474 					</form>';
   475     if ( $can_do_admin_stuff )
   475 		if ( $can_do_admin_stuff )
   476     {
   476 		{
   477       echo '<form action="' . makeUrl($paths->page, 'act=adduser') . '" method="post" enctype="multipart/form-data" onsubmit="if(!submitAuthorized) return false;">
   477 			echo '<form action="' . makeUrl($paths->page, 'act=adduser') . '" method="post" enctype="multipart/form-data" onsubmit="if(!submitAuthorized) return false;">
   478               <div class="tblholder">
   478 							<div class="tblholder">
   479                 <table border="0" cellspacing="1" cellpadding="4">
   479 								<table border="0" cellspacing="1" cellpadding="4">
   480                   <tr>
   480 									<tr>
   481                     <th colspan="2">' . $lang->get('groupcp_th_add_member') . '</th>
   481 										<th colspan="2">' . $lang->get('groupcp_th_add_member') . '</th>
   482                   </tr>
   482 									</tr>
   483                   <tr>
   483 									<tr>
   484                     <td class="row2">' . $lang->get('groupcp_lbl_username') . '</td><td class="row1">' . $template->username_field('add_username') . '</td>
   484 										<td class="row2">' . $lang->get('groupcp_lbl_username') . '</td><td class="row1">' . $template->username_field('add_username') . '</td>
   485                   </tr>
   485 									</tr>
   486                   <tr>
   486 									<tr>
   487                     <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>
   487 										<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>
   488                   </tr>
   488 									</tr>
   489                   <tr>
   489 									<tr>
   490                     <th class="subhead" colspan="2">
   490 										<th class="subhead" colspan="2">
   491                       <input type="submit" value="' . $lang->get('groupcp_btn_add_member') . '" />
   491 											<input type="submit" value="' . $lang->get('groupcp_btn_add_member') . '" />
   492                     </th>
   492 										</th>
   493                   </tr>
   493 									</tr>
   494                 </table>
   494 								</table>
   495               </div>
   495 							</div>
   496               <input name="group_id" value="' . $gid . '" type="hidden" />
   496 							<input name="group_id" value="' . $gid . '" type="hidden" />
   497             </form>';
   497 						</form>';
   498     }
   498 		}
   499   }
   499 	}
   500   else
   500 	else
   501   {
   501 	{
   502     echo '<form action="'.makeUrlNS('Special', 'Usergroups').'" method="post" onsubmit="if(!submitAuthorized) return false;" enctype="multipart/form-data">';
   502 		echo '<form action="'.makeUrlNS('Special', 'Usergroups').'" method="post" onsubmit="if(!submitAuthorized) return false;" enctype="multipart/form-data">';
   503     echo '<div class="tblholder">
   503 		echo '<div class="tblholder">
   504           <table border="0" style="width: 100%;" cellspacing="1" cellpadding="4">
   504 					<table border="0" style="width: 100%;" cellspacing="1" cellpadding="4">
   505             <tr>
   505 						<tr>
   506               <th colspan="2">' . $lang->get('groupcp_th_select_group') . '</th>
   506 							<th colspan="2">' . $lang->get('groupcp_th_select_group') . '</th>
   507             </tr>
   507 						</tr>
   508             <tr>
   508 						<tr>
   509               <td class="row2" style="text-align: right; width: 50%;">
   509 							<td class="row2" style="text-align: right; width: 50%;">
   510                 ' . $lang->get('groupcp_lbl_current_memberships') . '
   510 								' . $lang->get('groupcp_lbl_current_memberships') . '
   511               </td>
   511 							</td>
   512               <td class="row1" style="width: 50%;">';
   512 							<td class="row1" style="width: 50%;">';
   513     $taboo = Array('Everyone');
   513 		$taboo = Array('Everyone');
   514     if ( sizeof ( $session->groups ) > count($taboo) )
   514 		if ( sizeof ( $session->groups ) > count($taboo) )
   515     {
   515 		{
   516       echo '<select name="group_id">';
   516 			echo '<select name="group_id">';
   517       foreach ( $session->groups as $id => $group )
   517 			foreach ( $session->groups as $id => $group )
   518       {
   518 			{
   519         $taboo[] = $db->escape($group);
   519 				$taboo[] = $db->escape($group);
   520         $group = htmlspecialchars($group);
   520 				$group = htmlspecialchars($group);
   521         if ( $group != 'Everyone' )
   521 				if ( $group != 'Everyone' )
   522         {
   522 				{
   523           $g_name_local = 'groupcp_grp_' . strtolower($group);
   523 					$g_name_local = 'groupcp_grp_' . strtolower($group);
   524           $str = $lang->get($g_name_local);
   524 					$str = $lang->get($g_name_local);
   525           if ( $str != $g_name_local )
   525 					if ( $str != $g_name_local )
   526             $group = $str;
   526 						$group = $str;
   527           echo '<option value="' . $id . '">' . $group . '</option>';
   527 					echo '<option value="' . $id . '">' . $group . '</option>';
   528         }
   528 				}
   529       }
   529 			}
   530       echo '</select>
   530 			echo '</select>
   531             <input type="submit" name="do_view" value="' . $lang->get('groupcp_btn_view') . '" />';
   531 						<input type="submit" name="do_view" value="' . $lang->get('groupcp_btn_view') . '" />';
   532     }
   532 		}
   533     else
   533 		else
   534     {
   534 		{
   535       echo 'None';
   535 			echo 'None';
   536     }
   536 		}
   537     
   537 		
   538     echo '</td>
   538 		echo '</td>
   539         </tr>';
   539 				</tr>';
   540     $taboo = 'WHERE group_name != \'' . implode('\' AND group_name != \'', $taboo) . '\'';
   540 		$taboo = 'WHERE group_name != \'' . implode('\' AND group_name != \'', $taboo) . '\'';
   541     $q = $db->sql_query('SELECT group_id,group_name FROM '.table_prefix.'groups '.$taboo.' AND group_type != ' . GROUP_HIDDEN . ' ORDER BY group_name ASC;');
   541 		$q = $db->sql_query('SELECT group_id,group_name FROM '.table_prefix.'groups '.$taboo.' AND group_type != ' . GROUP_HIDDEN . ' ORDER BY group_name ASC;');
   542     if(!$q)
   542 		if(!$q)
   543     {
   543 		{
   544       echo $db->get_error();
   544 			echo $db->get_error();
   545       $template->footer();
   545 			$template->footer();
   546       return;
   546 			return;
   547     }
   547 		}
   548     if($db->numrows() > 0)
   548 		if($db->numrows() > 0)
   549     {
   549 		{
   550       echo '<tr>
   550 			echo '<tr>
   551               <td class="row2" style="text-align: right;">
   551 							<td class="row2" style="text-align: right;">
   552                 ' . $lang->get('groupcp_lbl_non_memberships') . '
   552 								' . $lang->get('groupcp_lbl_non_memberships') . '
   553               </td>
   553 							</td>
   554               <td class="row1">
   554 							<td class="row1">
   555               <select name="group_id_n">';
   555 							<select name="group_id_n">';
   556       while ( $row = $db->fetchrow() )
   556 			while ( $row = $db->fetchrow() )
   557       {
   557 			{
   558         if ( $row['group_name'] != 'Everyone' )
   558 				if ( $row['group_name'] != 'Everyone' )
   559         {
   559 				{
   560           echo '<option value="' . $row['group_id'] . '">' . htmlspecialchars($row['group_name']) . '</option>';
   560 					echo '<option value="' . $row['group_id'] . '">' . htmlspecialchars($row['group_name']) . '</option>';
   561         }
   561 				}
   562       }
   562 			}
   563       echo '</select>
   563 			echo '</select>
   564             <input type="submit" name="do_view_n" value="' . $lang->get('groupcp_btn_view') . '" />
   564 						<input type="submit" name="do_view_n" value="' . $lang->get('groupcp_btn_view') . '" />
   565           </td>
   565 					</td>
   566         </tr>
   566 				</tr>
   567       ';
   567 			';
   568     }
   568 		}
   569     $db->free_result();
   569 		$db->free_result();
   570     echo '</table>
   570 		echo '</table>
   571         </div>
   571 				</div>
   572         </form>';
   572 				</form>';
   573   }
   573 	}
   574   $template->footer();
   574 	$template->footer();
   575 }
   575 }
   576 
   576 
   577 ?>
   577 ?>