~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to www/php/phpBB3/includes/ucp/ucp_groups.php

  • Committer: William Grant
  • Date: 2009-02-23 23:47:02 UTC
  • mfrom: (1099.1.211 new-dispatch)
  • Revision ID: grantw@unimelb.edu.au-20090223234702-db4b1llly46ignwo
Merge from lp:~ivle-dev/ivle/new-dispatch.

Pretty much everything changes. Reread the setup docs. Backup your databases.
Every file is now in a different installed location, the configuration system
is rewritten, the dispatch system is rewritten, URLs are different, the
database is different, worksheets and exercises are no longer on the
filesystem, we use a templating engine, jail service protocols are rewritten,
we don't repeat ourselves, we have authorization rewritten, phpBB is gone,
and probably lots of other things that I cannot remember.

This is certainly the biggest commit I have ever made, and hopefully
the largest I ever will.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?php
2
 
/**
3
 
*
4
 
* @package ucp
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
8
 
*
9
 
*/
10
 
 
11
 
/**
12
 
* @ignore
13
 
*/
14
 
if (!defined('IN_PHPBB'))
15
 
{
16
 
        exit;
17
 
}
18
 
 
19
 
/**
20
 
* ucp_groups
21
 
* @package ucp
22
 
*/
23
 
class ucp_groups
24
 
{
25
 
        var $u_action;
26
 
 
27
 
        function main($id, $mode)
28
 
        {
29
 
                global $config, $phpbb_root_path, $phpEx;
30
 
                global $db, $user, $auth, $cache, $template;
31
 
 
32
 
                $user->add_lang('groups');
33
 
 
34
 
                $return_page = '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $this->u_action . '">', '</a>');
35
 
 
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();
40
 
 
41
 
                switch ($mode)
42
 
                {
43
 
                        case 'membership':
44
 
                
45
 
                                $this->page_title = 'UCP_USERGROUPS_MEMBER';
46
 
 
47
 
                                if ($submit || isset($_POST['change_default']))
48
 
                                {
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);
51
 
 
52
 
                                        if (!$group_id)
53
 
                                        {
54
 
                                                trigger_error('NO_GROUP_SELECTED');
55
 
                                        }
56
 
 
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);
61
 
 
62
 
                                        $group_row = array();
63
 
                                        while ($row = $db->sql_fetchrow($result))
64
 
                                        {
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;
67
 
                                        }
68
 
                                        $db->sql_freeresult($result);
69
 
 
70
 
                                        if (!sizeof($group_row))
71
 
                                        {
72
 
                                                trigger_error('GROUP_NOT_EXIST');
73
 
                                        }
74
 
 
75
 
                                        switch ($action)
76
 
                                        {
77
 
                                                case 'change_default':
78
 
                                                        // User already having this group set as default?
79
 
                                                        if ($group_id == $user->data['group_id'])
80
 
                                                        {
81
 
                                                                trigger_error($user->lang['ALREADY_DEFAULT_GROUP'] . $return_page);
82
 
                                                        }
83
 
 
84
 
                                                        if (!$auth->acl_get('u_chggrp'))
85
 
                                                        {
86
 
                                                                trigger_error($user->lang['NOT_AUTHORISED'] . $return_page);
87
 
                                                        }
88
 
 
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))
91
 
                                                        {
92
 
                                                                trigger_error($user->lang['NOT_MEMBER_OF_GROUP'] . $return_page);
93
 
                                                        }
94
 
 
95
 
                                                        if (confirm_box(true))
96
 
                                                        {
97
 
                                                                group_user_attributes('default', $group_id, $user->data['user_id']);
98
 
 
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']));
100
 
 
101
 
                                                                meta_refresh(3, $this->u_action);
102
 
                                                                trigger_error($user->lang['CHANGED_DEFAULT_GROUP'] . $return_page);
103
 
                                                        }
104
 
                                                        else
105
 
                                                        {
106
 
                                                                $s_hidden_fields = array(
107
 
                                                                        'default'               => $group_id,
108
 
                                                                        'change_default'=> true
109
 
                                                                );
110
 
 
111
 
                                                                confirm_box(false, sprintf($user->lang['GROUP_CHANGE_DEFAULT'], $group_row[$group_id]['group_name']), build_hidden_fields($s_hidden_fields));
112
 
                                                        }
113
 
 
114
 
                                                break;
115
 
 
116
 
                                                case 'resign':
117
 
 
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'))
120
 
                                                        {
121
 
                                                                trigger_error($user->lang['NOT_RESIGN_FROM_DEFAULT_GROUP'] . $return_page);
122
 
                                                        }
123
 
 
124
 
                                                        if (!($row = group_memberships($group_id, $user->data['user_id'])))
125
 
                                                        {
126
 
                                                                trigger_error($user->lang['NOT_MEMBER_OF_GROUP'] . $return_page);
127
 
                                                        }
128
 
                                                        list(, $row) = each($row);
129
 
 
130
 
                                                        if (confirm_box(true))
131
 
                                                        {
132
 
                                                                group_user_del($group_id, $user->data['user_id']);
133
 
 
134
 
                                                                add_log('user', $user->data['user_id'], 'LOG_USER_GROUP_RESIGN', $group_row[$group_id]['group_name']);
135
 
 
136
 
                                                                meta_refresh(3, $this->u_action);
137
 
                                                                trigger_error($user->lang[($row['user_pending']) ? 'GROUP_RESIGNED_PENDING' : 'GROUP_RESIGNED_MEMBERSHIP'] . $return_page);
138
 
                                                        }
139
 
                                                        else
140
 
                                                        {
141
 
                                                                $s_hidden_fields = array(
142
 
                                                                        'selected'              => $group_id,
143
 
                                                                        'action'                => 'resign',
144
 
                                                                        'submit'                => true
145
 
                                                                );
146
 
 
147
 
                                                                confirm_box(false, ($row['user_pending']) ? 'GROUP_RESIGN_PENDING' : 'GROUP_RESIGN_MEMBERSHIP', build_hidden_fields($s_hidden_fields));
148
 
                                                        }
149
 
 
150
 
                                                break;
151
 
 
152
 
                                                case 'join':
153
 
 
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);
162
 
 
163
 
                                                        if ($row)
