Code Duplication    Length = 17-18 lines in 2 locations

Sources/Subs-Membergroups.php 1 location

@@ 349-366 (lines=18) @@
346
	$groups = array_diff($groups, $implicitGroups);
347
348
	// Don't forget the protected groups.
349
	if (!allowedTo('admin_forum') && !$ignoreProtected)
350
	{
351
		$request = $smcFunc['db_query']('', '
352
			SELECT id_group
353
			FROM {db_prefix}membergroups
354
			WHERE group_type = {int:is_protected}',
355
			array(
356
				'is_protected' => 1,
357
			)
358
		);
359
		$protected_groups = array(1);
360
		while ($row = $smcFunc['db_fetch_assoc']($request))
361
			$protected_groups[] = $row['id_group'];
362
		$smcFunc['db_free_result']($request);
363
364
		// If you're not an admin yourself, you can't touch protected groups!
365
		$groups = array_diff($groups, array_unique($protected_groups));
366
	}
367
368
	// Only continue if there are still groups and members left.
369
	if (empty($groups) || empty($members))

Sources/Profile-Modify.php 1 location

@@ 3035-3051 (lines=17) @@
3032
	global $profile_vars, $old_profile, $context, $smcFunc, $cur_profile;
3033
3034
	// Do we need to protect some groups?
3035
	if (!allowedTo('admin_forum'))
3036
	{
3037
		$request = $smcFunc['db_query']('', '
3038
			SELECT id_group
3039
			FROM {db_prefix}membergroups
3040
			WHERE group_type = {int:is_protected}',
3041
			array(
3042
				'is_protected' => 1,
3043
			)
3044
		);
3045
		$protected_groups = array(1);
3046
		while ($row = $smcFunc['db_fetch_assoc']($request))
3047
			$protected_groups[] = $row['id_group'];
3048
		$smcFunc['db_free_result']($request);
3049
3050
		$protected_groups = array_unique($protected_groups);
3051
	}
3052
3053
	// The account page allows the change of your id_group - but not to a protected group!
3054
	if (empty($protected_groups) || count(array_intersect(array((int) $value, $old_profile['id_group']), $protected_groups)) == 0)