phpBB

Code Changes

File: includes/acp/acp_groups.php

  Unmodified   Added   Modified   Removed
Line 26Line 26
	function main($id, $mode)
{
global $config, $db, $user, $auth, $template, $cache;

	function main($id, $mode)
{
global $config, $db, $user, $auth, $template, $cache;

		global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix, $file_uploads;

		global $phpbb_root_path, $phpbb_admin_path, $phpEx;

		global $request, $phpbb_container, $phpbb_dispatcher;

$user->add_lang('acp/groups');

		global $request, $phpbb_container, $phpbb_dispatcher;

$user->add_lang('acp/groups');

Line 42Line 42
			return;
}


			return;
}


 
		if (!function_exists('group_user_attributes'))
{

		include($phpbb_root_path . 'includes/functions_user.' . $phpEx);

		include($phpbb_root_path . 'includes/functions_user.' . $phpEx);

 
		}


// Check and set some common vars


// Check and set some common vars

		$action		= (isset($_POST['add'])) ? 'add' : ((isset($_POST['addusers'])) ? 'addusers' : request_var('action', ''));
$group_id = request_var('g', 0);
$mark_ary = request_var('mark', array(0));
$name_ary = request_var('usernames', '', true);
$leader = request_var('leader', 0);
$default = request_var('default', 0);
$start = request_var('start', 0);

		$action		= (isset($_POST['add'])) ? 'add' : ((isset($_POST['addusers'])) ? 'addusers' : $request->variable('action', ''));
$group_id = $request->variable('g', 0);
$mark_ary = $request->variable('mark', array(0));
$name_ary = $request->variable('usernames', '', true);
$leader = $request->variable('leader', 0);
$default = $request->variable('default', 0);
$start = $request->variable('start', 0);

		$update		= (isset($_POST['update'])) ? true : false;

		$update		= (isset($_POST['update'])) ? true : false;

 

/** @var \phpbb\group\helper $group_helper */
$group_helper = $phpbb_container->get('group_helper');


// Clear some vars
$group_row = array();


// Clear some vars
$group_row = array();

Line 98Line 104
				}

// Approve, demote or promote

				}

// Approve, demote or promote

				$group_name = ($group_row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $group_row['group_name']] : $group_row['group_name'];

				$group_name = $group_helper->get_name($group_row['group_name']);

				$error = group_user_attributes($action, $group_id, $mark_ary, false, $group_name);

if (!$error)

				$error = group_user_attributes($action, $group_id, $mark_ary, false, $group_name);

if (!$error)

Line 139Line 145

if (confirm_box(true))
{


if (confirm_box(true))
{

					$group_name = ($group_row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $group_row['group_name']] : $group_row['group_name'];

					$group_name = $group_helper->get_name($group_row['group_name']);

					group_user_attributes('default', $group_id, $mark_ary, false, $group_name, $group_row);
trigger_error($user->lang['GROUP_DEFS_UPDATED'] . adm_back_link($this->u_action . '&action=list&g=' . $group_id));
}

					group_user_attributes('default', $group_id, $mark_ary, false, $group_name, $group_row);
trigger_error($user->lang['GROUP_DEFS_UPDATED'] . adm_back_link($this->u_action . '&action=list&g=' . $group_id));
}

Line 158Line 164
			case 'set_default_on_all':
if (confirm_box(true))
{

			case 'set_default_on_all':
if (confirm_box(true))
{

					$group_name = ($group_row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $group_row['group_name']] : $group_row['group_name'];

					$group_name = $group_helper->get_name($group_row['group_name']);


$start = 0;



$start = 0;


Line 217Line 223
				}
else if ($action === 'delete' && $group_row['group_type'] == GROUP_SPECIAL)
{

				}
else if ($action === 'delete' && $group_row['group_type'] == GROUP_SPECIAL)
{

 
					send_status_line(403, 'Forbidden');

					trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
}


					trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
}


Line 229Line 236
						case 'delete':
if (!$auth->acl_get('a_groupdel'))
{

						case 'delete':
if (!$auth->acl_get('a_groupdel'))
{

 
								send_status_line(403, 'Forbidden');

								trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
}


								trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
}