164
 
                                                        {
165
 
                                                                if ($row['user_pending'])
166
 
                                                                {
167
 
                                                                        trigger_error($user->lang['ALREADY_IN_GROUP_PENDING'] . $return_page);
168
 
                                                                }
169
 
 
170
 
                                                                trigger_error($user->lang['ALREADY_IN_GROUP'] . $return_page);
171
 
                                                        }
172
 
 
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)
175
 
                                                        {
176
 
                                                                trigger_error($user->lang['CANNOT_JOIN_GROUP'] . $return_page);
177
 
                                                        }
178
 
 
179
 
                                                        if (confirm_box(true))
180
 
                                                        {
181
 
                                                                if ($group_row[$group_id]['group_type'] == GROUP_FREE)
182
 
                                                                {
183
 
                                                                        group_user_add($group_id, $user->data['user_id']);
184
 
 
185
 
                                                                        $email_template = 'group_added';
186
 
                                                                }
187
 
                                                                else
188
 
                                                                {
189
 
                                                                        group_user_add($group_id, $user->data['user_id'], false, false, false, 0, 1);
190
 
 
191
 
                                                                        $email_template = 'group_request';
192
 
                                                                }
193
 
 
194
 
                                                                include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
195
 
                                                                $messenger = new messenger();
196
 
 
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);
203
 
 
204
 
                                                                while ($row = $db->sql_fetchrow($result))
205
 
                                                                {
206
 
                                                                        $messenger->template($email_template, $row['user_lang']);
207
 
 
208
 
                                                                        $messenger->to($row['user_email'], $row['username']);
209
 
                                                                        $messenger->im($row['user_jabber'], $row['username']);
210
 
 
211
 
                                                                        $messenger->assign_vars(array(
212
 
                                                                                'USERNAME'              => htmlspecialchars_decode($row['username']),
213
 
                                                                                'GROUP_NAME'    => htmlspecialchars_decode($group_row[$group_id]['group_name']),
214
 
 
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")
217
 
                                                                        );
218
 
 
219
 
                                                                        $messenger->send($row['user_notify_type']);
220
 
                                                                }
221
 
                                                                $db->sql_freeresult($result);
222
 
 
223
 
                                                                $messenger->save_queue();
224
 
 
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']);
226
 
 
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);
229
 
                                                        }
230
 
                                                        else
231
 
                                                        {
232
 
                                                                $s_hidden_fields = array(
233
 
                                                                        'selected'              => $group_id,
234
 
                                                                        'action'                => 'join',
235
 
                                                                        'submit'                => true
236
 
                                                                );
237
 
 
238
 
                                                                confirm_box(false, ($group_row[$group_id]['group_type'] == GROUP_FREE) ? 'GROUP_JOIN' : 'GROUP_JOIN_PENDING', build_hidden_fields($s_hidden_fields));
239
 
                                                        }
240
 
 
241
 
                                                break;
242
 
 
243
 
                                                case 'demote':
244
 
 
245
 
                                                        if (!($row = group_memberships($group_id, $user->data['user_id'])))
246
 
                                                        {
247
 
                                                                trigger_error($user->lang['NOT_MEMBER_OF_GROUP'] . $return_page);
248
 
                                                        }
249
 
                                                        list(, $row) = each($row);
