Exemplo n.º 1
0
 public static function submit(Pieform $form, $values)
 {
     global $USER, $SESSION;
     if (!empty($values['activity'])) {
         $id = (int) $values['activity'];
         $artefact = new ArtefactTypeActivity($id);
     } else {
         $artefact = new ArtefactTypeActivity();
         $artefact->set('owner', $USER->get('id'));
         $artefact->set('parent', $values['parent']);
     }
     $artefact->set('title', $values['title']);
     $artefact->set('location', $values['location']);
     $artefact->set('description', $values['description']);
     $artefact->set('tags', $values['tags']);
     $artefact->set('hours', $values['hours']);
     $artefact->set('startdate', $values['startdate']);
     $artefact->set('enddate', $values['enddate']);
     $artefact->commit();
     $SESSION->add_ok_msg(get_string('cpdsavedsuccessfully', 'artefact.cpds'));
     redirect('/artefact/cpds/cpd.php?id=' . $values['parent']);
 }
Exemplo n.º 2
0
 /**
  * Set activity 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, 'activity artefact not found: ' . (string) $entry->id);
         }
         if (empty($ancestorids[0])) {
             throw new ImportException($importer, 'cpd artefact not found: ' . $ancestorid);
         }
         $artefact = new ArtefactTypeActivity($artefactids[0]);
         $artefact->set('parent', $ancestorids[0]);
         $artefact->commit();
     }
 }