plugins/SpecialGroups.php
changeset 1270 bd3ee7f12bc1
parent 1227 bdac73ed481e
equal deleted inserted replaced
1269:35986c6b2150 1270:bd3ee7f12bc1
   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 			$is_member = true;
   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 		else if ( isset($_GET['act']) && $_GET['act'] == 'update' && $is_member && ($row['group_type'] == GROUP_OPEN || $row['group_type'] == GROUP_REQUEST) && !$can_do_admin_stuff )
       
   301 		{
       
   302 			$q = $db->sql_query('DELETE FROM ' . table_prefix . "group_members WHERE group_id = $gid AND user_id = $session->user_id;");
       
   303 			if ( !$q )
       
   304 				$db->_die();
       
   305 			
       
   306 			foreach ( $members as $i => $m )
       
   307 			{
       
   308 				if ( $m['user_id'] == $session->user_id )
       
   309 				{
       
   310 					unset($members[$i]);
       
   311 					break;
       
   312 				}
       
   313 			}
       
   314 			
       
   315 			echo '<div class="info-box">' . $lang->get('groupcp_msg_self_removed') . '</div>';
       
   316 			$is_member = false;
       
   317 		}
       
   318 		else if ( isset($_GET['act']) && $_GET['act'] == 'update' && !$is_member && $row['group_type'] == GROUP_REQUEST && !$is_pending && !$can_do_admin_stuff )
   301 		{
   319 		{
   302 			$q = $db->sql_query('INSERT INTO '.table_prefix.'group_members(group_id,user_id,pending) VALUES(' . $gid . ', ' . $session->user_id . ', 1);');
   320 			$q = $db->sql_query('INSERT INTO '.table_prefix.'group_members(group_id,user_id,pending) VALUES(' . $gid . ', ' . $session->user_id . ', 1);');
   303 			if (!$q)
   321 			if (!$q)
   304 				$db->_die('SpecialGroups.php, line ' . __LINE__);
   322 				$db->_die('SpecialGroups.php, line ' . __LINE__);
   305 			echo '<div class="info-box">' . $lang->get('groupcp_msg_membership_requested') . '</div>';
   323 			echo '<div class="info-box">' . $lang->get('groupcp_msg_membership_requested') . '</div>';
       
   324 			$is_pending = true;
   306 		}
   325 		}
   307 		
   326 		
   308 		$state_btns = ( $can_do_admin_stuff ) ?
   327 		$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>
   328 									'<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>
   329  									<label><input type="radio" name="group_state" value="' . GROUP_CLOSED . '" ' . (( $row['group_type'] == GROUP_CLOSED ) ? 'checked="checked"' : '' ) . ' /> ' . $lang->get('groupcp_type_closed') . '</label>
   320 		}
   339 		}
   321 		
   340 		
   322 		if ( !$can_do_admin_stuff && $row['group_type'] == GROUP_OPEN && !$is_member )
   341 		if ( !$can_do_admin_stuff && $row['group_type'] == GROUP_OPEN && !$is_member )
   323 		{
   342 		{
   324 			$state_btns .= ' <input type="submit" value="' . $lang->get('groupcp_btn_join') . '" />';
   343 			$state_btns .= ' <input type="submit" value="' . $lang->get('groupcp_btn_join') . '" />';
       
   344 		}
       
   345 		else if ( !$can_do_admin_stuff && ($row['group_type'] == GROUP_OPEN || $row['group_type'] == GROUP_REQUEST) && $is_member )
       
   346 		{
       
   347 			$state_btns .= ' <input type="submit" value="' . $lang->get('groupcp_btn_leave') . '" />';
   325 		}
   348 		}
   326 		
   349 		
   327 		$g_name_local = 'groupcp_grp_' . strtolower($row['group_name']);
   350 		$g_name_local = 'groupcp_grp_' . strtolower($row['group_name']);
   328 		$str = $lang->get($g_name_local);
   351 		$str = $lang->get($g_name_local);
   329 		if ( $str != $g_name_local )
   352 		if ( $str != $g_name_local )