Code Duplication    Length = 63-64 lines in 3 locations

mod/au_subgroups/lib/groups.php 1 location

@@ 546-608 (lines=63) @@
543
 * @param mixed $group ElggGroup or null. If a group, uses values from the group.
544
 * @return array
545
 */
546
function groups_prepare_form_vars($group = null) {
547
	$values = array(
548
		'name' => '',
549
		'membership' => ACCESS_PUBLIC,
550
		'vis' => ACCESS_PUBLIC,
551
		'guid' => null,
552
		'entity' => null,
553
		'owner_guid' => elgg_get_logged_in_user_guid(),
554
		'content_access_mode' => ElggGroup::CONTENT_ACCESS_MODE_UNRESTRICTED
555
	);
556
557
	// handle customizable profile fields
558
	$fields = elgg_get_config('group');
559
560
	if ($fields) {
561
		foreach ($fields as $name => $type) {
562
			$values[$name] = '';
563
		}
564
	}
565
566
	// handle tool options
567
	$tools = elgg_get_config('group_tool_options');
568
	if ($tools) {
569
		foreach ($tools as $group_option) {
570
			$option_name = $group_option->name . "_enable";
571
			$values[$option_name] = $group_option->default_on ? 'yes' : 'no';
572
		}
573
	}
574
575
	// get current group settings
576
	if ($group) {
577
		foreach (array_keys($values) as $field) {
578
			if (isset($group->$field)) {
579
				$values[$field] = $group->$field;
580
			}
581
		}
582
583
		if ($group->access_id != ACCESS_PUBLIC && $group->access_id != ACCESS_LOGGED_IN) {
584
			// group only access - this is done to handle access not created when group is created
585
			$values['vis'] = ACCESS_PRIVATE;
586
		} else {
587
			$values['vis'] = $group->access_id;
588
		}
589
590
		// The content_access_mode was introduced in 1.9. This method must be
591
		// used for backwards compatibility with groups created before 1.9.
592
		$values['content_access_mode'] = $group->getContentAccessMode();
593
594
		$values['entity'] = $group;
595
	}
596
597
	// get any sticky form settings
598
	if (elgg_is_sticky_form('groups')) {
599
		$sticky_values = elgg_get_sticky_values('groups');
600
		foreach ($sticky_values as $key => $value) {
601
			$values[$key] = $value;
602
		}
603
	}
604
605
	elgg_clear_sticky_form('groups');
606
607
	return $values;
608
}
609

mod/groups/lib/groups.php 1 location

@@ 577-640 (lines=64) @@
574
 * @param mixed $group ElggGroup or null. If a group, uses values from the group.
575
 * @return array
576
 */
577
function groups_prepare_form_vars($group = null) {
578
	$values = array(
579
		'name' => '',
580
		'name2' => '',
581
		'membership' => ACCESS_PUBLIC,
582
		'vis' => ACCESS_PUBLIC,
583
		'guid' => null,
584
		'entity' => null,
585
		'owner_guid' => elgg_get_logged_in_user_guid(),
586
		'content_access_mode' => ElggGroup::CONTENT_ACCESS_MODE_UNRESTRICTED
587
	);
588
589
	// handle customizable profile fields
590
	$fields = elgg_get_config('group');
591
592
	if ($fields) {
593
		foreach ($fields as $name => $type) {
594
			$values[$name] = '';
595
		}
596
	}
597
598
	// handle tool options
599
	$tools = elgg_get_config('group_tool_options');
600
	if ($tools) {
601
		foreach ($tools as $group_option) {
602
			$option_name = $group_option->name . "_enable";
603
			$values[$option_name] = $group_option->default_on ? 'yes' : 'no';
604
		}
605
	}
606
607
	// get current group settings
608
	if ($group) {
609
		foreach (array_keys($values) as $field) {
610
			if (isset($group->$field)) {
611
				$values[$field] = $group->$field;
612
			}
613
		}
614
615
		if ($group->access_id != ACCESS_PUBLIC && $group->access_id != ACCESS_LOGGED_IN) {
616
			// group only access - this is done to handle access not created when group is created
617
			$values['vis'] = ACCESS_PRIVATE;
618
		} else {
619
			$values['vis'] = $group->access_id;
620
		}
621
622
		// The content_access_mode was introduced in 1.9. This method must be
623
		// used for backwards compatibility with groups created before 1.9.
624
		$values['content_access_mode'] = $group->getContentAccessMode();
625
626
		$values['entity'] = $group;
627
	}
628
629
	// get any sticky form settings
630
	if (elgg_is_sticky_form('groups')) {
631
		$sticky_values = elgg_get_sticky_values('groups');
632
		foreach ($sticky_values as $key => $value) {
633
			$values[$key] = $value;
634
		}
635
	}
636
637
	elgg_clear_sticky_form('groups');
638
639
	return $values;
640
}
641
642
/**
643
 * View stats for a group

mod/gc_group_layout/lib/groups.php 1 location

@@ 599-662 (lines=64) @@
596
 * @param mixed $group ElggGroup or null. If a group, uses values from the group.
597
 * @return array
598
 */
599
function groups_prepare_form_vars($group = null) {
600
	$values = array(
601
		'name' => '',
602
		'name2' => '',
603
		'membership' => ACCESS_PUBLIC,
604
		'vis' => ACCESS_PUBLIC,
605
		'guid' => null,
606
		'entity' => null,
607
		'owner_guid' => elgg_get_logged_in_user_guid(),
608
		'content_access_mode' => ElggGroup::CONTENT_ACCESS_MODE_UNRESTRICTED
609
	);
610
611
	// handle customizable profile fields
612
	$fields = elgg_get_config('group');
613
614
	if ($fields) {
615
		foreach ($fields as $name => $type) {
616
			$values[$name] = '';
617
		}
618
	}
619
620
	// handle tool options
621
	$tools = elgg_get_config('group_tool_options');
622
	if ($tools) {
623
		foreach ($tools as $group_option) {
624
			$option_name = $group_option->name . "_enable";
625
			$values[$option_name] = $group_option->default_on ? 'yes' : 'no';
626
		}
627
	}
628
629
	// get current group settings
630
	if ($group) {
631
		foreach (array_keys($values) as $field) {
632
			if (isset($group->$field)) {
633
				$values[$field] = $group->$field;
634
			}
635
		}
636
637
		if ($group->access_id != ACCESS_PUBLIC && $group->access_id != ACCESS_LOGGED_IN) {
638
			// group only access - this is done to handle access not created when group is created
639
			$values['vis'] = ACCESS_PRIVATE;
640
		} else {
641
			$values['vis'] = $group->access_id;
642
		}
643
644
		// The content_access_mode was introduced in 1.9. This method must be
645
		// used for backwards compatibility with groups created before 1.9.
646
		$values['content_access_mode'] = $group->getContentAccessMode();
647
648
		$values['entity'] = $group;
649
	}
650
651
	// get any sticky form settings
652
	if (elgg_is_sticky_form('groups')) {
653
		$sticky_values = elgg_get_sticky_values('groups');
654
		foreach ($sticky_values as $key => $value) {
655
			$values[$key] = $value;
656
		}
657
	}
658
659
	elgg_clear_sticky_form('groups');
660
661
	return $values;
662
}
663
664
/**
665
 * View stats for a group