Пример #1
0
 public static function submit(Pieform $form, $values)
 {
     global $USER, $SESSION;
     if (!empty($values['fact'])) {
         $id = (int) $values['fact'];
         $artefact = new ArtefactTypeFact($id);
     } else {
         $artefact = new ArtefactTypeFact();
         $artefact->set('owner', $USER->get('id'));
         $artefact->set('parent', $values['parent']);
     }
     $artefact->set('title', $values['title']);
     $artefact->set('description', $values['description']);
     $artefact->set('completed', $values['completed'] ? 1 : 0);
     $artefact->set('completiondate', $values['completiondate']);
     if (get_config('licensemetadata')) {
         $artefact->set('license', $values['license']);
         $artefact->set('licensor', $values['licensor']);
         $artefact->set('licensorurl', $values['licensorurl']);
     }
     $artefact->set('tags', $values['tags']);
     $artefact->commit();
     $SESSION->add_ok_msg(get_string('milestonesavedsuccessfully', 'artefact.milestones'));
     redirect('/artefact/milestones/milestone.php?id=' . $values['parent']);
 }
Пример #2
0
 /**
  * Set fact 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, 'Fact artefact not found: ' . (string) $entry->id);
         }
         if (empty($ancestorids[0])) {
             throw new ImportException($importer, 'Milestone artefact not found: ' . $ancestorid);
         }
         $artefact = new ArtefactTypeFact($artefactids[0]);
         $artefact->set('parent', $ancestorids[0]);
         $artefact->commit();
     }
 }