Code Duplication    Length = 20-21 lines in 2 locations

lib/objects/ariadne_object.php 2 locations

@@ 1001-1021 (lines=21) @@
998
						}
999
						$AR->user->groups["owner"]->data->config->usergrants = $AR->user->ownergrants;
1000
					}
1001
					foreach($AR->user->groups as $group){
1002
						$groupgrants=array();
1003
						if (is_object($group)) {
1004
							$group->FindGrants($path, $groupgrants, $userpath);
1005
							if (isset($grants) && is_array($grants)) {
1006
								foreach($groupgrants as $gkey => $gval ){
1007
									if (isset($grants[$gkey]) && is_array($grants[$gkey]) && is_array($gval)) {
1008
										$grants[$gkey]=array_merge($gval, $grants[$gkey]);
1009
									} else
1010
									if ($gval && !is_array($gval)) {
1011
										$grants[$gkey] = $gval;
1012
									} else
1013
									if ($gval && !$grants[$gkey]) {
1014
										$grants[$gkey] = $gval;
1015
									}
1016
								}
1017
							} else {
1018
								$grants = $groupgrants;
1019
							}
1020
						}
1021
					}
1022
				}
1023
				if(isset($AR->sgGrants) && is_array($AR->sgGrants) ) {
1024
					ksort($AR->sgGrants);
@@ 1026-1045 (lines=20) @@
1023
				if(isset($AR->sgGrants) && is_array($AR->sgGrants) ) {
1024
					ksort($AR->sgGrants);
1025
					$ppath = $this->make_path($path);
1026
					foreach( $AR->sgGrants as $sgpath => $sggrants) {
1027
						$sgpath = $this->make_path($sgpath);
1028
						if( substr($ppath, 0, strlen($sgpath)) == $sgpath ) { // sgpath is parent of ppath or equal to ppath
1029
							if (isset($grants) && is_array($grants)) {
1030
								foreach($sggrants as $gkey => $gval ){
1031
									if (isset($grants[$gkey]) && is_array($grants[$gkey]) && is_array($gval)) {
1032
										$grants[$gkey]=array_merge($gval, $grants[$gkey]);
1033
									} else
1034
									if ($gval && !is_array($gval)) {
1035
										$grants[$gkey] = $gval;
1036
									} else
1037
									if ($gval && !$grants[$gkey]) {
1038
										$grants[$gkey] = $gval;
1039
									}
1040
								}
1041
							} else {
1042
								$grants = $sggrants;
1043
							}
1044
						}
1045
					}
1046
				}
1047
				$AR->user->grants[$path]=$grants;
1048
			}