Skip to content
Snippets Groups Projects
Commit 9873b25e authored by Jared Hancock's avatar Jared Hancock
Browse files

users: Update information on CSV import

parent ad9276e9
No related branches found
No related tags found
No related merge requests found
...@@ -163,7 +163,7 @@ class User extends UserModel { ...@@ -163,7 +163,7 @@ class User extends UserModel {
var $_entries; var $_entries;
var $_forms; var $_forms;
static function fromVars($vars) { static function fromVars($vars, $update=false) {
// Try and lookup by email address // Try and lookup by email address
$user = static::lookupByEmail($vars['email']); $user = static::lookupByEmail($vars['email']);
if (!$user) { if (!$user) {
...@@ -196,6 +196,20 @@ class User extends UserModel { ...@@ -196,6 +196,20 @@ class User extends UserModel {
return null; return null;
} }
} }
elseif ($update) {
foreach ($user->getDynamicData() as $entry) {
// FIXME: Convert this to ->form for `develop-next`
if ($entry->getForm()->type == 'U') {
$entry->setSource($vars);
$entry->save();
}
}
// Update name
if (isset($vars['name'])) {
$user->name = $vars['name'];
$user->save();
}
}
return $user; return $user;
} }
...@@ -472,7 +486,7 @@ class User extends UserModel { ...@@ -472,7 +486,7 @@ class User extends UserModel {
foreach ($users as $u) { foreach ($users as $u) {
$vars = array_combine($keys, $u); $vars = array_combine($keys, $u);
if (!static::fromVars($vars)) if (!static::fromVars($vars, true))
return sprintf(__('Unable to import user: %s'), return sprintf(__('Unable to import user: %s'),
print_r($vars, true)); print_r($vars, true));
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment