5
* @version $Id: ucp_groups.php,v 1.67 2007/10/05 14:36:33 acydburn Exp $
6
* @copyright (c) 2005 phpBB Group
7
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
14
if (!defined('IN_PHPBB'))
27
function main($id, $mode)
29
global $config, $phpbb_root_path, $phpEx;
30
global $db, $user, $auth, $cache, $template;
32
$user->add_lang('groups');
34
$return_page = '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $this->u_action . '">', '</a>');
36
$mark_ary = request_var('mark', array(0));
37
$submit = (!empty($_POST['submit'])) ? true : false;
38
$delete = (!empty($_POST['delete'])) ? true : false;
39
$error = $data = array();
45
$this->page_title = 'UCP_USERGROUPS_MEMBER';
47
if ($submit || isset($_POST['change_default']))
49
$action = (isset($_POST['change_default'])) ? 'change_default' : request_var('action', '');
50
$group_id = ($action == 'change_default') ? request_var('default', 0) : request_var('selected', 0);
54
trigger_error('NO_GROUP_SELECTED');
57
$sql = 'SELECT group_id, group_name, group_type
58
FROM ' . GROUPS_TABLE . "
59
WHERE group_id IN ($group_id, {$user->data['group_id']})";
60
$result = $db->sql_query($sql);
63
while ($row = $db->sql_fetchrow($result))
65
$row['group_name'] = ($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name'];
66
$group_row[$row['group_id']] = $row;
68
$db->sql_freeresult($result);
70
if (!sizeof($group_row))
72
trigger_error('GROUP_NOT_EXIST');
77
case 'change_default':
78
// User already having this group set as default?
79
if ($group_id == $user->data['group_id'])
81
trigger_error($user->lang['ALREADY_DEFAULT_GROUP'] . $return_page);
84
if (!$auth->acl_get('u_chggrp'))
86
trigger_error($user->lang['NOT_AUTHORISED'] . $return_page);
89
// User needs to be member of the group in order to make it default
90
if (!group_memberships($group_id, $user->data['user_id'], true))
92
trigger_error($user->lang['NOT_MEMBER_OF_GROUP'] . $return_page);
95
if (confirm_box(true))
97
group_user_attributes('default', $group_id, $user->data['user_id']);
99
add_log('user', $user->data['user_id'], 'LOG_USER_GROUP_CHANGE', sprintf($user->lang['USER_GROUP_CHANGE'], $group_row[$user->data['group_id']]['group_name'], $group_row[$group_id]['group_name']));
101
meta_refresh(3, $this->u_action);
102
trigger_error($user->lang['CHANGED_DEFAULT_GROUP'] . $return_page);
106
$s_hidden_fields = array(
107
'default' => $group_id,
108
'change_default'=> true
111
confirm_box(false, sprintf($user->lang['GROUP_CHANGE_DEFAULT'], $group_row[$group_id]['group_name']), build_hidden_fields($s_hidden_fields));
118
// User tries to resign from default group but is not allowed to change it?
119
if ($group_id == $user->data['group_id'] && !$auth->acl_get('u_chggrp'))
121
trigger_error($user->lang['NOT_RESIGN_FROM_DEFAULT_GROUP'] . $return_page);
124
if (!($row = group_memberships($group_id, $user->data['user_id'])))
126
trigger_error($user->lang['NOT_MEMBER_OF_GROUP'] . $return_page);
128
list(, $row) = each($row);
130
if (confirm_box(true))
132
group_user_del($group_id, $user->data['user_id']);
134
add_log('user', $user->data['user_id'], 'LOG_USER_GROUP_RESIGN', $group_row[$group_id]['group_name']);
136
meta_refresh(3, $this->u_action);
137
trigger_error($user->lang[($row['user_pending']) ? 'GROUP_RESIGNED_PENDING' : 'GROUP_RESIGNED_MEMBERSHIP'] . $return_page);
141
$s_hidden_fields = array(
142
'selected' => $group_id,
143
'action' => 'resign',
147
confirm_box(false, ($row['user_pending']) ? 'GROUP_RESIGN_PENDING' : 'GROUP_RESIGN_MEMBERSHIP', build_hidden_fields($s_hidden_fields));
154
$sql = 'SELECT ug.*, u.username, u.username_clean, u.user_email
155
FROM ' . USER_GROUP_TABLE . ' ug, ' . USERS_TABLE . ' u
156
WHERE ug.user_id = u.user_id
157
AND ug.group_id = ' . $group_id . '
158
AND ug.user_id = ' . $user->data['user_id'];
159
$result = $db->sql_query($sql);
160
$row = $db->sql_fetchrow($result);
161
$db->sql_freeresult($result);
165
if ($row['user_pending'])
167
trigger_error($user->lang['ALREADY_IN_GROUP_PENDING'] . $return_page);
170
trigger_error($user->lang['ALREADY_IN_GROUP'] . $return_page);
173
// Check permission to join (open group or request)
174
if ($group_row[$group_id]['group_type'] != GROUP_OPEN && $group_row[$group_id]['group_type'] != GROUP_FREE)
176
trigger_error($user->lang['CANNOT_JOIN_GROUP'] . $return_page);
179
if (confirm_box(true))
181
if ($group_row[$group_id]['group_type'] == GROUP_FREE)
183
group_user_add($group_id, $user->data['user_id']);
185
$email_template = 'group_added';
189
group_user_add($group_id, $user->data['user_id'], false, false, false, 0, 1);
191
$email_template = 'group_request';
194
include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
195
$messenger = new messenger();
197
$sql = 'SELECT u.username, u.username_clean, u.user_email, u.user_notify_type, u.user_jabber, u.user_lang
198
FROM ' . USER_GROUP_TABLE . ' ug, ' . USERS_TABLE . ' u
199
WHERE ug.user_id = u.user_id
200
AND ' . (($group_row[$group_id]['group_type'] == GROUP_FREE) ? "ug.user_id = {$user->data['user_id']}" : 'ug.group_leader = 1') . "
201
AND ug.group_id = $group_id";
202
$result = $db->sql_query($sql);
204
while ($row = $db->sql_fetchrow($result))
206
$messenger->template($email_template, $row['user_lang']);
208
$messenger->to($row['user_email'], $row['username']);
209
$messenger->im($row['user_jabber'], $row['username']);
211
$messenger->assign_vars(array(
212
'USERNAME' => htmlspecialchars_decode($row['username']),
213
'GROUP_NAME' => htmlspecialchars_decode($group_row[$group_id]['group_name']),
215
'U_PENDING' => generate_board_url() . "/ucp.$phpEx?i=groups&mode=manage&action=list&g=$group_id",
216
'U_GROUP' => generate_board_url() . "/memberlist.$phpEx?mode=group&g=$group_id")
219
$messenger->send($row['user_notify_type']);
221
$db->sql_freeresult($result);
223
$messenger->save_queue();
225
add_log('user', $user->data['user_id'], 'LOG_USER_GROUP_JOIN' . (($group_row[$group_id]['group_type'] == GROUP_FREE) ? '' : '_PENDING'), $group_row[$group_id]['group_name']);
227
meta_refresh(3, $this->u_action);
228
trigger_error($user->lang[($group_row[$group_id]['group_type'] == GROUP_FREE) ? 'GROUP_JOINED' : 'GROUP_JOINED_PENDING'] . $return_page);
232
$s_hidden_fields = array(
233
'selected' => $group_id,
238
confirm_box(false, ($group_row[$group_id]['group_type'] == GROUP_FREE) ? 'GROUP_JOIN' : 'GROUP_JOIN_PENDING', build_hidden_fields($s_hidden_fields));
245
if (!($row = group_memberships($group_id, $user->data['user_id'])))
247
trigger_error($user->lang['NOT_MEMBER_OF_GROUP'] . $return_page);
249
list(, $row) = each($row);
251
if (!$row['group_leader'])
253
trigger_error($user->lang['NOT_LEADER_OF_GROUP'] . $return_page);
256
if (confirm_box(true))
258
group_user_attributes('demote', $group_id, $user->data['user_id']);
260
add_log('user', $user->data['user_id'], 'LOG_USER_GROUP_DEMOTE', $group_row[$group_id]['group_name']);
262
meta_refresh(3, $this->u_action);
263
trigger_error($user->lang['USER_GROUP_DEMOTED'] . $return_page);
267
$s_hidden_fields = array(
268
'selected' => $group_id,
269
'action' => 'demote',
273
confirm_box(false, 'USER_GROUP_DEMOTE', build_hidden_fields($s_hidden_fields));
280
$sql = 'SELECT g.*, ug.group_leader, ug.user_pending
281
FROM ' . GROUPS_TABLE . ' g, ' . USER_GROUP_TABLE . ' ug
282
WHERE ug.user_id = ' . $user->data['user_id'] . '
283
AND g.group_id = ug.group_id
284
ORDER BY g.group_type DESC, g.group_name';
285
$result = $db->sql_query($sql);
287
$group_id_ary = array();
288
$leader_count = $member_count = $pending_count = 0;
289
while ($row = $db->sql_fetchrow($result))
291
$block = ($row['group_leader']) ? 'leader' : (($row['user_pending']) ? 'pending' : 'member');
293
switch ($row['group_type'])
296
$group_status = 'OPEN';
300
$group_status = 'CLOSED';
304
$group_status = 'HIDDEN';
308
$group_status = 'SPECIAL';
312
$group_status = 'FREE';
316
$template->assign_block_vars($block, array(
317
'GROUP_ID' => $row['group_id'],
318
'GROUP_NAME' => ($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name'],
319
'GROUP_DESC' => ($row['group_type'] <> GROUP_SPECIAL) ? generate_text_for_display($row['group_desc'], $row['group_desc_uid'], $row['group_desc_bitfield'], $row['group_desc_options']) : $user->lang['GROUP_IS_SPECIAL'],
320
'GROUP_SPECIAL' => ($row['group_type'] <> GROUP_SPECIAL) ? false : true,
321
'GROUP_STATUS' => $user->lang['GROUP_IS_' . $group_status],
322
'GROUP_COLOUR' => $row['group_colour'],
324
'U_VIEW_GROUP' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&g=' . $row['group_id']),
326
'S_GROUP_DEFAULT' => ($row['group_id'] == $user->data['group_id']) ? true : false,
327
'S_ROW_COUNT' => ${$block . '_count'}++)
330
$group_id_ary[] = $row['group_id'];
332
$db->sql_freeresult($result);
334
// Hide hidden groups unless user is an admin with group privileges
335
$sql_and = ($auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel')) ? '<> ' . GROUP_SPECIAL : 'NOT IN (' . GROUP_SPECIAL . ', ' . GROUP_HIDDEN . ')';
337
$sql = 'SELECT group_id, group_name, group_colour, group_desc, group_desc_uid, group_desc_bitfield, group_desc_options, group_type, group_founder_manage
338
FROM ' . GROUPS_TABLE . '
339
WHERE ' . ((sizeof($group_id_ary)) ? $db->sql_in_set('group_id', $group_id_ary, true) . ' AND ' : '') . "
341
ORDER BY group_type DESC, group_name";
342
$result = $db->sql_query($sql);
344
$nonmember_count = 0;
345
while ($row = $db->sql_fetchrow($result))
347
switch ($row['group_type'])
350
$group_status = 'OPEN';
354
$group_status = 'CLOSED';
358
$group_status = 'HIDDEN';
362
$group_status = 'SPECIAL';
366
$group_status = 'FREE';
370
$template->assign_block_vars('nonmember', array(
371
'GROUP_ID' => $row['group_id'],
372
'GROUP_NAME' => ($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name'],
373
'GROUP_DESC' => ($row['group_type'] <> GROUP_SPECIAL) ? generate_text_for_display($row['group_desc'], $row['group_desc_uid'], $row['group_desc_bitfield'], $row['group_desc_options']) : $user->lang['GROUP_IS_SPECIAL'],
374
'GROUP_SPECIAL' => ($row['group_type'] <> GROUP_SPECIAL) ? false : true,
375
'GROUP_CLOSED' => ($row['group_type'] <> GROUP_CLOSED || $auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel')) ? false : true,
376
'GROUP_STATUS' => $user->lang['GROUP_IS_' . $group_status],
377
'S_CAN_JOIN' => ($row['group_type'] == GROUP_OPEN || $row['group_type'] == GROUP_FREE) ? true : false,
378
'GROUP_COLOUR' => $row['group_colour'],
380
'U_VIEW_GROUP' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&g=' . $row['group_id']),
382
'S_ROW_COUNT' => $nonmember_count++)
385
$db->sql_freeresult($result);
387
$template->assign_vars(array(
388
'S_CHANGE_DEFAULT' => ($auth->acl_get('u_chggrp')) ? true : false,
389
'S_LEADER_COUNT' => $leader_count,
390
'S_MEMBER_COUNT' => $member_count,
391
'S_PENDING_COUNT' => $pending_count,
392
'S_NONMEMBER_COUNT' => $nonmember_count,
394
'S_UCP_ACTION' => $this->u_action)
401
$this->page_title = 'UCP_USERGROUPS_MANAGE';
402
$action = (isset($_POST['addusers'])) ? 'addusers' : request_var('action', '');
403
$group_id = request_var('g', 0);
404
add_form_key('ucp_groups');
409
FROM ' . GROUPS_TABLE . "
410
WHERE group_id = $group_id";
411
$result = $db->sql_query($sql);
412
$group_row = $db->sql_fetchrow($result);
413
$db->sql_freeresult($result);
417
trigger_error($user->lang['NO_GROUP'] . $return_page);
420
// Check if the user is allowed to manage this group if set to founder only.
421
if ($user->data['user_type'] != USER_FOUNDER && $group_row['group_founder_manage'])
423
trigger_error($user->lang['NOT_ALLOWED_MANAGE_GROUP'] . $return_page, E_USER_WARNING);
431
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
435
trigger_error($user->lang['NO_GROUP'] . $return_page);
438
if (!($row = group_memberships($group_id, $user->data['user_id'])))
440
trigger_error($user->lang['NOT_MEMBER_OF_GROUP'] . $return_page);
442
list(, $row) = each($row);
444
if (!$row['group_leader'])
446
trigger_error($user->lang['NOT_LEADER_OF_GROUP'] . $return_page);
449
$file_uploads = (@ini_get('file_uploads') || strtolower(@ini_get('file_uploads')) == 'on') ? true : false;
450
$user->add_lang(array('acp/groups', 'acp/common'));
452
$data = $submit_ary = array();
454
$update = (isset($_POST['update'])) ? true : false;
458
$avatar_select = basename(request_var('avatar_select', ''));
459
$category = basename(request_var('category', ''));
461
$can_upload = (file_exists($phpbb_root_path . $config['avatar_path']) && @is_writable($phpbb_root_path . $config['avatar_path']) && $file_uploads) ? true : false;
466
$group_name = utf8_normalize_nfc(request_var('group_name', '', true));
467
$group_desc = utf8_normalize_nfc(request_var('group_desc', '', true));
468
$group_type = request_var('group_type', GROUP_FREE);
470
$allow_desc_bbcode = request_var('desc_parse_bbcode', false);
471
$allow_desc_urls = request_var('desc_parse_urls', false);
472
$allow_desc_smilies = request_var('desc_parse_smilies', false);
475
'colour' => request_var('group_colour', ''),
476
'rank' => request_var('group_rank', 0),
477
'receive_pm' => isset($_REQUEST['group_receive_pm']) ? 1 : 0,
478
'message_limit' => request_var('group_message_limit', 0)
481
$data['uploadurl'] = request_var('uploadurl', '');
482
$data['remotelink'] = request_var('remotelink', '');
483
$data['width'] = request_var('width', '');
484
$data['height'] = request_var('height', '');
485
$delete = request_var('delete', '');
487
if (!empty($_FILES['uploadfile']['tmp_name']) || $data['uploadurl'] || $data['remotelink'])
491
'uploadurl' => array('string', true, 5, 255),
492
'remotelink' => array('string', true, 5, 255),
493
'width' => array('string', true, 1, 3),
494
'height' => array('string', true, 1, 3),
497
if (!($error = validate_data($data, $var_ary)))
499
$data['user_id'] = "g$group_id";
501
if ((!empty($_FILES['uploadfile']['tmp_name']) || $data['uploadurl']) && $can_upload)
503
list($submit_ary['avatar_type'], $submit_ary['avatar'], $submit_ary['avatar_width'], $submit_ary['avatar_height']) = avatar_upload($data, $error);
505
else if ($data['remotelink'])
507
list($submit_ary['avatar_type'], $submit_ary['avatar'], $submit_ary['avatar_width'], $submit_ary['avatar_height']) = avatar_remote($data, $error);
511
else if ($avatar_select && $config['allow_avatar_local'])
513
// check avatar gallery
514
if (is_dir($phpbb_root_path . $config['avatar_gallery_path'] . '/' . $category))
516
$submit_ary['avatar_type'] = AVATAR_GALLERY;
518
list($submit_ary['avatar_width'], $submit_ary['avatar_height']) = getimagesize($phpbb_root_path . $config['avatar_gallery_path'] . '/' . $category . '/' . $avatar_select);
519
$submit_ary['avatar'] = $category . '/' . $avatar_select;
524
$submit_ary['avatar'] = '';
525
$submit_ary['avatar_type'] = $submit_ary['avatar_width'] = $submit_ary['avatar_height'] = 0;
527
else if ($data['width'] && $data['height'])
529
// Only update the dimensions?
530
if ($config['avatar_max_width'] || $config['avatar_max_height'])
532
if ($data['width'] > $config['avatar_max_width'] || $data['height'] > $config['avatar_max_height'])
534
$error[] = sprintf($user->lang['AVATAR_WRONG_SIZE'], $config['avatar_min_width'], $config['avatar_min_height'], $config['avatar_max_width'], $config['avatar_max_height'], $data['width'], $data['height']);
540
if ($config['avatar_min_width'] || $config['avatar_min_height'])
542
if ($data['width'] < $config['avatar_min_width'] || $data['height'] < $config['avatar_min_height'])
544
$error[] = sprintf($user->lang['AVATAR_WRONG_SIZE'], $config['avatar_min_width'], $config['avatar_min_height'], $config['avatar_max_width'], $config['avatar_max_height'], $data['width'], $data['height']);
551
$submit_ary['avatar_width'] = $data['width'];
552
$submit_ary['avatar_height'] = $data['height'];
556
if ((isset($submit_ary['avatar']) && $submit_ary['avatar'] && (!isset($group_row['group_avatar']))) || $delete)
558
if (isset($group_row['group_avatar']) && $group_row['group_avatar'])
560
avatar_delete('group', $group_row, true);
564
if (!check_form_key('ucp_groups'))
566
$error[] = $user->lang['FORM_INVALID'];
571
// Only set the rank, colour, etc. if it's changed or if we're adding a new
572
// group. This prevents existing group members being updated if no changes
575
$group_attributes = array();
576
$test_variables = array('rank', 'colour', 'avatar', 'avatar_type', 'avatar_width', 'avatar_height');
577
foreach ($test_variables as $test)
579
if ($action == 'add' || (isset($submit_ary[$test]) && $group_row['group_' . $test] != $submit_ary[$test]))
581
$group_attributes['group_' . $test] = $group_row['group_' . $test] = $submit_ary[$test];
585
if (!($error = group_create($group_id, $group_type, $group_name, $group_desc, $group_attributes, $allow_desc_bbcode, $allow_desc_urls, $allow_desc_smilies)))
587
$cache->destroy('sql', GROUPS_TABLE);
589
$message = ($action == 'edit') ? 'GROUP_UPDATED' : 'GROUP_CREATED';
590
trigger_error($user->lang[$message] . $return_page);
596
$group_rank = $submit_ary['rank'];
598
$group_desc_data = array(
599
'text' => $group_desc,
600
'allow_bbcode' => $allow_desc_bbcode,
601
'allow_smilies' => $allow_desc_smilies,
602
'allow_urls' => $allow_desc_urls
608
$group_name = utf8_normalize_nfc(request_var('group_name', '', true));
609
$group_desc_data = array(
611
'allow_bbcode' => true,
612
'allow_smilies' => true,
616
$group_type = GROUP_OPEN;
620
$group_name = $group_row['group_name'];
621
$group_desc_data = generate_text_for_edit($group_row['group_desc'], $group_row['group_desc_uid'], $group_row['group_desc_options']);
622
$group_type = $group_row['group_type'];
623
$group_rank = $group_row['group_rank'];
627
FROM ' . RANKS_TABLE . '
628
WHERE rank_special = 1
629
ORDER BY rank_title';
630
$result = $db->sql_query($sql);
632
$rank_options = '<option value="0"' . ((!$group_rank) ? ' selected="selected"' : '') . '>' . $user->lang['USER_DEFAULT'] . '</option>';
633
while ($row = $db->sql_fetchrow($result))
635
$selected = ($group_rank && $row['rank_id'] == $group_rank) ? ' selected="selected"' : '';
636
$rank_options .= '<option value="' . $row['rank_id'] . '"' . $selected . '>' . $row['rank_title'] . '</option>';
638
$db->sql_freeresult($result);
640
$type_free = ($group_type == GROUP_FREE) ? ' checked="checked"' : '';
641
$type_open = ($group_type == GROUP_OPEN) ? ' checked="checked"' : '';
642
$type_closed = ($group_type == GROUP_CLOSED) ? ' checked="checked"' : '';
643
$type_hidden = ($group_type == GROUP_HIDDEN) ? ' checked="checked"' : '';
645
$avatar_img = (!empty($group_row['group_avatar'])) ? get_user_avatar($group_row['group_avatar'], $group_row['group_avatar_type'], $group_row['group_avatar_width'], $group_row['group_avatar_height'], 'GROUP_AVATAR') : '<img src="' . $phpbb_root_path . 'adm/images/no_avatar.gif" alt="" />';
647
$display_gallery = (isset($_POST['display_gallery'])) ? true : false;
649
if ($config['allow_avatar_local'] && $display_gallery)
651
avatar_gallery($category, $avatar_select, 4);
654
$avatars_enabled = ($can_upload || ($config['allow_avatar_local'] || $config['allow_avatar_remote'])) ? true : false;
657
$template->assign_vars(array(
659
'S_INCLUDE_SWATCH' => true,
660
'S_CAN_UPLOAD' => $can_upload,
661
'S_FORM_ENCTYPE' => ($can_upload) ? ' enctype="multipart/form-data"' : '',
662
'S_ERROR' => (sizeof($error)) ? true : false,
663
'S_SPECIAL_GROUP' => ($group_type == GROUP_SPECIAL) ? true : false,
664
'S_AVATARS_ENABLED' => $avatars_enabled,
665
'S_DISPLAY_GALLERY' => ($config['allow_avatar_local'] && !$display_gallery) ? true : false,
666
'S_IN_GALLERY' => ($config['allow_avatar_local'] && $display_gallery) ? true : false,
668
'ERROR_MSG' => (sizeof($error)) ? implode('<br />', $error) : '',
669
'GROUP_NAME' => ($group_type == GROUP_SPECIAL) ? $user->lang['G_' . $group_name] : $group_name,
670
'GROUP_INTERNAL_NAME' => $group_name,
671
'GROUP_DESC' => $group_desc_data['text'],
672
'GROUP_RECEIVE_PM' => (isset($group_row['group_receive_pm']) && $group_row['group_receive_pm']) ? ' checked="checked"' : '',
673
'GROUP_MESSAGE_LIMIT' => (isset($group_row['group_message_limit'])) ? $group_row['group_message_limit'] : 0,
674
'GROUP_COLOUR' => (isset($group_row['group_colour'])) ? $group_row['group_colour'] : '',
676
'S_DESC_BBCODE_CHECKED' => $group_desc_data['allow_bbcode'],
677
'S_DESC_URLS_CHECKED' => $group_desc_data['allow_urls'],
678
'S_DESC_SMILIES_CHECKED'=> $group_desc_data['allow_smilies'],
680
'S_RANK_OPTIONS' => $rank_options,
681
'AVATAR' => $avatar_img,
682
'AVATAR_IMAGE' => $avatar_img,
683
'AVATAR_MAX_FILESIZE' => $config['avatar_filesize'],
684
'AVATAR_WIDTH' => (isset($group_row['group_avatar_width'])) ? $group_row['group_avatar_width'] : '',
685
'AVATAR_HEIGHT' => (isset($group_row['group_avatar_height'])) ? $group_row['group_avatar_height'] : '',
687
'GROUP_TYPE_FREE' => GROUP_FREE,
688
'GROUP_TYPE_OPEN' => GROUP_OPEN,
689
'GROUP_TYPE_CLOSED' => GROUP_CLOSED,
690
'GROUP_TYPE_HIDDEN' => GROUP_HIDDEN,
691
'GROUP_TYPE_SPECIAL' => GROUP_SPECIAL,
693
'GROUP_FREE' => $type_free,
694
'GROUP_OPEN' => $type_open,
695
'GROUP_CLOSED' => $type_closed,
696
'GROUP_HIDDEN' => $type_hidden,
698
'U_SWATCH' => append_sid("{$phpbb_root_path}adm/swatch.$phpEx", 'form=ucp&name=group_colour'),
699
'S_UCP_ACTION' => $this->u_action . "&action=$action&g=$group_id",
700
'L_AVATAR_EXPLAIN' => sprintf($user->lang['AVATAR_EXPLAIN'], $config['avatar_max_width'], $config['avatar_max_height'], round($config['avatar_filesize'] / 1024)))
709
trigger_error($user->lang['NO_GROUP'] . $return_page);
712
if (!($row = group_memberships($group_id, $user->data['user_id'])))
714
trigger_error($user->lang['NOT_MEMBER_OF_GROUP'] . $return_page);
716
list(, $row) = each($row);
718
if (!$row['group_leader'])
720
trigger_error($user->lang['NOT_LEADER_OF_GROUP'] . $return_page);
723
$user->add_lang(array('acp/groups', 'acp/common'));
724
$start = request_var('start', 0);
726
// Grab the leaders - always, on every page...
727
$sql = 'SELECT u.user_id, u.username, u.username_clean, u.user_colour, u.user_regdate, u.user_posts, u.group_id, ug.group_leader, ug.user_pending
728
FROM ' . USERS_TABLE . ' u, ' . USER_GROUP_TABLE . " ug
729
WHERE ug.group_id = $group_id
730
AND u.user_id = ug.user_id
731
AND ug.group_leader = 1
732
ORDER BY ug.group_leader DESC, ug.user_pending ASC, u.username_clean";
733
$result = $db->sql_query($sql);
735
while ($row = $db->sql_fetchrow($result))
737
$template->assign_block_vars('leader', array(
738
'USERNAME' => $row['username'],
739
'USERNAME_COLOUR' => $row['user_colour'],
740
'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']),
741
'U_USER_VIEW' => get_username_string('profile', $row['user_id'], $row['username']),
742
'S_GROUP_DEFAULT' => ($row['group_id'] == $group_id) ? true : false,
743
'JOINED' => ($row['user_regdate']) ? $user->format_date($row['user_regdate']) : ' - ',
744
'USER_POSTS' => $row['user_posts'],
745
'USER_ID' => $row['user_id'])
748
$db->sql_freeresult($result);
750
// Total number of group members (non-leaders)
751
$sql = 'SELECT COUNT(user_id) AS total_members
752
FROM ' . USER_GROUP_TABLE . "
753
WHERE group_id = $group_id
754
AND group_leader = 0";
755
$result = $db->sql_query($sql);
756
$total_members = (int) $db->sql_fetchfield('total_members');
757
$db->sql_freeresult($result);
760
$sql = 'SELECT u.user_id, u.username, u.username_clean, u.user_colour, u.user_regdate, u.user_posts, u.group_id, ug.group_leader, ug.user_pending
761
FROM ' . USERS_TABLE . ' u, ' . USER_GROUP_TABLE . " ug
762
WHERE ug.group_id = $group_id
763
AND u.user_id = ug.user_id
764
AND ug.group_leader = 0
765
ORDER BY ug.group_leader DESC, ug.user_pending ASC, u.username_clean";
766
$result = $db->sql_query_limit($sql, $config['topics_per_page'], $start);
770
while ($row = $db->sql_fetchrow($result))
772
if ($row['user_pending'] && !$pending)
774
$template->assign_block_vars('member', array(
781
$template->assign_block_vars('member', array(
782
'USERNAME' => $row['username'],
783
'USERNAME_COLOUR' => $row['user_colour'],
784
'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']),
785
'U_USER_VIEW' => get_username_string('profile', $row['user_id'], $row['username']),
786
'S_GROUP_DEFAULT' => ($row['group_id'] == $group_id) ? true : false,
787
'JOINED' => ($row['user_regdate']) ? $user->format_date($row['user_regdate']) : ' - ',
788
'USER_POSTS' => $row['user_posts'],
789
'USER_ID' => $row['user_id'])
792
$db->sql_freeresult($result);
794
$s_action_options = '';
795
$options = array('default' => 'DEFAULT', 'approve' => 'APPROVE', 'deleteusers' => 'DELETE');
797
foreach ($options as $option => $lang)
799
$s_action_options .= '<option value="' . $option . '">' . $user->lang['GROUP_' . $lang] . '</option>';
802
$template->assign_vars(array(
804
'S_ACTION_OPTIONS' => $s_action_options,
805
'S_ON_PAGE' => on_page($total_members, $config['topics_per_page'], $start),
806
'PAGINATION' => generate_pagination($this->u_action . "&action=$action&g=$group_id", $total_members, $config['topics_per_page'], $start),
808
'U_ACTION' => $this->u_action . "&g=$group_id",
809
'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&form=ucp&field=usernames'),
818
trigger_error($user->lang['NO_GROUP'] . $return_page);
821
if (!($row = group_memberships($group_id, $user->data['user_id'])))
823
trigger_error($user->lang['NOT_MEMBER_OF_GROUP'] . $return_page);
825
list(, $row) = each($row);
827
if (!$row['group_leader'])
829
trigger_error($user->lang['NOT_LEADER_OF_GROUP'] . $return_page);
832
$user->add_lang('acp/groups');
834
// Approve, demote or promote
835
group_user_attributes('approve', $group_id, $mark_ary, false, false);
837
trigger_error($user->lang['USERS_APPROVED'] . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $this->u_action . '&action=list&g=' . $group_id . '">', '</a>'));
845
trigger_error($user->lang['NO_GROUP'] . $return_page);
848
if (!($row = group_memberships($group_id, $user->data['user_id'])))
850
trigger_error($user->lang['NOT_MEMBER_OF_GROUP'] . $return_page);
852
list(, $row) = each($row);
854
if (!$row['group_leader'])
856
trigger_error($user->lang['NOT_LEADER_OF_GROUP'] . $return_page);
859
$group_row['group_name'] = ($group_row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $group_row['group_name']] : $group_row['group_name'];
861
if (confirm_box(true))
863
if (!sizeof($mark_ary))
869
$sql = 'SELECT user_id
870
FROM ' . USER_GROUP_TABLE . "
871
WHERE group_id = $group_id
873
$result = $db->sql_query_limit($sql, 200, $start);
876
if ($row = $db->sql_fetchrow($result))
880
$mark_ary[] = $row['user_id'];
882
while ($row = $db->sql_fetchrow($result));
884
group_user_attributes('default', $group_id, $mark_ary, false, $group_row['group_name'], $group_row);
886
$start = (sizeof($mark_ary) < 200) ? 0 : $start + 200;
892
$db->sql_freeresult($result);
898
group_user_attributes('default', $group_id, $mark_ary, false, $group_row['group_name'], $group_row);
901
$user->add_lang('acp/groups');
903
trigger_error($user->lang['GROUP_DEFS_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $this->u_action . '&action=list&g=' . $group_id . '">', '</a>'));
907
$user->add_lang('acp/common');
909
confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
914
'action' => $action))
922
$user->add_lang(array('acp/groups', 'acp/common'));
924
if (!($row = group_memberships($group_id, $user->data['user_id'])))
926
trigger_error($user->lang['NOT_MEMBER_OF_GROUP'] . $return_page);
928
list(, $row) = each($row);
930
if (!$row['group_leader'])
932
trigger_error($user->lang['NOT_LEADER_OF_GROUP'] . $return_page);
935
$group_row['group_name'] = ($group_row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $group_row['group_name']] : $group_row['group_name'];
937
if (confirm_box(true))
941
trigger_error($user->lang['NO_GROUP'] . $return_page);
944
$error = group_user_del($group_id, $mark_ary, false, $group_row['group_name']);
948
trigger_error($user->lang[$error] . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $this->u_action . '&action=list&g=' . $group_id . '">', '</a>'));
951
trigger_error($user->lang['GROUP_USERS_REMOVE'] . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $this->u_action . '&action=list&g=' . $group_id . '">', '</a>'));
955
confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
960
'action' => $action))
968
$user->add_lang(array('acp/groups', 'acp/common'));
970
$names = utf8_normalize_nfc(request_var('usernames', '', true));
974
trigger_error($user->lang['NO_GROUP'] . $return_page);
979
trigger_error($user->lang['NO_USERS'] . $return_page);
982
if (!($row = group_memberships($group_id, $user->data['user_id'])))
984
trigger_error($user->lang['NOT_MEMBER_OF_GROUP'] . $return_page);
986
list(, $row) = each($row);
988
if (!$row['group_leader'])
990
trigger_error($user->lang['NOT_LEADER_OF_GROUP'] . $return_page);
993
$name_ary = array_unique(explode("\n", $names));
994
$group_name = ($group_row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $group_row['group_name']] : $group_row['group_name'];
996
$default = request_var('default', 0);
998
if (confirm_box(true))
1000
// Add user/s to group
1001
if ($error = group_user_add($group_id, false, $name_ary, $group_name, $default, 0, 0, $group_row))
1003
trigger_error($user->lang[$error] . $return_page);
1008
$s_hidden_fields = array(
1009
'default' => $default,
1010
'usernames' => $names,
1016
confirm_box(false, sprintf($user->lang['GROUP_CONFIRM_ADD_USER' . ((sizeof($name_ary) == 1) ? '' : 'S')], implode(', ', $name_ary)), build_hidden_fields($s_hidden_fields));
1019
trigger_error($user->lang['GROUP_USERS_ADDED'] . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $this->u_action . '&action=list&g=' . $group_id . '">', '</a>'));
1024
$user->add_lang('acp/common');
1026
$sql = 'SELECT g.group_id, g.group_name, g.group_colour, g.group_desc, g.group_desc_uid, g.group_desc_bitfield, g.group_desc_options, g.group_type, ug.group_leader
1027
FROM ' . GROUPS_TABLE . ' g, ' . USER_GROUP_TABLE . ' ug
1028
WHERE ug.user_id = ' . $user->data['user_id'] . '
1029
AND g.group_id = ug.group_id
1030
AND ug.group_leader = 1
1031
ORDER BY g.group_type DESC, g.group_name';
1032
$result = $db->sql_query($sql);
1034
while ($value = $db->sql_fetchrow($result))
1036
$template->assign_block_vars('leader', array(
1037
'GROUP_NAME' => ($value['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $value['group_name']] : $value['group_name'],
1038
'GROUP_DESC' => generate_text_for_display($value['group_desc'], $value['group_desc_uid'], $value['group_desc_bitfield'], $value['group_desc_options']),
1039
'GROUP_TYPE' => $value['group_type'],
1040
'GROUP_ID' => $value['group_id'],
1041
'GROUP_COLOUR' => $value['group_colour'],
1043
'U_LIST' => $this->u_action . "&action=list&g={$value['group_id']}",
1044
'U_EDIT' => $this->u_action . "&action=edit&g={$value['group_id']}")
1047
$db->sql_freeresult($result);
1055
$this->tpl_name = 'ucp_groups_' . $mode;
b'\\ No newline at end of file'