Verzeichnisstruktur phpBB-3.0.0
- Veröffentlicht
- 12.12.2007
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
acp_groups.php
001 <?php
002 /**
003 *
004 * @package acp
005 * @version $Id$
006 * @copyright (c) 2005 phpBB Group
007 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
008 *
009 */
010
011 /**
012 * @ignore
013 */
014 if (!defined('IN_PHPBB'))
015 {
016 exit;
017 }
018
019 /**
020 * @package acp
021 */
022 class acp_groups
023 {
024 var $u_action;
025
026 function main($id, $mode)
027 {
028 global $config, $db, $user, $auth, $template, $cache;
029 global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix, $file_uploads;
030
031 $user->add_lang('acp/groups');
032 $this->tpl_name = 'acp_groups';
033 $this->page_title = 'ACP_GROUPS_MANAGE';
034
035 $form_key = 'acp_groups';
036 add_form_key($form_key);
037
038 include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
039
040 // Check and set some common vars
041 $action = (isset($_POST['add'])) ? 'add' : ((isset($_POST['addusers'])) ? 'addusers' : request_var('action', ''));
042 $group_id = request_var('g', 0);
043 $mark_ary = request_var('mark', array(0));
044 $name_ary = request_var('usernames', '', true);
045 $leader = request_var('leader', 0);
046 $default = request_var('default', 0);
047 $start = request_var('start', 0);
048 $update = (isset($_POST['update'])) ? true : false;
049
050
051 // Clear some vars
052 $can_upload = (file_exists($phpbb_root_path . $config['avatar_path']) && @is_writable($phpbb_root_path . $config['avatar_path']) && $file_uploads) ? true : false;
053 $group_row = array();
054
055 // Grab basic data for group, if group_id is set and exists
056 if ($group_id)
057 {
058 $sql = 'SELECT *
059 FROM ' . GROUPS_TABLE . "
060 WHERE group_id = $group_id";
061 $result = $db->sql_query($sql);
062 $group_row = $db->sql_fetchrow($result);
063 $db->sql_freeresult($result);
064
065 if (!$group_row)
066 {
067 trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action), E_USER_WARNING);
068 }
069
070 // Check if the user is allowed to manage this group if set to founder only.
071 if ($user->data['user_type'] != USER_FOUNDER && $group_row['group_founder_manage'])
072 {
073 trigger_error($user->lang['NOT_ALLOWED_MANAGE_GROUP'] . adm_back_link($this->u_action), E_USER_WARNING);
074 }
075 }
076
077 // Which page?
078 switch ($action)
079 {
080 case 'approve':
081 case 'demote':
082 case 'promote':
083 if (!$group_id)
084 {
085 trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action), E_USER_WARNING);
086 }
087
088 // Approve, demote or promote
089 $group_name = ($group_row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $group_row['group_name']] : $group_row['group_name'];
090 group_user_attributes($action, $group_id, $mark_ary, false, $group_name);
091
092 switch ($action)
093 {
094 case 'demote':
095 $message = 'GROUP_MODS_DEMOTED';
096 break;
097
098 case 'promote':
099 $message = 'GROUP_MODS_PROMOTED';
100 break;
101
102 case 'approve':
103 $message = 'USERS_APPROVED';
104 break;
105 }
106
107 trigger_error($user->lang[$message] . adm_back_link($this->u_action . '&action=list&g=' . $group_id));
108 break;
109
110 case 'default':
111 if (!$group_id)
112 {
113 trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action), E_USER_WARNING);
114 }
115
116 if (confirm_box(true))
117 {
118 $group_name = ($group_row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $group_row['group_name']] : $group_row['group_name'];
119
120 if (!sizeof($mark_ary))
121 {
122 $start = 0;
123
124 do
125 {
126 $sql = 'SELECT user_id
127 FROM ' . USER_GROUP_TABLE . "
128 WHERE group_id = $group_id
129 ORDER BY user_id";
130 $result = $db->sql_query_limit($sql, 200, $start);
131
132 $mark_ary = array();
133 if ($row = $db->sql_fetchrow($result))
134 {
135 do
136 {
137 $mark_ary[] = $row['user_id'];
138 }
139 while ($row = $db->sql_fetchrow($result));
140
141 group_user_attributes('default', $group_id, $mark_ary, false, $group_name, $group_row);
142
143 $start = (sizeof($mark_ary) < 200) ? 0 : $start + 200;
144 }
145 else
146 {
147 $start = 0;
148 }
149 $db->sql_freeresult($result);
150 }
151 while ($start);
152 }
153 else
154 {
155 group_user_attributes('default', $group_id, $mark_ary, false, $group_name, $group_row);
156 }
157
158 trigger_error($user->lang['GROUP_DEFS_UPDATED'] . adm_back_link($this->u_action . '&action=list&g=' . $group_id));
159 }
160 else
161 {
162 confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
163 'mark' => $mark_ary,
164 'g' => $group_id,
165 'i' => $id,
166 'mode' => $mode,
167 'action' => $action))
168 );
169 }
170
171 break;
172
173 case 'deleteusers':
174 case 'delete':
175 if (confirm_box(true))
176 {
177 if (!$group_id)
178 {
179 trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action), E_USER_WARNING);
180 }
181
182 $error = '';
183
184 switch ($action)
185 {
186 case 'delete':
187 if (!$auth->acl_get('a_groupdel'))
188 {
189 trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
190 }
191
192 $error = group_delete($group_id, $group_row['group_name']);
193 break;
194
195 case 'deleteusers':
196 $group_name = ($group_row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $group_row['group_name']] : $group_row['group_name'];
197 $error = group_user_del($group_id, $mark_ary, false, $group_name);
198 break;
199 }
200
201 $back_link = ($action == 'delete') ? $this->u_action : $this->u_action . '&action=list&g=' . $group_id;
202
203 if ($error)
204 {
205 trigger_error($user->lang[$error] . adm_back_link($back_link), E_USER_WARNING);
206 }
207
208 $message = ($action == 'delete') ? 'GROUP_DELETED' : 'GROUP_USERS_REMOVE';
209 trigger_error($user->lang[$message] . adm_back_link($back_link));
210 }
211 else
212 {
213 confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
214 'mark' => $mark_ary,
215 'g' => $group_id,
216 'i' => $id,
217 'mode' => $mode,
218 'action' => $action))
219 );
220 }
221 break;
222
223 case 'addusers':
224 if (!$group_id)
225 {
226 trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action), E_USER_WARNING);
227 }
228
229 if (!$name_ary)
230 {
231 trigger_error($user->lang['NO_USERS'] . adm_back_link($this->u_action . '&action=list&g=' . $group_id), E_USER_WARNING);
232 }
233
234 $name_ary = array_unique(explode("\n", $name_ary));
235 $group_name = ($group_row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $group_row['group_name']] : $group_row['group_name'];
236
237 // Add user/s to group
238 if ($error = group_user_add($group_id, false, $name_ary, $group_name, $default, $leader, 0, $group_row))
239 {
240 trigger_error($user->lang[$error] . adm_back_link($this->u_action . '&action=list&g=' . $group_id), E_USER_WARNING);
241 }
242
243 $message = ($leader) ? 'GROUP_MODS_ADDED' : 'GROUP_USERS_ADDED';
244 trigger_error($user->lang[$message] . adm_back_link($this->u_action . '&action=list&g=' . $group_id));
245 break;
246
247 case 'edit':
248 case 'add':
249
250 include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
251
252 $data = $submit_ary = array();
253
254 if ($action == 'edit' && !$group_id)
255 {
256 trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action), E_USER_WARNING);
257 }
258
259 if ($action == 'add' && !$auth->acl_get('a_groupadd'))
260 {
261 trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
262 }
263
264 $error = array();
265 $user->add_lang('ucp');
266
267 $avatar_select = basename(request_var('avatar_select', ''));
268 $category = basename(request_var('category', ''));
269
270 // Did we submit?
271 if ($update)
272 {
273 if (!check_form_key($form_key))
274 {
275 trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
276 }
277
278 $group_name = utf8_normalize_nfc(request_var('group_name', '', true));
279 $group_desc = utf8_normalize_nfc(request_var('group_desc', '', true));
280 $group_type = request_var('group_type', GROUP_FREE);
281
282 $allow_desc_bbcode = request_var('desc_parse_bbcode', false);
283 $allow_desc_urls = request_var('desc_parse_urls', false);
284 $allow_desc_smilies = request_var('desc_parse_smilies', false);
285
286 $data['uploadurl'] = request_var('uploadurl', '');
287 $data['remotelink'] = request_var('remotelink', '');
288 $data['width'] = request_var('width', '');
289 $data['height'] = request_var('height', '');
290 $delete = request_var('delete', '');
291
292 $submit_ary = array(
293 'colour' => request_var('group_colour', ''),
294 'rank' => request_var('group_rank', 0),
295 'receive_pm' => isset($_REQUEST['group_receive_pm']) ? 1 : 0,
296 'legend' => isset($_REQUEST['group_legend']) ? 1 : 0,
297 'message_limit' => request_var('group_message_limit', 0),
298 'founder_manage' => 0,
299 );
300
301 if ($user->data['user_type'] == USER_FOUNDER)
302 {
303 $submit_ary['founder_manage'] = isset($_REQUEST['group_founder_manage']) ? 1 : 0;
304 }
305
306 if (!empty($_FILES['uploadfile']['tmp_name']) || $data['uploadurl'] || $data['remotelink'])
307 {
308 // Avatar stuff
309 $var_ary = array(
310 'uploadurl' => array('string', true, 5, 255),
311 'remotelink' => array('string', true, 5, 255),
312 'width' => array('string', true, 1, 3),
313 'height' => array('string', true, 1, 3),
314 );
315
316 if (!($error = validate_data($data, $var_ary)))
317 {
318 $data['user_id'] = "g$group_id";
319
320 if ((!empty($_FILES['uploadfile']['tmp_name']) || $data['uploadurl']) && $can_upload)
321 {
322 list($submit_ary['avatar_type'], $submit_ary['avatar'], $submit_ary['avatar_width'], $submit_ary['avatar_height']) = avatar_upload($data, $error);
323 }
324 else if ($data['remotelink'])
325 {
326 list($submit_ary['avatar_type'], $submit_ary['avatar'], $submit_ary['avatar_width'], $submit_ary['avatar_height']) = avatar_remote($data, $error);
327 }
328 }
329 }
330 else if ($avatar_select && $config['allow_avatar_local'])
331 {
332 // check avatar gallery
333 if (is_dir($phpbb_root_path . $config['avatar_gallery_path'] . '/' . $category))
334 {
335 $submit_ary['avatar_type'] = AVATAR_GALLERY;
336
337 list($submit_ary['avatar_width'], $submit_ary['avatar_height']) = getimagesize($phpbb_root_path . $config['avatar_gallery_path'] . '/' . $category . '/' . $avatar_select);
338 $submit_ary['avatar'] = $category . '/' . $avatar_select;
339 }
340 }
341 else if ($delete)
342 {
343 $submit_ary['avatar'] = '';
344 $submit_ary['avatar_type'] = $submit_ary['avatar_width'] = $submit_ary['avatar_height'] = 0;
345 }
346 else if ($data['width'] && $data['height'])
347 {
348 // Only update the dimensions?
349 if ($config['avatar_max_width'] || $config['avatar_max_height'])
350 {
351 if ($data['width'] > $config['avatar_max_width'] || $data['height'] > $config['avatar_max_height'])
352 {
353 $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']);
354 }
355 }
356
357 if (!sizeof($error))
358 {
359 if ($config['avatar_min_width'] || $config['avatar_min_height'])
360 {
361 if ($data['width'] < $config['avatar_min_width'] || $data['height'] < $config['avatar_min_height'])
362 {
363 $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']);
364 }
365 }
366 }
367
368 if (!sizeof($error))
369 {
370 $submit_ary['avatar_width'] = $data['width'];
371 $submit_ary['avatar_height'] = $data['height'];
372 }
373 }
374
375 if ((isset($submit_ary['avatar']) && $submit_ary['avatar'] && (!isset($group_row['group_avatar']))) || $delete)
376 {
377 if (isset($group_row['group_avatar']) && $group_row['group_avatar'])
378 {
379 avatar_delete('group', $group_row, true);
380 }
381 }
382
383 if (!sizeof($error))
384 {
385 // Only set the rank, colour, etc. if it's changed or if we're adding a new
386 // group. This prevents existing group members being updated if no changes
387 // were made.
388
389 $group_attributes = array();
390 $test_variables = array('rank', 'colour', 'avatar', 'avatar_type', 'avatar_width', 'avatar_height', 'receive_pm', 'legend', 'message_limit', 'founder_manage');
391 foreach ($test_variables as $test)
392 {
393 if (isset($submit_ary[$test]) && ($action == 'add' || $group_row['group_' . $test] != $submit_ary[$test]))
394 {
395 $group_attributes['group_' . $test] = $group_row['group_' . $test] = $submit_ary[$test];
396 }
397 }
398
399 if (!($error = group_create($group_id, $group_type, $group_name, $group_desc, $group_attributes, $allow_desc_bbcode, $allow_desc_urls, $allow_desc_smilies)))
400 {
401 $group_perm_from = request_var('group_perm_from', 0);
402
403 // Copy permissions?
404 // If the user has the a_authgroups permission and at least one additional permission ability set the permissions are fully transferred.
405 // We do not limit on one auth category because this can lead to incomplete permissions being tricky to fix for the admin, roles being assigned or added non-default permissions.
406 // Since the user only has the option to copy permissions from non leader managed groups this seems to be a good compromise.
407 if ($group_perm_from && $action == 'add' && $auth->acl_get('a_authgroups') && $auth->acl_gets('a_aauth', 'a_fauth', 'a_mauth', 'a_uauth'))
408 {
409 $sql = 'SELECT group_founder_manage
410 FROM ' . GROUPS_TABLE . '
411 WHERE group_id = ' . $group_perm_from;
412 $result = $db->sql_query($sql);
413 $check_row = $db->sql_fetchrow($result);
414 $db->sql_freeresult($result);
415
416 // Check the group if non-founder
417 if ($check_row && ($user->data['user_type'] == USER_FOUNDER || $check_row['group_founder_manage'] == 0))
418 {
419 // From the mysql documentation:
420 // Prior to MySQL 4.0.14, the target table of the INSERT statement cannot appear in the FROM clause of the SELECT part of the query. This limitation is lifted in 4.0.14.
421 // Due to this we stay on the safe side if we do the insertion "the manual way"
422
423 // Copy permisisons from/to the acl groups table (only group_id gets changed)
424 $sql = 'SELECT forum_id, auth_option_id, auth_role_id, auth_setting
425 FROM ' . ACL_GROUPS_TABLE . '
426 WHERE group_id = ' . $group_perm_from;
427 $result = $db->sql_query($sql);
428
429 $groups_sql_ary = array();
430 while ($row = $db->sql_fetchrow($result))
431 {
432 $groups_sql_ary[] = array(
433 'group_id' => (int) $group_id,
434 'forum_id' => (int) $row['forum_id'],
435 'auth_option_id' => (int) $row['auth_option_id'],
436 'auth_role_id' => (int) $row['auth_role_id'],
437 'auth_setting' => (int) $row['auth_setting']
438 );
439 }
440 $db->sql_freeresult($result);
441
442 // Now insert the data
443 $db->sql_multi_insert(ACL_GROUPS_TABLE, $groups_sql_ary);
444
445 $auth->acl_clear_prefetch();
446 }
447 }
448
449 $cache->destroy('sql', GROUPS_TABLE);
450
451 $message = ($action == 'edit') ? 'GROUP_UPDATED' : 'GROUP_CREATED';
452 trigger_error($user->lang[$message] . adm_back_link($this->u_action));
453 }
454 }
455
456 if (sizeof($error))
457 {
458 $group_rank = $submit_ary['rank'];
459
460 $group_desc_data = array(
461 'text' => $group_desc,
462 'allow_bbcode' => $allow_desc_bbcode,
463 'allow_smilies' => $allow_desc_smilies,
464 'allow_urls' => $allow_desc_urls
465 );
466 }
467 }
468 else if (!$group_id)
469 {
470 $group_name = utf8_normalize_nfc(request_var('group_name', '', true));
471 $group_desc_data = array(
472 'text' => '',
473 'allow_bbcode' => true,
474 'allow_smilies' => true,
475 'allow_urls' => true
476 );
477 $group_rank = 0;
478 $group_type = GROUP_OPEN;
479 }
480 else
481 {
482 $group_name = $group_row['group_name'];
483 $group_desc_data = generate_text_for_edit($group_row['group_desc'], $group_row['group_desc_uid'], $group_row['group_desc_options']);
484 $group_type = $group_row['group_type'];
485 $group_rank = $group_row['group_rank'];
486 }
487
488 $sql = 'SELECT *
489 FROM ' . RANKS_TABLE . '
490 WHERE rank_special = 1
491 ORDER BY rank_title';
492 $result = $db->sql_query($sql);
493
494 $rank_options = '<option value="0"' . ((!$group_rank) ? ' selected="selected"' : '') . '>' . $user->lang['USER_DEFAULT'] . '</option>';
495
496 while ($row = $db->sql_fetchrow($result))
497 {
498 $selected = ($group_rank && $row['rank_id'] == $group_rank) ? ' selected="selected"' : '';
499 $rank_options .= '<option value="' . $row['rank_id'] . '"' . $selected . '>' . $row['rank_title'] . '</option>';
500 }
501 $db->sql_freeresult($result);
502
503 $type_free = ($group_type == GROUP_FREE) ? ' checked="checked"' : '';
504 $type_open = ($group_type == GROUP_OPEN) ? ' checked="checked"' : '';
505 $type_closed = ($group_type == GROUP_CLOSED) ? ' checked="checked"' : '';
506 $type_hidden = ($group_type == GROUP_HIDDEN) ? ' checked="checked"' : '';
507
508 $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_admin_path . 'images/no_avatar.gif" alt="" />';
509
510 $display_gallery = (isset($_POST['display_gallery'])) ? true : false;
511
512 if ($config['allow_avatar_local'] && $display_gallery)
513 {
514 avatar_gallery($category, $avatar_select, 4);
515 }
516
517 $back_link = request_var('back_link', '');
518
519 switch ($back_link)
520 {
521 case 'acp_users_groups':
522 $u_back = append_sid("{$phpbb_admin_path}index.$phpEx", 'i=users&mode=groups&u=' . request_var('u', 0));
523 break;
524
525 default:
526 $u_back = $this->u_action;
527 break;
528 }
529
530 $template->assign_vars(array(
531 'S_EDIT' => true,
532 'S_ADD_GROUP' => ($action == 'add') ? true : false,
533 'S_GROUP_PERM' => ($action == 'add' && $auth->acl_get('a_authgroups') && $auth->acl_gets('a_aauth', 'a_fauth', 'a_mauth', 'a_uauth')) ? true : false,
534 'S_INCLUDE_SWATCH' => true,
535 'S_CAN_UPLOAD' => $can_upload,
536 'S_ERROR' => (sizeof($error)) ? true : false,
537 'S_SPECIAL_GROUP' => ($group_type == GROUP_SPECIAL) ? true : false,
538 'S_DISPLAY_GALLERY' => ($config['allow_avatar_local'] && !$display_gallery) ? true : false,
539 'S_IN_GALLERY' => ($config['allow_avatar_local'] && $display_gallery) ? true : false,
540 'S_USER_FOUNDER' => ($user->data['user_type'] == USER_FOUNDER) ? true : false,
541
542 'ERROR_MSG' => (sizeof($error)) ? implode('<br />', $error) : '',
543 'GROUP_NAME' => ($group_type == GROUP_SPECIAL) ? $user->lang['G_' . $group_name] : $group_name,
544 'GROUP_INTERNAL_NAME' => $group_name,
545 'GROUP_DESC' => $group_desc_data['text'],
546 'GROUP_RECEIVE_PM' => (isset($group_row['group_receive_pm']) && $group_row['group_receive_pm']) ? ' checked="checked"' : '',
547 'GROUP_FOUNDER_MANAGE' => (isset($group_row['group_founder_manage']) && $group_row['group_founder_manage']) ? ' checked="checked"' : '',
548 'GROUP_LEGEND' => (isset($group_row['group_legend']) && $group_row['group_legend']) ? ' checked="checked"' : '',
549 'GROUP_MESSAGE_LIMIT' => (isset($group_row['group_message_limit'])) ? $group_row['group_message_limit'] : 0,
550 'GROUP_COLOUR' => (isset($group_row['group_colour'])) ? $group_row['group_colour'] : '',
551
552
553 'S_DESC_BBCODE_CHECKED' => $group_desc_data['allow_bbcode'],
554 'S_DESC_URLS_CHECKED' => $group_desc_data['allow_urls'],
555 'S_DESC_SMILIES_CHECKED'=> $group_desc_data['allow_smilies'],
556
557 'S_RANK_OPTIONS' => $rank_options,
558 'S_GROUP_OPTIONS' => group_select_options(false, false, (($user->data['user_type'] == USER_FOUNDER) ? false : 0)),
559 'AVATAR' => $avatar_img,
560 'AVATAR_IMAGE' => $avatar_img,
561 'AVATAR_MAX_FILESIZE' => $config['avatar_filesize'],
562 'AVATAR_WIDTH' => (isset($group_row['group_avatar_width'])) ? $group_row['group_avatar_width'] : '',
563 'AVATAR_HEIGHT' => (isset($group_row['group_avatar_height'])) ? $group_row['group_avatar_height'] : '',
564
565 'GROUP_TYPE_FREE' => GROUP_FREE,
566 'GROUP_TYPE_OPEN' => GROUP_OPEN,
567 'GROUP_TYPE_CLOSED' => GROUP_CLOSED,
568 'GROUP_TYPE_HIDDEN' => GROUP_HIDDEN,
569 'GROUP_TYPE_SPECIAL' => GROUP_SPECIAL,
570
571 'GROUP_FREE' => $type_free,
572 'GROUP_OPEN' => $type_open,
573 'GROUP_CLOSED' => $type_closed,
574 'GROUP_HIDDEN' => $type_hidden,
575
576 'U_BACK' => $u_back,
577 'U_SWATCH' => append_sid("{$phpbb_admin_path}swatch.$phpEx", 'form=settings&name=group_colour'),
578 'U_ACTION' => "{$this->u_action}&action=$action&g=$group_id",
579 'L_AVATAR_EXPLAIN' => sprintf($user->lang['AVATAR_EXPLAIN'], $config['avatar_max_width'], $config['avatar_max_height'], round($config['avatar_filesize'] / 1024)),
580 )
581 );
582
583 return;
584 break;
585
586 case 'list':
587
588 if (!$group_id)
589 {
590 trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action), E_USER_WARNING);
591 }
592
593 $this->page_title = 'GROUP_MEMBERS';
594
595 // Grab the leaders - always, on every page...
596 $sql = 'SELECT u.user_id, u.username, u.username_clean, u.user_regdate, u.user_posts, u.group_id, ug.group_leader, ug.user_pending
597 FROM ' . USERS_TABLE . ' u, ' . USER_GROUP_TABLE . " ug
598 WHERE ug.group_id = $group_id
599 AND u.user_id = ug.user_id
600 AND ug.group_leader = 1
601 ORDER BY ug.group_leader DESC, ug.user_pending ASC, u.username_clean";
602 $result = $db->sql_query($sql);
603
604 while ($row = $db->sql_fetchrow($result))
605 {
606 $template->assign_block_vars('leader', array(
607 'U_USER_EDIT' => append_sid("{$phpbb_admin_path}index.$phpEx", "i=users&action=edit&u={$row['user_id']}"),
608
609 'USERNAME' => $row['username'],
610 'S_GROUP_DEFAULT' => ($row['group_id'] == $group_id) ? true : false,
611 'JOINED' => ($row['user_regdate']) ? $user->format_date($row['user_regdate']) : ' - ',
612 'USER_POSTS' => $row['user_posts'],
613 'USER_ID' => $row['user_id'])
614 );
615 }
616 $db->sql_freeresult($result);
617
618 // Total number of group members (non-leaders)
619 $sql = 'SELECT COUNT(user_id) AS total_members
620 FROM ' . USER_GROUP_TABLE . "
621 WHERE group_id = $group_id
622 AND group_leader = 0";
623 $result = $db->sql_query($sql);
624 $total_members = (int) $db->sql_fetchfield('total_members');
625 $db->sql_freeresult($result);
626
627 $s_action_options = '';
628 $options = array('default' => 'DEFAULT', 'approve' => 'APPROVE', 'demote' => 'DEMOTE', 'promote' => 'PROMOTE', 'deleteusers' => 'DELETE');
629
630 foreach ($options as $option => $lang)
631 {
632 $s_action_options .= '<option value="' . $option . '">' . $user->lang['GROUP_' . $lang] . '</option>';
633 }
634
635 $template->assign_vars(array(
636 'S_LIST' => true,
637 'S_GROUP_SPECIAL' => ($group_row['group_type'] == GROUP_SPECIAL) ? true : false,
638 'S_ACTION_OPTIONS' => $s_action_options,
639
640 'S_ON_PAGE' => on_page($total_members, $config['topics_per_page'], $start),
641 'PAGINATION' => generate_pagination($this->u_action . "&action=$action&g=$group_id", $total_members, $config['topics_per_page'], $start, true),
642 'GROUP_NAME' => ($group_row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $group_row['group_name']] : $group_row['group_name'],
643
644 'U_ACTION' => $this->u_action . "&g=$group_id",
645 'U_BACK' => $this->u_action,
646 'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&form=list&field=usernames'),
647 'U_DEFAULT_ALL' => "{$this->u_action}&action=default&g=$group_id",
648 ));
649
650 // Grab the members
651 $sql = 'SELECT u.user_id, u.username, u.username_clean, u.user_regdate, u.user_posts, u.group_id, ug.group_leader, ug.user_pending
652 FROM ' . USERS_TABLE . ' u, ' . USER_GROUP_TABLE . " ug
653 WHERE ug.group_id = $group_id
654 AND u.user_id = ug.user_id
655 AND ug.group_leader = 0
656 ORDER BY ug.group_leader DESC, ug.user_pending ASC, u.username_clean";
657 $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start);
658
659 $pending = false;
660
661 while ($row = $db->sql_fetchrow($result))
662 {
663 if ($row['user_pending'] && !$pending)
664 {
665 $template->assign_block_vars('member', array(
666 'S_PENDING' => true)
667 );
668
669 $pending = true;
670 }
671
672 $template->assign_block_vars('member', array(
673 'U_USER_EDIT' => append_sid("{$phpbb_admin_path}index.$phpEx", "i=users&action=edit&u={$row['user_id']}"),
674
675 'USERNAME' => $row['username'],
676 'S_GROUP_DEFAULT' => ($row['group_id'] == $group_id) ? true : false,
677 'JOINED' => ($row['user_regdate']) ? $user->format_date($row['user_regdate']) : ' - ',
678 'USER_POSTS' => $row['user_posts'],
679 'USER_ID' => $row['user_id'])
680 );
681 }
682 $db->sql_freeresult($result);
683
684 return;
685 break;
686 }
687
688 $template->assign_vars(array(
689 'U_ACTION' => $this->u_action,
690 'S_GROUP_ADD' => ($auth->acl_get('a_groupadd')) ? true : false)
691 );
692
693 // Get us all the groups
694 $sql = 'SELECT g.group_id, g.group_name, g.group_type
695 FROM ' . GROUPS_TABLE . ' g
696 ORDER BY g.group_type ASC, g.group_name';
697 $result = $db->sql_query($sql);
698
699 $lookup = $cached_group_data = array();
700 while ($row = $db->sql_fetchrow($result))
701 {
702 $type = ($row['group_type'] == GROUP_SPECIAL) ? 'special' : 'normal';
703
704 // used to determine what type a group is
705 $lookup[$row['group_id']] = $type;
706
707 // used for easy access to the data within a group
708 $cached_group_data[$type][$row['group_id']] = $row;
709 $cached_group_data[$type][$row['group_id']]['total_members'] = 0;
710 }
711 $db->sql_freeresult($result);
712
713 // How many people are in which group?
714 $sql = 'SELECT COUNT(ug.user_id) AS total_members, ug.group_id
715 FROM ' . USER_GROUP_TABLE . ' ug
716 WHERE ' . $db->sql_in_set('ug.group_id', array_keys($lookup)) . '
717 GROUP BY ug.group_id';
718 $result = $db->sql_query($sql);
719
720 while ($row = $db->sql_fetchrow($result))
721 {
722 $type = $lookup[$row['group_id']];
723 $cached_group_data[$type][$row['group_id']]['total_members'] = $row['total_members'];
724 }
725 $db->sql_freeresult($result);
726
727 // The order is... normal, then special
728 ksort($cached_group_data);
729
730 foreach ($cached_group_data as $type => $row_ary)
731 {
732 if ($type == 'special')
733 {
734 $template->assign_block_vars('groups', array(
735 'S_SPECIAL' => true)
736 );
737 }
738
739 foreach ($row_ary as $group_id => $row)
740 {
741 $group_name = (!empty($user->lang['G_' . $row['group_name']]))? $user->lang['G_' . $row['group_name']] : $row['group_name'];
742
743 $template->assign_block_vars('groups', array(
744 'U_LIST' => "{$this->u_action}&action=list&g=$group_id",
745 'U_EDIT' => "{$this->u_action}&action=edit&g=$group_id",
746 'U_DELETE' => ($auth->acl_get('a_groupdel')) ? "{$this->u_action}&action=delete&g=$group_id" : '',
747
748 'S_GROUP_SPECIAL' => ($row['group_type'] == GROUP_SPECIAL) ? true : false,
749
750 'GROUP_NAME' => $group_name,
751 'TOTAL_MEMBERS' => $row['total_members'],
752 )
753 );
754 }
755 }
756 }
757 }
758
759 ?>