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/gc_group_layout/lib/groups.php 1 location

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

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