Line 236Line 244
						break;

case 'deleteusers':

						break;

case 'deleteusers':

							$group_name = ($group_row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $group_row['group_name']] : $group_row['group_name'];

							$group_name = $group_helper->get_name($group_row['group_name']);

							$error = group_user_del($group_id, $mark_ary, false, $group_name);
break;
}

							$error = group_user_del($group_id, $mark_ary, false, $group_name);
break;
}

Line 280Line 288
				}

$name_ary = array_unique(explode("\n", $name_ary));

				}

$name_ary = array_unique(explode("\n", $name_ary));

				$group_name = ($group_row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $group_row['group_name']] : $group_row['group_name'];

				$group_name = $group_helper->get_name($group_row['group_name']);


// Add user/s to group
if ($error = group_user_add($group_id, false, $name_ary, $group_name, $default, $leader, 0, $group_row))


// Add user/s to group
if ($error = group_user_add($group_id, false, $name_ary, $group_name, $default, $leader, 0, $group_row))

Line 295Line 303
			case 'edit':
case 'add':


			case 'edit':
case 'add':


 
				if (!function_exists('display_forums'))
{

				include($phpbb_root_path . 'includes/functions_display.' . $phpEx);

				include($phpbb_root_path . 'includes/functions_display.' . $phpEx);


$data = $submit_ary = array();

				}



