Commit de49a95f authored by Penny Leach's avatar Penny Leach
Browse files

leap2a: improved the detection of reimporting contactinformation artefacts


Signed-off-by: default avatarPenny Leach <penny@mjollnir.org>
parent aca3ae41
...@@ -212,20 +212,15 @@ class ArtefactTypeContactinformation extends ArtefactTypeResume { ...@@ -212,20 +212,15 @@ class ArtefactTypeContactinformation extends ArtefactTypeResume {
} }
public static function setup_new($userid) { public static function setup_new($userid) {
$code = get_random_key(10, range(0, 9));
try { try {
$existing = artefact_instance_from_type('contactinformation', $userid); return artefact_instance_from_type('contactinformation', $userid);
throw new ParamOutOfRangeException("Cannot create a new Contactinformation artefact for $userid - they already have one!", $code); } catch (ArtefactNotFoundException $e) {
} catch (Exception $e) { $artefact = new ArtefactTypeContactinformation(null, array(
if ($e->getCode() == $code) { // it is the exception we *just* threw 'owner' => $userid,
throw $e; 'title' => get_string('contactinformation', 'artefact.resume')
} ));
$artefact->commit();
} }
$artefact = new ArtefactTypeContactinformation(null, array(
'owner' => $userid,
'title' => get_string('contactinformation', 'artefact.resume')
));
$artefact->commit();
return $artefact; return $artefact;
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment