Skip to content

Commit

Permalink
Fix salesagility#10491 - Display error message when importing user th…
Browse files Browse the repository at this point in the history
…at it reports to itself
  • Loading branch information
SinergiaCRM committed Aug 5, 2024
1 parent 8735575 commit 099309f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions modules/Import/language/en_us.lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <b>Import Again</b>',
'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;
9 changes: 6 additions & 3 deletions modules/Users/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -1478,13 +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);
echo("fetched: " . $row['reports_to_id'] . " from " . $check_user . "<br>");
$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") . "<br><br>" . $check_user_previous . $mod_strings['LBL_ERROR_CYCLIC_DEPENDENCY'] . $check_user);
return true;
}
}
}

Expand Down

0 comments on commit 099309f

Please sign in to comment.