/** * Set unit parents */ public static function setup_relationships(SimpleXMLElement $entry, PluginImportLeap $importer) { if ($ancestorid = self::get_ancestor_entryid($entry, $importer)) { $ancestorids = $importer->get_artefactids_imported_by_entryid($ancestorid); $artefactids = $importer->get_artefactids_imported_by_entryid((string) $entry->id); if (empty($artefactids[0])) { throw new ImportException($importer, 'unit artefact not found: ' . (string) $entry->id); } if (empty($ancestorids[0])) { throw new ImportException($importer, 'ilp artefact not found: ' . $ancestorid); } $artefact = new ArtefactTypeunit($artefactids[0]); $artefact->set('parent', $ancestorids[0]); $artefact->commit(); } }
public static function submit(Pieform $form, $values) { global $USER, $SESSION; if (!empty($values['unit'])) { $id = (int) $values['unit']; $artefact = new ArtefactTypeUnit($id); } else { $artefact = new ArtefactTypeunit(); $artefact->set('owner', $USER->get('id')); $artefact->set('parent', $values['parent']); } $artefact->set('title', $values['title']); $artefact->set('status', $values['status']); $artefact->set('points', $values['points']); $artefact->set('targetcompletion', $values['targetcompletion']); $artefact->set('datecompleted', $values['datecompleted']); $artefact->commit(); $SESSION->add_ok_msg(get_string('ilpsavedsuccessfully', 'artefact.ilps')); redirect('/artefact/ilps/ilp.php?id=' . $values['parent']); }