Handle errors during import users
This commit is contained in:
parent
c772fa61c2
commit
2023685c1a
|
@ -32,6 +32,8 @@ if (!empty($_FILES["inputFile"]['tmp_name']))
|
||||||
if (!is_null($elements))
|
if (!is_null($elements))
|
||||||
{
|
{
|
||||||
$output = "";
|
$output = "";
|
||||||
|
$error = "";
|
||||||
|
|
||||||
foreach ($elements as $element)
|
foreach ($elements as $element)
|
||||||
{
|
{
|
||||||
$team = new Team();
|
$team = new Team();
|
||||||
|
@ -47,7 +49,10 @@ if (!empty($_FILES["inputFile"]['tmp_name']))
|
||||||
else if ($child->nodeName == "member")
|
else if ($child->nodeName == "member")
|
||||||
{
|
{
|
||||||
if (!$team->update())
|
if (!$team->update())
|
||||||
erreur("Unable to add team ".$team->team_name);
|
{
|
||||||
|
$error .= "Unable to add team $team->team_name</br>";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$user = new Member();
|
$user = new Member();
|
||||||
$user->team = $team;
|
$user->team = $team;
|
||||||
|
@ -62,15 +67,21 @@ if (!empty($_FILES["inputFile"]['tmp_name']))
|
||||||
|
|
||||||
else if ($child_member->nodeName == "company")
|
else if ($child_member->nodeName == "company")
|
||||||
$user->company = $child_member->nodeValue;
|
$user->company = $child_member->nodeValue;
|
||||||
|
else if ($child_member->nodeName == "nickname")
|
||||||
|
$user->nickname = $child_member->nodeValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$user->update())
|
if (!$user->update())
|
||||||
erreur("Unable to add user ".$user->nickname);
|
{
|
||||||
|
$error .= "Unable to add user $user->firstname $user->lastname $user->nickname </br>";
|
||||||
|
$team->drop();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$team->members[] = $user;
|
$team->members[] = $user;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!empty($team->team_name))
|
if (!empty($team->id) && !empty($team->team_name))
|
||||||
{
|
{
|
||||||
//TODO save the certificate subject
|
//TODO save the certificate subject
|
||||||
$output .= new_client($team->team_name, $misc_dir);
|
$output .= new_client($team->team_name, $misc_dir);
|
||||||
|
@ -78,7 +89,11 @@ if (!empty($_FILES["inputFile"]['tmp_name']))
|
||||||
}
|
}
|
||||||
$template->assign("output", $output);
|
$template->assign("output", $output);
|
||||||
}
|
}
|
||||||
erreur("Fichier XML importé avec succès.", "success");
|
|
||||||
|
if ($error != "")
|
||||||
|
erreur($error);
|
||||||
|
else
|
||||||
|
erreur("Fichier XML importé avec succès.", "success");
|
||||||
}
|
}
|
||||||
|
|
||||||
return "admin/import_users";
|
return "admin/import_users";
|
||||||
|
|
Loading…
Reference in New Issue
Block a user