if ($action == 'edit' && !$group_id)
{


if ($action == 'edit' && !$group_id)
{

Line 306Line 315

if ($action == 'add' && !$auth->acl_get('a_groupadd'))
{


if ($action == 'add' && !$auth->acl_get('a_groupadd'))
{

 
					send_status_line(403, 'Forbidden');

					trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
}


					trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
}


Line 317Line 327
				$avatar_drivers = null;
$avatar_data = null;
$avatar_error = array();

				$avatar_drivers = null;
$avatar_data = null;
$avatar_error = array();

 

/** @var \phpbb\avatar\manager $phpbb_avatar_manager */
$phpbb_avatar_manager = $phpbb_container->get('avatar.manager');


if ($config['allow_avatar'])
{


if ($config['allow_avatar'])
{

					$phpbb_avatar_manager = $phpbb_container->get('avatar.manager');

 
					$avatar_drivers = $phpbb_avatar_manager->get_enabled_drivers();

// This is normalised data, without the group_ prefix

					$avatar_drivers = $phpbb_avatar_manager->get_enabled_drivers();

// This is normalised data, without the group_ prefix

Line 361Line 373
						trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
}


						trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
}


					$group_name	= utf8_normalize_nfc(request_var('group_name', '', true));
$group_desc = utf8_normalize_nfc(request_var('group_desc', '', true));
$group_type = request_var('group_type', GROUP_FREE);

					$group_name	= $request->variable('group_name', '', true);
$group_desc = $request->variable('group_desc', '', true);
$group_type = $request->variable('group_type', GROUP_FREE);





					$allow_desc_bbcode	= request_var('desc_parse_bbcode', false);
$allow_desc_urls = request_var('desc_parse_urls', false);
$allow_desc_smilies = request_var('desc_parse_smilies', false);

					$allow_desc_bbcode	= $request->variable('desc_parse_bbcode', false);
$allow_desc_urls = $request->variable('desc_parse_urls', false);
$allow_desc_smilies = $request->variable('desc_parse_smilies', false);


$submit_ary = array(


$submit_ary = array(

						'colour'			=> request_var('group_colour', ''),
'rank' => request_var('group_rank', 0),

						'colour'			=> $request->variable('group_colour', ''),
'rank' => $request->variable('group_rank', 0),

						'receive_pm'		=> isset($_REQUEST['group_receive_pm']) ? 1 : 0,
'legend' => isset($_REQUEST['group_legend']) ? 1 : 0,
'teampage' => isset($_REQUEST['group_teampage']) ? 1 : 0,

						'receive_pm'		=> isset($_REQUEST['group_receive_pm']) ? 1 : 0,
'legend' => isset($_REQUEST['group_legend']) ? 1 : 0,
'teampage' => isset($_REQUEST['group_teampage']) ? 1 : 0,

						'message_limit'		=> request_var('group_message_limit', 0),
'max_recipients' => request_var('group_max_recipients', 0),

						'message_limit'		=> $request->variable('group_message_limit', 0),
'max_recipients' => $request->variable('group_max_recipients', 0),

						'founder_manage'	=> 0,

						'founder_manage'	=> 0,

						'skip_auth'			=> request_var('group_skip_auth', 0),

						'skip_auth'			=> $request->variable('group_skip_auth', 0),

					);

if ($user->data['user_type'] == USER_FOUNDER)

					);

if ($user->data['user_type'] == USER_FOUNDER)

Line 547Line 559

if (!($error = group_create($group_id, $group_type, $group_name, $group_desc, $group_attributes, $allow_desc_bbcode, $allow_desc_urls, $allow_desc_smilies)))
{


if (!($error = group_create($group_id, $group_type, $group_name, $group_desc, $group_attributes, $allow_desc_bbcode, $allow_desc_urls, $allow_desc_smilies)))
{

							$group_perm_from = request_var('group_perm_from', 0);

							$group_perm_from = $request->variable('group_perm_from', 0);


// Copy permissions?
// If the user has the a_authgroups permission and at least one additional permission ability set the permissions are fully transferred.


// Copy permissions?
// If the user has the a_authgroups permission and at least one additional permission ability set the permissions are fully transferred.

Line 617Line 629
				}
else if (!$group_id)
{

				}
else if (!$group_id)
{

					$group_name = utf8_normalize_nfc(request_var('group_name', '', true));

					$group_name = $request->variable('group_name', '', true);

					$group_desc_data = array(
'text' => '',
'allow_bbcode' => true,

					$group_desc_data = array(
'text' => '',
'allow_bbcode' => true,

Line 660Line 672
				{
$avatars_enabled = false;
$selected_driver = $phpbb_avatar_manager->clean_driver_name($request->variable('avatar_driver', $avatar_data['avatar_type']));

				{
$avatars_enabled = false;
$selected_driver = $phpbb_avatar_manager->clean_driver_name($request->variable('avatar_driver', $avatar_data['avatar_type']));

 

// Assign min and max values before generating avatar driver html
$template->assign_vars(array(
'AVATAR_MIN_WIDTH' => $config['avatar_min_width'],
'AVATAR_MAX_WIDTH' => $config['avatar_max_width'],
'AVATAR_MIN_HEIGHT' => $config['avatar_min_height'],
'AVATAR_MAX_HEIGHT' => $config['avatar_max_height'],
));


foreach ($avatar_drivers as $current_driver)
{
$driver = $phpbb_avatar_manager->get_driver($current_driver);

$avatars_enabled = true;


foreach ($avatar_drivers as $current_driver)
{
$driver = $phpbb_avatar_manager->get_driver($current_driver);

$avatars_enabled = true;

						$config_name = $phpbb_avatar_manager->get_driver_config_name($driver);

 
						$template->set_filenames(array(

						$template->set_filenames(array(

							'avatar' => "acp_avatar_options_{$config_name}.html",

							'avatar' => $driver->get_acp_template_name(),

						));

if ($driver->prepare_form($request, $template, $user, $avatar_data, $avatar_error))

						));

if ($driver->prepare_form($request, $template, $user, $avatar_data, $avatar_error))

Line 695Line 714
					$error = array_merge($error, $phpbb_avatar_manager->localize_errors($user, $avatar_error));
}


					$error = array_merge($error, $phpbb_avatar_manager->localize_errors($user, $avatar_error));
}


				$back_link = request_var('back_link', '');

				$back_link = $request->variable('back_link', '');


switch ($back_link)
{
case 'acp_users_groups':


switch ($back_link)
{
case 'acp_users_groups':

						$u_back = append_sid("{$phpbb_admin_path}index.$phpEx", 'i=users&mode=groups&u=' . request_var('u', 0));

						$u_back = append_sid("{$phpbb_admin_path}index.$phpEx", 'i=users&mode=groups&u=' . $request->variable('u', 0));

					break;

default:

					break;

default:

Line 719Line 738
					'S_AVATARS_ENABLED'		=> ($config['allow_avatar'] && $avatars_enabled),

'ERROR_MSG' => (sizeof($error)) ? implode('<br />', $error) : '',

					'S_AVATARS_ENABLED'		=> ($config['allow_avatar'] && $avatars_enabled),

'ERROR_MSG' => (sizeof($error)) ? implode('<br />', $error) : '',

					'GROUP_NAME'			=> ($group_type == GROUP_SPECIAL) ? $user->lang['G_' . $group_name] : $group_name,

					'GROUP_NAME'			=> $group_helper->get_name($group_name),

					'GROUP_INTERNAL_NAME'	=> $group_name,
'GROUP_DESC' => $group_desc_data['text'],
'GROUP_RECEIVE_PM' => (isset($group_row['group_receive_pm']) && $group_row['group_receive_pm']) ? ' checked="checked"' : '',

					'GROUP_INTERNAL_NAME'	=> $group_name,
'GROUP_DESC' => $group_desc_data['text'],
'GROUP_RECEIVE_PM' => (isset($group_row['group_receive_pm']) && $group_row['group_receive_pm']) ? ' checked="checked"' : '',

Line 801Line 820
					trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action), E_USER_WARNING);
}


					trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action), E_USER_WARNING);
}


				$this->page_title = 'GROUP_MEMBERS';

				/* @var $pagination \phpbb\pagination */

				$pagination = $phpbb_container->get('pagination');

				$pagination = $phpbb_container->get('pagination');

 
				$this->page_title = 'GROUP_MEMBERS';


// Grab the leaders - always, on every page...
$sql = 'SELECT u.user_id, u.username, u.username_clean, u.user_regdate, u.user_colour, u.user_posts, u.group_id, ug.group_leader, ug.user_pending


// Grab the leaders - always, on every page...
$sql = 'SELECT u.user_id, u.username, u.username_clean, u.user_regdate, u.user_colour, u.user_posts, u.group_id, ug.group_leader, ug.user_pending

Line 853Line 873
					'S_GROUP_SPECIAL'	=> ($group_row['group_type'] == GROUP_SPECIAL) ? true : false,
'S_ACTION_OPTIONS' => $s_action_options,


					'S_GROUP_SPECIAL'	=> ($group_row['group_type'] == GROUP_SPECIAL) ? true : false,
'S_ACTION_OPTIONS' => $s_action_options,


					'GROUP_NAME'	=> ($group_row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $group_row['group_name']] : $group_row['group_name'],

					'GROUP_NAME'	=> $group_helper->get_name($group_row['group_name']),


'U_ACTION' => $this->u_action . "&amp;g=$group_id",
'U_BACK' => $this->u_action,


'U_ACTION' => $this->u_action . "&amp;g=$group_id",
'U_BACK' => $this->u_action,

Line 922Line 942
			// used for easy access to the data within a group
$cached_group_data[$type][$row['group_id']] = $row;
$cached_group_data[$type][$row['group_id']]['total_members'] = 0;

			// used for easy access to the data within a group
$cached_group_data[$type][$row['group_id']] = $row;
$cached_group_data[$type][$row['group_id']]['total_members'] = 0;

 
			$cached_group_data[$type][$row['group_id']]['pending_members'] = 0;

		}
$db->sql_freeresult($result);

// How many people are in which group?

		}
$db->sql_freeresult($result);

// How many people are in which group?

		$sql = 'SELECT COUNT(ug.user_id) AS total_members, ug.group_id

		$sql = 'SELECT COUNT(ug.user_id) AS total_members, SUM(ug.user_pending) AS pending_members, ug.group_id

			FROM ' . USER_GROUP_TABLE . ' ug
WHERE ' . $db->sql_in_set('ug.group_id', array_keys($lookup)) . '
GROUP BY ug.group_id';

			FROM ' . USER_GROUP_TABLE . ' ug
WHERE ' . $db->sql_in_set('ug.group_id', array_keys($lookup)) . '
GROUP BY ug.group_id';

Line 936Line 957
		{
$type = $lookup[$row['group_id']];
$cached_group_data[$type][$row['group_id']]['total_members'] = $row['total_members'];

		{
$type = $lookup[$row['group_id']];
$cached_group_data[$type][$row['group_id']]['total_members'] = $row['total_members'];

 
			$cached_group_data[$type][$row['group_id']]['pending_members'] = $row['pending_members'];

		}
$db->sql_freeresult($result);


		}
$db->sql_freeresult($result);


Line 964Line 986

'GROUP_NAME' => $group_name,
'TOTAL_MEMBERS' => $row['total_members'],


'GROUP_NAME' => $group_name,
'TOTAL_MEMBERS' => $row['total_members'],

 
					'PENDING_MEMBERS' => $row['pending_members']

				));
}
}

				));
}
}

