From ece0b25c85f7cbdf6a75dbb221e1566558f42da8 Mon Sep 17 00:00:00 2001 From: SinergiaCRM Date: Mon, 5 Aug 2024 15:13:56 +0000 Subject: [PATCH] Fix #10491 - Display error message when importing user that it reports to itself --- modules/Import/language/en_us.lang.php | 1 + modules/Users/User.php | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/Import/language/en_us.lang.php b/modules/Import/language/en_us.lang.php index a5af53a58df..d5e0faa7a8f 100755 --- a/modules/Import/language/en_us.lang.php +++ b/modules/Import/language/en_us.lang.php @@ -235,6 +235,7 @@ 'LBL_ERROR_HELP' => 'Here are the rows in the import file that were not imported due to errors. To re-import these rows, download the list, make changes and click Import Again', 'LBL_EXTERNAL_ASSIGNED_TOOLTIP' => 'To assign the new records to a user other than yourself, use the Default Value column to select a different user.', 'LBL_EXTERNAL_TEAM_TOOLTIP' => 'To assign the new records to teams other than your default team(s), use the Default Value column to select different teams.', + 'LBL_ERROR_CYCLIC_DEPENDENCY' => ' cannot report to ', ); global $timedate; diff --git a/modules/Users/User.php b/modules/Users/User.php index d438c5c32b7..5b6de8b1efd 100755 --- a/modules/Users/User.php +++ b/modules/Users/User.php @@ -1463,6 +1463,7 @@ public function verify_data($ieVerified = true) $reports_to_self = 0; $check_user = $this->reports_to_id; $already_seen_list = array(); + $check_user_previous = $check_user; while (!empty($check_user)) { if (isset($already_seen_list[$check_user])) { // This user doesn't actually report to themselves @@ -1478,12 +1479,15 @@ public function verify_data($ieVerified = true) $query = "SELECT reports_to_id FROM users WHERE id='" . $this->db->quote($check_user) . "'"; $result = $this->db->query($query, true, "Error checking for reporting-loop"); $row = $this->db->fetchByAssoc($result); + $check_user_previous = $check_user; $check_user = $row['reports_to_id']; } if ($reports_to_self == 1) { - $this->error_string .= $mod_strings['ERR_REPORT_LOOP']; - $verified = false; + if ($_REQUEST["module"] == 'Import') { + echo(translate('ERR_REPORT_LOOP', "Users") . "

" . $check_user_previous . $mod_strings['LBL_ERROR_CYCLIC_DEPENDENCY'] . $check_user); + return true; + } } }