Esempio n. 1
0
$plugindir = get_plugin_directory('dhimport', 'version1elis');
require_once $plugindir . '/version1elis.class.php';
require_once $plugindir . '/lib.php';
require_once $CFG->dirroot . '/local/datahub/form/rlip_importfield_form.class.php';
//permissions checking
require_login();
$context = context_system::instance();
require_capability('moodle/site:config', $context);
$pluginwwwroot = str_replace($CFG->dirroot, $CFG->wwwroot, $plugindir);
$baseurl = $pluginwwwroot . '/config_fields.php';
$tab = optional_param('tab', 'user', PARAM_CLEAN);
//page header
rlipimport_version1elis_page_setup($baseurl);
echo $OUTPUT->header();
//tabs
$tabs = rlipimport_version1elis_get_tabs($baseurl);
print_tabs(array($tabs), $tab);
//TODO: implement all necessary calls, etc, to make the rest of this code work
//data from db
$mappingdata = rlipimport_version1elis_get_mapping($tab);
//options
$plugin = new rlip_importplugin_version1elis(NULL, false);
$options = $plugin->get_available_fields($tab);
//body
$form = new rlip_importfield_form(null, $options);
//handle data submission
if ($data = $form->get_data()) {
    if (isset($data->submitbutton)) {
        rlipimport_version1elis_save_mapping($tab, $options, $data);
        //notify to the user that settings were saved
        echo $OUTPUT->heading(get_string('mappingssaved', 'dhimport_version1elis'));
 /**
  * Validate that the method to get tabs works correctly
  *
  * @param $index Position in the tabs array to use
  * @param $entitytype The type of entity that tab represents
  *
  * @dataProvider gettabsprovider
  */
 public function test_gettabsreturnsvalidobjects($index, $entitytype)
 {
     global $CFG;
     // Get collection of tabs.
     $baseurl = 'base';
     $tabs = rlipimport_version1elis_get_tabs($baseurl);
     $this->assertEquals(count($tabs), 3);
     // The string displayed on the tab.
     $displaystring = get_string($entitytype . 'tab', 'dhimport_version1elis');
     // Data validation.
     $tab = $tabs[$index];
     $this->assertEquals($tab->link->out(), $baseurl . '?tab=' . $entitytype);
     $this->assertEquals($tab->text, $displaystring);
     $this->assertEquals($tab->title, $displaystring);
 }