|
|
ef5584 |
|
|
|
ef5584 |
/**
|
|
|
ef5584 |
*
|
|
|
ef5584 |
* @package acp
|
|
|
ef5584 |
* @version $Id: acp_groups.php 9053 2008-11-09 15:10:40Z acydburn $
|
|
|
ef5584 |
* @copyright (c) 2005 phpBB Group
|
|
|
ef5584 |
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
|
|
ef5584 |
*
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
|
|
|
ef5584 |
/**
|
|
|
ef5584 |
* @ignore
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
if (!defined('IN_PHPBB'))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
exit;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
/**
|
|
|
ef5584 |
* @package acp
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
class acp_groups
|
|
|
ef5584 |
{
|
|
|
ef5584 |
var $u_action;
|
|
|
ef5584 |
|
|
|
ef5584 |
function main($id, $mode)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
global $config, $db, $user, $auth, $template, $cache;
|
|
|
ef5584 |
global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix, $file_uploads;
|
|
|
ef5584 |
|
|
|
ef5584 |
$user->add_lang('acp/groups');
|
|
|
ef5584 |
$this->tpl_name = 'acp_groups';
|
|
|
ef5584 |
$this->page_title = 'ACP_GROUPS_MANAGE';
|
|
|
ef5584 |
|
|
|
ef5584 |
$form_key = 'acp_groups';
|
|
|
ef5584 |
add_form_key($form_key);
|
|
|
ef5584 |
|
|
|
ef5584 |
include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
|
|
|
ef5584 |
|
|
|
ef5584 |
// Check and set some common vars
|
|
|
ef5584 |
$action = (isset($_POST['add'])) ? 'add' : ((isset($_POST['addusers'])) ? 'addusers' : request_var('action', ''));
|
|
|
ef5584 |
$group_id = request_var('g', 0);
|
|
|
ef5584 |
$mark_ary = request_var('mark', array(0));
|
|
|
ef5584 |
$name_ary = request_var('usernames', '', true);
|
|
|
ef5584 |
$leader = request_var('leader', 0);
|
|
|
ef5584 |
$default = request_var('default', 0);
|
|
|
ef5584 |
$start = request_var('start', 0);
|
|
|
ef5584 |
$update = (isset($_POST['update'])) ? true : false;
|
|
|
ef5584 |
|
|
|
ef5584 |
|
|
|
ef5584 |
// Clear some vars
|
|
|
ef5584 |
$can_upload = (file_exists($phpbb_root_path . $config['avatar_path']) && @is_writable($phpbb_root_path . $config['avatar_path']) && $file_uploads) ? true : false;
|
|
|
ef5584 |
$group_row = array();
|
|
|
ef5584 |
|
|
|
ef5584 |
// Grab basic data for group, if group_id is set and exists
|
|
|
ef5584 |
if ($group_id)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$sql = 'SELECT *
|
|
|
ef5584 |
FROM ' . GROUPS_TABLE . "
|
|
|
ef5584 |
WHERE group_id = $group_id";
|
|
|
ef5584 |
$result = $db->sql_query($sql);
|
|
|
ef5584 |
$group_row = $db->sql_fetchrow($result);
|
|
|
ef5584 |
$db->sql_freeresult($result);
|
|
|
ef5584 |
|
|
|
ef5584 |
if (!$group_row)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action), E_USER_WARNING);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
// Check if the user is allowed to manage this group if set to founder only.
|
|
|
ef5584 |
if ($user->data['user_type'] != USER_FOUNDER && $group_row['group_founder_manage'])
|
|
|
ef5584 |
{
|
|
|
ef5584 |
trigger_error($user->lang['NOT_ALLOWED_MANAGE_GROUP'] . adm_back_link($this->u_action), E_USER_WARNING);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
// Which page?
|
|
|
ef5584 |
switch ($action)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
case 'approve':
|
|
|
ef5584 |
case 'demote':
|
|
|
ef5584 |
case 'promote':
|
|
|
ef5584 |
if (!$group_id)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action), E_USER_WARNING);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
// Approve, demote or promote
|
|
|
ef5584 |
$group_name = ($group_row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $group_row['group_name']] : $group_row['group_name'];
|
|
|
ef5584 |
$error = group_user_attributes($action, $group_id, $mark_ary, false, $group_name);
|
|
|
ef5584 |
|
|
|
ef5584 |
if (!$error)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
switch ($action)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
case 'demote':
|
|
|
ef5584 |
$message = 'GROUP_MODS_DEMOTED';
|
|
|
ef5584 |
break;
|
|
|
ef5584 |
|
|
|
ef5584 |
case 'promote':
|
|
|
ef5584 |
$message = 'GROUP_MODS_PROMOTED';
|
|
|
ef5584 |
break;
|
|
|
ef5584 |
|
|
|
ef5584 |
case 'approve':
|
|
|
ef5584 |
$message = 'USERS_APPROVED';
|
|
|
ef5584 |
break;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
trigger_error($user->lang[$message] . adm_back_link($this->u_action . '&action=list&g=' . $group_id));
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else
|
|
|
ef5584 |
{
|
|
|
ef5584 |
trigger_error($user->lang[$error] . adm_back_link($this->u_action . '&action=list&g=' . $group_id), E_USER_WARNING);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
break;
|
|
|
ef5584 |
|
|
|
ef5584 |
case 'default':
|
|
|
ef5584 |
if (!$group_id)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action), E_USER_WARNING);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if (confirm_box(true))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$group_name = ($group_row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $group_row['group_name']] : $group_row['group_name'];
|
|
|
ef5584 |
|
|
|
ef5584 |
if (!sizeof($mark_ary))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$start = 0;
|
|
|
ef5584 |
|
|
|
ef5584 |
do
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$sql = 'SELECT user_id
|
|
|
ef5584 |
FROM ' . USER_GROUP_TABLE . "
|
|
|
ef5584 |
WHERE group_id = $group_id
|
|
|
ef5584 |
ORDER BY user_id";
|
|
|
ef5584 |
$result = $db->sql_query_limit($sql, 200, $start);
|
|
|
ef5584 |
|
|
|
ef5584 |
$mark_ary = array();
|
|
|
ef5584 |
if ($row = $db->sql_fetchrow($result))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
do
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$mark_ary[] = $row['user_id'];
|
|
|
ef5584 |
}
|
|
|
ef5584 |
while ($row = $db->sql_fetchrow($result));
|
|
|
ef5584 |
|
|
|
ef5584 |
group_user_attributes('default', $group_id, $mark_ary, false, $group_name, $group_row);
|
|
|
ef5584 |
|
|
|
ef5584 |
$start = (sizeof($mark_ary) < 200) ? 0 : $start + 200;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$start = 0;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
$db->sql_freeresult($result);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
while ($start);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else
|
|
|
ef5584 |
{
|
|
|
ef5584 |
group_user_attributes('default', $group_id, $mark_ary, false, $group_name, $group_row);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
trigger_error($user->lang['GROUP_DEFS_UPDATED'] . adm_back_link($this->u_action . '&action=list&g=' . $group_id));
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else
|
|
|
ef5584 |
{
|
|
|
ef5584 |
confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
|
|
|
ef5584 |
'mark' => $mark_ary,
|
|
|
ef5584 |
'g' => $group_id,
|
|
|
ef5584 |
'i' => $id,
|
|
|
ef5584 |
'mode' => $mode,
|
|
|
ef5584 |
'action' => $action))
|
|
|
ef5584 |
);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
break;
|
|
|
ef5584 |
|
|
|
ef5584 |
case 'deleteusers':
|
|
|
ef5584 |
case 'delete':
|
|
|
ef5584 |
if (!$group_id)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action), E_USER_WARNING);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else if ($action === 'delete' && $group_row['group_type'] == GROUP_SPECIAL)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if (confirm_box(true))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$error = '';
|
|
|
ef5584 |
|
|
|
ef5584 |
switch ($action)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
case 'delete':
|
|
|
ef5584 |
if (!$auth->acl_get('a_groupdel'))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$error = group_delete($group_id, $group_row['group_name']);
|
|
|
ef5584 |
break;
|
|
|
ef5584 |
|
|
|
ef5584 |
case 'deleteusers':
|
|
|
ef5584 |
$group_name = ($group_row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $group_row['group_name']] : $group_row['group_name'];
|
|
|
ef5584 |
$error = group_user_del($group_id, $mark_ary, false, $group_name);
|
|
|
ef5584 |
break;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$back_link = ($action == 'delete') ? $this->u_action : $this->u_action . '&action=list&g=' . $group_id;
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($error)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
trigger_error($user->lang[$error] . adm_back_link($back_link), E_USER_WARNING);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$message = ($action == 'delete') ? 'GROUP_DELETED' : 'GROUP_USERS_REMOVE';
|
|
|
ef5584 |
trigger_error($user->lang[$message] . adm_back_link($back_link));
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else
|
|
|
ef5584 |
{
|
|
|
ef5584 |
confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
|
|
|
ef5584 |
'mark' => $mark_ary,
|
|
|
ef5584 |
'g' => $group_id,
|
|
|
ef5584 |
'i' => $id,
|
|
|
ef5584 |
'mode' => $mode,
|
|
|
ef5584 |
'action' => $action))
|
|
|
ef5584 |
);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
break;
|
|
|
ef5584 |
|
|
|
ef5584 |
case 'addusers':
|
|
|
ef5584 |
if (!$group_id)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action), E_USER_WARNING);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if (!$name_ary)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
trigger_error($user->lang['NO_USERS'] . adm_back_link($this->u_action . '&action=list&g=' . $group_id), E_USER_WARNING);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$name_ary = array_unique(explode("\n", $name_ary));
|
|
|
ef5584 |
$group_name = ($group_row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $group_row['group_name']] : $group_row['group_name'];
|
|
|
ef5584 |
|
|
|
ef5584 |
// Add user/s to group
|
|
|
ef5584 |
if ($error = group_user_add($group_id, false, $name_ary, $group_name, $default, $leader, 0, $group_row))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
trigger_error($user->lang[$error] . adm_back_link($this->u_action . '&action=list&g=' . $group_id), E_USER_WARNING);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$message = ($leader) ? 'GROUP_MODS_ADDED' : 'GROUP_USERS_ADDED';
|
|
|
ef5584 |
trigger_error($user->lang[$message] . adm_back_link($this->u_action . '&action=list&g=' . $group_id));
|
|
|
ef5584 |
break;
|
|
|
ef5584 |
|
|
|
ef5584 |
case 'edit':
|
|
|
ef5584 |
case 'add':
|
|
|
ef5584 |
|
|
|
ef5584 |
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
|
|
|
ef5584 |
|
|
|
ef5584 |
$data = $submit_ary = array();
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($action == 'edit' && !$group_id)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action), E_USER_WARNING);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($action == 'add' && !$auth->acl_get('a_groupadd'))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$error = array();
|
|
|
ef5584 |
$user->add_lang('ucp');
|
|
|
ef5584 |
|
|
|
ef5584 |
$avatar_select = basename(request_var('avatar_select', ''));
|
|
|
ef5584 |
$category = basename(request_var('category', ''));
|
|
|
ef5584 |
|
|
|
ef5584 |
// Did we submit?
|
|
|
ef5584 |
if ($update)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if (!check_form_key($form_key))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$group_name = utf8_normalize_nfc(request_var('group_name', '', true));
|
|
|
ef5584 |
$group_desc = utf8_normalize_nfc(request_var('group_desc', '', true));
|
|
|
ef5584 |
$group_type = request_var('group_type', GROUP_FREE);
|
|
|
ef5584 |
|
|
|
ef5584 |
$allow_desc_bbcode = request_var('desc_parse_bbcode', false);
|
|
|
ef5584 |
$allow_desc_urls = request_var('desc_parse_urls', false);
|
|
|
ef5584 |
$allow_desc_smilies = request_var('desc_parse_smilies', false);
|
|
|
ef5584 |
|
|
|
ef5584 |
$data['uploadurl'] = request_var('uploadurl', '');
|
|
|
ef5584 |
$data['remotelink'] = request_var('remotelink', '');
|
|
|
ef5584 |
$data['width'] = request_var('width', '');
|
|
|
ef5584 |
$data['height'] = request_var('height', '');
|
|
|
ef5584 |
$delete = request_var('delete', '');
|
|
|
ef5584 |
|
|
|
ef5584 |
$submit_ary = array(
|
|
|
ef5584 |
'colour' => request_var('group_colour', ''),
|
|
|
ef5584 |
'rank' => request_var('group_rank', 0),
|
|
|
ef5584 |
'receive_pm' => isset($_REQUEST['group_receive_pm']) ? 1 : 0,
|
|
|
ef5584 |
'legend' => isset($_REQUEST['group_legend']) ? 1 : 0,
|
|
|
ef5584 |
'message_limit' => request_var('group_message_limit', 0),
|
|
|
ef5584 |
'max_recipients' => request_var('group_max_recipients', 0),
|
|
|
ef5584 |
'founder_manage' => 0,
|
|
|
ef5584 |
);
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($user->data['user_type'] == USER_FOUNDER)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$submit_ary['founder_manage'] = isset($_REQUEST['group_founder_manage']) ? 1 : 0;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if (!empty($_FILES['uploadfile']['tmp_name']) || $data['uploadurl'] || $data['remotelink'])
|
|
|
ef5584 |
{
|
|
|
ef5584 |
// Avatar stuff
|
|
|
ef5584 |
$var_ary = array(
|
|
|
ef5584 |
'uploadurl' => array('string', true, 5, 255),
|
|
|
ef5584 |
'remotelink' => array('string', true, 5, 255),
|
|
|
ef5584 |
'width' => array('string', true, 1, 3),
|
|
|
ef5584 |
'height' => array('string', true, 1, 3),
|
|
|
ef5584 |
);
|
|
|
ef5584 |
|
|
|
ef5584 |
if (!($error = validate_data($data, $var_ary)))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$data['user_id'] = "g$group_id";
|
|
|
ef5584 |
|
|
|
ef5584 |
if ((!empty($_FILES['uploadfile']['tmp_name']) || $data['uploadurl']) && $can_upload)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
list($submit_ary['avatar_type'], $submit_ary['avatar'], $submit_ary['avatar_width'], $submit_ary['avatar_height']) = avatar_upload($data, $error);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else if ($data['remotelink'])
|
|
|
ef5584 |
{
|
|
|
ef5584 |
list($submit_ary['avatar_type'], $submit_ary['avatar'], $submit_ary['avatar_width'], $submit_ary['avatar_height']) = avatar_remote($data, $error);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else if ($avatar_select && $config['allow_avatar_local'])
|
|
|
ef5584 |
{
|
|
|
ef5584 |
// check avatar gallery
|
|
|
ef5584 |
if (is_dir($phpbb_root_path . $config['avatar_gallery_path'] . '/' . $category))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$submit_ary['avatar_type'] = AVATAR_GALLERY;
|
|
|
ef5584 |
|
|
|
ef5584 |
list($submit_ary['avatar_width'], $submit_ary['avatar_height']) = getimagesize($phpbb_root_path . $config['avatar_gallery_path'] . '/' . $category . '/' . $avatar_select);
|
|
|
ef5584 |
$submit_ary['avatar'] = $category . '/' . $avatar_select;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else if ($delete)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$submit_ary['avatar'] = '';
|
|
|
ef5584 |
$submit_ary['avatar_type'] = $submit_ary['avatar_width'] = $submit_ary['avatar_height'] = 0;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else if ($data['width'] && $data['height'])
|
|
|
ef5584 |
{
|
|
|
ef5584 |
// Only update the dimensions?
|
|
|
ef5584 |
if ($config['avatar_max_width'] || $config['avatar_max_height'])
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if ($data['width'] > $config['avatar_max_width'] || $data['height'] > $config['avatar_max_height'])
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$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']);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if (!sizeof($error))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if ($config['avatar_min_width'] || $config['avatar_min_height'])
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if ($data['width'] < $config['avatar_min_width'] || $data['height'] < $config['avatar_min_height'])
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$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']);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if (!sizeof($error))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$submit_ary['avatar_width'] = $data['width'];
|
|
|
ef5584 |
$submit_ary['avatar_height'] = $data['height'];
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if ((isset($submit_ary['avatar']) && $submit_ary['avatar'] && (!isset($group_row['group_avatar']))) || $delete)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if (isset($group_row['group_avatar']) && $group_row['group_avatar'])
|
|
|
ef5584 |
{
|
|
|
ef5584 |
avatar_delete('group', $group_row, true);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if (!sizeof($error))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
// Only set the rank, colour, etc. if it's changed or if we're adding a new
|
|
|
ef5584 |
// group. This prevents existing group members being updated if no changes
|
|
|
ef5584 |
// were made.
|
|
|
ef5584 |
|
|
|
ef5584 |
$group_attributes = array();
|
|
|
ef5584 |
$test_variables = array('rank', 'colour', 'avatar', 'avatar_type', 'avatar_width', 'avatar_height', 'receive_pm', 'legend', 'message_limit', 'max_recipients', 'founder_manage');
|
|
|
ef5584 |
foreach ($test_variables as $test)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if (isset($submit_ary[$test]) && ($action == 'add' || $group_row['group_' . $test] != $submit_ary[$test]))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$group_attributes['group_' . $test] = $group_row['group_' . $test] = $submit_ary[$test];
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if (!($error = group_create($group_id, $group_type, $group_name, $group_desc, $group_attributes, $allow_desc_bbcode, $allow_desc_urls, $allow_desc_smilies)))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$group_perm_from = request_var('group_perm_from', 0);
|
|
|
ef5584 |
|
|
|
ef5584 |
// Copy permissions?
|
|
|
ef5584 |
// If the user has the a_authgroups permission and at least one additional permission ability set the permissions are fully transferred.
|
|
|
ef5584 |
// 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.
|
|
|
ef5584 |
// Since the user only has the option to copy permissions from non leader managed groups this seems to be a good compromise.
|
|
|
ef5584 |
if ($group_perm_from && $action == 'add' && $auth->acl_get('a_authgroups') && $auth->acl_gets('a_aauth', 'a_fauth', 'a_mauth', 'a_uauth'))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$sql = 'SELECT group_founder_manage
|
|
|
ef5584 |
FROM ' . GROUPS_TABLE . '
|
|
|
ef5584 |
WHERE group_id = ' . $group_perm_from;
|
|
|
ef5584 |
$result = $db->sql_query($sql);
|
|
|
ef5584 |
$check_row = $db->sql_fetchrow($result);
|
|
|
ef5584 |
$db->sql_freeresult($result);
|
|
|
ef5584 |
|
|
|
ef5584 |
// Check the group if non-founder
|
|
|
ef5584 |
if ($check_row && ($user->data['user_type'] == USER_FOUNDER || $check_row['group_founder_manage'] == 0))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
// From the mysql documentation:
|
|
|
ef5584 |
// 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.
|
|
|
ef5584 |
// Due to this we stay on the safe side if we do the insertion "the manual way"
|
|
|
ef5584 |
|
|
|
ef5584 |
// Copy permisisons from/to the acl groups table (only group_id gets changed)
|
|
|
ef5584 |
$sql = 'SELECT forum_id, auth_option_id, auth_role_id, auth_setting
|
|
|
ef5584 |
FROM ' . ACL_GROUPS_TABLE . '
|
|
|
ef5584 |
WHERE group_id = ' . $group_perm_from;
|
|
|
ef5584 |
$result = $db->sql_query($sql);
|
|
|
ef5584 |
|
|
|
ef5584 |
$groups_sql_ary = array();
|
|
|
ef5584 |
while ($row = $db->sql_fetchrow($result))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$groups_sql_ary[] = array(
|
|
|
ef5584 |
'group_id' => (int) $group_id,
|
|
|
ef5584 |
'forum_id' => (int) $row['forum_id'],
|
|
|
ef5584 |
'auth_option_id' => (int) $row['auth_option_id'],
|
|
|
ef5584 |
'auth_role_id' => (int) $row['auth_role_id'],
|
|
|
ef5584 |
'auth_setting' => (int) $row['auth_setting']
|
|
|
ef5584 |
);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
$db->sql_freeresult($result);
|
|
|
ef5584 |
|
|
|
ef5584 |
// Now insert the data
|
|
|
ef5584 |
$db->sql_multi_insert(ACL_GROUPS_TABLE, $groups_sql_ary);
|
|
|
ef5584 |
|
|
|
ef5584 |
$auth->acl_clear_prefetch();
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$cache->destroy('sql', GROUPS_TABLE);
|
|
|
ef5584 |
|
|
|
ef5584 |
$message = ($action == 'edit') ? 'GROUP_UPDATED' : 'GROUP_CREATED';
|
|
|
ef5584 |
trigger_error($user->lang[$message] . adm_back_link($this->u_action));
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if (sizeof($error))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$group_rank = $submit_ary['rank'];
|
|
|
ef5584 |
|
|
|
ef5584 |
$group_desc_data = array(
|
|
|
ef5584 |
'text' => $group_desc,
|
|
|
ef5584 |
'allow_bbcode' => $allow_desc_bbcode,
|
|
|
ef5584 |
'allow_smilies' => $allow_desc_smilies,
|
|
|
ef5584 |
'allow_urls' => $allow_desc_urls
|
|
|
ef5584 |
);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else if (!$group_id)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$group_name = utf8_normalize_nfc(request_var('group_name', '', true));
|
|
|
ef5584 |
$group_desc_data = array(
|
|
|
ef5584 |
'text' => '',
|
|
|
ef5584 |
'allow_bbcode' => true,
|
|
|
ef5584 |
'allow_smilies' => true,
|
|
|
ef5584 |
'allow_urls' => true
|
|
|
ef5584 |
);
|
|
|
ef5584 |
$group_rank = 0;
|
|
|
ef5584 |
$group_type = GROUP_OPEN;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$group_name = $group_row['group_name'];
|
|
|
ef5584 |
$group_desc_data = generate_text_for_edit($group_row['group_desc'], $group_row['group_desc_uid'], $group_row['group_desc_options']);
|
|
|
ef5584 |
$group_type = $group_row['group_type'];
|
|
|
ef5584 |
$group_rank = $group_row['group_rank'];
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$sql = 'SELECT *
|
|
|
ef5584 |
FROM ' . RANKS_TABLE . '
|
|
|
ef5584 |
WHERE rank_special = 1
|
|
|
ef5584 |
ORDER BY rank_title';
|
|
|
ef5584 |
$result = $db->sql_query($sql);
|
|
|
ef5584 |
|
|
|
ef5584 |
$rank_options = '<option value="0"' . ((!$group_rank) ? ' selected="selected"' : '') . '>' . $user->lang['USER_DEFAULT'] . '</option>';
|
|
|
ef5584 |
|
|
|
ef5584 |
while ($row = $db->sql_fetchrow($result))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$selected = ($group_rank && $row['rank_id'] == $group_rank) ? ' selected="selected"' : '';
|
|
|
ef5584 |
$rank_options .= '<option value="' . $row['rank_id'] . '"' . $selected . '>' . $row['rank_title'] . '</option>';
|
|
|
ef5584 |
}
|
|
|
ef5584 |
$db->sql_freeresult($result);
|
|
|
ef5584 |
|
|
|
ef5584 |
$type_free = ($group_type == GROUP_FREE) ? ' checked="checked"' : '';
|
|
|
ef5584 |
$type_open = ($group_type == GROUP_OPEN) ? ' checked="checked"' : '';
|
|
|
ef5584 |
$type_closed = ($group_type == GROUP_CLOSED) ? ' checked="checked"' : '';
|
|
|
ef5584 |
$type_hidden = ($group_type == GROUP_HIDDEN) ? ' checked="checked"' : '';
|
|
|
ef5584 |
|
|
|
ef5584 |
$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') : '';
|
|
|
ef5584 |
|
|
|
ef5584 |
$display_gallery = (isset($_POST['display_gallery'])) ? true : false;
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($config['allow_avatar_local'] && $display_gallery)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
avatar_gallery($category, $avatar_select, 4);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$back_link = request_var('back_link', '');
|
|
|
ef5584 |
|
|
|
ef5584 |
switch ($back_link)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
case 'acp_users_groups':
|
|
|
ef5584 |
$u_back = append_sid("{$phpbb_admin_path}index.$phpEx", 'i=users&mode=groups&u=' . request_var('u', 0));
|
|
|
ef5584 |
break;
|
|
|
ef5584 |
|
|
|
ef5584 |
default:
|
|
|
ef5584 |
$u_back = $this->u_action;
|
|
|
ef5584 |
break;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$template->assign_vars(array(
|
|
|
ef5584 |
'S_EDIT' => true,
|
|
|
ef5584 |
'S_ADD_GROUP' => ($action == 'add') ? true : false,
|
|
|
ef5584 |
'S_GROUP_PERM' => ($action == 'add' && $auth->acl_get('a_authgroups') && $auth->acl_gets('a_aauth', 'a_fauth', 'a_mauth', 'a_uauth')) ? true : false,
|
|
|
ef5584 |
'S_INCLUDE_SWATCH' => true,
|
|
|
ef5584 |
'S_CAN_UPLOAD' => $can_upload,
|
|
|
ef5584 |
'S_ERROR' => (sizeof($error)) ? true : false,
|
|
|
ef5584 |
'S_SPECIAL_GROUP' => ($group_type == GROUP_SPECIAL) ? true : false,
|
|
|
ef5584 |
'S_DISPLAY_GALLERY' => ($config['allow_avatar_local'] && !$display_gallery) ? true : false,
|
|
|
ef5584 |
'S_IN_GALLERY' => ($config['allow_avatar_local'] && $display_gallery) ? true : false,
|
|
|
ef5584 |
'S_USER_FOUNDER' => ($user->data['user_type'] == USER_FOUNDER) ? true : false,
|
|
|
ef5584 |
|
|
|
ef5584 |
'ERROR_MSG' => (sizeof($error)) ? implode(' ', $error) : '',
|
|
|
ef5584 |
'GROUP_NAME' => ($group_type == GROUP_SPECIAL) ? $user->lang['G_' . $group_name] : $group_name,
|
|
|
ef5584 |
'GROUP_INTERNAL_NAME' => $group_name,
|
|
|
ef5584 |
'GROUP_DESC' => $group_desc_data['text'],
|
|
|
ef5584 |
'GROUP_RECEIVE_PM' => (isset($group_row['group_receive_pm']) && $group_row['group_receive_pm']) ? ' checked="checked"' : '',
|
|
|
ef5584 |
'GROUP_FOUNDER_MANAGE' => (isset($group_row['group_founder_manage']) && $group_row['group_founder_manage']) ? ' checked="checked"' : '',
|
|
|
ef5584 |
'GROUP_LEGEND' => (isset($group_row['group_legend']) && $group_row['group_legend']) ? ' checked="checked"' : '',
|
|
|
ef5584 |
'GROUP_MESSAGE_LIMIT' => (isset($group_row['group_message_limit'])) ? $group_row['group_message_limit'] : 0,
|
|
|
ef5584 |
'GROUP_MAX_RECIPIENTS' => (isset($group_row['group_max_recipients'])) ? $group_row['group_max_recipients'] : 0,
|
|
|
ef5584 |
'GROUP_COLOUR' => (isset($group_row['group_colour'])) ? $group_row['group_colour'] : '',
|
|
|
ef5584 |
|
|
|
ef5584 |
|
|
|
ef5584 |
'S_DESC_BBCODE_CHECKED' => $group_desc_data['allow_bbcode'],
|
|
|
ef5584 |
'S_DESC_URLS_CHECKED' => $group_desc_data['allow_urls'],
|
|
|
ef5584 |
'S_DESC_SMILIES_CHECKED'=> $group_desc_data['allow_smilies'],
|
|
|
ef5584 |
|
|
|
ef5584 |
'S_RANK_OPTIONS' => $rank_options,
|
|
|
ef5584 |
'S_GROUP_OPTIONS' => group_select_options(false, false, (($user->data['user_type'] == USER_FOUNDER) ? false : 0)),
|
|
|
ef5584 |
'AVATAR' => $avatar_img,
|
|
|
ef5584 |
'AVATAR_IMAGE' => $avatar_img,
|
|
|
ef5584 |
'AVATAR_MAX_FILESIZE' => $config['avatar_filesize'],
|
|
|
ef5584 |
'AVATAR_WIDTH' => (isset($group_row['group_avatar_width'])) ? $group_row['group_avatar_width'] : '',
|
|
|
ef5584 |
'AVATAR_HEIGHT' => (isset($group_row['group_avatar_height'])) ? $group_row['group_avatar_height'] : '',
|
|
|
ef5584 |
|
|
|
ef5584 |
'GROUP_TYPE_FREE' => GROUP_FREE,
|
|
|
ef5584 |
'GROUP_TYPE_OPEN' => GROUP_OPEN,
|
|
|
ef5584 |
'GROUP_TYPE_CLOSED' => GROUP_CLOSED,
|
|
|
ef5584 |
'GROUP_TYPE_HIDDEN' => GROUP_HIDDEN,
|
|
|
ef5584 |
'GROUP_TYPE_SPECIAL' => GROUP_SPECIAL,
|
|
|
ef5584 |
|
|
|
ef5584 |
'GROUP_FREE' => $type_free,
|
|
|
ef5584 |
'GROUP_OPEN' => $type_open,
|
|
|
ef5584 |
'GROUP_CLOSED' => $type_closed,
|
|
|
ef5584 |
'GROUP_HIDDEN' => $type_hidden,
|
|
|
ef5584 |
|
|
|
ef5584 |
'U_BACK' => $u_back,
|
|
|
ef5584 |
'U_SWATCH' => append_sid("{$phpbb_admin_path}swatch.$phpEx", 'form=settings&name=group_colour'),
|
|
|
ef5584 |
'U_ACTION' => "{$this->u_action}&action=$action&g=$group_id",
|
|
|
ef5584 |
'L_AVATAR_EXPLAIN' => sprintf($user->lang['AVATAR_EXPLAIN'], $config['avatar_max_width'], $config['avatar_max_height'], round($config['avatar_filesize'] / 1024)),
|
|
|
ef5584 |
)
|
|
|
ef5584 |
);
|
|
|
ef5584 |
|
|
|
ef5584 |
return;
|
|
|
ef5584 |
break;
|
|
|
ef5584 |
|
|
|
ef5584 |
case 'list':
|
|
|
ef5584 |
|
|
|
ef5584 |
if (!$group_id)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action), E_USER_WARNING);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$this->page_title = 'GROUP_MEMBERS';
|
|
|
ef5584 |
|
|
|
ef5584 |
// Grab the leaders - always, on every page...
|
|
|
ef5584 |
$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
|
|
|
ef5584 |
FROM ' . USERS_TABLE . ' u, ' . USER_GROUP_TABLE . " ug
|
|
|
ef5584 |
WHERE ug.group_id = $group_id
|
|
|
ef5584 |
AND u.user_id = ug.user_id
|
|
|
ef5584 |
AND ug.group_leader = 1
|
|
|
ef5584 |
ORDER BY ug.group_leader DESC, ug.user_pending ASC, u.username_clean";
|
|
|
ef5584 |
$result = $db->sql_query($sql);
|
|
|
ef5584 |
|
|
|
ef5584 |
while ($row = $db->sql_fetchrow($result))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$template->assign_block_vars('leader', array(
|
|
|
ef5584 |
'U_USER_EDIT' => append_sid("{$phpbb_admin_path}index.$phpEx", "i=users&action=edit&u={$row['user_id']}"),
|
|
|
ef5584 |
|
|
|
ef5584 |
'USERNAME' => $row['username'],
|
|
|
ef5584 |
'S_GROUP_DEFAULT' => ($row['group_id'] == $group_id) ? true : false,
|
|
|
ef5584 |
'JOINED' => ($row['user_regdate']) ? $user->format_date($row['user_regdate']) : ' - ',
|
|
|
ef5584 |
'USER_POSTS' => $row['user_posts'],
|
|
|
ef5584 |
'USER_ID' => $row['user_id'])
|
|
|
ef5584 |
);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
$db->sql_freeresult($result);
|
|
|
ef5584 |
|
|
|
ef5584 |
// Total number of group members (non-leaders)
|
|
|
ef5584 |
$sql = 'SELECT COUNT(user_id) AS total_members
|
|
|
ef5584 |
FROM ' . USER_GROUP_TABLE . "
|
|
|
ef5584 |
WHERE group_id = $group_id
|
|
|
ef5584 |
AND group_leader = 0";
|
|
|
ef5584 |
$result = $db->sql_query($sql);
|
|
|
ef5584 |
$total_members = (int) $db->sql_fetchfield('total_members');
|
|
|
ef5584 |
$db->sql_freeresult($result);
|
|
|
ef5584 |
|
|
|
ef5584 |
$s_action_options = '';
|
|
|
ef5584 |
$options = array('default' => 'DEFAULT', 'approve' => 'APPROVE', 'demote' => 'DEMOTE', 'promote' => 'PROMOTE', 'deleteusers' => 'DELETE');
|
|
|
ef5584 |
|
|
|
ef5584 |
foreach ($options as $option => $lang)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$s_action_options .= '<option value="' . $option . '">' . $user->lang['GROUP_' . $lang] . '</option>';
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$template->assign_vars(array(
|
|
|
ef5584 |
'S_LIST' => true,
|
|
|
ef5584 |
'S_GROUP_SPECIAL' => ($group_row['group_type'] == GROUP_SPECIAL) ? true : false,
|
|
|
ef5584 |
'S_ACTION_OPTIONS' => $s_action_options,
|
|
|
ef5584 |
|
|
|
ef5584 |
'S_ON_PAGE' => on_page($total_members, $config['topics_per_page'], $start),
|
|
|
ef5584 |
'PAGINATION' => generate_pagination($this->u_action . "&action=$action&g=$group_id", $total_members, $config['topics_per_page'], $start, true),
|
|
|
ef5584 |
'GROUP_NAME' => ($group_row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $group_row['group_name']] : $group_row['group_name'],
|
|
|
ef5584 |
|
|
|
ef5584 |
'U_ACTION' => $this->u_action . "&g=$group_id",
|
|
|
ef5584 |
'U_BACK' => $this->u_action,
|
|
|
ef5584 |
'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&form=list&field=usernames'),
|
|
|
ef5584 |
'U_DEFAULT_ALL' => "{$this->u_action}&action=default&g=$group_id",
|
|
|
ef5584 |
));
|
|
|
ef5584 |
|
|
|
ef5584 |
// Grab the members
|
|
|
ef5584 |
$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
|
|
|
ef5584 |
FROM ' . USERS_TABLE . ' u, ' . USER_GROUP_TABLE . " ug
|
|
|
ef5584 |
WHERE ug.group_id = $group_id
|
|
|
ef5584 |
AND u.user_id = ug.user_id
|
|
|
ef5584 |
AND ug.group_leader = 0
|
|
|
ef5584 |
ORDER BY ug.group_leader DESC, ug.user_pending ASC, u.username_clean";
|
|
|
ef5584 |
$result = $db->sql_query_limit($sql, $config['topics_per_page'], $start);
|
|
|
ef5584 |
|
|
|
ef5584 |
$pending = false;
|
|
|
ef5584 |
|
|
|
ef5584 |
while ($row = $db->sql_fetchrow($result))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if ($row['user_pending'] && !$pending)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$template->assign_block_vars('member', array(
|
|
|
ef5584 |
'S_PENDING' => true)
|
|
|
ef5584 |
);
|
|
|
ef5584 |
|
|
|
ef5584 |
$pending = true;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$template->assign_block_vars('member', array(
|
|
|
ef5584 |
'U_USER_EDIT' => append_sid("{$phpbb_admin_path}index.$phpEx", "i=users&action=edit&u={$row['user_id']}"),
|
|
|
ef5584 |
|
|
|
ef5584 |
'USERNAME' => $row['username'],
|
|
|
ef5584 |
'S_GROUP_DEFAULT' => ($row['group_id'] == $group_id) ? true : false,
|
|
|
ef5584 |
'JOINED' => ($row['user_regdate']) ? $user->format_date($row['user_regdate']) : ' - ',
|
|
|
ef5584 |
'USER_POSTS' => $row['user_posts'],
|
|
|
ef5584 |
'USER_ID' => $row['user_id'])
|
|
|
ef5584 |
);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
$db->sql_freeresult($result);
|
|
|
ef5584 |
|
|
|
ef5584 |
return;
|
|
|
ef5584 |
break;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$template->assign_vars(array(
|
|
|
ef5584 |
'U_ACTION' => $this->u_action,
|
|
|
ef5584 |
'S_GROUP_ADD' => ($auth->acl_get('a_groupadd')) ? true : false)
|
|
|
ef5584 |
);
|
|
|
ef5584 |
|
|
|
ef5584 |
// Get us all the groups
|
|
|
ef5584 |
$sql = 'SELECT g.group_id, g.group_name, g.group_type
|
|
|
ef5584 |
FROM ' . GROUPS_TABLE . ' g
|
|
|
ef5584 |
ORDER BY g.group_type ASC, g.group_name';
|
|
|
ef5584 |
$result = $db->sql_query($sql);
|
|
|
ef5584 |
|
|
|
ef5584 |
$lookup = $cached_group_data = array();
|
|
|
ef5584 |
while ($row = $db->sql_fetchrow($result))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$type = ($row['group_type'] == GROUP_SPECIAL) ? 'special' : 'normal';
|
|
|
ef5584 |
|
|
|
ef5584 |
// used to determine what type a group is
|
|
|
ef5584 |
$lookup[$row['group_id']] = $type;
|
|
|
ef5584 |
|
|
|
ef5584 |
// used for easy access to the data within a group
|
|
|
ef5584 |
$cached_group_data[$type][$row['group_id']] = $row;
|
|
|
ef5584 |
$cached_group_data[$type][$row['group_id']]['total_members'] = 0;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
$db->sql_freeresult($result);
|
|
|
ef5584 |
|
|
|
ef5584 |
// How many people are in which group?
|
|
|
ef5584 |
$sql = 'SELECT COUNT(ug.user_id) AS total_members, ug.group_id
|
|
|
ef5584 |
FROM ' . USER_GROUP_TABLE . ' ug
|
|
|
ef5584 |
WHERE ' . $db->sql_in_set('ug.group_id', array_keys($lookup)) . '
|
|
|
ef5584 |
GROUP BY ug.group_id';
|
|
|
ef5584 |
$result = $db->sql_query($sql);
|
|
|
ef5584 |
|
|
|
ef5584 |
while ($row = $db->sql_fetchrow($result))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$type = $lookup[$row['group_id']];
|
|
|
ef5584 |
$cached_group_data[$type][$row['group_id']]['total_members'] = $row['total_members'];
|
|
|
ef5584 |
}
|
|
|
ef5584 |
$db->sql_freeresult($result);
|
|
|
ef5584 |
|
|
|
ef5584 |
// The order is... normal, then special
|
|
|
ef5584 |
ksort($cached_group_data);
|
|
|
ef5584 |
|
|
|
ef5584 |
foreach ($cached_group_data as $type => $row_ary)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if ($type == 'special')
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$template->assign_block_vars('groups', array(
|
|
|
ef5584 |
'S_SPECIAL' => true)
|
|
|
ef5584 |
);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
foreach ($row_ary as $group_id => $row)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$group_name = (!empty($user->lang['G_' . $row['group_name']]))? $user->lang['G_' . $row['group_name']] : $row['group_name'];
|
|
|
ef5584 |
|
|
|
ef5584 |
$template->assign_block_vars('groups', array(
|
|
|
ef5584 |
'U_LIST' => "{$this->u_action}&action=list&g=$group_id",
|
|
|
ef5584 |
'U_EDIT' => "{$this->u_action}&action=edit&g=$group_id",
|
|
|
ef5584 |
'U_DELETE' => ($auth->acl_get('a_groupdel')) ? "{$this->u_action}&action=delete&g=$group_id" : '',
|
|
|
ef5584 |
|
|
|
ef5584 |
'S_GROUP_SPECIAL' => ($row['group_type'] == GROUP_SPECIAL) ? true : false,
|
|
|
ef5584 |
|
|
|
ef5584 |
'GROUP_NAME' => $group_name,
|
|
|
ef5584 |
'TOTAL_MEMBERS' => $row['total_members'],
|
|
|
ef5584 |
)
|
|
|
ef5584 |
);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
?>
|