users: Update information on CSV import #1993

Merged
merged 2 commits into from Apr 29, 2015

Projects

None yet

4 participants

@greezybacon
Member

This patch adds a feature to the import process, so that if a user already exists (identified by its email address), then the name and other custom data are updated with the information in the CSV record being imported.

Outstanding

  • Touch DynamicFormEntry::updated when custom data is updated
@greezybacon greezybacon commented on an outdated diff Apr 29, 2015
include/class.user.php
@@ -196,6 +196,20 @@ static function fromVars($vars) {
return null;
}
}
+ elseif ($update) {
+ foreach ($user->getDynamicData() as $entry) {
@greezybacon
greezybacon Apr 29, 2015 Member

Use $this->updateInfo()

@protich protich merged commit c5790c5 into osTicket:develop Apr 29, 2015
@Remo
Remo commented Jun 3, 2015

Shouldn't this code result in a user with the name bbb?

$data = [
    'name' => 'aaa',
    'email' => 'info@aaa.ch',
    'phone' => 123,
];
$user = User::fromVars($data, true);

$data = [
    'name' => 'bbb',
    'email' => 'info@aaa.ch',
    'phone' => 456,
];
$user = User::fromVars($data, true);
@ntozier
ntozier commented Jun 3, 2015

email is a unique field, so no.

@Remo
Remo commented Jun 3, 2015

Yes, it is, but this line added an implicit update, didn't it?
https://github.com/osTicket/osTicket-1.8/pull/1993/files#diff-051ae6fc9b5c9f4276374b24cb7bd5b6R166

I would expect that the user gets updated after merging this change..

@greezybacon
Member

@Remo we've had significant troubles with the custom data system including strange issues like this. We made some very significant changes in the develop-next branch to remove most of the "magic" employed to make it work in this version. Could you try your code against the code in the develop-next branch to see if we've already fixed this and should just consider back-porting the changes?

@Remo
Remo commented Jun 8, 2015

Looks good, will run a more sophisticated test on Thurday

@Remo
Remo commented Jun 11, 2015

@greezybacon the implicit update didn't work with develop-next, but writing multiple fields at once worked fine. I did change my call to User::fromVars(.., true, true)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment