Code Duplication    Length = 22-22 lines in 2 locations

app/PrivilegeUtil.php 2 locations

@@ 760-781 (lines=22) @@
757
			if (empty($groupList)) {
758
				$groupList = [0];
759
			}
760
			if ($groupList) {
761
				foreach (static::getDatashare('role2group', $modTabId, $groupList) as $row) {
762
					$shareRoleId = $row['share_roleid'];
763
					$shareIdRoles = [];
764
					$shareIdRoles[] = $shareRoleId;
765
					$shareIdMembers[$row['shareid']] = ['ROLE' => $shareIdRoles];
766
					if ((int) $row['permission'] === 1) {
767
						if ($modDefOrgShare === 3) {
768
							if (!isset($roleReadPer[$shareRoleId])) {
769
								$roleReadPer[$shareRoleId] = static::getUsersByRole($shareRoleId);
770
							}
771
						}
772
						if (!isset($roleWritePer[$shareRoleId])) {
773
							$roleWritePer[$shareRoleId] = static::getUsersByRole($shareRoleId);
774
						}
775
					} elseif ((int) $row['permission'] === 0 && $modDefOrgShare === 3) {
776
						if (!isset($roleReadPer[$shareRoleId])) {
777
							$roleReadPer[$shareRoleId] = static::getUsersByRole($shareRoleId);
778
						}
779
					}
780
				}
781
			}
782
			//Get roles from Role2Us
783
			if (!empty($userid)) {
784
				foreach (static::getDatashare('role2user', $modTabId, $userid) as $row) {
@@ 783-804 (lines=22) @@
780
				}
781
			}
782
			//Get roles from Role2Us
783
			if (!empty($userid)) {
784
				foreach (static::getDatashare('role2user', $modTabId, $userid) as $row) {
785
					$shareRoleId = $row['share_roleid'];
786
					$shareIdRoles = [];
787
					$shareIdRoles[] = $shareRoleId;
788
					$shareIdMembers[$row['shareid']] = ['ROLE' => $shareIdRoles];
789
					if ((int) $row['permission'] === 1) {
790
						if ($modDefOrgShare === 3) {
791
							if (!isset($roleReadPer[$shareRoleId])) {
792
								$roleReadPer[$shareRoleId] = static::getUsersByRole($shareRoleId);
793
							}
794
						}
795
						if (!isset($roleWritePer[$shareRoleId])) {
796
							$roleWritePer[$shareRoleId] = static::getUsersByRole($shareRoleId);
797
						}
798
					} elseif ((int) $row['permission'] === 0 && $modDefOrgShare === 3) {
799
						if (!isset($roleReadPer[$shareRoleId])) {
800
							$roleReadPer[$shareRoleId] = static::getUsersByRole($shareRoleId);
801
						}
802
					}
803
				}
804
			}
805
			//Retreiving from rs to vtiger_role
806
			foreach (static::getDatashare('rs2role', $modTabId, $currentUserRoles) as $row) {
807
				$shareRoleIds = static::getRoleSubordinates($row['share_roleandsubid']);