250
 
 
251
 
                                                        if (!$row['group_leader'])
252
 
                                                        {
253
 
                                                                trigger_error($user->lang['NOT_LEADER_OF_GROUP'] . $return_page);
254
 
                                                        }
255
 
 
256
 
                                                        if (confirm_box(true))
257
 
                                                        {
258
 
                                                                group_user_attributes('demote', $group_id, $user->data['user_id']);
259
 
 
260
 
                                                                add_log('user', $user->data['user_id'], 'LOG_USER_GROUP_DEMOTE', $group_row[$group_id]['group_name']);
261
 
 
262
 
                                                                meta_refresh(3, $this->u_action);
263
 
                                                                trigger_error($user->lang['USER_GROUP_DEMOTED'] . $return_page);
264
 
                                                        }
265
 
                                                        else
266
 
                                                        {
267
 
                                                                $s_hidden_fields = array(
268
 
                                                                        'selected'              => $group_id,
269
 
                                                                        'action'                => 'demote',
270
 
                                                                        'submit'                => true
271
 
                                                                );
272
 
 
273
 
                                                                confirm_box(false, 'USER_GROUP_DEMOTE', build_hidden_fields($s_hidden_fields));
274
 
                                                        }
275
 
 
276
 
                                                break;
277
 
                                        }
278
 
                                }
279
 
 
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);
286
 
 
287
 
                                $group_id_ary = array();
288
 
                                $leader_count = $member_count = $pending_count = 0;
289
 
                                while ($row = $db->sql_fetchrow($result))
290
 
                                {
291
 
                                        $block = ($row['group_leader']) ? 'leader' : (($row['user_pending']) ? 'pending' : 'member');
292
 
 
293
 
                                        switch ($row['group_type'])
294
 
                                        {
295
 
                                                case GROUP_OPEN:
296
 
                                                        $group_status = 'OPEN';
297
 
                                                break;
298
 
 
299
 
                                                case GROUP_CLOSED:
300
 
                                                        $group_status = 'CLOSED';
301
 
                                                break;
302
 
 
303
 
                                                case GROUP_HIDDEN:
304
 
                                                        $group_status = 'HIDDEN';
305
 
                                                break;
306
 
 
307
 
                                                case GROUP_SPECIAL:
308
 
                                                        $group_status = 'SPECIAL';
309
 
                                                break;
310
 
 
311
 
                                                case GROUP_FREE:
312
 
                                                        $group_status = 'FREE';
313
 
                                                break;
314
 
                                        }
315
 
 
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'],
323
 
 
324
 
                                                'U_VIEW_GROUP'  => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&amp;g=' . $row['group_id']),
325
 
 
326
 
                                                'S_GROUP_DEFAULT'       => ($row['group_id'] == $user->data['group_id']) ? true : false,
327
 
                                                'S_ROW_COUNT'           => ${$block . '_count'}++)
328
 
                                        );
329
 
 
330
 
                                        $group_id_ary[] = $row['group_id'];
331
 
                                }
332
 
                                $db->sql_freeresult($result);
333
 
 
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 . ')';
336
 
 
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 ' : '') . "
340
 
                                                group_type $sql_and
341
 
                                        ORDER BY group_type DESC, group_name";
342
 
                                $result = $db->sql_query($sql);
343
 
 
344
 
                                $nonmember_count = 0;
345
 
                                while ($row = $db->sql_fetchrow($result))
346
 
                                {
347
 
                                        switch ($row['group_type'])
348
 
                                        {
349
 
                                                case GROUP_OPEN:
350
 
                                                        $group_status = 'OPEN';
351
 
                                                break;
352
 
 
353
 
                                                case GROUP_CLOSED:
354
 
                                                        $group_status = 'CLOSED';
355
 
                                                break;
356
 
 
357
 
                                                case GROUP_HIDDEN:
358
 
                                                        $group_status = 'HIDDEN';
359
 
                                                break;
360
 
 
361
 
                                                case GROUP_SPECIAL:
362
 
                                                        $group_status = 'SPECIAL';
363
 
                                                break;
364
 
 
365
 
                                                case GROUP_FREE:
366
 
                                                        $group_status = 'FREE';
367
 
                                                break;
368
 
                                        }
369
 
 
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'],
379
 
 
380
 
                                                'U_VIEW_GROUP'  => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&amp;g=' . $row['group_id']),
381
 
 
382
 
                                                'S_ROW_COUNT'   => $nonmember_count++)
383
 
                                        );
384
 
                                }
385
 
                                $db->sql_freeresult($result);
386
 
 
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,
393
 
 
394
 
                                        'S_UCP_ACTION'                  => $this->u_action)
395
 
                                );
396
 
 
397
 
                        break;
398
 
 
399
 
                        case 'manage':
