Code Duplication    Length = 33-33 lines in 6 locations

mod/gcRegistration_collab/activate.php 6 locations

@@ 443-475 (lines=33) @@
440
   	'type' => 'object',
441
   	'subtype' => 'federal_departments',
442
));
443
if ( !$deptObj ){
444
	$depts = new ElggObject();
445
	$depts->subtype = "federal_departments";
446
	$depts->title = "departments";
447
	$depts->access_id = ACCESS_PUBLIC;
448
449
	$depts->set('federal_departments_en', json_encode($federal_departments_en));
450
	$depts->set('federal_departments_fr', json_encode($federal_departments_fr));
451
	$depts->save();
452
} else {
453
	$depts = get_entity($deptObj[0]->guid);
454
	$depts_en = json_decode($depts->federal_departments_en, true);
455
	if ($depts_en != $federal_departments_en){
456
		foreach ($federal_departments_en as $key => $value){
457
			if ($depts_en[$key] != $value){
458
				$depts_en[$key] = $value;
459
			}
460
		}
461
		$depts->set('federal_departments_en', json_encode($depts_en));
462
		$depts->save();
463
	}
464
465
	$depts_fr = json_decode($depts->federal_departments_fr, true);
466
	if ($depts_fr != $federal_departments_fr){
467
		foreach ($federal_departments_fr as $key => $value){
468
			if ($depts_fr[$key] != $value){
469
				$depts_fr[$key] = $value;
470
			}
471
		}
472
		$depts->set('federal_departments_fr', json_encode($depts_fr));
473
		$depts->save();
474
	}
475
}
476
477
/**** Provinces ****/
478
@@ 511-543 (lines=33) @@
508
   	'type' => 'object',
509
   	'subtype' => 'provinces',
510
));
511
if ( !$provObj ){
512
	$provs = new ElggObject();
513
	$provs->subtype = "provinces";
514
	$provs->title = "provinces";
515
	$provs->access_id = ACCESS_PUBLIC;
516
517
	$provs->set('provinces_en', json_encode($provinces_en));
518
	$provs->set('provinces_fr', json_encode($provinces_fr));
519
	$provs->save();
520
} else {
521
	$provs = get_entity($provObj[0]->guid);
522
	$provs_en = json_decode($provs->provinces_en, true);
523
	if ($provs_en != $provinces_en){
524
		foreach ($provinces_en as $key => $value){
525
			if ($provs_en[$key] != $value){
526
				$provs_en[$key] = $value;
527
			}
528
		}
529
		$provs->set('provinces_en', json_encode($provs_en));
530
		$provs->save();
531
	}
532
533
	$provs_fr = json_decode($provs->provinces_fr, true);
534
	if ($provs_fr != $provinces_fr){
535
		foreach ($provinces_fr as $key => $value){
536
			if ($provs_fr[$key] != $value){
537
				$provs_fr[$key] = $value;
538
			}
539
		}
540
		$provs->set('provinces_fr', json_encode($provs_fr));
541
		$provs->save();
542
	}
543
}
544
545
/**** Ministries ****/
546
@@ 1425-1457 (lines=33) @@
1422
   	'type' => 'object',
1423
   	'subtype' => 'ministries',
1424
));
1425
if ( !$minObj ){
1426
	$mins = new ElggObject();
1427
	$mins->subtype = "ministries";
1428
	$mins->title = "ministries";
1429
	$mins->access_id = ACCESS_PUBLIC;
1430
1431
	$mins->set('ministries_en', json_encode($ministries_en));
1432
	$mins->set('ministries_fr', json_encode($ministries_fr));
1433
	$mins->save();
1434
} else {
1435
	$mins = get_entity($minObj[0]->guid);
1436
	$mins_en = json_decode($mins->ministries_en, true);
1437
	if ($mins_en != $ministries_en){
1438
		foreach ($ministries_en as $key => $value){
1439
			if ($mins_en[$key] != $value){
1440
				$mins_en[$key] = $value;
1441
			}
1442
		}
1443
		$mins->set('ministries_en', json_encode($mins_en));
1444
		$mins->save();
1445
	}
1446
1447
	$mins_fr = json_decode($mins->ministries_fr, true);
1448
	if ($mins_fr != $ministries_fr){
1449
		foreach ($ministries_fr as $key => $value){
1450
			if ($mins_fr[$key] != $value){
1451
				$mins_fr[$key] = $value;
1452
			}
1453
		}
1454
		$mins->set('ministries_fr', json_encode($mins_fr));
1455
		$mins->save();
1456
	}
1457
}
1458
1459
/**** Universities ****/
1460
@@ 1564-1596 (lines=33) @@
1561
   	'type' => 'object',
