Some fixes to autofill with Unicode usernames; fixed a few end user experience pieces of the group CP. Users are now allowed to freely leave GROUP_OPEN and GROUP_REQUEST groups, and must be removed by a group mod for GROUP_CLOSED and GROUP_HIDDEN.
--- a/language/english/user.json Thu Jul 29 11:53:15 2010 -0400
+++ b/language/english/user.json Thu Jul 29 12:25:14 2010 -0400
@@ -419,10 +419,12 @@
msg_user_already_in: 'The user "%username%" is already in this group.',
msg_user_added: 'The user "%username%" has been added to this usergroup.',
msg_self_added: 'You have been added to this group.',
+ msg_self_removed: 'You have removed yourself from this group.',
btn_view: 'View information',
btn_request_join: 'Request membership',
btn_join: 'Join this group',
+ btn_leave: 'Leave this group',
btn_approve_pending: 'Approve membership',
btn_reject_pending: 'Reject membership',
btn_remove_selected: 'Remove selected users',
--- a/plugins/SpecialGroups.php Thu Jul 29 11:53:15 2010 -0400
+++ b/plugins/SpecialGroups.php Thu Jul 29 12:25:14 2010 -0400
@@ -294,15 +294,34 @@
$r = $db->fetchrow();
$members[] = $r;
$db->free_result();
+ $is_member = true;
}
-
- if ( isset($_GET['act']) && $_GET['act'] == 'update' && !$is_member && $row['group_type'] == GROUP_REQUEST && !$is_pending && !$can_do_admin_stuff )
+ else if ( isset($_GET['act']) && $_GET['act'] == 'update' && $is_member && ($row['group_type'] == GROUP_OPEN || $row['group_type'] == GROUP_REQUEST) && !$can_do_admin_stuff )
+ {
+ $q = $db->sql_query('DELETE FROM ' . table_prefix . "group_members WHERE group_id = $gid AND user_id = $session->user_id;");
+ if ( !$q )
+ $db->_die();
+
+ foreach ( $members as $i => $m )
+ {
+ if ( $m['user_id'] == $session->user_id )
+ {
+ unset($members[$i]);
+ break;
+ }
+ }
+
+ echo '<div class="info-box">' . $lang->get('groupcp_msg_self_removed') . '</div>';
+ $is_member = false;
+ }
+ else if ( isset($_GET['act']) && $_GET['act'] == 'update' && !$is_member && $row['group_type'] == GROUP_REQUEST && !$is_pending && !$can_do_admin_stuff )
{
$q = $db->sql_query('INSERT INTO '.table_prefix.'group_members(group_id,user_id,pending) VALUES(' . $gid . ', ' . $session->user_id . ', 1);');
if (!$q)
$db->_die('SpecialGroups.php, line ' . __LINE__);
echo '<div class="info-box">' . $lang->get('groupcp_msg_membership_requested') . '</div>';
+ $is_pending = true;
}
$state_btns = ( $can_do_admin_stuff ) ?
@@ -323,6 +342,10 @@
{
$state_btns .= ' <input type="submit" value="' . $lang->get('groupcp_btn_join') . '" />';
}
+ else if ( !$can_do_admin_stuff && ($row['group_type'] == GROUP_OPEN || $row['group_type'] == GROUP_REQUEST) && $is_member )
+ {
+ $state_btns .= ' <input type="submit" value="' . $lang->get('groupcp_btn_leave') . '" />';
+ }
$g_name_local = 'groupcp_grp_' . strtolower($row['group_name']);
$str = $lang->get($g_name_local);
--- a/plugins/SpecialPageFuncs.php Thu Jul 29 11:53:15 2010 -0400
+++ b/plugins/SpecialPageFuncs.php Thu Jul 29 12:25:14 2010 -0400
@@ -643,8 +643,9 @@
if ( isset($_GET['userinput']) && strlen($_GET['userinput']) >= 3 )
{
$search = '%' . escape_string_like($_GET['userinput']) . '%';
+ $lsearch = strtolower($search);
$min_id = ( isset($_GET['allow_anon']) && $_GET['allow_anon'] == '1' ) ? '1' : '2';
- $q = $db->sql_query('SELECT username FROM ' . table_prefix . "users WHERE " . ENANO_SQLFUNC_LOWERCASE . "(username) LIKE '$search' AND user_id >= $min_id");
+ $q = $db->sql_query('SELECT username FROM ' . table_prefix . "users WHERE (" . ENANO_SQLFUNC_LOWERCASE . "(username) LIKE '$lsearch' OR username LIKE '$search') AND user_id >= $min_id");
if ( !$q )
$db->die_json();