| @@ 413-426 (lines=14) @@ | ||
| 410 | } |
|
| 411 | ||
| 412 | // Deal with User relations on target object |
|
| 413 | if ($hasUsers) { |
|
| 414 | if ($clear) { |
|
| 415 | $relName = $userRelationName[0]; |
|
| 416 | $object->$relName()->removeAll(); |
|
| 417 | } |
|
| 418 | if (isset($source['users']) && is_array($source['users'])) { |
|
| 419 | foreach ($source['users'] as $user) { |
|
| 420 | $email = Convert::raw2sql($user['email']); |
|
| 421 | if ($_user = DataObject::get_one(Member::class, "Email = '".$email."'")) { |
|
| 422 | $object->Users()->add($_user); |
|
| 423 | } |
|
| 424 | } |
|
| 425 | } |
|
| 426 | } |
|
| 427 | ||
| 428 | // Deal with Group relations on target object |
|
| 429 | if ($hasGroups) { |
|
| @@ 429-442 (lines=14) @@ | ||
| 426 | } |
|
| 427 | ||
| 428 | // Deal with Group relations on target object |
|
| 429 | if ($hasGroups) { |
|
| 430 | if ($clear) { |
|
| 431 | $relName = $groupRelationName[0]; |
|
| 432 | $object->$relName()->removeAll(); |
|
| 433 | } |
|
| 434 | if (isset($source['groups']) && is_array($source['groups'])) { |
|
| 435 | foreach ($source['groups'] as $group) { |
|
| 436 | $title = Convert::raw2sql($group['title']); |
|
| 437 | if ($_group = DataObject::get_one(Group::class, "Title = '".$title."'")) { |
|
| 438 | $object->Groups()->add($_group); |
|
| 439 | } |
|
| 440 | } |
|
| 441 | } |
|
| 442 | } |
|
| 443 | } |
|
| 444 | } |
|
| 445 | ||