400
 
 
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');
405
 
 
406
 
                                if ($group_id)
407
 
                                {
408
 
                                        $sql = 'SELECT *
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);
414
 
 
415
 
                                        if (!$group_row)
416
 
                                        {
417
 
                                                trigger_error($user->lang['NO_GROUP'] . $return_page);
418
 
                                        }
419
 
 
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'])
422
 
                                        {
423
 
                                                trigger_error($user->lang['NOT_ALLOWED_MANAGE_GROUP'] . $return_page, E_USER_WARNING);
424
 
                                        }
425
 
                                }
426
 
 
427
 
                                switch ($action)
428
 
                                {
429
 
                                        case 'edit':
430
 
 
431
 
                                                include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
432
 
 
433
 
                                                if (!$group_id)
434
 
                                                {
435
 
                                                        trigger_error($user->lang['NO_GROUP'] . $return_page);
436
 
                                                }
437
 
 
438
 
                                                if (!($row = group_memberships($group_id, $user->data['user_id'])))
439
 
                                                {
440
 
                                                        trigger_error($user->lang['NOT_MEMBER_OF_GROUP'] . $return_page);
441
 
                                                }
442
 
                                                list(, $row) = each($row);
443
 
 
444
 
                                                if (!$row['group_leader'])
445
 
                                                {
446
 
                                                        trigger_error($user->lang['NOT_LEADER_OF_GROUP'] . $return_page);
447
 
                                                }
448
 
 
449
 
                                                $file_uploads = (@ini_get('file_uploads') || strtolower(@ini_get('file_uploads')) == 'on') ? true : false;
450
 
                                                $user->add_lang(array('acp/groups', 'acp/common'));
451
 
 
452
 
                                                $data = $submit_ary = array();
453
 
 
454
 
                                                $update = (isset($_POST['update'])) ? true : false;
455
 
 
456
 
                                                $error = array();
457
 
 
458
 
                                                $avatar_select = basename(request_var('avatar_select', ''));
459
 
                                                $category = basename(request_var('category', ''));
460
 
 
461
 
                                                $can_upload = (file_exists($phpbb_root_path . $config['avatar_path']) && @is_writable($phpbb_root_path . $config['avatar_path']) && $file_uploads) ? true : false;
462
 
 
463
 
                                                // Did we submit?
464
 
                                                if ($update)
465
 
                                                {
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);
469
 
 
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);
473
 
 
474
 
                                                        $submit_ary = array(
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)
479
 
                                                        );
480
 
 
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', '');
486
 
 
487
 
                                                        if (!empty($_FILES['uploadfile']['tmp_name']) || $data['uploadurl'] || $data['remotelink'])
488
 
                                                        {
489
 
                                                                // Avatar stuff
490
 
                                                                $var_ary = array(
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),
495
 
                                                                );
496
 
 
497
 
                                                                if (!($error = validate_data($data, $var_ary)))
498
 
                                                                {
499
 
                                                                        $data['user_id'] = "g$group_id";
500
 
 
501
 
                                                                        if ((!empty($_FILES['uploadfile']['tmp_name']) || $data['uploadurl']) && $can_upload)
502
 
                                                                        {
503
 
                                                                                list($submit_ary['avatar_type'], $submit_ary['avatar'], $submit_ary['avatar_width'], $submit_ary['avatar_height']) = avatar_upload($data, $error);
504
 
                                                                        }
505
 
                                                                        else if ($data['remotelink'])
506
 
                                                                        {
507
 
                                                                                list($submit_ary['avatar_type'], $submit_ary['avatar'], $submit_ary['avatar_width'], $submit_ary['avatar_height']) = avatar_remote($data, $error);
508
 
                                                                        }
509
 
                                                                }
510
 
                                                        }
511
 
                                                        else if ($avatar_select && $config['allow_avatar_local'])
512
 
                                                        {
513
 
                                                                // check avatar gallery
514
 
                                                                if (is_dir($phpbb_root_path . $config['avatar_gallery_path'] . '/' . $category))
515
 
                                                                {
516
 
                                                                        $submit_ary['avatar_type'] = AVATAR_GALLERY;
517
 
 
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;
520
 
                                                                }
521
 
                                                        }
522
 
                                                        else if ($delete)
523
 
                                                        {
524
 
                                                                $submit_ary['avatar'] = '';
525
 
                                                                $submit_ary['avatar_type'] = $submit_ary['avatar_width'] = $submit_ary['avatar_height'] = 0;
526
 
                                                        }
527
 
                                                        else if ($data['width'] && $data['height'])
