Exemplo n.º 1
0
 /**
  * Validate that the API call for moving a profile field down in export
  * position deals with deleted user profile fields correctly
  */
 public function test_version1exporthandlesdeletedfieldswhenmovingdown()
 {
     global $CFG, $DB;
     $file = get_plugin_directory('dhexport', 'version1') . '/lib.php';
     require_once $file;
     // Set up the category and field, along with the export mapping.
     $categoryid = $this->create_custom_field_category();
     $firstfieldid = $this->create_profile_field('rliptext', 'text', $categoryid);
     $this->create_field_mapping($firstfieldid);
     // Set up a second mapping record without a field.
     $secondfieldid = 9999;
     $this->create_field_mapping($secondfieldid, 'Header2', 2);
     // Set up a third field with a mapping record.
     $thirdfieldid = $this->create_profile_field('rliptext3', 'text', $categoryid);
     $this->create_field_mapping($thirdfieldid, 'Header3', 3);
     // Move the first field down.
     $id = $DB->get_field(RLIPEXPORT_VERSION1_FIELD_TABLE, 'id', array('fieldid' => $firstfieldid));
     rlipexport_version1_config::move_field($id, rlipexport_version1_config::DIR_DOWN);
     // Validate that the first and third fields swapped, ignoring the second field.
     $this->assert_record_exists(RLIPEXPORT_VERSION1_FIELD_TABLE, array('fieldid' => $firstfieldid, 'fieldorder' => 3));
     $this->assert_record_exists(RLIPEXPORT_VERSION1_FIELD_TABLE, array('fieldid' => $thirdfieldid, 'fieldorder' => 1));
 }
Exemplo n.º 2
0
    //button to revert headers to last saved state
    $attributes = array('type' => 'submit', 'value' => get_string('revertheaders', 'dhexport_version1'), 'name' => 'revertfields');
    echo html_writer::empty_tag('input', $attributes);
    echo $OUTPUT->spacer(null, true);
    echo $OUTPUT->spacer(null, true);
    //button to save changes to headers
    $attributes = array('type' => 'submit', 'value' => get_string('updateheaders', 'dhexport_version1'), 'name' => 'updatefields');
    echo html_writer::empty_tag('input', $attributes);
    echo $OUTPUT->spacer(null, true);
    echo $OUTPUT->spacer(null, true);
    //close form
    echo html_writer::end_tag('form');
}
//fetch all available profile fields
$options = array();
if ($recordset = rlipexport_version1_config::get_available_fields()) {
    foreach ($recordset as $record) {
        $options[$record->id] = $record->name;
    }
}
if (empty($options)) {
    if (empty($table->data)) {
        echo html_writer::tag('span', get_string('profilefieldnotconfig', 'dhexport_version1'));
    } else {
        echo html_writer::tag('span', get_string('profilefieldalladded', 'dhexport_version1'));
    }
} else {
    echo html_writer::tag('span', get_string('addfieldinstructions', 'dhexport_version1'));
    echo $OUTPUT->spacer(null, true);
    $displaystring = get_string('addprofilefield', 'dhexport_version1');
    echo $OUTPUT->single_select($baseurl, 'field', $options, '', array('' => $displaystring));