/**
  * Test that an artefact gets deleted.
  */
 public function testArtefactDelete()
 {
     $todelete = new ArtefactTypePlan();
     $data = array('owner' => $this->testuserid, 'title' => 'Test artefact', 'description' => 'Test artefact description');
     $todelete->set('owner', $data['owner']);
     $todelete->set('title', $data['title']);
     $todelete->set('description', $data['description']);
     $todelete->commit();
     $todeleteid = $todelete->get('id');
     $todelete->delete();
     try {
         $deleted = new ArtefactTypePlan($todeleteid);
         $this->fail("Artefact wasn't deleted properly!");
     } catch (Exception $e) {
     }
 }
Exemplo n.º 2
0
 /**
  * Creates a plan or task from the given entry
  *
  * @param SimpleXMLElement $entry    The entry to create the plan or task from
  * @param PluginImportLeap $importer The importer
  * @return array A list of artefact IDs created, to be used with the artefact mapping.
  */
 private static function create_plan(SimpleXMLElement $entry, PluginImportLeap $importer)
 {
     // First decide if it's going to be a plan or a task depending
     // on whether it has any ancestral plans.
     if (self::get_ancestor_entryid($entry, $importer)) {
         $artefact = new ArtefactTypeTask();
     } else {
         $artefact = new ArtefactTypePlan();
     }
     $artefact->set('title', (string) $entry->title);
     $artefact->set('description', PluginImportLeap::get_entry_content($entry, $importer));
     $artefact->set('owner', $importer->get('usr'));
     if (isset($entry->author->name) && strlen($entry->author->name)) {
         $artefact->set('authorname', $entry->author->name);
     } else {
         $artefact->set('author', $importer->get('usr'));
     }
     if ($published = strtotime((string) $entry->published)) {
         $artefact->set('ctime', $published);
     }
     if ($updated = strtotime((string) $entry->updated)) {
         $artefact->set('mtime', $updated);
     }
     $artefact->set('tags', PluginImportLeap::get_entry_tags($entry));
     // Set completiondate and completed status if we can find them
     if ($artefact instanceof ArtefactTypeTask) {
         $namespaces = $importer->get_namespaces();
         $ns = $importer->get_leap2a_namespace();
         $dates = PluginImportLeap::get_leap_dates($entry, $namespaces, $ns);
         if (!empty($dates['target']['value'])) {
             $completiondate = strtotime($dates['target']['value']);
         }
         $artefact->set('completiondate', empty($completiondate) ? $artefact->get('mtime') : $completiondate);
         if ($entry->xpath($namespaces[$ns] . ':status[@' . $namespaces[$ns] . ':stage="completed"]')) {
             $artefact->set('completed', 1);
         }
     }
     $artefact->commit();
     return array($artefact->get('id'));
 }
Exemplo n.º 3
0
 public static function submit(Pieform $form, $values)
 {
     global $USER, $SESSION;
     $new = false;
     if (!empty($values['plan'])) {
         $id = (int) $values['plan'];
         $artefact = new ArtefactTypePlan($id);
     } else {
         $artefact = new ArtefactTypePlan();
         $artefact->set('owner', $USER->get('id'));
         $new = true;
     }
     $artefact->set('title', $values['title']);
     $artefact->set('description', $values['description']);
     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('plansavedsuccessfully', 'artefact.plans'));
     if ($new) {
         redirect('/artefact/plans/plan.php?id=' . $artefact->get('id'));
     } else {
         redirect('/artefact/plans/index.php');
     }
 }