Line 981Line 1004
		$group_id = $request->variable('g', 0);
$teampage_id = $request->variable('t', 0);
$category_id = $request->variable('c', 0);

		$group_id = $request->variable('g', 0);
$teampage_id = $request->variable('t', 0);
$category_id = $request->variable('c', 0);

 

/** @var \phpbb\group\helper $group_helper */
$group_helper = $phpbb_container->get('group_helper');


if ($field && !in_array($field, array('legend', 'teampage')))
{


if ($field && !in_array($field, array('legend', 'teampage')))
{

Line 989Line 1015
		}
else if ($field && in_array($field, array('legend', 'teampage')))
{

		}
else if ($field && in_array($field, array('legend', 'teampage')))
{



			/* @var $group_position \phpbb\groupposition\groupposition_interface */

			$group_position = $phpbb_container->get('groupposition.' . $field);
}


			$group_position = $phpbb_container->get('groupposition.' . $field);
}


Line 1081Line 1107
			ORDER BY group_legend ASC, group_type DESC, group_name ASC';
$result = $db->sql_query($sql);


			ORDER BY group_legend ASC, group_type DESC, group_name ASC';
$result = $db->sql_query($sql);


		$s_group_select_legend = '';

 
		while ($row = $db->sql_fetchrow($result))
{

		while ($row = $db->sql_fetchrow($result))
{

			$group_name = ($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name'];

			$group_name = $group_helper->get_name($row['group_name']);

			if ($row['group_legend'])
{
$template->assign_block_vars('legend', array(

			if ($row['group_legend'])
{
$template->assign_block_vars('legend', array(

Line 1119Line 1144
			ORDER BY t.teampage_position ASC';
$result = $db->sql_query($sql);


			ORDER BY t.teampage_position ASC';
$result = $db->sql_query($sql);


		$category_data = array();

 
		while ($row = $db->sql_fetchrow($result))
{
if ($row['teampage_id'] == $category_id)

		while ($row = $db->sql_fetchrow($result))
{
if ($row['teampage_id'] == $category_id)

Line 1132Line 1156

if ($row['group_id'])
{


if ($row['group_id'])
{

				$group_name = ($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name'];

				$group_name = $group_helper->get_name($row['group_name']);

				$group_type = $user->lang[\phpbb\groupposition\teampage::group_type_language($row['group_type'])];
}
else

				$group_type = $user->lang[\phpbb\groupposition\teampage::group_type_language($row['group_type'])];
}
else

Line 1162Line 1186
			ORDER BY g.group_type DESC, g.group_name ASC';
$result = $db->sql_query($sql);


			ORDER BY g.group_type DESC, g.group_name ASC';
$result = $db->sql_query($sql);


		$s_group_select_teampage = '';

 
		while ($row = $db->sql_fetchrow($result))
{

		while ($row = $db->sql_fetchrow($result))
{

			$group_name = ($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name'];

			$group_name = $group_helper->get_name($row['group_name']);

			$template->assign_block_vars('add_teampage', array(
'GROUP_ID' => (int) $row['group_id'],
'GROUP_NAME' => $group_name,

			$template->assign_block_vars('add_teampage', array(
'GROUP_ID' => (int) $row['group_id'],
'GROUP_NAME' => $group_name,