528
 
                                                        {
529
 
                                                                // Only update the dimensions?
530
 
                                                                if ($config['avatar_max_width'] || $config['avatar_max_height'])
531
 
                                                                {
532
 
                                                                        if ($data['width'] > $config['avatar_max_width'] || $data['height'] > $config['avatar_max_height'])
533
 
                                                                        {
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']);
535
 
                                                                        }
536
 
                                                                }
537
 
 
538
 
                                                                if (!sizeof($error))
539
 
                                                                {
540
 
                                                                        if ($config['avatar_min_width'] || $config['avatar_min_height'])
541
 
                                                                        {
542
 
                                                                                if ($data['width'] < $config['avatar_min_width'] || $data['height'] < $config['avatar_min_height'])
543
 
                                                                                {
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']);
545
 
                                                                                }
546
 
                                                                        }
547
 
                                                                }
548
 
 
549
 
                                                                if (!sizeof($error))
550
 
                                                                {
551
 
                                                                        $submit_ary['avatar_width'] = $data['width'];
552
 
                                                                        $submit_ary['avatar_height'] = $data['height'];
553
 
                                                                }
554
 
                                                        }
555
 
 
556
 
                                                        if ((isset($submit_ary['avatar']) && $submit_ary['avatar'] && (!isset($group_row['group_avatar']))) || $delete)
557
 
                                                        {
558
 
                                                                if (isset($group_row['group_avatar']) && $group_row['group_avatar'])
559
 
                                                                {
560
 
                                                                        avatar_delete('group', $group_row, true);
561
 
                                                                }
562
 
                                                        }
563
 
 
564
 
                                                        if (!check_form_key('ucp_groups'))
565
 
                                                        {
566
 
                                                                $error[] = $user->lang['FORM_INVALID'];
567
 
                                                        }
568
 
 
569
 
                                                        if (!sizeof($error))
570
 
                                                        {
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
573
 
                                                                // were made.
574
 
                                                
575
 
                                                                $group_attributes = array();
576
 
                                                                $test_variables = array('rank', 'colour', 'avatar', 'avatar_type', 'avatar_width', 'avatar_height');
577
 
                                                                foreach ($test_variables as $test)
578
 
                                                                {
579
 
                                                                        if ($action == 'add' || (isset($submit_ary[$test]) && $group_row['group_' . $test] != $submit_ary[$test]))
580
 
                                                                        {
581
 
                                                                                $group_attributes['group_' . $test] = $group_row['group_' . $test] = $submit_ary[$test];
582
 
                                                                        }
583
 
                                                                }
584
 
 
585
 
                                                                if (!($error = group_create($group_id, $group_type, $group_name, $group_desc, $group_attributes, $allow_desc_bbcode, $allow_desc_urls, $allow_desc_smilies)))
586
 
                                                                {
587
 
                                                                        $cache->destroy('sql', GROUPS_TABLE);
588
 
 
589
 
                                                                        $message = ($action == 'edit') ? 'GROUP_UPDATED' : 'GROUP_CREATED';
590
 
                                                                        trigger_error($user->lang[$message] . $return_page);
591
 
                                                                }
592
 
                                                        }
593
 
 
594
 
                                                        if (sizeof($error))
595
 
                                                        {
596
 
                                                                $group_rank = $submit_ary['rank'];
597
 
 
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
603
 
                                                                );
604
 
                                                        }
605
 
                                                }
606
 
                                                else if (!$group_id)
607
 
                                                {
608
 
                                                        $group_name = utf8_normalize_nfc(request_var('group_name', '', true));
609
 
                                                        $group_desc_data = array(
610
 
                                                                'text'                  => '',
611
 
                                                                'allow_bbcode'  => true,
612
 
                                                                'allow_smilies' => true,
613
 
                                                                'allow_urls'    => true
614
 
                                                        );
615
 
                                                        $group_rank = 0;
616
 
                                                        $group_type = GROUP_OPEN;
617
 
                                                }
618
 
                                                else
619
 
                                                {
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'];
624
 
                                                }
625
 
 
626
 
                                                $sql = 'SELECT *
627
 
                                                        FROM ' . RANKS_TABLE . '
628
 
                                                        WHERE rank_special = 1
629
 
                                                        ORDER BY rank_title';
630
 
                                                $result = $db->sql_query($sql);
631
 
 
632
 
                                                $rank_options = '<option value="0"' . ((!$group_rank) ? ' selected="selected"' : '') . '>' . $user->lang['USER_DEFAULT'] . '</option>';
633
 
                                                while ($row = $db->sql_fetchrow($result))
634
 
                                                {
635
 
                                                        $selected = ($group_rank && $row['rank_id'] == $group_rank) ? ' selected="selected"' : '';
636
 
                                                        $rank_options .= '<option value="' . $row['rank_id'] . '"' . $selected . '>' . $row['rank_title'] . '</option>';
637
 
                                                }
638
 
                                                $db->sql_freeresult($result);