1562
   	'subtype' => 'universities',
1563
));
1564
if ( !$uniObj ){
1565
	$unis = new ElggObject();
1566
	$unis->subtype = "universities";
1567
	$unis->title = "universities";
1568
	$unis->access_id = ACCESS_PUBLIC;
1569
1570
	$unis->set('universities_en', json_encode($universities_en));
1571
	$unis->set('universities_fr', json_encode($universities_fr));
1572
	$unis->save();
1573
} else {
1574
	$unis = get_entity($uniObj[0]->guid);
1575
	$unis_en = json_decode($unis->universities_en, true);
1576
	if ($unis_en != $universities_en){
1577
		foreach ($universities_en as $key => $value){
1578
			if ($unis_en[$key] != $value){
1579
				$unis_en[$key] = $value;
1580
			}
1581
		}
1582
		$unis->set('universities_en', json_encode($unis_en));
1583
		$unis->save();
1584
	}
1585
1586
	$unis_fr = json_decode($unis->universities_fr, true);
1587
	if ($unis_fr != $universities_fr){
1588
		foreach ($universities_fr as $key => $value){
1589
			if ($unis_fr[$key] != $value){
1590
				$unis_fr[$key] = $value;
1591
			}
1592
		}
1593
		$unis->set('universities_fr', json_encode($unis_fr));
1594
		$unis->save();
1595
	}
1596
}
1597
1598
/**** Colleges ****/
1599
@@ 1732-1764 (lines=33) @@
1729
   	'type' => 'object',
1730
   	'subtype' => 'colleges',
1731
));
1732
if ( !$colObj ){
1733
	$cols = new ElggObject();
1734
	$cols->subtype = "colleges";
1735
	$cols->title = "colleges";
1736
	$cols->access_id = ACCESS_PUBLIC;
1737
1738
	$cols->set('colleges_en', json_encode($colleges_en));
1739
	$cols->set('colleges_fr', json_encode($colleges_fr));
1740
	$cols->save();
1741
} else {
1742
	$cols = get_entity($colObj[0]->guid);
1743
	$cols_en = json_decode($cols->colleges_en, true);
1744
	if ($cols_en != $colleges_en){
1745
		foreach ($colleges_en as $key => $value){
1746
			if ($cols_en[$key] != $value){
1747
				$cols_en[$key] = $value;
1748
			}
1749
		}
1750
		$cols->set('colleges_en', json_encode($cols_en));
1751
		$cols->save();
1752
	}
1753
1754
	$cols_fr = json_decode($cols->colleges_fr, true);
1755
	if ($cols_fr != $colleges_fr){
1756
		foreach ($colleges_fr as $key => $value){
1757
			if ($cols_fr[$key] != $value){
1758
				$cols_fr[$key] = $value;
1759
			}
1760
		}
1761
		$cols->set('colleges_fr', json_encode($cols_fr));
1762
		$cols->save();
1763
	}
1764
}
1765
1766
/**** Municipal ****/
1767
@@ 3867-3899 (lines=33) @@
3864
   	'type' => 'object',
3865
   	'subtype' => 'other',
3866
));
3867
if ( !$otherObj ){
3868
	$oths = new ElggObject();
3869
	$oths->subtype = "other";
3870
	$oths->title = "other";
3871
	$oths->access_id = ACCESS_PUBLIC;
3872
3873
	$oths->set('other_en', json_encode($other_en));
3874
	$oths->set('other_fr', json_encode($other_fr));
3875
	$oths->save();
3876
} else {
3877
	$oths = get_entity($otherObj[0]->guid);
3878
	$oths_en = json_decode($oths->other_en, true);
3879
	if ($oths_en != $other_en){
3880
		foreach ($other_en as $key => $value){
3881
			if ($oths_en[$key] != $value){
3882
				$oths_en[$key] = $value;
3883
			}
3884
		}
3885
		$oths->set('other_en', json_encode($oths_en));
3886
		$oths->save();
3887
	}
3888
3889
	$oths_fr = json_decode($oths->other_fr, true);
3890
	if ($oths_fr != $other_fr){
3891
		foreach ($other_fr as $key => $value){
3892
			if ($oths_fr[$key] != $value){
3893
				$oths_fr[$key] = $value;
3894
			}
3895
		}
3896
		$oths->set('other_fr', json_encode($oths_fr));
3897
		$oths->save();
3898
	}
3899
}
3900