1 rizwank 1.1 <?php
2 /***************************************************************************
3 * groupcp.php
4 * -------------------
5 * begin : Saturday, Feb 13, 2001
6 * copyright : (C) 2001 The phpBB Group
7 * email : support@phpbb.com
8 *
9 * $Id: groupcp.php,v 1.58.2.12 2003/01/09 00:17:23 psotfx Exp $
10 *
11 *
12 ***************************************************************************/
13
14 /***************************************************************************
15 *
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.
20 *
21 ***************************************************************************/
22 rizwank 1.1
23 define('IN_PHPBB', true);
24 $phpbb_root_path = './';
25 include($phpbb_root_path . 'extension.inc');
26 include($phpbb_root_path . 'common.'.$phpEx);
27
28 // -------------------------
29 //
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)
31 {
32 global $lang, $images, $board_config, $phpEx;
33
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;
37
38 $poster_avatar = '';
39 if ( $row['user_avatar_type'] && $row['user_id'] != ANONYMOUS && $row['user_allowavatar'] )
40 {
41 switch( $row['user_avatar_type'] )
42 {
43 rizwank 1.1 case USER_AVATAR_UPLOAD:
44 $poster_avatar = ( $board_config['allow_avatar_upload'] ) ? '<img src="' . $board_config['avatar_path'] . '/' . $row['user_avatar'] . '" alt="" border="0" />' : '';
45 break;
46 case USER_AVATAR_REMOTE:
47 $poster_avatar = ( $board_config['allow_avatar_remote'] ) ? '<img src="' . $row['user_avatar'] . '" alt="" border="0" />' : '';
48 break;
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" />' : '';
51 break;
52 }
53 }
54
55 if ( !empty($row['user_viewemail']) || $group_mod )
56 {
57 $email_uri = ( $board_config['board_email_form'] ) ? append_sid("profile.$phpEx?mode=email&" . POST_USERS_URL .'=' . $row['user_id']) : 'mailto:' . $row['user_email'];
58
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>';
61 }
62 else
63 {
64 rizwank 1.1 $email_img = ' ';
65 $email = ' ';
66 }
67
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>';
71
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>';
75
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>' : '';
78
79 if ( !empty($row['user_icq']) )
80 {
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>';
84 }
85 rizwank 1.1 else
86 {
87 $icq_status_img = '';
88 $icq_img = '';
89 $icq = '';
90 }
91
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>' : '';
94
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>' : '';
98
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>' : '';
101
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>';
105
106 rizwank 1.1 return;
107 }
108 //
109 // --------------------------
110
111 //
112 // Start session management
113 //
114 $userdata = session_pagestart($user_ip, PAGE_GROUPCP);
115 init_userprefs($userdata);
116 //
117 // End session management
118 //
119
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']) . '/' : '/';
125
126 $server_url = $server_protocol . $server_name . $server_port . $script_name;
127 rizwank 1.1
128 if ( isset($HTTP_GET_VARS[POST_GROUPS_URL]) || isset($HTTP_POST_VARS[POST_GROUPS_URL]) )
129 {
130 $group_id = ( isset($HTTP_POST_VARS[POST_GROUPS_URL]) ) ? intval($HTTP_POST_VARS[POST_GROUPS_URL]) : intval($HTTP_GET_VARS[POST_GROUPS_URL]);
131 }
132 else
133 {
134 $group_id = '';
135 }
136
137 if ( isset($HTTP_POST_VARS['mode']) || isset($HTTP_GET_VARS['mode']) )
138 {
139 $mode = ( isset($HTTP_POST_VARS['mode']) ) ? $HTTP_POST_VARS['mode'] : $HTTP_GET_VARS['mode'];
140 }
141 else
142 {
143 $mode = '';
144 }
145
146 $confirm = ( isset($HTTP_POST_VARS['confirm']) ) ? TRUE : 0;
147 $cancel = ( isset($HTTP_POST_VARS['cancel']) ) ? TRUE : 0;
148 rizwank 1.1
149 $start = ( isset($HTTP_GET_VARS['start']) ) ? intval($HTTP_GET_VARS['start']) : 0;
150
151 //
152 // Default var values
153 //
154 $is_moderator = FALSE;
155
156 if ( isset($HTTP_POST_VARS['groupstatus']) && $group_id )
157 {
158 if ( !$userdata['session_logged_in'] )
159 {
160 redirect(append_sid("login.$phpEx?redirect=groupcp.$phpEx&" . POST_GROUPS_URL . "=$group_id", true));
161 }
162
163 if (!isset($HTTP_POST_VARS['sid']) || $HTTP_POST_VARS['sid'] != $userdata['session_id'])
164 {
165 message_die(GENERAL_ERROR, 'Invalid_session');
166 }
167
168 $sql = "SELECT group_moderator
169 rizwank 1.1 FROM " . GROUPS_TABLE . "
170 WHERE group_id = $group_id";
171 if ( !($result = $db->sql_query($sql)) )
172 {
173 message_die(GENERAL_ERROR, 'Could not obtain user and group information', '', __LINE__, __FILE__, $sql);
174 }
175
176 $row = $db->sql_fetchrow($result);
177
178 if ( $row['group_moderator'] != $userdata['user_id'] && $userdata['user_level'] != ADMIN )
179 {
180 $template->assign_vars(array(
181 'META' => '<meta http-equiv="refresh" content="3;url=' . append_sid("index.$phpEx") . '">')
182 );
183
184 $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>');
185
186 message_die(GENERAL_MESSAGE, $message);
187 }
188
189 $sql = "UPDATE " . GROUPS_TABLE . "
190 rizwank 1.1 SET group_type = " . intval($HTTP_POST_VARS['group_type']) . "
191 WHERE group_id = $group_id";
192 if ( !($result = $db->sql_query($sql)) )
193 {
194 message_die(GENERAL_ERROR, 'Could not obtain user and group information', '', __LINE__, __FILE__, $sql);
195 }
196
197 $template->assign_vars(array(
198 'META' => '<meta http-equiv="refresh" content="3;url=' . append_sid("groupcp.$phpEx?" . POST_GROUPS_URL . "=$group_id") . '">')
199 );
200
201 $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>');
202
203 message_die(GENERAL_MESSAGE, $message);
204
205 }
206 else if ( isset($HTTP_POST_VARS['joingroup']) && $group_id )
207 {
208 //
209 // First, joining a group
210 // If the user isn't logged in redirect them to login
211 rizwank 1.1 //
212 if ( !$userdata['session_logged_in'] )
213 {
214 redirect(append_sid("login.$phpEx?redirect=groupcp.$phpEx&" . POST_GROUPS_URL . "=$group_id", true));
215 }
216
217 if (!isset($HTTP_POST_VARS['sid']) || $HTTP_POST_VARS['sid'] != $userdata['session_id'])
218 {
219 message_die(GENERAL_ERROR, 'Invalid_session');
220 }
221
222 $sql = "SELECT ug.user_id, g.group_type
223 FROM " . USER_GROUP_TABLE . " ug, " . GROUPS_TABLE . " g
224 WHERE g.group_id = $group_id
225 AND g.group_type <> " . GROUP_HIDDEN . "
226 AND ug.group_id = g.group_id";
227 if ( !($result = $db->sql_query($sql)) )
228 {
229 message_die(GENERAL_ERROR, 'Could not obtain user and group information', '', __LINE__, __FILE__, $sql);
230 }
231
232 rizwank 1.1 if ( $row = $db->sql_fetchrow($result) )
233 {
234 if ( $row['group_type'] == GROUP_OPEN )
235 {
236 do
237 {
238 if ( $userdata['user_id'] == $row['user_id'] )
239 {
240 $template->assign_vars(array(
241 'META' => '<meta http-equiv="refresh" content="3;url=' . append_sid("index.$phpEx") . '">')
242 );
243
244 $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>');
245
246 message_die(GENERAL_MESSAGE, $message);
247 }
248 } while ( $row = $db->sql_fetchrow($result) );
249 }
250 else
251 {
252 $template->assign_vars(array(
253 rizwank 1.1 'META' => '<meta http-equiv="refresh" content="3;url=' . append_sid("index.$phpEx") . '">')
254 );
255
256 $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>');
257
258 message_die(GENERAL_MESSAGE, $message);
259 }
260 }
261 else
262 {
263 message_die(GENERAL_MESSAGE, $lang['No_groups_exist']);
264 }
265
266 $sql = "INSERT INTO " . USER_GROUP_TABLE . " (group_id, user_id, user_pending)
267 VALUES ($group_id, " . $userdata['user_id'] . ", 1)";
268 if ( !($result = $db->sql_query($sql)) )
269 {
270 message_die(GENERAL_ERROR, "Error inserting user group subscription", "", __LINE__, __FILE__, $sql);
271 }
272
273 $sql = "SELECT u.user_email, u.username, u.user_lang, g.group_name
274 rizwank 1.1 FROM ".USERS_TABLE . " u, " . GROUPS_TABLE . " g
275 WHERE u.user_id = g.group_moderator
276 AND g.group_id = $group_id";
277 if ( !($result = $db->sql_query($sql)) )
278 {
279 message_die(GENERAL_ERROR, "Error getting group moderator data", "", __LINE__, __FILE__, $sql);
280 }
281
282 $moderator = $db->sql_fetchrow($result);
283
284 include($phpbb_root_path . 'includes/emailer.'.$phpEx);
285 $emailer = new emailer($board_config['smtp_delivery']);
286
287 $email_headers = 'From: ' . $board_config['board_email'] . "\nReturn-Path: " . $board_config['board_email'] . "\n";
288
289 $emailer->use_template('group_request', $moderator['user_lang']);
290 $emailer->email_address($moderator['user_email']);
291 $emailer->set_subject($lang['Group_request']);
292 $emailer->extra_headers($email_headers);
293
294 $emailer->assign_vars(array(
295 rizwank 1.1 'SITENAME' => $board_config['sitename'],
296 'GROUP_MODERATOR' => $moderator['username'],
297 'EMAIL_SIG' => (!empty($board_config['board_email_sig'])) ? str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']) : '',
298
299 'U_GROUPCP' => $server_url . '?' . POST_GROUPS_URL . "=$group_id&validate=true")
300 );
301 $emailer->send();
302 $emailer->reset();
303
304 $template->assign_vars(array(
305 'META' => '<meta http-equiv="refresh" content="3;url=' . append_sid("index.$phpEx") . '">')
306 );
307
308 $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>');
309
310 message_die(GENERAL_MESSAGE, $message);
311 }
312 else if ( isset($HTTP_POST_VARS['unsub']) || isset($HTTP_POST_VARS['unsubpending']) && $group_id )
313 {
314 //
315 // Second, unsubscribing from a group
316 rizwank 1.1 // Check for confirmation of unsub.
317 //
318 if ( $cancel )
319 {
320 redirect(append_sid("groupcp.$phpEx", true));
321 }
322 elseif ( !$userdata['session_logged_in'] )
323 {
324 redirect(append_sid("login.$phpEx?redirect=groupcp.$phpEx&" . POST_GROUPS_URL . "=$group_id", true));
325 }
326
327 if (!isset($HTTP_POST_VARS['sid']) || $HTTP_POST_VARS['sid'] != $userdata['session_id'])
328 {
329 message_die(GENERAL_ERROR, 'Invalid_session');
330 }
331
332 if ( $confirm )
333 {
334 $sql = "DELETE FROM " . USER_GROUP_TABLE . "
335 WHERE user_id = " . $userdata['user_id'] . "
336 AND group_id = $group_id";
337 rizwank 1.1 if ( !($result = $db->sql_query($sql)) )
338 {
339 message_die(GENERAL_ERROR, 'Could not delete group memebership data', '', __LINE__, __FILE__, $sql);
340 }
341
342 if ( $userdata['user_level'] != ADMIN && $userdata['user_level'] == MOD )
343 {
344 $sql = "SELECT COUNT(auth_mod) AS is_auth_mod
345 FROM " . AUTH_ACCESS_TABLE . " aa, " . USER_GROUP_TABLE . " ug
346 WHERE ug.user_id = " . $userdata['user_id'] . "
347 AND aa.group_id = ug.group_id
348 AND aa.auth_mod = 1";
349 if ( !($result = $db->sql_query($sql)) )
350 {
351 message_die(GENERAL_ERROR, 'Could not obtain moderator status', '', __LINE__, __FILE__, $sql);
352 }
353
354 if ( !($row = $db->sql_fetchrow($result)) )
355 {
356 $sql = "UPDATE " . USERS_TABLE . "
357 SET user_level = " . USER . "
358 rizwank 1.1 WHERE user_id = " . $userdata['user_id'];
359 if ( !($result = $db->sql_query($sql)) )
360 {
361 message_die(GENERAL_ERROR, 'Could not update user level', '', __LINE__, __FILE__, $sql);
362 }
363 }
364 }
365
366 $template->assign_vars(array(
367 'META' => '<meta http-equiv="refresh" content="3;url=' . append_sid("index.$phpEx") . '">')
368 );
369
370 $message = $lang['Usub_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>');
371
372 message_die(GENERAL_MESSAGE, $message);
373 }
374 else
375 {
376 $unsub_msg = ( isset($HTTP_POST_VARS['unsub']) ) ? $lang['Confirm_unsub'] : $lang['Confirm_unsub_pending'];
377
378 $s_hidden_fields = '<input type="hidden" name="sid" value="' . $userdata['session_id'] . '" /><input type="hidden" name="' . POST_GROUPS_URL . '" value="' . $group_id . '" /><input type="hidden" name="unsub" value="1" />';
379 rizwank 1.1
380 $page_title = $lang['Group_Control_Panel'];
381 include($phpbb_root_path . 'includes/page_header.'.$phpEx);
382
383 $template->set_filenames(array(
384 'confirm' => 'confirm_body.tpl')
385 );
386
387 $template->assign_vars(array(
388 'MESSAGE_TITLE' => $lang['Confirm'],
389 'MESSAGE_TEXT' => $unsub_msg,
390 'L_YES' => $lang['Yes'],
391 'L_NO' => $lang['No'],
392 'S_CONFIRM_ACTION' => append_sid("groupcp.$phpEx"),
393 'S_HIDDEN_FIELDS' => $s_hidden_fields)
394 );
395
396 $template->pparse('confirm');
397
398 include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
399 }
400 rizwank 1.1
401 }
402 else if ( $group_id )
403 {
404 //
405 // Did the group moderator get here through an email?
406 // If so, check to see if they are logged in.
407 //
408 if ( isset($HTTP_GET_VARS['validate']) )
409 {
410 if ( !$userdata['session_logged_in'] )
411 {
412 redirect(append_sid("login.$phpEx?redirect=groupcp.$phpEx&" . POST_GROUPS_URL . "=$group_id", true));
413 }
414 }
415
416 //
417 // For security, get the ID of the group moderator.
418 //
419 switch(SQL_LAYER)
420 {
421 rizwank 1.1 case 'postgresql':
422 $sql = "SELECT g.group_moderator, g.group_type, aa.auth_mod
423 FROM " . GROUPS_TABLE . " g, " . AUTH_ACCESS_TABLE . " aa
424 WHERE g.group_id = $group_id
425 AND aa.group_id = g.group_id
426 UNION (
427 SELECT g.group_moderator, g.group_type, NULL
428 FROM " . GROUPS_TABLE . " g
429 WHERE g.group_id = $group_id
430 AND NOT EXISTS (
431 SELECT aa.group_id
432 FROM " . AUTH_ACCESS_TABLE . " aa
433 WHERE aa.group_id = g.group_id
434 )
435 )";
436 break;
437
438 case 'oracle':
439 $sql = "SELECT g.group_moderator, g.group_type, aa.auth_mod
440 FROM " . GROUPS_TABLE . " g, " . AUTH_ACCESS_TABLE . " aa
441 WHERE g.group_id = $group_id
442 rizwank 1.1 AND aa.group_id = g.group_id(+)";
443 break;
444
445 default:
446 $sql = "SELECT g.group_moderator, g.group_type, aa.auth_mod
447 FROM ( " . GROUPS_TABLE . " g
448 LEFT JOIN " . AUTH_ACCESS_TABLE . " aa ON aa.group_id = g.group_id )
449 WHERE g.group_id = $group_id";
450 break;
451 }
452 if ( !($result = $db->sql_query($sql)) )
453 {
454 message_die(GENERAL_ERROR, 'Could not get moderator information', '', __LINE__, __FILE__, $sql);
455 }
456
457 if ( $group_info = $db->sql_fetchrow($result) )
458 {
459 $group_moderator = $group_info['group_moderator'];
460
461 if ( $group_moderator == $userdata['user_id'] || $userdata['user_level'] == ADMIN )
462 {
463 rizwank 1.1 $is_moderator = TRUE;
464 }
465
466 //
467 // Handle Additions, removals, approvals and denials
468 //
469 if ( !empty($HTTP_POST_VARS['add']) || !empty($HTTP_POST_VARS['remove']) || isset($HTTP_POST_VARS['approve']) || isset($HTTP_POST_VARS['deny']) )
470 {
471 if ( !$userdata['session_logged_in'] )
472 {
473 redirect(append_sid("login.$phpEx?redirect=groupcp.$phpEx&" . POST_GROUPS_URL . "=$group_id", true));
474 }
475
476 if (!isset($HTTP_POST_VARS['sid']) || $HTTP_POST_VARS['sid'] != $userdata['session_id'])
477 {
478 message_die(GENERAL_ERROR, 'Invalid_session');
479 }
480
481 if ( !$is_moderator )
482 {
483 $template->assign_vars(array(
484 rizwank 1.1 'META' => '<meta http-equiv="refresh" content="3;url=' . append_sid("index.$phpEx") . '">')
485 );
486
487 $message = $lang['Not_group_moderator'] . '<br /><br />' . sprintf($lang['Click_return_index'], '<a href="' . append_sid("index.$phpEx") . '">', '</a>');
488
489 message_die(GENERAL_MESSAGE, $message);
490 }
491
492 if ( isset($HTTP_POST_VARS['add']) )
493 {
494 $username = ( isset($HTTP_POST_VARS['username']) ) ? $HTTP_POST_VARS['username'] : "";
495
496 $sql = "SELECT user_id, user_email, user_lang, user_level
497 FROM " . USERS_TABLE . "
498 WHERE username = '" . str_replace("\'", "''", $username) . "'";
499 if ( !($result = $db->sql_query($sql)) )
500 {
501 message_die(GENERAL_ERROR, "Could not get user information", $lang['Error'], __LINE__, __FILE__, $sql);
502 }
503
504 if ( !($row = $db->sql_fetchrow($result)) )
505 rizwank 1.1 {
506 $template->assign_vars(array(
507 'META' => '<meta http-equiv="refresh" content="3;url=' . append_sid("groupcp.$phpEx?" . POST_GROUPS_URL . "=$group_id") . '">')
508 );
509
510 $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>");
511
512 message_die(GENERAL_MESSAGE, $message);
513 }
514
515 if ( $row['user_id'] == ANONYMOUS )
516 {
517 $template->assign_vars(array(
518 'META' => '<meta http-equiv="refresh" content="3;url=' . append_sid("groupcp.$phpEx?" . POST_GROUPS_URL . "=$group_id") . '">')
519 );
520
521 $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>');
522
523 message_die(GENERAL_MESSAGE, $message);
524 }
525
526 rizwank 1.1 $sql = "SELECT ug.user_id, u.user_level
527 FROM " . USER_GROUP_TABLE . " ug, " . USERS_TABLE . " u
528 WHERE u.user_id = " . $row['user_id'] . "
529 AND ug.user_id = u.user_id
530 AND ug.group_id = $group_id";
531 if ( !($result = $db->sql_query($sql)) )
532 {
533 message_die(GENERAL_ERROR, 'Could not get user information', '', __LINE__, __FILE__, $sql);
534 }
535
536 if ( !($db->sql_fetchrow($result)) )
537 {
538 $sql = "INSERT INTO " . USER_GROUP_TABLE . " (user_id, group_id, user_pending)
539 VALUES (" . $row['user_id'] . ", $group_id, 0)";
540 if ( !$db->sql_query($sql) )
541 {
542 message_die(GENERAL_ERROR, 'Could not add user to group', '', __LINE__, __FILE__, $sql);
543 }
544
545 if ( $row['user_level'] != ADMIN && $row['user_level'] != MOD && $group_info['auth_mod'] )
546 {
547 rizwank 1.1 $sql = "UPDATE " . USERS_TABLE . "
548 SET user_level = " . MOD . "
549 WHERE user_id = " . $row['user_id'];
550 if ( !$db->sql_query($sql) )
551 {
552 message_die(GENERAL_ERROR, 'Could not update user level', '', __LINE__, __FILE__, $sql);
553 }
554 }
555
556 //
557 // Get the group name
558 // Email the user and tell them they're in the group
559 //
560 $group_sql = "SELECT group_name
561 FROM " . GROUPS_TABLE . "
562 WHERE group_id = $group_id";
563 if ( !($result = $db->sql_query($group_sql)) )
564 {
565 message_die(GENERAL_ERROR, 'Could not get group information', '', __LINE__, __FILE__, $group_sql);
566 }
567
568 rizwank 1.1 $group_name_row = $db->sql_fetchrow($result);
569
570 $group_name = $group_name_row['group_name'];
571
572 include($phpbb_root_path . 'includes/emailer.'.$phpEx);
573 $emailer = new emailer($board_config['smtp_delivery']);
574
575 $email_headers = 'From: ' . $board_config['board_email'] . "\nReturn-Path: " . $board_config['board_email'] . "\n";
576
577 $emailer->use_template('group_added', $row['user_lang']);
578 $emailer->email_address($row['user_email']);
579 $emailer->set_subject($lang['Group_added']);
580 $emailer->extra_headers($email_headers);
581
582 $emailer->assign_vars(array(
583 'SITENAME' => $board_config['sitename'],
584 'GROUP_NAME' => $group_name,
585 'EMAIL_SIG' => (!empty($board_config['board_email_sig'])) ? str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']) : '',
586
587 'U_GROUPCP' => $server_url . '?' . POST_GROUPS_URL . "=$group_id")
588 );
589 rizwank 1.1 $emailer->send();
590 $emailer->reset();
591 }
592 else
593 {
594 $template->assign_vars(array(
595 'META' => '<meta http-equiv="refresh" content="3;url=' . append_sid("groupcp.$phpEx?" . POST_GROUPS_URL . "=$group_id") . '">')
596 );
597
598 $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>');
599
600 message_die(GENERAL_MESSAGE, $message);
601 }
602 }
603 else
604 {
605 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']) ) )
606 {
607
608 $members = ( isset($HTTP_POST_VARS['approve']) || isset($HTTP_POST_VARS['deny']) ) ? $HTTP_POST_VARS['pending_members'] : $HTTP_POST_VARS['members'];
609
610 rizwank 1.1 $sql_in = '';
611 for($i = 0; $i < count($members); $i++)
612 {
613 $sql_in .= ( ( $sql_in != '' ) ? ', ' : '' ) . $members[$i];
614 }
615
616 if ( isset($HTTP_POST_VARS['approve']) )
617 {
618 if ( $group_info['auth_mod'] )
619 {
620 $sql = "UPDATE " . USERS_TABLE . "
621 SET user_level = " . MOD . "
622 WHERE user_id IN ($sql_in)
623 AND user_level NOT IN (" . MOD . ", " . ADMIN . ")";
624 if ( !$db->sql_query($sql) )
625 {
626 message_die(GENERAL_ERROR, 'Could not update user level', '', __LINE__, __FILE__, $sql);
627 }
628 }
629
630 $sql = "UPDATE " . USER_GROUP_TABLE . "
631 rizwank 1.1 SET user_pending = 0
632 WHERE user_id IN ($sql_in)
633 AND group_id = $group_id";
634 $sql_select = "SELECT user_email
635 FROM ". USERS_TABLE . "
636 WHERE user_id IN ($sql_in)";
637 }
638 else if ( isset($HTTP_POST_VARS['deny']) || isset($HTTP_POST_VARS['remove']) )
639 {
640 if ( $group_info['auth_mod'] )
641 {
642 $sql = "SELECT ug.user_id, ug.group_id
643 FROM " . AUTH_ACCESS_TABLE . " aa, " . USER_GROUP_TABLE . " ug
644 WHERE ug.user_id IN ($sql_in)
645 AND aa.group_id = ug.group_id
646 AND aa.auth_mod = 1
647 GROUP BY ug.user_id, ug.group_id
648 ORDER BY ug.user_id, ug.group_id";
649 if ( !($result = $db->sql_query($sql)) )
650 {
651 message_die(GENERAL_ERROR, 'Could not obtain moderator status', '', __LINE__, __FILE__, $sql);
652 rizwank 1.1 }
653
654 if ( $row = $db->sql_fetchrow($result) )
655 {
656 $group_check = array();
657 $remove_mod_sql = '';
658
659 do
660 {
661 $group_check[$row['user_id']][] = $row['group_id'];
662 }
663 while ( $row = $db->sql_fetchrow($result) );
664
665 while( list($user_id, $group_list) = @each($group_check) )
666 {
667 if ( count($group_list) == 1 )
668 {
669 $remove_mod_sql .= ( ( $remove_mod_sql != '' ) ? ', ' : '' ) . $user_id;
670 }
671 }
672
673 rizwank 1.1 if ( $remove_mod_sql != '' )
674 {
675 $sql = "UPDATE " . USERS_TABLE . "
676 SET user_level = " . USER . "
677 WHERE user_id IN ($remove_mod_sql)
678 AND user_level NOT IN (" . ADMIN . ")";
679 if ( !$db->sql_query($sql) )
680 {
681 message_die(GENERAL_ERROR, 'Could not update user level', '', __LINE__, __FILE__, $sql);
682 }
683 }
684 }
685 }
686
687 $sql = "DELETE FROM " . USER_GROUP_TABLE . "
688 WHERE user_id IN ($sql_in)
689 AND group_id = $group_id";
690 }
691
692 if ( !$db->sql_query($sql) )
693 {
694 rizwank 1.1 message_die(GENERAL_ERROR, 'Could not update user group table', '', __LINE__, __FILE__, $sql);
695 }
696
697 //
698 // Email users when they are approved
699 //
700 if ( isset($HTTP_POST_VARS['approve']) )
701 {
702 if ( !($result = $db->sql_query($sql_select)) )
703 {
704 message_die(GENERAL_ERROR, 'Could not get user email information', '', __LINE__, __FILE__, $sql);
705 }
706
707 $email_addresses = '';
708 while( $row = $db->sql_fetchrow($result) )
709 {
710 $email_addresses .= ( ( $email_addresses != '' ) ? ', ' : '' ) . $row['user_email'];
711 }
712
713 //
714 // Get the group name
715 rizwank 1.1 //
716 $group_sql = "SELECT group_name
717 FROM " . GROUPS_TABLE . "
718 WHERE group_id = $group_id";
719 if ( !($result = $db->sql_query($group_sql)) )
720 {
721 message_die(GENERAL_ERROR, 'Could not get group information', '', __LINE__, __FILE__, $group_sql);
722 }
723
724 $group_name_row = $db->sql_fetchrow($result);
725 $group_name = $group_name_row['group_name'];
726
727 include($phpbb_root_path . 'includes/emailer.'.$phpEx);
728 $emailer = new emailer($board_config['smtp_delivery']);
729
730 $email_headers = 'From: ' . $board_config['board_email'] . "\nReturn-Path: " . $board_config['board_email'] . "\nBcc: " . $email_addresses . "\n";
731
732 $emailer->use_template('group_approved');
733 $emailer->email_address(' ');//$userdata['user_email']
734 $emailer->set_subject($lang['Group_approved']);
735 $emailer->extra_headers($email_headers);
736 rizwank 1.1
737 $emailer->assign_vars(array(
738 'SITENAME' => $board_config['sitename'],
739 'GROUP_NAME' => $group_name,
740 'EMAIL_SIG' => (!empty($board_config['board_email_sig'])) ? str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']) : '',
741
742 'U_GROUPCP' => $server_url . '?' . POST_GROUPS_URL . "=$group_id")
743 );
744 $emailer->send();
745 $emailer->reset();
746 }
747 }
748 }
749 }
750 //
751 // END approve or deny
752 //
753 }
754 else
755 {
756 message_die(GENERAL_MESSAGE, $lang['No_groups_exist']);
757 rizwank 1.1 }
758
759 //
760 // Get group details
761 //
762 $sql = "SELECT *
763 FROM " . GROUPS_TABLE . "
764 WHERE group_id = $group_id
765 AND group_single_user = 0";
766 if ( !($result = $db->sql_query($sql)) )
767 {
768 message_die(GENERAL_ERROR, 'Error getting group information', '', __LINE__, __FILE__, $sql);
769 }
770
771 if ( !($group_info = $db->sql_fetchrow($result)) )
772 {
773 message_die(GENERAL_MESSAGE, $lang['Group_not_exist']);
774 }
775
776 //
777 // Get moderator details for this group
778 rizwank 1.1 //
779 $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
780 FROM " . USERS_TABLE . "
781 WHERE user_id = " . $group_info['group_moderator'];
782 if ( !($result = $db->sql_query($sql)) )
783 {
784 message_die(GENERAL_ERROR, 'Error getting user list for group', '', __LINE__, __FILE__, $sql);
785 }
786
787 $group_moderator = $db->sql_fetchrow($result);
788
789 //
790 // Get user information for this group
791 //
792 $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
793 FROM " . USERS_TABLE . " u, " . USER_GROUP_TABLE . " ug
794 WHERE ug.group_id = $group_id
795 AND u.user_id = ug.user_id
796 AND ug.user_pending = 0
797 AND ug.user_id <> " . $group_moderator['user_id'] . "
798 ORDER BY u.username";
799 rizwank 1.1 if ( !($result = $db->sql_query($sql)) )
800 {
801 message_die(GENERAL_ERROR, 'Error getting user list for group', '', __LINE__, __FILE__, $sql);
802 }
803
804 $group_members = $db->sql_fetchrowset($result);
805 $members_count = count($group_members);
806 $db->sql_freeresult($result);
807
808 $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
809 FROM " . GROUPS_TABLE . " g, " . USER_GROUP_TABLE . " ug, " . USERS_TABLE . " u
810 WHERE ug.group_id = $group_id
811 AND g.group_id = ug.group_id
812 AND ug.user_pending = 1
813 AND u.user_id = ug.user_id
814 ORDER BY u.username";
815 if ( !($result = $db->sql_query($sql)) )
816 {
817 message_die(GENERAL_ERROR, 'Error getting user pending information', '', __LINE__, __FILE__, $sql);
818 }
819
820 rizwank 1.1 $modgroup_pending_list = $db->sql_fetchrowset($result);
821 $modgroup_pending_count = count($modgroup_pending_list);
822 $db->sql_freeresult($result);
823
824 $is_group_member = 0;
825 if ( $members_count )
826 {
827 for($i = 0; $i < $members_count; $i++)
828 {
829 if ( $group_members[$i]['user_id'] == $userdata['user_id'] && $userdata['session_logged_in'] )
830 {
831 $is_group_member = TRUE;
832 }
833 }
834 }
835
836 $is_group_pending_member = 0;
837 if ( $modgroup_pending_count )
838 {
839 for($i = 0; $i < $modgroup_pending_count; $i++)
840 {
841 rizwank 1.1 if ( $modgroup_pending_list[$i]['user_id'] == $userdata['user_id'] && $userdata['session_logged_in'] )
842 {
843 $is_group_pending_member = TRUE;
844 }
845 }
846 }
847
848 if ( $userdata['user_level'] == ADMIN )
849 {
850 $is_moderator = TRUE;
851 }
852
853 if ( $userdata['user_id'] == $group_info['group_moderator'] )
854 {
855 $is_moderator = TRUE;
856
857 $group_details = $lang['Are_group_moderator'];
858
859 $s_hidden_fields = '<input type="hidden" name="' . POST_GROUPS_URL . '" value="' . $group_id . '" />';
860 }
861 else if ( $is_group_member || $is_group_pending_member )
862 rizwank 1.1 {
863 $template->assign_block_vars('switch_unsubscribe_group_input', array());
864
865 $group_details = ( $is_group_pending_member ) ? $lang['Pending_this_group'] : $lang['Member_this_group'];
866
867 $s_hidden_fields = '<input type="hidden" name="' . POST_GROUPS_URL . '" value="' . $group_id . '" />';
868 }
869 else if ( $userdata['user_id'] == ANONYMOUS )
870 {
871 $group_details = $lang['Login_to_join'];
872 $s_hidden_fields = '';
873 }
874 else
875 {
876 if ( $group_info['group_type'] == GROUP_OPEN )
877 {
878 $template->assign_block_vars('switch_subscribe_group_input', array());
879
880 $group_details = $lang['This_open_group'];
881 $s_hidden_fields = '<input type="hidden" name="' . POST_GROUPS_URL . '" value="' . $group_id . '" />';
882 }
883 rizwank 1.1 else if ( $group_info['group_type'] == GROUP_CLOSED )
884 {
885 $group_details = $lang['This_closed_group'];
886 $s_hidden_fields = '';
887 }
888 else if ( $group_info['group_type'] == GROUP_HIDDEN )
889 {
890 $group_details = $lang['This_hidden_group'];
891 $s_hidden_fields = '';
892 }
893 }
894
895 $page_title = $lang['Group_Control_Panel'];
896 include($phpbb_root_path . 'includes/page_header.'.$phpEx);
897
898 //
899 // Load templates
900 //
901 $template->set_filenames(array(
902 'info' => 'groupcp_info_body.tpl',
903 'pendinginfo' => 'groupcp_pending_info.tpl')
904 rizwank 1.1 );
905 make_jumpbox('viewforum.'.$phpEx);
906
907 //
908 // Add the moderator
909 //
910 $username = $group_moderator['username'];
911 $user_id = $group_moderator['user_id'];
912
913 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);
914
915 $s_hidden_fields .= '<input type="hidden" name="sid" value="' . $userdata['session_id'] . '" />';
916
917 $template->assign_vars(array(
918 'L_GROUP_INFORMATION' => $lang['Group_Information'],
919 'L_GROUP_NAME' => $lang['Group_name'],
920 'L_GROUP_DESC' => $lang['Group_description'],
921 'L_GROUP_TYPE' => $lang['Group_type'],
922 'L_GROUP_MEMBERSHIP' => $lang['Group_membership'],
923 'L_SUBSCRIBE' => $lang['Subscribe'],
924 'L_UNSUBSCRIBE' => $lang['Unsubscribe'],
925 rizwank 1.1 'L_JOIN_GROUP' => $lang['Join_group'],
926 'L_UNSUBSCRIBE_GROUP' => $lang['Unsubscribe'],
927 'L_GROUP_OPEN' => $lang['Group_open'],
928 'L_GROUP_CLOSED' => $lang['Group_closed'],
929 'L_GROUP_HIDDEN' => $lang['Group_hidden'],
930 'L_UPDATE' => $lang['Update'],
931 'L_GROUP_MODERATOR' => $lang['Group_Moderator'],
932 'L_GROUP_MEMBERS' => $lang['Group_Members'],
933 'L_PENDING_MEMBERS' => $lang['Pending_members'],
934 'L_SELECT_SORT_METHOD' => $lang['Select_sort_method'],
935 'L_PM' => $lang['Private_Message'],
936 'L_EMAIL' => $lang['Email'],
937 'L_POSTS' => $lang['Posts'],
938 'L_WEBSITE' => $lang['Website'],
939 'L_FROM' => $lang['Location'],
940 'L_ORDER' => $lang['Order'],
941 'L_SORT' => $lang['Sort'],
942 'L_SUBMIT' => $lang['Sort'],
943 'L_AIM' => $lang['AIM'],
944 'L_YIM' => $lang['YIM'],
945 'L_MSNM' => $lang['MSNM'],
946 rizwank 1.1 'L_ICQ' => $lang['ICQ'],
947 'L_SELECT' => $lang['Select'],
948 'L_REMOVE_SELECTED' => $lang['Remove_selected'],
949 'L_ADD_MEMBER' => $lang['Add_member'],
950 'L_FIND_USERNAME' => $lang['Find_username'],
951
952 'GROUP_NAME' => $group_info['group_name'],
953 'GROUP_DESC' => $group_info['group_description'],
954 'GROUP_DETAILS' => $group_details,
955 'MOD_ROW_COLOR' => '#' . $theme['td_color1'],
956 'MOD_ROW_CLASS' => $theme['td_class1'],
957 'MOD_USERNAME' => $username,
958 'MOD_FROM' => $from,
959 'MOD_JOINED' => $joined,
960 'MOD_POSTS' => $posts,
961 'MOD_AVATAR_IMG' => $poster_avatar,
962 'MOD_PROFILE_IMG' => $profile_img,
963 'MOD_PROFILE' => $profile,
964 'MOD_SEARCH_IMG' => $search_img,
965 'MOD_SEARCH' => $search,
966 'MOD_PM_IMG' => $pm_img,
967 rizwank 1.1 'MOD_PM' => $pm,
968 'MOD_EMAIL_IMG' => $email_img,
969 'MOD_EMAIL' => $email,
970 'MOD_WWW_IMG' => $www_img,
971 'MOD_WWW' => $www,
972 'MOD_ICQ_STATUS_IMG' => $icq_status_img,
973 'MOD_ICQ_IMG' => $icq_img,
974 'MOD_ICQ' => $icq,
975 'MOD_AIM_IMG' => $aim_img,
976 'MOD_AIM' => $aim,
977 'MOD_MSN_IMG' => $msn_img,
978 'MOD_MSN' => $msn,
979 'MOD_YIM_IMG' => $yim_img,
980 'MOD_YIM' => $yim,
981
982 'U_MOD_VIEWPROFILE' => append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=$user_id"),
983 'U_SEARCH_USER' => append_sid("search.$phpEx?mode=searchuser"),
984
985 'S_GROUP_OPEN_TYPE' => GROUP_OPEN,
986 'S_GROUP_CLOSED_TYPE' => GROUP_CLOSED,
987 'S_GROUP_HIDDEN_TYPE' => GROUP_HIDDEN,
988 rizwank 1.1 'S_GROUP_OPEN_CHECKED' => ( $group_info['group_type'] == GROUP_OPEN ) ? ' checked="checked"' : '',
989 'S_GROUP_CLOSED_CHECKED' => ( $group_info['group_type'] == GROUP_CLOSED ) ? ' checked="checked"' : '',
990 'S_GROUP_HIDDEN_CHECKED' => ( $group_info['group_type'] == GROUP_HIDDEN ) ? ' checked="checked"' : '',
991 'S_HIDDEN_FIELDS' => $s_hidden_fields,
992 'S_MODE_SELECT' => $select_sort_mode,
993 'S_ORDER_SELECT' => $select_sort_order,
994 'S_GROUPCP_ACTION' => append_sid("groupcp.$phpEx?" . POST_GROUPS_URL . "=$group_id"))
995 );
996
997 //
998 // Dump out the remaining users
999 //
1000 for($i = $start; $i < min($board_config['topics_per_page'] + $start, $members_count); $i++)
1001 {
1002 $username = $group_members[$i]['username'];
1003 $user_id = $group_members[$i]['user_id'];
1004
1005 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);
1006
1007 if ( $group_info['group_type'] != GROUP_HIDDEN || $is_group_member || $is_moderator )
1008 {
1009 rizwank 1.1 $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
1010 $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
1011
1012 $template->assign_block_vars('member_row', array(
1013 'ROW_COLOR' => '#' . $row_color,
1014 'ROW_CLASS' => $row_class,
1015 'USERNAME' => $username,
1016 'FROM' => $from,
1017 'JOINED' => $joined,
1018 'POSTS' => $posts,
1019 'USER_ID' => $user_id,
1020 'AVATAR_IMG' => $poster_avatar,
1021 'PROFILE_IMG' => $profile_img,
1022 'PROFILE' => $profile,
1023 'SEARCH_IMG' => $search_img,
1024 'SEARCH' => $search,
1025 'PM_IMG' => $pm_img,
1026 'PM' => $pm,
1027 'EMAIL_IMG' => $email_img,
1028 'EMAIL' => $email,
1029 'WWW_IMG' => $www_img,
1030 rizwank 1.1 'WWW' => $www,
1031 'ICQ_STATUS_IMG' => $icq_status_img,
1032 'ICQ_IMG' => $icq_img,
1033 'ICQ' => $icq,
1034 'AIM_IMG' => $aim_img,
1035 'AIM' => $aim,
1036 'MSN_IMG' => $msn_img,
1037 'MSN' => $msn,
1038 'YIM_IMG' => $yim_img,
1039 'YIM' => $yim,
1040
1041 'U_VIEWPROFILE' => append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=$user_id"))
1042 );
1043
1044 if ( $is_moderator )
1045 {
1046 $template->assign_block_vars('member_row.switch_mod_option', array());
1047 }
1048 }
1049 }
1050
1051 rizwank 1.1 if ( !$members_count )
1052 {
1053 //
1054 // No group members
1055 //
1056 $template->assign_block_vars('switch_no_members', array());
1057 $template->assign_vars(array(
1058 'L_NO_MEMBERS' => $lang['No_group_members'])
1059 );
1060 }
1061
1062 $current_page = ( !$members_count ) ? 1 : ceil( $members_count / $board_config['topics_per_page'] );
1063
1064 $template->assign_vars(array(
1065 'PAGINATION' => generate_pagination("groupcp.$phpEx?" . POST_GROUPS_URL . "=$group_id", $members_count, $board_config['topics_per_page'], $start),
1066 'PAGE_NUMBER' => sprintf($lang['Page_of'], ( floor( $start / $board_config['topics_per_page'] ) + 1 ), $current_page ),
1067
1068 'L_GOTO_PAGE' => $lang['Goto_page'])
1069 );
1070
1071 if ( $group_info['group_type'] == GROUP_HIDDEN && !$is_group_member && !$is_moderator )
1072 rizwank 1.1 {
1073 //
1074 // No group members
1075 //
1076 $template->assign_block_vars('switch_hidden_group', array());
1077 $template->assign_vars(array(
1078 'L_HIDDEN_MEMBERS' => $lang['Group_hidden_members'])
1079 );
1080 }
1081
1082 //
1083 // We've displayed the members who belong to the group, now we
1084 // do that pending memebers...
1085 //
1086 if ( $is_moderator )
1087 {
1088 //
1089 // Users pending in ONLY THIS GROUP (which is moderated by this user)
1090 //
1091 if ( $modgroup_pending_count )
1092 {
1093 rizwank 1.1 for($i = 0; $i < $modgroup_pending_count; $i++)
1094 {
1095 $username = $modgroup_pending_list[$i]['username'];
1096 $user_id = $modgroup_pending_list[$i]['user_id'];
1097
1098 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);
1099
1100 $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
1101 $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
1102
1103 $user_select = '<input type="checkbox" name="member[]" value="' . $user_id . '">';
1104
1105 $template->assign_block_vars('pending_members_row', array(
1106 'ROW_CLASS' => $row_class,
1107 'ROW_COLOR' => '#' . $row_color,
1108 'USERNAME' => $username,
1109 'FROM' => $from,
1110 'JOINED' => $joined,
1111 'POSTS' => $posts,
1112 'USER_ID' => $user_id,
1113 'AVATAR_IMG' => $poster_avatar,
1114 rizwank 1.1 'PROFILE_IMG' => $profile_img,
1115 'PROFILE' => $profile,
1116 'SEARCH_IMG' => $search_img,
1117 'SEARCH' => $search,
1118 'PM_IMG' => $pm_img,
1119 'PM' => $pm,
1120 'EMAIL_IMG' => $email_img,
1121 'EMAIL' => $email,
1122 'WWW_IMG' => $www_img,
1123 'WWW' => $www,
1124 'ICQ_STATUS_IMG' => $icq_status_img,
1125 'ICQ_IMG' => $icq_img,
1126 'ICQ' => $icq,
1127 'AIM_IMG' => $aim_img,
1128 'AIM' => $aim,
1129 'MSN_IMG' => $msn_img,
1130 'MSN' => $msn,
1131 'YIM_IMG' => $yim_img,
1132 'YIM' => $yim,
1133
1134 'U_VIEWPROFILE' => append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=$user_id"))
1135 rizwank 1.1 );
1136 }
1137
1138 $template->assign_block_vars('switch_pending_members', array() );
1139
1140 $template->assign_vars(array(
1141 'L_SELECT' => $lang['Select'],
1142 'L_APPROVE_SELECTED' => $lang['Approve_selected'],
1143 'L_DENY_SELECTED' => $lang['Deny_selected'])
1144 );
1145
1146 $template->assign_var_from_handle('PENDING_USER_BOX', 'pendinginfo');
1147
1148 }
1149 }
1150
1151 if ( $is_moderator )
1152 {
1153 $template->assign_block_vars('switch_mod_option', array());
1154 $template->assign_block_vars('switch_add_member', array());
1155 }
1156 rizwank 1.1
1157 $template->pparse('info');
1158 }
1159 else
1160 {
1161 //
1162 // Show the main groupcp.php screen where the user can select a group.
1163 //
1164 // Select all group that the user is a member of or where the user has
1165 // a pending membership.
1166 //
1167 if ( $userdata['session_logged_in'] )
1168 {
1169 $sql = "SELECT g.group_id, g.group_name, g.group_type, ug.user_pending
1170 FROM " . GROUPS_TABLE . " g, " . USER_GROUP_TABLE . " ug
1171 WHERE ug.user_id = " . $userdata['user_id'] . "
1172 AND ug.group_id = g.group_id
1173 AND g.group_single_user <> " . TRUE . "
1174 ORDER BY g.group_name, ug.user_id";
1175 if ( !($result = $db->sql_query($sql)) )
1176 {
1177 rizwank 1.1 message_die(GENERAL_ERROR, 'Error getting group information', '', __LINE__, __FILE__, $sql);
1178 }
1179
1180 if ( $row = $db->sql_fetchrow($result) )
1181 {
1182 $in_group = array();
1183 $s_member_groups_opt = '';
1184 $s_pending_groups_opt = '';
1185
1186 do
1187 {
1188 $in_group[] = $row['group_id'];
1189 if ( $row['user_pending'] )
1190 {
1191 $s_pending_groups_opt .= '<option value="' . $row['group_id'] . '">' . $row['group_name'] . '</option>';
1192 }
1193 else
1194 {
1195 $s_member_groups_opt .= '<option value="' . $row['group_id'] . '">' . $row['group_name'] . '</option>';
1196 }
1197 }
1198 rizwank 1.1 while( $row = $db->sql_fetchrow($result) );
1199
1200 $s_pending_groups = '<select name="' . POST_GROUPS_URL . '">' . $s_pending_groups_opt . "</select>";
1201 $s_member_groups = '<select name="' . POST_GROUPS_URL . '">' . $s_member_groups_opt . "</select>";
1202 }
1203 }
1204
1205 //
1206 // Select all other groups i.e. groups that this user is not a member of
1207 //
1208 $ignore_group_sql = ( count($in_group) ) ? "AND group_id NOT IN (" . implode(', ', $in_group) . ")" : '';
1209 $sql = "SELECT group_id, group_name, group_type
1210 FROM " . GROUPS_TABLE . " g
1211 WHERE group_single_user <> " . TRUE . "
1212 $ignore_group_sql
1213 ORDER BY g.group_name";
1214 if ( !($result = $db->sql_query($sql)) )
1215 {
1216 message_die(GENERAL_ERROR, 'Error getting group information', '', __LINE__, __FILE__, $sql);
1217 }
1218
1219 rizwank 1.1 $s_group_list_opt = '';
1220 while( $row = $db->sql_fetchrow($result) )
1221 {
1222 if ( $row['group_type'] != GROUP_HIDDEN || $userdata['user_level'] == ADMIN )
1223 {
1224 $s_group_list_opt .='<option value="' . $row['group_id'] . '">' . $row['group_name'] . '</option>';
1225 }
1226 }
1227 $s_group_list = '<select name="' . POST_GROUPS_URL . '">' . $s_group_list_opt . '</select>';
1228
1229 if ( $s_group_list_opt != '' || $s_pending_groups_opt != '' || $s_member_groups_opt != '' )
1230 {
1231 //
1232 // Load and process templates
1233 //
1234 include($phpbb_root_path . 'includes/page_header.'.$phpEx);
1235
1236 $template->set_filenames(array(
1237 'user' => 'groupcp_user_body.tpl')
1238 );
1239 make_jumpbox('viewforum.'.$phpEx);
1240 rizwank 1.1
1241 if ( $s_pending_groups_opt != '' || $s_member_groups_opt != '' )
1242 {
1243 $template->assign_block_vars('switch_groups_joined', array() );
1244 }
1245
1246 if ( $s_member_groups_opt != '' )
1247 {
1248 $template->assign_block_vars('switch_groups_joined.switch_groups_member', array() );
1249 }
1250
1251 if ( $s_pending_groups_opt != '' )
1252 {
1253 $template->assign_block_vars('switch_groups_joined.switch_groups_pending', array() );
1254 }
1255
1256 if ( $s_group_list_opt != '' )
1257 {
1258 $template->assign_block_vars('switch_groups_remaining', array() );
1259 }
1260
1261 rizwank 1.1 $s_hidden_fields = '<input type="hidden" name="sid" value="' . $userdata['session_id'] . '" />';
1262
1263 $template->assign_vars(array(
1264 'L_GROUP_MEMBERSHIP_DETAILS' => $lang['Group_member_details'],
1265 'L_JOIN_A_GROUP' => $lang['Group_member_join'],
1266 'L_YOU_BELONG_GROUPS' => $lang['Current_memberships'],
1267 'L_SELECT_A_GROUP' => $lang['Non_member_groups'],
1268 'L_PENDING_GROUPS' => $lang['Memberships_pending'],
1269 'L_SUBSCRIBE' => $lang['Subscribe'],
1270 'L_UNSUBSCRIBE' => $lang['Unsubscribe'],
1271 'L_VIEW_INFORMATION' => $lang['View_Information'],
1272
1273 'S_USERGROUP_ACTION' => append_sid("groupcp.$phpEx"),
1274 'S_HIDDEN_FIELDS' => $s_hidden_fields,
1275
1276 'GROUP_LIST_SELECT' => $s_group_list,
1277 'GROUP_PENDING_SELECT' => $s_pending_groups,
1278 'GROUP_MEMBER_SELECT' => $s_member_groups)
1279 );
1280
1281 $template->pparse('user');
1282 rizwank 1.1 }
1283 else
1284 {
1285 message_die(GENERAL_MESSAGE, $lang['No_groups_exist']);
1286 }
1287
1288 }
1289
1290 include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
1291
1292 ?>
|