639
 
 
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"' : '';
644
 
 
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="" />';
646
 
 
647
 
                                                $display_gallery = (isset($_POST['display_gallery'])) ? true : false;
648
 
 
649
 
                                                if ($config['allow_avatar_local'] && $display_gallery)
650
 
                                                {
651
 
                                                        avatar_gallery($category, $avatar_select, 4);
652
 
                                                }
653
 
                                                
654
 
                                                $avatars_enabled = ($can_upload || ($config['allow_avatar_local'] || $config['allow_avatar_remote'])) ? true : false;
655
 
 
656
 
 
657
 
                                                $template->assign_vars(array(
658
 
                                                        'S_EDIT'                        => true,
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,
667
 
 
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'] : '',
675
 
 
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'],
679
 
 
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'] : '',
686
 
 
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,
692
 
 
693
 
                                                        'GROUP_FREE'            => $type_free,
694
 
                                                        'GROUP_OPEN'            => $type_open,
695
 
                                                        'GROUP_CLOSED'          => $type_closed,
696
 
                                                        'GROUP_HIDDEN'          => $type_hidden,
697
 
 
698
 
                                                        'U_SWATCH'                      => append_sid("{$phpbb_root_path}adm/swatch.$phpEx", 'form=ucp&amp;name=group_colour'),
699
 
                                                        'S_UCP_ACTION'          => $this->u_action . "&amp;action=$action&amp;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)))
701
 
                                                );
702
 
 
703
 
                                        break;
704
 
 
705
 
                                        case 'list':
706
 
 
707
 
                                                if (!$group_id)
708
 
                                                {
709
 
                                                        trigger_error($user->lang['NO_GROUP'] . $return_page);
710
 
                                                }
711
 
 
712
 
                                                if (!($row = group_memberships($group_id, $user->data['user_id'])))
713
 
                                                {
714
 
                                                        trigger_error($user->lang['NOT_MEMBER_OF_GROUP'] . $return_page);
715
 
                                                }
716
 
                                                list(, $row) = each($row);
717
 
 
718
 
                                                if (!$row['group_leader'])
719
 
                                                {
720
 
                                                        trigger_error($user->lang['NOT_LEADER_OF_GROUP'] . $return_page);
721
 
                                                }
722
 
 
723
 
                                                $user->add_lang(array('acp/groups', 'acp/common'));
724
 
                                                $start = request_var('start', 0);
725
 
 
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);
734
 
 
735
 
                                                while ($row = $db->sql_fetchrow($result))
736
 
                                                {
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'])
746
 
                                                        );
747
 
                                                }
748
 
                                                $db->sql_freeresult($result);
749
 
 
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);
758
 
 
759
 
                                                // Grab the members
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);
767
 
 
768
 
                                                $pending = false;
769
 
 
770
 
                                                while ($row = $db->sql_fetchrow($result))
771
 
                                                {
772
 
                                                        if ($row['user_pending'] && !$pending)
773
 
                                                        {
774
 
                                                                $template->assign_block_vars('member', array(
775
 
                                                                        'S_PENDING'             => true)
776
 
                                                                );
777
 
 
778
 
                                                                $pending = true;
779
 
                                                        }
780
 
 
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'])
790
 
                                                        );
791
 
                                                }
792
 
                                                $db->sql_freeresult($result);
793
 
 
794
 
                                                $s_action_options = '';
795
 
                                                $options = array('default' => 'DEFAULT', 'approve' => 'APPROVE', 'deleteusers' => 'DELETE');
796
 
 
797
 
                                                foreach ($options as $option => $lang)
798
 
                                                {
799
 
                                                        $s_action_options .= '<option value="' . $option . '">' . $user->lang['GROUP_' . $lang] . '</option>';
800
 
                                                }
801
 
 
802
 
                                                $template->assign_vars(array(
803
 
                                                        'S_LIST'                        => true,
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 . "&amp;action=$action&amp;g=$group_id", $total_members, $config['topics_per_page'], $start),
807
 
 
808
 
                                                        'U_ACTION'                      => $this->u_action . "&amp;g=$group_id",
809
 
                                                        'U_FIND_USERNAME'       => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&amp;form=ucp&amp;field=usernames'),
810
 
                                                ));
811
 
 
812
 
                                        break;
813
 
 
814
 
                                        case 'approve':
815
 
 
816
 
                                                if (!$group_id)
817
 
                                                {
818
 
                                                        trigger_error($user->lang['NO_GROUP'] . $return_page);
819
 
                                                }
820
 
 
821
 
                                                if (!($row = group_memberships($group_id, $user->data['user_id'])))
822
 
                                                {
823
 
                                                        trigger_error($user->lang['NOT_MEMBER_OF_GROUP'] . $return_page);
824
 
                                                }
