Code Duplication    Length = 14-14 lines in 2 locations

code/templates/WorkflowTemplate.php 2 locations

@@ 399-412 (lines=14) @@
396
        }
397
        
398
        // Deal with User relations on target object
399
        if ($hasUsers) {
400
            if ($clear) {
401
                $relName = $userRelationName[0];
402
                $object->$relName()->removeAll();
403
            }
404
            if (isset($source['users']) && is_array($source['users'])) {
405
                foreach ($source['users'] as $user) {
406
                    $email = Convert::raw2sql($user['email']);
407
                    if ($_user = DataObject::get_one('Member', "Email = '".$email."'")) {
408
                        $object->Users()->add($_user);
409
                    }
410
                }
411
            }
412
        }
413
        
414
        // Deal with Group relations on target object
415
        if ($hasGroups) {
@@ 415-428 (lines=14) @@
412
        }
413
        
414
        // Deal with Group relations on target object
415
        if ($hasGroups) {
416
            if ($clear) {
417
                $relName = $groupRelationName[0];
418
                $object->$relName()->removeAll();
419
            }
420
            if (isset($source['groups']) && is_array($source['groups'])) {
421
                foreach ($source['groups'] as $group) {
422
                    $title = Convert::raw2sql($group['title']);
423
                    if ($_group = DataObject::get_one('Group', "Title = '".$title."'")) {
424
                        $object->Groups()->add($_group);
425
                    }
426
                }
427
            }
428
        }
429
    }
430
}
431