2 /***************************************************************************
5 * begin : Saturday, Feb 13, 2001
6 * copyright : (C) 2001 The phpBB Group
7 * email : support@phpbb.com
9 * $Id: groupcp.php,v 1.58.2.22 2004/11/18 17:49:34 acydburn Exp $
12 ***************************************************************************/
14 /***************************************************************************
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
21 ***************************************************************************/
23 define('IN_PHPBB', true);
24 $phpbb_root_path = './';
25 include($phpbb_root_path . 'extension.inc');
26 include($phpbb_root_path . 'common.'.$phpEx);
28 // -------------------------
30 function generate_user_info(&$row, $date_format, $group_mod, &$from, &$posts, &$joined, &$poster_avatar, &$profile_img, &$profile, &$search_img, &$search, &$pm_img, &$pm, &$email_img, &$email, &$www_img, &$www, &$icq_status_img, &$icq_img, &$icq, &$aim_img, &$aim, &$msn_img, &$msn, &$yim_img, &$yim)
32 global $lang, $images, $board_config, $phpEx;
34 $from = ( !empty($row['user_from']) ) ? $row['user_from'] : ' ';
35 $joined = create_date($date_format, $row['user_regdate'], $board_config['board_timezone']);
36 $posts = ( $row['user_posts'] ) ? $row['user_posts'] : 0;
39 if ( $row['user_avatar_type'] && $row['user_id'] != ANONYMOUS && $row['user_allowavatar'] )
41 switch( $row['user_avatar_type'] )
43 case USER_AVATAR_UPLOAD:
44 $poster_avatar = ( $board_config['allow_avatar_upload'] ) ? '<img src="' . $board_config['avatar_path'] . '/' . $row['user_avatar'] . '" alt="" border="0" />' : '';
46 case USER_AVATAR_REMOTE:
47 $poster_avatar = ( $board_config['allow_avatar_remote'] ) ? '<img src="' . $row['user_avatar'] . '" alt="" border="0" />' : '';
49 case USER_AVATAR_GALLERY:
50 $poster_avatar = ( $board_config['allow_avatar_local'] ) ? '<img src="' . $board_config['avatar_gallery_path'] . '/' . $row['user_avatar'] . '" alt="" border="0" />' : '';
55 if ( !empty($row['user_viewemail']) || $group_mod )
57 $email_uri = ( $board_config['board_email_form'] ) ? append_sid("profile.$phpEx?mode=email&" . POST_USERS_URL .'=' . $row['user_id']) : 'mailto:' . $row['user_email'];
59 $email_img = '<a href="' . $email_uri . '"><img src="' . $images['icon_email'] . '" alt="' . $lang['Send_email'] . '" title="' . $lang['Send_email'] . '" border="0" /></a>';
60 $email = '<a href="' . $email_uri . '">' . $lang['Send_email'] . '</a>';
64 $email_img = ' ';
68 $temp_url = append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $row['user_id']);
69 $profile_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_profile'] . '" alt="' . $lang['Read_profile'] . '" title="' . $lang['Read_profile'] . '" border="0" /></a>';
70 $profile = '<a href="' . $temp_url . '">' . $lang['Read_profile'] . '</a>';
72 $temp_url = append_sid("privmsg.$phpEx?mode=post&" . POST_USERS_URL . "=" . $row['user_id']);
73 $pm_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_pm'] . '" alt="' . $lang['Send_private_message'] . '" title="' . $lang['Send_private_message'] . '" border="0" /></a>';
74 $pm = '<a href="' . $temp_url . '">' . $lang['Send_private_message'] . '</a>';
76 $www_img = ( $row['user_website'] ) ? '<a href="' . $row['user_website'] . '" target="_userwww"><img src="' . $images['icon_www'] . '" alt="' . $lang['Visit_website'] . '" title="' . $lang['Visit_website'] . '" border="0" /></a>' : '';
77 $www = ( $row['user_website'] ) ? '<a href="' . $row['user_website'] . '" target="_userwww">' . $lang['Visit_website'] . '</a>' : '';
79 if ( !empty($row['user_icq']) )
81 $icq_status_img = '<a href="http://wwp.icq.com/' . $row['user_icq'] . '#pager"><img src="http://web.icq.com/whitepages/online?icq=' . $row['user_icq'] . '&img=5" width="18" height="18" border="0" /></a>';
82 $icq_img = '<a href="http://wwp.icq.com/scripts/search.dll?to=' . $row['user_icq'] . '"><img src="' . $images['icon_icq'] . '" alt="' . $lang['ICQ'] . '" title="' . $lang['ICQ'] . '" border="0" /></a>';
83 $icq = '<a href="http://wwp.icq.com/scripts/search.dll?to=' . $row['user_icq'] . '">' . $lang['ICQ'] . '</a>';
92 $aim_img = ( $row['user_aim'] ) ? '<a href="aim:goim?screenname=' . $row['user_aim'] . '&message=Hello+Are+you+there?"><img src="' . $images['icon_aim'] . '" alt="' . $lang['AIM'] . '" title="' . $lang['AIM'] . '" border="0" /></a>' : '';
93 $aim = ( $row['user_aim'] ) ? '<a href="aim:goim?screenname=' . $row['user_aim'] . '&message=Hello+Are+you+there?">' . $lang['AIM'] . '</a>' : '';
95 $temp_url = append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $row['user_id']);
96 $msn_img = ( $row['user_msnm'] ) ? '<a href="' . $temp_url . '"><img src="' . $images['icon_msnm'] . '" alt="' . $lang['MSNM'] . '" title="' . $lang['MSNM'] . '" border="0" /></a>' : '';
97 $msn = ( $row['user_msnm'] ) ? '<a href="' . $temp_url . '">' . $lang['MSNM'] . '</a>' : '';
99 $yim_img = ( $row['user_yim'] ) ? '<a href="http://edit.yahoo.com/config/send_webmesg?.target=' . $row['user_yim'] . '&.src=pg"><img src="' . $images['icon_yim'] . '" alt="' . $lang['YIM'] . '" title="' . $lang['YIM'] . '" border="0" /></a>' : '';
100 $yim = ( $row['user_yim'] ) ? '<a href="http://edit.yahoo.com/config/send_webmesg?.target=' . $row['user_yim'] . '&.src=pg">' . $lang['YIM'] . '</a>' : '';
102 $temp_url = append_sid("search.$phpEx?search_author=" . urlencode($username) . "&showresults=posts");
103 $search_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_search'] . '" alt="' . $lang['Search_user_posts'] . '" title="' . $lang['Search_user_posts'] . '" border="0" /></a>';
104 $search = '<a href="' . $temp_url . '">' . $lang['Search_user_posts'] . '</a>';
109 // --------------------------
112 // Start session management
114 $userdata = session_pagestart($user_ip, PAGE_GROUPCP);
115 init_userprefs($userdata);
117 // End session management
120 $script_name = preg_replace('/^\/?(.*?)\/?$/', "\\1", trim($board_config['script_path']));
121 $script_name = ( $script_name != '' ) ? $script_name . '/groupcp.'.$phpEx : 'groupcp.'.$phpEx;
122 $server_name = trim($board_config['server_name']);
123 $server_protocol = ( $board_config['cookie_secure'] ) ? 'https://' : 'http://';
124 $server_port = ( $board_config['server_port'] <> 80 ) ? ':' . trim($board_config['server_port']) . '/' : '/';
126 $server_url = $server_protocol . $server_name . $server_port . $script_name;
128 if ( isset($HTTP_GET_VARS[POST_GROUPS_URL]) || isset($HTTP_POST_VARS[POST_GROUPS_URL]) )
130 $group_id = ( isset($HTTP_POST_VARS[POST_GROUPS_URL]) ) ? intval($HTTP_POST_VARS[POST_GROUPS_URL]) : intval($HTTP_GET_VARS[POST_GROUPS_URL]);
137 if ( isset($HTTP_POST_VARS['mode']) || isset($HTTP_GET_VARS['mode']) )
139 $mode = ( isset($HTTP_POST_VARS['mode']) ) ? $HTTP_POST_VARS['mode'] : $HTTP_GET_VARS['mode'];
140 $mode = htmlspecialchars($mode);
147 $confirm = ( isset($HTTP_POST_VARS['confirm']) ) ? TRUE : 0;
148 $cancel = ( isset($HTTP_POST_VARS['cancel']) ) ? TRUE : 0;
150 $start = ( isset($HTTP_GET_VARS['start']) ) ? intval($HTTP_GET_VARS['start']) : 0;
153 // Default var values
155 $is_moderator = FALSE;
157 if ( isset($HTTP_POST_VARS['groupstatus']) && $group_id )
159 if ( !$userdata['session_logged_in'] )
161 redirect(append_sid("login.$phpEx?redirect=groupcp.$phpEx&" . POST_GROUPS_URL . "=$group_id", true));
164 $sql = "SELECT group_moderator
165 FROM " . GROUPS_TABLE . "
166 WHERE group_id = $group_id";
167 if ( !($result = $db->sql_query($sql)) )
169 message_die(GENERAL_ERROR, 'Could not obtain user and group information', '', __LINE__, __FILE__, $sql);
172 $row = $db->sql_fetchrow($result);
174 if ( $row['group_moderator'] != $userdata['user_id'] && $userdata['user_level'] != ADMIN )
176 $template->assign_vars(array(
177 'META' => '<meta http-equiv="refresh" content="3;url=' . append_sid("index.$phpEx") . '">')
180 $message = $lang['Not_group_moderator'] . '<br /><br />' . sprintf($lang['Click_return_group'], '<a href="' . append_sid("groupcp.$phpEx?" . POST_GROUPS_URL . "=$group_id") . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_index'], '<a href="' . append_sid("index.$phpEx") . '">', '</a>');
182 message_die(GENERAL_MESSAGE, $message);
185 $sql = "UPDATE " . GROUPS_TABLE . "
186 SET group_type = " . intval($HTTP_POST_VARS['group_type']) . "
187 WHERE group_id = $group_id";
188 if ( !($result = $db->sql_query($sql)) )
190 message_die(GENERAL_ERROR, 'Could not obtain user and group information', '', __LINE__, __FILE__, $sql);
193 $template->assign_vars(array(
194 'META' => '<meta http-equiv="refresh" content="3;url=' . append_sid("groupcp.$phpEx?" . POST_GROUPS_URL . "=$group_id") . '">')
197 $message = $lang['Group_type_updated'] . '<br /><br />' . sprintf($lang['Click_return_group'], '<a href="' . append_sid("groupcp.$phpEx?" . POST_GROUPS_URL . "=$group_id") . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_index'], '<a href="' . append_sid("index.$phpEx") . '">', '</a>');
199 message_die(GENERAL_MESSAGE, $message);
202 else if ( isset($HTTP_POST_VARS['joingroup']) && $group_id )
205 // First, joining a group
206 // If the user isn't logged in redirect them to login
208 if ( !$userdata['session_logged_in'] )
210 redirect(append_sid("login.$phpEx?redirect=groupcp.$phpEx&" . POST_GROUPS_URL . "=$group_id", true));
213 $sql = "SELECT ug.user_id, g.group_type
214 FROM " . USER_GROUP_TABLE . " ug, " . GROUPS_TABLE . " g
215 WHERE g.group_id = $group_id
216 AND g.group_type <> " . GROUP_HIDDEN . "
217 AND ug.group_id = g.group_id";
218 if ( !($result = $db->sql_query($sql)) )
220 message_die(GENERAL_ERROR, 'Could not obtain user and group information', '', __LINE__, __FILE__, $sql);
223 if ( $row = $db->sql_fetchrow($result) )
225 if ( $row['group_type'] == GROUP_OPEN )
229 if ( $userdata['user_id'] == $row['user_id'] )
231 $template->assign_vars(array(
232 'META' => '<meta http-equiv="refresh" content="3;url=' . append_sid("index.$phpEx") . '">')
235 $message = $lang['Already_member_group'] . '<br /><br />' . sprintf($lang['Click_return_group'], '<a href="' . append_sid("groupcp.$phpEx?" . POST_GROUPS_URL . "=$group_id") . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_index'], '<a href="' . append_sid("index.$phpEx") . '">', '</a>');
237 message_die(GENERAL_MESSAGE, $message);
239 } while ( $row = $db->sql_fetchrow($result) );
243 $template->assign_vars(array(
244 'META' => '<meta http-equiv="refresh" content="3;url=' . append_sid("index.$phpEx") . '">')
247 $message = $lang['This_closed_group'] . '<br /><br />' . sprintf($lang['Click_return_group'], '<a href="' . append_sid("groupcp.$phpEx?" . POST_GROUPS_URL . "=$group_id") . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_index'], '<a href="' . append_sid("index.$phpEx") . '">', '</a>');
249 message_die(GENERAL_MESSAGE, $message);
254 message_die(GENERAL_MESSAGE, $lang['No_groups_exist']);
257 $sql = "INSERT INTO " . USER_GROUP_TABLE . " (group_id, user_id, user_pending)
258 VALUES ($group_id, " . $userdata['user_id'] . ", 1)";
259 if ( !($result = $db->sql_query($sql)) )
261 message_die(GENERAL_ERROR, "Error inserting user group subscription", "", __LINE__, __FILE__, $sql);
264 $sql = "SELECT u.user_email, u.username, u.user_lang, g.group_name
265 FROM ".USERS_TABLE . " u, " . GROUPS_TABLE . " g
266 WHERE u.user_id = g.group_moderator
267 AND g.group_id = $group_id";
268 if ( !($result = $db->sql_query($sql)) )
270 message_die(GENERAL_ERROR, "Error getting group moderator data", "", __LINE__, __FILE__, $sql);
273 $moderator = $db->sql_fetchrow($result);
275 include($phpbb_root_path . 'includes/emailer.'.$phpEx);
276 $emailer = new emailer($board_config['smtp_delivery']);
278 $emailer->from($board_config['board_email']);
279 $emailer->replyto($board_config['board_email']);
281 $emailer->use_template('group_request', $moderator['user_lang']);
282 $emailer->email_address($moderator['user_email']);
283 $emailer->set_subject($lang['Group_request']);
285 $emailer->assign_vars(array(
286 'SITENAME' => $board_config['sitename'],
287 'GROUP_MODERATOR' => $moderator['username'],
288 'EMAIL_SIG' => (!empty($board_config['board_email_sig'])) ? str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']) : '',
290 'U_GROUPCP' => $server_url . '?' . POST_GROUPS_URL . "=$group_id&validate=true")
295 $template->assign_vars(array(
296 'META' => '<meta http-equiv="refresh" content="3;url=' . append_sid("index.$phpEx") . '">')
299 $message = $lang['Group_joined'] . '<br /><br />' . sprintf($lang['Click_return_group'], '<a href="' . append_sid("groupcp.$phpEx?" . POST_GROUPS_URL . "=$group_id") . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_index'], '<a href="' . append_sid("index.$phpEx") . '">', '</a>');
301 message_die(GENERAL_MESSAGE, $message);
303 else if ( isset($HTTP_POST_VARS['unsub']) || isset($HTTP_POST_VARS['unsubpending']) && $group_id )
306 // Second, unsubscribing from a group
307 // Check for confirmation of unsub.
311 redirect(append_sid("groupcp.$phpEx", true));
313 elseif ( !$userdata['session_logged_in'] )
315 redirect(append_sid("login.$phpEx?redirect=groupcp.$phpEx&" . POST_GROUPS_URL . "=$group_id", true));
320 $sql = "DELETE FROM " . USER_GROUP_TABLE . "
321 WHERE user_id = " . $userdata['user_id'] . "
322 AND group_id = $group_id";
323 if ( !($result = $db->sql_query($sql)) )
325 message_die(GENERAL_ERROR, 'Could not delete group memebership data', '', __LINE__, __FILE__, $sql);
328 if ( $userdata['user_level'] != ADMIN && $userdata['user_level'] == MOD )
330 $sql = "SELECT COUNT(auth_mod) AS is_auth_mod
331 FROM " . AUTH_ACCESS_TABLE . " aa, " . USER_GROUP_TABLE . " ug
332 WHERE ug.user_id = " . $userdata['user_id'] . "
333 AND aa.group_id = ug.group_id
334 AND aa.auth_mod = 1";
335 if ( !($result = $db->sql_query($sql)) )
337 message_die(GENERAL_ERROR, 'Could not obtain moderator status', '', __LINE__, __FILE__, $sql);
340 if ( !($row = $db->sql_fetchrow($result)) )
342 $sql = "UPDATE " . USERS_TABLE . "
343 SET user_level = " . USER . "
344 WHERE user_id = " . $userdata['user_id'];
345 if ( !($result = $db->sql_query($sql)) )
347 message_die(GENERAL_ERROR, 'Could not update user level', '', __LINE__, __FILE__, $sql);
352 $template->assign_vars(array(
353 'META' => '<meta http-equiv="refresh" content="3;url=' . append_sid("index.$phpEx") . '">')
356 $message = $lang['Unsub_success'] . '<br /><br />' . sprintf($lang['Click_return_group'], '<a href="' . append_sid("groupcp.$phpEx?" . POST_GROUPS_URL . "=$group_id") . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_index'], '<a href="' . append_sid("index.$phpEx") . '">', '</a>');
358 message_die(GENERAL_MESSAGE, $message);
362 $unsub_msg = ( isset($HTTP_POST_VARS['unsub']) ) ? $lang['Confirm_unsub'] : $lang['Confirm_unsub_pending'];
364 $s_hidden_fields = '<input type="hidden" name="' . POST_GROUPS_URL . '" value="' . $group_id . '" /><input type="hidden" name="unsub" value="1" />';
366 $page_title = $lang['Group_Control_Panel'];
367 include($phpbb_root_path . 'includes/page_header.'.$phpEx);
369 $template->set_filenames(array(
370 'confirm' => 'confirm_body.tpl')
373 $template->assign_vars(array(
374 'MESSAGE_TITLE' => $lang['Confirm'],
375 'MESSAGE_TEXT' => $unsub_msg,
376 'L_YES' => $lang['Yes'],
377 'L_NO' => $lang['No'],
378 'S_CONFIRM_ACTION' => append_sid("groupcp.$phpEx"),
379 'S_HIDDEN_FIELDS' => $s_hidden_fields)
382 $template->pparse('confirm');
384 include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
388 else if ( $group_id )
391 // Did the group moderator get here through an email?
392 // If so, check to see if they are logged in.
394 if ( isset($HTTP_GET_VARS['validate']) )
396 if ( !$userdata['session_logged_in'] )
398 redirect(append_sid("login.$phpEx?redirect=groupcp.$phpEx&" . POST_GROUPS_URL . "=$group_id", true));
403 // For security, get the ID of the group moderator.
408 $sql = "SELECT g.group_moderator, g.group_type, aa.auth_mod
409 FROM " . GROUPS_TABLE . " g, " . AUTH_ACCESS_TABLE . " aa
410 WHERE g.group_id = $group_id
411 AND aa.group_id = g.group_id
413 SELECT g.group_moderator, g.group_type, NULL
414 FROM " . GROUPS_TABLE . " g
415 WHERE g.group_id = $group_id
418 FROM " . AUTH_ACCESS_TABLE . " aa
419 WHERE aa.group_id = g.group_id
425 $sql = "SELECT g.group_moderator, g.group_type, aa.auth_mod
426 FROM " . GROUPS_TABLE . " g, " . AUTH_ACCESS_TABLE . " aa
427 WHERE g.group_id = $group_id
428 AND aa.group_id (+) = g.group_id";
432 $sql = "SELECT g.group_moderator, g.group_type, aa.auth_mod
433 FROM ( " . GROUPS_TABLE . " g
434 LEFT JOIN " . AUTH_ACCESS_TABLE . " aa ON aa.group_id = g.group_id )
435 WHERE g.group_id = $group_id";
438 if ( !($result = $db->sql_query($sql)) )
440 message_die(GENERAL_ERROR, 'Could not get moderator information', '', __LINE__, __FILE__, $sql);
443 if ( $group_info = $db->sql_fetchrow($result) )
445 $group_moderator = $group_info['group_moderator'];
447 if ( $group_moderator == $userdata['user_id'] || $userdata['user_level'] == ADMIN )
449 $is_moderator = TRUE;
453 // Handle Additions, removals, approvals and denials
455 if ( !empty($HTTP_POST_VARS['add']) || !empty($HTTP_POST_VARS['remove']) || isset($HTTP_POST_VARS['approve']) || isset($HTTP_POST_VARS['deny']) )
457 if ( !$userdata['session_logged_in'] )
459 redirect(append_sid("login.$phpEx?redirect=groupcp.$phpEx&" . POST_GROUPS_URL . "=$group_id", true));
462 if ( !$is_moderator )
464 $template->assign_vars(array(
465 'META' => '<meta http-equiv="refresh" content="3;url=' . append_sid("index.$phpEx") . '">')
468 $message = $lang['Not_group_moderator'] . '<br /><br />' . sprintf($lang['Click_return_index'], '<a href="' . append_sid("index.$phpEx") . '">', '</a>');
470 message_die(GENERAL_MESSAGE, $message);
473 if ( isset($HTTP_POST_VARS['add']) )
475 $username = ( isset($HTTP_POST_VARS['username']) ) ? phpbb_clean_username($HTTP_POST_VARS['username']) : '';
477 $sql = "SELECT user_id, user_email, user_lang, user_level
478 FROM " . USERS_TABLE . "
479 WHERE username = '" . str_replace("\'", "''", $username) . "'";
480 if ( !($result = $db->sql_query($sql)) )
482 message_die(GENERAL_ERROR, "Could not get user information", $lang['Error'], __LINE__, __FILE__, $sql);
485 if ( !($row = $db->sql_fetchrow($result)) )
487 $template->assign_vars(array(
488 'META' => '<meta http-equiv="refresh" content="3;url=' . append_sid("groupcp.$phpEx?" . POST_GROUPS_URL . "=$group_id") . '">')
491 $message = $lang['Could_not_add_user'] . "<br /><br />" . sprintf($lang['Click_return_group'], "<a href=\"" . append_sid("groupcp.$phpEx?" . POST_GROUPS_URL . "=$group_id") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_index'], "<a href=\"" . append_sid("index.$phpEx") . "\">", "</a>");
493 message_die(GENERAL_MESSAGE, $message);
496 if ( $row['user_id'] == ANONYMOUS )
498 $template->assign_vars(array(
499 'META' => '<meta http-equiv="refresh" content="3;url=' . append_sid("groupcp.$phpEx?" . POST_GROUPS_URL . "=$group_id") . '">')
502 $message = $lang['Could_not_anon_user'] . '<br /><br />' . sprintf($lang['Click_return_group'], '<a href="' . append_sid("groupcp.$phpEx?" . POST_GROUPS_URL . "=$group_id") . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_index'], '<a href="' . append_sid("index.$phpEx") . '">', '</a>');
504 message_die(GENERAL_MESSAGE, $message);
507 $sql = "SELECT ug.user_id, u.user_level
508 FROM " . USER_GROUP_TABLE . " ug, " . USERS_TABLE . " u
509 WHERE u.user_id = " . $row['user_id'] . "
510 AND ug.user_id = u.user_id
511 AND ug.group_id = $group_id";
512 if ( !($result = $db->sql_query($sql)) )
514 message_die(GENERAL_ERROR, 'Could not get user information', '', __LINE__, __FILE__, $sql);
517 if ( !($db->sql_fetchrow($result)) )
519 $sql = "INSERT INTO " . USER_GROUP_TABLE . " (user_id, group_id, user_pending)
520 VALUES (" . $row['user_id'] . ", $group_id, 0)";
521 if ( !$db->sql_query($sql) )
523 message_die(GENERAL_ERROR, 'Could not add user to group', '', __LINE__, __FILE__, $sql);
526 if ( $row['user_level'] != ADMIN && $row['user_level'] != MOD && $group_info['auth_mod'] )
528 $sql = "UPDATE " . USERS_TABLE . "
529 SET user_level = " . MOD . "
530 WHERE user_id = " . $row['user_id'];
531 if ( !$db->sql_query($sql) )
533 message_die(GENERAL_ERROR, 'Could not update user level', '', __LINE__, __FILE__, $sql);
538 // Get the group name
539 // Email the user and tell them they're in the group
541 $group_sql = "SELECT group_name
542 FROM " . GROUPS_TABLE . "
543 WHERE group_id = $group_id";
544 if ( !($result = $db->sql_query($group_sql)) )
546 message_die(GENERAL_ERROR, 'Could not get group information', '', __LINE__, __FILE__, $group_sql);
549 $group_name_row = $db->sql_fetchrow($result);
551 $group_name = $group_name_row['group_name'];
553 include($phpbb_root_path . 'includes/emailer.'.$phpEx);
554 $emailer = new emailer($board_config['smtp_delivery']);
556 $emailer->from($board_config['board_email']);
557 $emailer->replyto($board_config['board_email']);
559 $emailer->use_template('group_added', $row['user_lang']);
560 $emailer->email_address($row['user_email']);
561 $emailer->set_subject($lang['Group_added']);
563 $emailer->assign_vars(array(
564 'SITENAME' => $board_config['sitename'],
565 'GROUP_NAME' => $group_name,
566 'EMAIL_SIG' => (!empty($board_config['board_email_sig'])) ? str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']) : '',
568 'U_GROUPCP' => $server_url . '?' . POST_GROUPS_URL . "=$group_id")
575 $template->assign_vars(array(
576 'META' => '<meta http-equiv="refresh" content="3;url=' . append_sid("groupcp.$phpEx?" . POST_GROUPS_URL . "=$group_id") . '">')
579 $message = $lang['User_is_member_group'] . '<br /><br />' . sprintf($lang['Click_return_group'], '<a href="' . append_sid("groupcp.$phpEx?" . POST_GROUPS_URL . "=$group_id") . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_index'], '<a href="' . append_sid("index.$phpEx") . '">', '</a>');
581 message_die(GENERAL_MESSAGE, $message);
586 if ( ( ( isset($HTTP_POST_VARS['approve']) || isset($HTTP_POST_VARS['deny']) ) && isset($HTTP_POST_VARS['pending_members']) ) || ( isset($HTTP_POST_VARS['remove']) && isset($HTTP_POST_VARS['members']) ) )
589 $members = ( isset($HTTP_POST_VARS['approve']) || isset($HTTP_POST_VARS['deny']) ) ? $HTTP_POST_VARS['pending_members'] : $HTTP_POST_VARS['members'];
592 for($i = 0; $i < count($members); $i++)
594 $sql_in .= ( ( $sql_in != '' ) ? ', ' : '' ) . intval($members[$i]);
597 if ( isset($HTTP_POST_VARS['approve']) )
599 if ( $group_info['auth_mod'] )
601 $sql = "UPDATE " . USERS_TABLE . "
602 SET user_level = " . MOD . "
603 WHERE user_id IN ($sql_in)
604 AND user_level NOT IN (" . MOD . ", " . ADMIN . ")";
605 if ( !$db->sql_query($sql) )
607 message_die(GENERAL_ERROR, 'Could not update user level', '', __LINE__, __FILE__, $sql);
611 $sql = "UPDATE " . USER_GROUP_TABLE . "
613 WHERE user_id IN ($sql_in)
614 AND group_id = $group_id";
615 $sql_select = "SELECT user_email
616 FROM ". USERS_TABLE . "
617 WHERE user_id IN ($sql_in)";
619 else if ( isset($HTTP_POST_VARS['deny']) || isset($HTTP_POST_VARS['remove']) )
621 if ( $group_info['auth_mod'] )
623 $sql = "SELECT ug.user_id, ug.group_id
624 FROM " . AUTH_ACCESS_TABLE . " aa, " . USER_GROUP_TABLE . " ug
625 WHERE ug.user_id IN ($sql_in)
626 AND aa.group_id = ug.group_id
628 GROUP BY ug.user_id, ug.group_id
629 ORDER BY ug.user_id, ug.group_id";
630 if ( !($result = $db->sql_query($sql)) )
632 message_die(GENERAL_ERROR, 'Could not obtain moderator status', '', __LINE__, __FILE__, $sql);
635 if ( $row = $db->sql_fetchrow($result) )
637 $group_check = array();
638 $remove_mod_sql = '';
642 $group_check[$row['user_id']][] = $row['group_id'];
644 while ( $row = $db->sql_fetchrow($result) );
646 while( list($user_id, $group_list) = @each($group_check) )
648 if ( count($group_list) == 1 )
650 $remove_mod_sql .= ( ( $remove_mod_sql != '' ) ? ', ' : '' ) . $user_id;
654 if ( $remove_mod_sql != '' )
656 $sql = "UPDATE " . USERS_TABLE . "
657 SET user_level = " . USER . "
658 WHERE user_id IN ($remove_mod_sql)
659 AND user_level NOT IN (" . ADMIN . ")";
660 if ( !$db->sql_query($sql) )
662 message_die(GENERAL_ERROR, 'Could not update user level', '', __LINE__, __FILE__, $sql);
668 $sql = "DELETE FROM " . USER_GROUP_TABLE . "
669 WHERE user_id IN ($sql_in)
670 AND group_id = $group_id";
673 if ( !$db->sql_query($sql) )
675 message_die(GENERAL_ERROR, 'Could not update user group table', '', __LINE__, __FILE__, $sql);
679 // Email users when they are approved
681 if ( isset($HTTP_POST_VARS['approve']) )
683 if ( !($result = $db->sql_query($sql_select)) )
685 message_die(GENERAL_ERROR, 'Could not get user email information', '', __LINE__, __FILE__, $sql);
689 while ($row = $db->sql_fetchrow($result))
691 $bcc_list[] = $row['user_email'];
695 // Get the group name
697 $group_sql = "SELECT group_name
698 FROM " . GROUPS_TABLE . "
699 WHERE group_id = $group_id";
700 if ( !($result = $db->sql_query($group_sql)) )
702 message_die(GENERAL_ERROR, 'Could not get group information', '', __LINE__, __FILE__, $group_sql);
705 $group_name_row = $db->sql_fetchrow($result);
706 $group_name = $group_name_row['group_name'];
708 include($phpbb_root_path . 'includes/emailer.'.$phpEx);
709 $emailer = new emailer($board_config['smtp_delivery']);
711 $emailer->from($board_config['board_email']);
712 $emailer->replyto($board_config['board_email']);
714 for ($i = 0; $i < count($bcc_list); $i++)
716 $emailer->bcc($bcc_list[$i]);
719 $emailer->use_template('group_approved');
720 $emailer->set_subject($lang['Group_approved']);
722 $emailer->assign_vars(array(
723 'SITENAME' => $board_config['sitename'],
724 'GROUP_NAME' => $group_name,
725 'EMAIL_SIG' => (!empty($board_config['board_email_sig'])) ? str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']) : '',
727 'U_GROUPCP' => $server_url . '?' . POST_GROUPS_URL . "=$group_id")
736 // END approve or deny
741 message_die(GENERAL_MESSAGE, $lang['No_groups_exist']);
748 FROM " . GROUPS_TABLE . "
749 WHERE group_id = $group_id
750 AND group_single_user = 0";
751 if ( !($result = $db->sql_query($sql)) )
753 message_die(GENERAL_ERROR, 'Error getting group information', '', __LINE__, __FILE__, $sql);
756 if ( !($group_info = $db->sql_fetchrow($result)) )
758 message_die(GENERAL_MESSAGE, $lang['Group_not_exist']);
762 // Get moderator details for this group
764 $sql = "SELECT username, user_id, user_viewemail, user_posts, user_regdate, user_from, user_website, user_email, user_icq, user_aim, user_yim, user_msnm
765 FROM " . USERS_TABLE . "
766 WHERE user_id = " . $group_info['group_moderator'];
767 if ( !($result = $db->sql_query($sql)) )
769 message_die(GENERAL_ERROR, 'Error getting user list for group', '', __LINE__, __FILE__, $sql);
772 $group_moderator = $db->sql_fetchrow($result);
775 // Get user information for this group
777 $sql = "SELECT u.username, u.user_id, u.user_viewemail, u.user_posts, u.user_regdate, u.user_from, u.user_website, u.user_email, u.user_icq, u.user_aim, u.user_yim, u.user_msnm, ug.user_pending
778 FROM " . USERS_TABLE . " u, " . USER_GROUP_TABLE . " ug
779 WHERE ug.group_id = $group_id
780 AND u.user_id = ug.user_id
781 AND ug.user_pending = 0
782 AND ug.user_id <> " . $group_moderator['user_id'] . "
783 ORDER BY u.username";
784 if ( !($result = $db->sql_query($sql)) )
786 message_die(GENERAL_ERROR, 'Error getting user list for group', '', __LINE__, __FILE__, $sql);
789 $group_members = $db->sql_fetchrowset($result);
790 $members_count = count($group_members);
791 $db->sql_freeresult($result);
793 $sql = "SELECT u.username, u.user_id, u.user_viewemail, u.user_posts, u.user_regdate, u.user_from, u.user_website, u.user_email, u.user_icq, u.user_aim, u.user_yim, u.user_msnm
794 FROM " . GROUPS_TABLE . " g, " . USER_GROUP_TABLE . " ug, " . USERS_TABLE . " u
795 WHERE ug.group_id = $group_id
796 AND g.group_id = ug.group_id
797 AND ug.user_pending = 1
798 AND u.user_id = ug.user_id
799 ORDER BY u.username";
800 if ( !($result = $db->sql_query($sql)) )
802 message_die(GENERAL_ERROR, 'Error getting user pending information', '', __LINE__, __FILE__, $sql);
805 $modgroup_pending_list = $db->sql_fetchrowset($result);
806 $modgroup_pending_count = count($modgroup_pending_list);
807 $db->sql_freeresult($result);
809 $is_group_member = 0;
810 if ( $members_count )
812 for($i = 0; $i < $members_count; $i++)
814 if ( $group_members[$i]['user_id'] == $userdata['user_id'] && $userdata['session_logged_in'] )
816 $is_group_member = TRUE;
821 $is_group_pending_member = 0;
822 if ( $modgroup_pending_count )
824 for($i = 0; $i < $modgroup_pending_count; $i++)
826 if ( $modgroup_pending_list[$i]['user_id'] == $userdata['user_id'] && $userdata['session_logged_in'] )
828 $is_group_pending_member = TRUE;
833 if ( $userdata['user_level'] == ADMIN )
835 $is_moderator = TRUE;
838 if ( $userdata['user_id'] == $group_info['group_moderator'] )
840 $is_moderator = TRUE;
842 $group_details = $lang['Are_group_moderator'];
844 $s_hidden_fields = '<input type="hidden" name="' . POST_GROUPS_URL . '" value="' . $group_id . '" />';
846 else if ( $is_group_member || $is_group_pending_member )
848 $template->assign_block_vars('switch_unsubscribe_group_input', array());
850 $group_details = ( $is_group_pending_member ) ? $lang['Pending_this_group'] : $lang['Member_this_group'];
852 $s_hidden_fields = '<input type="hidden" name="' . POST_GROUPS_URL . '" value="' . $group_id . '" />';
854 else if ( $userdata['user_id'] == ANONYMOUS )
856 $group_details = $lang['Login_to_join'];
857 $s_hidden_fields = '';
861 if ( $group_info['group_type'] == GROUP_OPEN )
863 $template->assign_block_vars('switch_subscribe_group_input', array());
865 $group_details = $lang['This_open_group'];
866 $s_hidden_fields = '<input type="hidden" name="' . POST_GROUPS_URL . '" value="' . $group_id . '" />';
868 else if ( $group_info['group_type'] == GROUP_CLOSED )
870 $group_details = $lang['This_closed_group'];
871 $s_hidden_fields = '';
873 else if ( $group_info['group_type'] == GROUP_HIDDEN )
875 $group_details = $lang['This_hidden_group'];
876 $s_hidden_fields = '';
880 $page_title = $lang['Group_Control_Panel'];
881 include($phpbb_root_path . 'includes/page_header.'.$phpEx);
886 $template->set_filenames(array(
887 'info' => 'groupcp_info_body.tpl',
888 'pendinginfo' => 'groupcp_pending_info.tpl')
890 make_jumpbox('viewforum.'.$phpEx);
895 $username = $group_moderator['username'];
896 $user_id = $group_moderator['user_id'];
898 generate_user_info($group_moderator, $board_config['default_dateformat'], $is_moderator, $from, $posts, $joined, $poster_avatar, $profile_img, $profile, $search_img, $search, $pm_img, $pm, $email_img, $email, $www_img, $www, $icq_status_img, $icq_img, $icq, $aim_img, $aim, $msn_img, $msn, $yim_img, $yim);
900 $s_hidden_fields .= '';
902 $template->assign_vars(array(
903 'L_GROUP_INFORMATION' => $lang['Group_Information'],
904 'L_GROUP_NAME' => $lang['Group_name'],
905 'L_GROUP_DESC' => $lang['Group_description'],
906 'L_GROUP_TYPE' => $lang['Group_type'],
907 'L_GROUP_MEMBERSHIP' => $lang['Group_membership'],
908 'L_SUBSCRIBE' => $lang['Subscribe'],
909 'L_UNSUBSCRIBE' => $lang['Unsubscribe'],
910 'L_JOIN_GROUP' => $lang['Join_group'],
911 'L_UNSUBSCRIBE_GROUP' => $lang['Unsubscribe'],
912 'L_GROUP_OPEN' => $lang['Group_open'],
913 'L_GROUP_CLOSED' => $lang['Group_closed'],
914 'L_GROUP_HIDDEN' => $lang['Group_hidden'],
915 'L_UPDATE' => $lang['Update'],
916 'L_GROUP_MODERATOR' => $lang['Group_Moderator'],
917 'L_GROUP_MEMBERS' => $lang['Group_Members'],
918 'L_PENDING_MEMBERS' => $lang['Pending_members'],
919 'L_SELECT_SORT_METHOD' => $lang['Select_sort_method'],
920 'L_PM' => $lang['Private_Message'],
921 'L_EMAIL' => $lang['Email'],
922 'L_POSTS' => $lang['Posts'],
923 'L_WEBSITE' => $lang['Website'],
924 'L_FROM' => $lang['Location'],
925 'L_ORDER' => $lang['Order'],
926 'L_SORT' => $lang['Sort'],
927 'L_SUBMIT' => $lang['Sort'],
928 'L_AIM' => $lang['AIM'],
929 'L_YIM' => $lang['YIM'],
930 'L_MSNM' => $lang['MSNM'],
931 'L_ICQ' => $lang['ICQ'],
932 'L_SELECT' => $lang['Select'],
933 'L_REMOVE_SELECTED' => $lang['Remove_selected'],
934 'L_ADD_MEMBER' => $lang['Add_member'],
935 'L_FIND_USERNAME' => $lang['Find_username'],
937 'GROUP_NAME' => $group_info['group_name'],
938 'GROUP_DESC' => $group_info['group_description'],
939 'GROUP_DETAILS' => $group_details,
940 'MOD_ROW_COLOR' => '#' . $theme['td_color1'],
941 'MOD_ROW_CLASS' => $theme['td_class1'],
942 'MOD_USERNAME' => $username,
944 'MOD_JOINED' => $joined,
945 'MOD_POSTS' => $posts,
946 'MOD_AVATAR_IMG' => $poster_avatar,
947 'MOD_PROFILE_IMG' => $profile_img,
948 'MOD_PROFILE' => $profile,
949 'MOD_SEARCH_IMG' => $search_img,
950 'MOD_SEARCH' => $search,
951 'MOD_PM_IMG' => $pm_img,
953 'MOD_EMAIL_IMG' => $email_img,
954 'MOD_EMAIL' => $email,
955 'MOD_WWW_IMG' => $www_img,
957 'MOD_ICQ_STATUS_IMG' => $icq_status_img,
958 'MOD_ICQ_IMG' => $icq_img,
960 'MOD_AIM_IMG' => $aim_img,
962 'MOD_MSN_IMG' => $msn_img,
964 'MOD_YIM_IMG' => $yim_img,
967 'U_MOD_VIEWPROFILE' => append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=$user_id"),
968 'U_SEARCH_USER' => append_sid("search.$phpEx?mode=searchuser"),
970 'S_GROUP_OPEN_TYPE' => GROUP_OPEN,
971 'S_GROUP_CLOSED_TYPE' => GROUP_CLOSED,
972 'S_GROUP_HIDDEN_TYPE' => GROUP_HIDDEN,
973 'S_GROUP_OPEN_CHECKED' => ( $group_info['group_type'] == GROUP_OPEN ) ? ' checked="checked"' : '',
974 'S_GROUP_CLOSED_CHECKED' => ( $group_info['group_type'] == GROUP_CLOSED ) ? ' checked="checked"' : '',
975 'S_GROUP_HIDDEN_CHECKED' => ( $group_info['group_type'] == GROUP_HIDDEN ) ? ' checked="checked"' : '',
976 'S_HIDDEN_FIELDS' => $s_hidden_fields,
977 'S_MODE_SELECT' => $select_sort_mode,
978 'S_ORDER_SELECT' => $select_sort_order,
979 'S_GROUPCP_ACTION' => append_sid("groupcp.$phpEx?" . POST_GROUPS_URL . "=$group_id"))
983 // Dump out the remaining users
985 for($i = $start; $i < min($board_config['topics_per_page'] + $start, $members_count); $i++)
987 $username = $group_members[$i]['username'];
988 $user_id = $group_members[$i]['user_id'];
990 generate_user_info($group_members[$i], $board_config['default_dateformat'], $is_moderator, $from, $posts, $joined, $poster_avatar, $profile_img, $profile, $search_img, $search, $pm_img, $pm, $email_img, $email, $www_img, $www, $icq_status_img, $icq_img, $icq, $aim_img, $aim, $msn_img, $msn, $yim_img, $yim);
992 if ( $group_info['group_type'] != GROUP_HIDDEN || $is_group_member || $is_moderator )
994 $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
995 $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
997 $template->assign_block_vars('member_row', array(
998 'ROW_COLOR' => '#' . $row_color,
999 'ROW_CLASS' => $row_class,
1000 'USERNAME' => $username,
1002 'JOINED' => $joined,
1004 'USER_ID' => $user_id,
1005 'AVATAR_IMG' => $poster_avatar,
1006 'PROFILE_IMG' => $profile_img,
1007 'PROFILE' => $profile,
1008 'SEARCH_IMG' => $search_img,
1009 'SEARCH' => $search,
1010 'PM_IMG' => $pm_img,
1012 'EMAIL_IMG' => $email_img,
1014 'WWW_IMG' => $www_img,
1016 'ICQ_STATUS_IMG' => $icq_status_img,
1017 'ICQ_IMG' => $icq_img,
1019 'AIM_IMG' => $aim_img,
1021 'MSN_IMG' => $msn_img,
1023 'YIM_IMG' => $yim_img,
1026 'U_VIEWPROFILE' => append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=$user_id"))
1029 if ( $is_moderator )
1031 $template->assign_block_vars('member_row.switch_mod_option', array());
1036 if ( !$members_count )
1041 $template->assign_block_vars('switch_no_members', array());
1042 $template->assign_vars(array(
1043 'L_NO_MEMBERS' => $lang['No_group_members'])
1047 $current_page = ( !$members_count ) ? 1 : ceil( $members_count / $board_config['topics_per_page'] );
1049 $template->assign_vars(array(
1050 'PAGINATION' => generate_pagination("groupcp.$phpEx?" . POST_GROUPS_URL . "=$group_id", $members_count, $board_config['topics_per_page'], $start),
1051 'PAGE_NUMBER' => sprintf($lang['Page_of'], ( floor( $start / $board_config['topics_per_page'] ) + 1 ), $current_page ),
1053 'L_GOTO_PAGE' => $lang['Goto_page'])
1056 if ( $group_info['group_type'] == GROUP_HIDDEN && !$is_group_member && !$is_moderator )
1061 $template->assign_block_vars('switch_hidden_group', array());
1062 $template->assign_vars(array(
1063 'L_HIDDEN_MEMBERS' => $lang['Group_hidden_members'])
1068 // We've displayed the members who belong to the group, now we
1069 // do that pending memebers...
1071 if ( $is_moderator )
1074 // Users pending in ONLY THIS GROUP (which is moderated by this user)
1076 if ( $modgroup_pending_count )
1078 for($i = 0; $i < $modgroup_pending_count; $i++)
1080 $username = $modgroup_pending_list[$i]['username'];
1081 $user_id = $modgroup_pending_list[$i]['user_id'];
1083 generate_user_info($modgroup_pending_list[$i], $board_config['default_dateformat'], $is_moderator, $from, $posts, $joined, $poster_avatar, $profile_img, $profile, $search_img, $search, $pm_img, $pm, $email_img, $email, $www_img, $www, $icq_status_img, $icq_img, $icq, $aim_img, $aim, $msn_img, $msn, $yim_img, $yim);
1085 $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
1086 $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
1088 $user_select = '<input type="checkbox" name="member[]" value="' . $user_id . '">';
1090 $template->assign_block_vars('pending_members_row', array(
1091 'ROW_CLASS' => $row_class,
1092 'ROW_COLOR' => '#' . $row_color,
1093 'USERNAME' => $username,
1095 'JOINED' => $joined,
1097 'USER_ID' => $user_id,
1098 'AVATAR_IMG' => $poster_avatar,
1099 'PROFILE_IMG' => $profile_img,
1100 'PROFILE' => $profile,
1101 'SEARCH_IMG' => $search_img,
1102 'SEARCH' => $search,
1103 'PM_IMG' => $pm_img,
1105 'EMAIL_IMG' => $email_img,
1107 'WWW_IMG' => $www_img,
1109 'ICQ_STATUS_IMG' => $icq_status_img,
1110 'ICQ_IMG' => $icq_img,
1112 'AIM_IMG' => $aim_img,
1114 'MSN_IMG' => $msn_img,
1116 'YIM_IMG' => $yim_img,
1119 'U_VIEWPROFILE' => append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=$user_id"))
1123 $template->assign_block_vars('switch_pending_members', array() );
1125 $template->assign_vars(array(
1126 'L_SELECT' => $lang['Select'],
1127 'L_APPROVE_SELECTED' => $lang['Approve_selected'],
1128 'L_DENY_SELECTED' => $lang['Deny_selected'])
1131 $template->assign_var_from_handle('PENDING_USER_BOX', 'pendinginfo');
1136 if ( $is_moderator )
1138 $template->assign_block_vars('switch_mod_option', array());
1139 $template->assign_block_vars('switch_add_member', array());
1142 $template->pparse('info');
1147 // Show the main groupcp.php screen where the user can select a group.
1149 // Select all group that the user is a member of or where the user has
1150 // a pending membership.
1152 $in_group = array();
1154 if ( $userdata['session_logged_in'] )
1156 $sql = "SELECT g.group_id, g.group_name, g.group_type, ug.user_pending
1157 FROM " . GROUPS_TABLE . " g, " . USER_GROUP_TABLE . " ug
1158 WHERE ug.user_id = " . $userdata['user_id'] . "
1159 AND ug.group_id = g.group_id
1160 AND g.group_single_user <> " . TRUE . "
1161 ORDER BY g.group_name, ug.user_id";
1162 if ( !($result = $db->sql_query($sql)) )
1164 message_die(GENERAL_ERROR, 'Error getting group information', '', __LINE__, __FILE__, $sql);
1167 if ( $row = $db->sql_fetchrow($result) )
1169 $in_group = array();
1170 $s_member_groups_opt = '';
1171 $s_pending_groups_opt = '';
1175 $in_group[] = $row['group_id'];
1176 if ( $row['user_pending'] )
1178 $s_pending_groups_opt .= '<option value="' . $row['group_id'] . '">' . $row['group_name'] . '</option>';
1182 $s_member_groups_opt .= '<option value="' . $row['group_id'] . '">' . $row['group_name'] . '</option>';
1185 while( $row = $db->sql_fetchrow($result) );
1187 $s_pending_groups = '<select name="' . POST_GROUPS_URL . '">' . $s_pending_groups_opt . "</select>";
1188 $s_member_groups = '<select name="' . POST_GROUPS_URL . '">' . $s_member_groups_opt . "</select>";
1193 // Select all other groups i.e. groups that this user is not a member of
1195 $ignore_group_sql = ( count($in_group) ) ? "AND group_id NOT IN (" . implode(', ', $in_group) . ")" : '';
1196 $sql = "SELECT group_id, group_name, group_type
1197 FROM " . GROUPS_TABLE . " g
1198 WHERE group_single_user <> " . TRUE . "
1200 ORDER BY g.group_name";
1201 if ( !($result = $db->sql_query($sql)) )
1203 message_die(GENERAL_ERROR, 'Error getting group information', '', __LINE__, __FILE__, $sql);
1206 $s_group_list_opt = '';
1207 while( $row = $db->sql_fetchrow($result) )
1209 if ( $row['group_type'] != GROUP_HIDDEN || $userdata['user_level'] == ADMIN )
1211 $s_group_list_opt .='<option value="' . $row['group_id'] . '">' . $row['group_name'] . '</option>';
1214 $s_group_list = '<select name="' . POST_GROUPS_URL . '">' . $s_group_list_opt . '</select>';
1216 if ( $s_group_list_opt != '' || $s_pending_groups_opt != '' || $s_member_groups_opt != '' )
1219 // Load and process templates
1221 include($phpbb_root_path . 'includes/page_header.'.$phpEx);
1223 $template->set_filenames(array(
1224 'user' => 'groupcp_user_body.tpl')
1226 make_jumpbox('viewforum.'.$phpEx);
1228 if ( $s_pending_groups_opt != '' || $s_member_groups_opt != '' )
1230 $template->assign_block_vars('switch_groups_joined', array() );
1233 if ( $s_member_groups_opt != '' )
1235 $template->assign_block_vars('switch_groups_joined.switch_groups_member', array() );
1238 if ( $s_pending_groups_opt != '' )
1240 $template->assign_block_vars('switch_groups_joined.switch_groups_pending', array() );
1243 if ( $s_group_list_opt != '' )
1245 $template->assign_block_vars('switch_groups_remaining', array() );
1248 $s_hidden_fields = '<input type="hidden" name="sid" value="' . $userdata['session_id'] . '" />';
1250 $template->assign_vars(array(
1251 'L_GROUP_MEMBERSHIP_DETAILS' => $lang['Group_member_details'],
1252 'L_JOIN_A_GROUP' => $lang['Group_member_join'],
1253 'L_YOU_BELONG_GROUPS' => $lang['Current_memberships'],
1254 'L_SELECT_A_GROUP' => $lang['Non_member_groups'],
1255 'L_PENDING_GROUPS' => $lang['Memberships_pending'],
1256 'L_SUBSCRIBE' => $lang['Subscribe'],
1257 'L_UNSUBSCRIBE' => $lang['Unsubscribe'],
1258 'L_VIEW_INFORMATION' => $lang['View_Information'],
1260 'S_USERGROUP_ACTION' => append_sid("groupcp.$phpEx"),
1261 'S_HIDDEN_FIELDS' => $s_hidden_fields,
1263 'GROUP_LIST_SELECT' => $s_group_list,
1264 'GROUP_PENDING_SELECT' => $s_pending_groups,
1265 'GROUP_MEMBER_SELECT' => $s_member_groups)
1268 $template->pparse('user');
1272 message_die(GENERAL_MESSAGE, $lang['No_groups_exist']);
1277 include($phpbb_root_path . 'includes/page_tail.'.$phpEx);