825
 
                                                list(, $row) = each($row);
826
 
 
827
 
                                                if (!$row['group_leader'])
828
 
                                                {
829
 
                                                        trigger_error($user->lang['NOT_LEADER_OF_GROUP'] . $return_page);
830
 
                                                }
831
 
 
832
 
                                                $user->add_lang('acp/groups');
833
 
 
834
 
                                                // Approve, demote or promote
835
 
                                                group_user_attributes('approve', $group_id, $mark_ary, false, false);
836
 
 
837
 
                                                trigger_error($user->lang['USERS_APPROVED'] . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $this->u_action . '&amp;action=list&amp;g=' . $group_id . '">', '</a>'));
838
 
 
839
 
                                        break;
840
 
 
841
 
                                        case 'default':
842
 
 
843
 
                                                if (!$group_id)
844
 
                                                {
845
 
                                                        trigger_error($user->lang['NO_GROUP'] . $return_page);
846
 
                                                }
847
 
 
848
 
                                                if (!($row = group_memberships($group_id, $user->data['user_id'])))
849
 
                                                {
850
 
                                                        trigger_error($user->lang['NOT_MEMBER_OF_GROUP'] . $return_page);
851
 
                                                }
852
 
                                                list(, $row) = each($row);
853
 
 
854
 
                                                if (!$row['group_leader'])
855
 
                                                {
856
 
                                                        trigger_error($user->lang['NOT_LEADER_OF_GROUP'] . $return_page);
857
 
                                                }
858
 
 
859
 
                                                $group_row['group_name'] = ($group_row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $group_row['group_name']] : $group_row['group_name'];
860
 
 
861
 
                                                if (confirm_box(true))
862
 
                                                {
863
 
                                                        if (!sizeof($mark_ary))
864
 
                                                        {
865
 
                                                                $start = 0;
866
 
                                
867
 
                                                                do
868
 
                                                                {
869
 
                                                                        $sql = 'SELECT user_id
870
 
                                                                                FROM ' . USER_GROUP_TABLE . "
871
 
                                                                                WHERE group_id = $group_id
872
 
                                                                                ORDER BY user_id";
873
 
                                                                        $result = $db->sql_query_limit($sql, 200, $start);
874
 
 
875
 
                                                                        $mark_ary = array();
876
 
                                                                        if ($row = $db->sql_fetchrow($result))
877
 
                                                                        {
878
 
                                                                                do
879
 
                                                                                {
880
 
                                                                                        $mark_ary[] = $row['user_id'];
881
 
                                                                                }
882
 
                                                                                while ($row = $db->sql_fetchrow($result));
883
 
 
884
 
                                                                                group_user_attributes('default', $group_id, $mark_ary, false, $group_row['group_name'], $group_row);
885
 
 
886
 
                                                                                $start = (sizeof($mark_ary) < 200) ? 0 : $start + 200;
887
 
                                                                        }
888
 
                                                                        else
889
 
                                                                        {
890
 
                                                                                $start = 0;
891
 
                                                                        }
892
 
                                                                        $db->sql_freeresult($result);
893
 
                                                                }
894
 
                                                                while ($start);
895
 
                                                        }
896
 
                                                        else
897
 
                                                        {
898
 
                                                                group_user_attributes('default', $group_id, $mark_ary, false, $group_row['group_name'], $group_row);
899
 
                                                        }
900
 
 
901
 
                                                        $user->add_lang('acp/groups');
902
 
 
903
 
                                                        trigger_error($user->lang['GROUP_DEFS_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $this->u_action . '&amp;action=list&amp;g=' . $group_id . '">', '</a>'));
904
 
                                                }
905
 
                                                else
906
 
                                                {
907
 
                                                        $user->add_lang('acp/common');
908
 
 
909
 
                                                        confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
910
 
                                                                'mark'          => $mark_ary,
911
 
                                                                'g'                     => $group_id,
912
 
                                                                'i'                     => $id,
913
 
                                                                'mode'          => $mode,
914
 
                                                                'action'        => $action))
915
 
                                                        );
916
 
                                                }
917
 
 
918
 
                                        break;
919
 
 
920
 
                                        case 'deleteusers':
921
 
 
922
 
                                                $user->add_lang(array('acp/groups', 'acp/common'));
923
 
 
924
 
                                                if (!($row = group_memberships($group_id, $user->data['user_id'])))
925
 
                                                {
926
 
                                                        trigger_error($user->lang['NOT_MEMBER_OF_GROUP'] . $return_page);
927
 
                                                }
928
 
                                                list(, $row) = each($row);
929
 
 
930
 
                                                if (!$row['group_leader'])
931
 
                                                {
932
 
                                                        trigger_error($user->lang['NOT_LEADER_OF_GROUP'] . $return_page);
933
 
                                                }
