Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #10491 - Display error message when importing user that it reports to itself #10492

Open
wants to merge 1 commit into
base: hotfix
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
8 changes: 6 additions & 2 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,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") . "<br><br>" . $check_user_previous . $mod_strings['LBL_ERROR_CYCLIC_DEPENDENCY'] . $check_user);
return true;
}
}
}

Expand Down