function europassform_submit(Pieform $form, $values)
{
    global $SESSION, $USER;
    if (isset($values['drivingform']) && $values['drivingform'] == true) {
        // Set driving licence values and serialize them...
        $values['drivinglicence'] = array('AM' => $values['AM'], 'A1' => $values['A1'], 'A' => $values['A'], 'B' => $values['B'], 'BE' => $values['BE'], 'B1' => $values['B1'], 'C' => $values['C'], 'CE' => $values['CE'], 'C1' => $values['C1'], 'C1E' => $values['C1E'], 'D' => $values['D'], 'DE' => $values['DE'], 'D1' => $values['D1'], 'D1E' => $values['D1E']);
        $values['drivinglicence'] = serialize($values['drivinglicence']);
        // Remove elements with indexes from 0 to 13 from array = unused drivinglicences!
        $values = array_slice($values, 14);
    }
    $dbnow = db_format_timestamp(time());
    $artefact_types = ArtefactTypeEuropassArtefacts::get_europass_artefact_types();
    foreach ($values as $key => $value) {
        if (!in_array($key, $artefact_types)) {
            continue;
        }
        if (record_exists('artefact', 'artefacttype', $key, 'owner', $USER->get('id'))) {
            update_record('artefact', (object) array('description' => $value, 'mtime' => $dbnow, 'atime' => $dbnow), (object) array('artefacttype' => $key, 'owner' => $USER->get('id')));
        } else {
            insert_record('artefact', (object) array('artefacttype' => $key, 'owner' => $USER->get('id'), 'author' => $USER->get('id'), 'title' => get_string($key), 'description' => $value, 'ctime' => $dbnow, 'mtime' => $dbnow, 'atime' => $dbnow));
        }
    }
    $SESSION->add_ok_msg(get_string('europassartefactsaved', 'artefact.europass'));
    redirect(get_config('wwwroot') . 'artefact/europass/' . $values['redirect'] . '.php');
}
 public static function artefactchooser_element($default = null)
 {
     safe_require('artefact', 'europass');
     return array('name' => 'artefactid', 'type' => 'artefactchooser', 'title' => get_string('fieldtoshow', 'blocktype.europass/europassfield'), 'defaultvalue' => $default, 'blocktype' => 'europassfield', 'limit' => 655360, 'selectone' => true, 'search' => false, 'artefacttypes' => ArtefactTypeEuropassArtefacts::get_europass_artefact_types(), 'template' => 'artefact:europass:artefactchooser-element.tpl');
 }