934
 
 
935
 
                                                $group_row['group_name'] = ($group_row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $group_row['group_name']] : $group_row['group_name'];
936
 
 
937
 
                                                if (confirm_box(true))
938
 
                                                {
939
 
                                                        if (!$group_id)
940
 
                                                        {
941
 
                                                                trigger_error($user->lang['NO_GROUP'] . $return_page);
942
 
                                                        }
943
 
 
944
 
                                                        $error = group_user_del($group_id, $mark_ary, false, $group_row['group_name']);
945
 
 
946
 
                                                        if ($error)
947
 
                                                        {
948
 
                                                                trigger_error($user->lang[$error] . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $this->u_action . '&amp;action=list&amp;g=' . $group_id . '">', '</a>'));
949
 
                                                        }
950
 
 
951
 
                                                        trigger_error($user->lang['GROUP_USERS_REMOVE'] . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $this->u_action . '&amp;action=list&amp;g=' . $group_id . '">', '</a>'));
952
 
                                                }
953
 
                                                else
954
 
                                                {
955
 
                                                        confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
956
 
                                                                'mark'          => $mark_ary,
957
 
                                                                'g'                     => $group_id,
958
 
                                                                'i'                     => $id,
959
 
                                                                'mode'          => $mode,
960
 
                                                                'action'        => $action))
961
 
                                                        );
962
 
                                                }
963
 
 
964
 
                                        break;
965
 
 
966
 
                                        case 'addusers':
967
 
 
968
 
                                                $user->add_lang(array('acp/groups', 'acp/common'));
969
 
 
970
 
                                                $names = utf8_normalize_nfc(request_var('usernames', '', true));
971
 
 
972
 
                                                if (!$group_id)
973
 
                                                {
974
 
                                                        trigger_error($user->lang['NO_GROUP'] . $return_page);
975
 
                                                }
976
 
 
977
 
                                                if (!$names)
978
 
                                                {
979
 
                                                        trigger_error($user->lang['NO_USERS'] . $return_page);
980
 
                                                }
981
 
 
982
 
                                                if (!($row = group_memberships($group_id, $user->data['user_id'])))
983
 
                                                {
984
 
                                                        trigger_error($user->lang['NOT_MEMBER_OF_GROUP'] . $return_page);
985
 
                                                }
986
 
                                                list(, $row) = each($row);
987
 
 
988
 
                                                if (!$row['group_leader'])
989
 
                                                {
990
 
                                                        trigger_error($user->lang['NOT_LEADER_OF_GROUP'] . $return_page);
991
 
                                                }
992
 
 
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'];
995
 
 
996
 
                                                $default = request_var('default', 0);
997
 
                                                
998
 
                                                if (confirm_box(true))
999
 
                                                {
1000
 
                                                        // Add user/s to group
1001
 
                                                        if ($error = group_user_add($group_id, false, $name_ary, $group_name, $default, 0, 0, $group_row))
1002
 
                                                        {
1003
 
                                                                trigger_error($user->lang[$error] . $return_page);
1004
 
                                                        }
1005
 
                                                }
1006
 
                                                else
1007
 
                                                {
1008
 
                                                        $s_hidden_fields = array(
1009
 
                                                                'default'       => $default,
1010
 
                                                                'usernames'     => $names,
1011
 
                                                                'g'                     => $group_id,
1012
 
                                                                'i'                     => $id,
1013
 
                                                                'mode'          => $mode,
1014
 
                                                                'action'        => $action
1015
 
                                                        );
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));
1017
 
                                                }
1018
 
 
1019
 
                                                trigger_error($user->lang['GROUP_USERS_ADDED'] . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $this->u_action . '&amp;action=list&amp;g=' . $group_id . '">', '</a>'));
1020
 
 
1021
 
                                        break;
1022
 
 
1023
 
                                        default:
1024
 
                                                $user->add_lang('acp/common');
1025
 
 
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);
1033
 
 
1034
 
                                                while ($value = $db->sql_fetchrow($result))
1035
 
                                                {
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'],
1042
 
 
1043
 
                                                                'U_LIST'        => $this->u_action . "&amp;action=list&amp;g={$value['group_id']}",
1044
 
                                                                'U_EDIT'        => $this->u_action . "&amp;action=edit&amp;g={$value['group_id']}")
1045
 
                                                        );
1046
 
                                                }
1047
 
                                                $db->sql_freeresult($result);
1048
 
 
1049
 
                                        break;
1050
 
                                }
1051
 
 
1052
 
                        break;
1053
 
                }
1054
 
 
1055
 
                $this->tpl_name = 'ucp_groups_' . $mode;
1056
 
        }
1057
 
}
1058
 
 
1059
 
?>
 
 
b'\\ No newline at end of file'