function definition()
 {
     $form =& $this->_form;
     $form->addElement('hidden', 'id');
     $form->setType('id', PARAM_INT);
     // common form elements (copied from /user/profile/definelib.php)
     $form->addElement('header', '_commonsettings', get_string('profilecommonsettings', 'admin'));
     $strrequired = get_string('required');
     $form->addElement('text', 'shortname', get_string('profileshortname', 'admin'), 'maxlength="100" size="25"');
     $form->addRule('shortname', $strrequired, 'required', null, 'client');
     $form->setType('shortname', PARAM_SAFEDIR);
     $form->addElement('text', 'name', get_string('profilename', 'admin'), 'size="50"');
     $form->addRule('name', $strrequired, 'required', null, 'client');
     $form->setType('name', PARAM_MULTILANG);
     $level = $this->_customdata->required_param('level', PARAM_ACTION);
     $ctxlvl = context_level_base::get_custom_context_level($level, 'block_curr_admin');
     $categories = field_category::get_for_context_level($ctxlvl);
     $choices = array();
     foreach ($categories as $category) {
         $choices[$category->id] = $category->name;
     }
     $form->addElement('select', 'categoryid', get_string('profilecategory', 'admin'), $choices);
     $form->addElement('htmleditor', 'description', get_string('profiledescription', 'admin'));
     $form->setHelpButton('description', array('text', get_string('helptext')));
     $choices = array('text' => get_string('field_datatype_text', 'block_curr_admin'), 'char' => get_string('field_datatype_char', 'block_curr_admin'), 'int' => get_string('field_datatype_int', 'block_curr_admin'), 'num' => get_string('field_datatype_num', 'block_curr_admin'), 'bool' => get_string('field_datatype_bool', 'block_curr_admin'));
     $form->addElement('select', 'datatype', get_string('field_datatype', 'block_curr_admin'), $choices);
     $form->addElement('advcheckbox', 'forceunique', get_string('profileforceunique', 'admin'));
     $form->setAdvanced('forceunique');
     $form->addElement('advcheckbox', 'multivalued', get_string('field_multivalued', 'block_curr_admin'));
     $form->setAdvanced('multivalued');
     $form->addElement('text', 'defaultdata', get_string('profiledefaultdata', 'admin'), 'size="50"');
     $form->setType('defaultdata', PARAM_MULTILANG);
     $plugins = get_list_of_plugins('curriculum/plugins');
     foreach ($plugins as $plugin) {
         if (is_readable(CURMAN_DIRLOCATION . '/plugins/' . $plugin . '/custom_fields.php')) {
             include_once CURMAN_DIRLOCATION . '/plugins/' . $plugin . '/custom_fields.php';
             if (function_exists("{$plugin}_field_edit_form_definition")) {
                 call_user_func("{$plugin}_field_edit_form_definition", $this);
             }
         }
     }
     $this->add_action_buttons(true);
 }
Ejemplo n.º 2
0
 /**
  * Makes sure that a custom field (identified by $field->shortname) exists
  * for the given context level.  If not, it will create a field, putting it
  * in the given category (identified by $category->name), creating it if
  * necessary.
  *
  * @param object a field object, specifying the field configuration if a
  * new field is created
  * @param mixed the context level
  * @param object a field_category object, specifying the category
  * configuration if a new category is created
  * @return object a field object
  */
 static function ensure_field_exists_for_context_level($field, $ctx_lvl, $category)
 {
     if (!is_numeric($ctx_lvl)) {
         $ctx_lvl = context_level_base::get_custom_context_level($ctx_lvl, 'block_curr_admin');
     }
     // see if we need to create a new field
     $fields = field::get_for_context_level($ctx_lvl);
     if (!empty($fields)) {
         foreach ($fields as $f) {
             if ($f->shortname === $field->shortname) {
                 return new field($f);
             }
         }
     }
     // No existing field found.  See if we need to create a category for it
     $categories = field_category::get_for_context_level($ctx_lvl);
     $found = false;
     if (!empty($categories)) {
         foreach ($categories as $c) {
             if ($c->name === $category->name) {
                 $category = $found = $c;
                 break;
             }
         }
     }
     if (!$found) {
         // create the category
         $category->add();
         $categorycontext = new field_category_contextlevel();
         $categorycontext->categoryid = $category->id;
         $categorycontext->contextlevel = $ctx_lvl;
         $categorycontext->add();
     }
     // create the field
     $field->categoryid = $category->id;
     $field->add();
     $fieldcontext = new field_contextlevel();
     $fieldcontext->fieldid = $field->id;
     $fieldcontext->contextlevel = $ctx_lvl;
     $fieldcontext->add();
     return $field;
 }
$site = get_site();
$block_id = required_param('instance', PARAM_RAW);
$fieldidlist = optional_param('fieldidlist', null, PARAM_TEXT);
$fieldnamelist = optional_param('fieldnamelist', null, PARAM_TEXT);
// Get custom course fields by context level
$context = context_level_base::get_custom_context_level('course', 'block_curr_admin');
$fields = field::get_for_context_level($context);
$fields = $fields ? $fields : array();
//Unserialize fieldidlist to check against field list
if (isset($fieldidlist)) {
    $fieldidlist = @unserialize(base64_decode($fieldidlist));
}
if (isset($fieldnamelist)) {
    $fieldnamelist = @unserialize(base64_decode($fieldnamelist));
}
$categories = field_category::get_for_context_level($context);
$categories = $categories ? $categories : array();
// divide the fields into categories
$fieldsbycategory = array();
foreach ($categories as $category) {
    $fieldsbycategory[$category->name] = array();
}
foreach ($fields as $field) {
    if (is_array($fieldidlist) && in_array($field->id, $fieldidlist)) {
        continue;
    }
    //make sure the current user can access this field in at least one
    //course context
    $owners = field_owner::get_for_field($field);
    if (!block_php_report_field_accessible($owners)) {
        continue;
Ejemplo n.º 4
0
 /**
  * Makes sure that a custom field (identified by $field->shortname) exists
  * for the given context level.  If not, it will create a field, putting it
  * in the given category (identified by $category->name), creating it if
  * necessary.
  *
  * @param field $field a field object, specifying the field configuration
  * if a new field is created
  * @param mixed $contextlevel the context level
  * @param field_category $category a field_category object, specifying the
  * category configuration if a new category is created
  * @return object a field object
  */
 public static function ensure_field_exists_for_context_level(field $field, $contextlevel, field_category $category)
 {
     if (!is_numeric($contextlevel)) {
         $contextlevel = \local_eliscore\context\helper::get_level_from_name($contextlevel);
     }
     // see if we need to create a new field
     $fields = self::get_for_context_level($contextlevel);
     if (!empty($fields)) {
         foreach ($fields as $f) {
             if ($f->shortname === $field->shortname) {
                 return $f;
             }
         }
     }
     // No existing field found.  See if we need to create a category for it
     $categories = field_category::get_for_context_level($contextlevel);
     $found = false;
     if (!empty($categories)) {
         foreach ($categories as $c) {
             if ($c->name === $category->name) {
                 $category = $found = $c;
                 break;
             }
         }
     }
     if (!$found) {
         // create the category
         $category->save();
         $categorycontext = new field_category_contextlevel();
         $categorycontext->categoryid = $category->id;
         $categorycontext->contextlevel = $contextlevel;
         $categorycontext->save();
     }
     // create the field
     $field->categoryid = $category->id;
     $field->save();
     $fieldcontext = new field_contextlevel();
     $fieldcontext->fieldid = $field->id;
     $fieldcontext->contextlevel = $contextlevel;
     $fieldcontext->save();
     return $field;
 }
Ejemplo n.º 5
0
 function display_default()
 {
     global $CFG, $DB, $OUTPUT;
     $level = $this->required_param('level', PARAM_ACTION);
     if (!($ctxlvl = \local_eliscore\context\helper::get_level_from_name($level))) {
         print_error('invalid_context_level', 'local_elisprogram');
     }
     $tmppage = new moodle_url($this->url);
     $tabs = array();
     $contextlevels = \local_eliscore\context\helper::get_legacy_levels();
     foreach ($contextlevels as $contextlevel => $val) {
         $tmppage->param('level', $contextlevel);
         $tabs[] = new tabobject($contextlevel, $tmppage->out(), get_string($contextlevel, 'local_elisprogram'));
     }
     print_tabs(array($tabs), $level);
     $fields = field::get_for_context_level($ctxlvl);
     $fields = $fields ? $fields : array();
     $categories = field_category::get_for_context_level($ctxlvl);
     $categories = $categories ? $categories : array();
     // divide the fields into categories
     $category_names = array();
     $fieldsbycategory = array();
     foreach ($categories as $category) {
         $category_names[$category->id] = $category->name;
         $fieldsbycategory[$category->id] = array();
     }
     foreach ($fields as $field) {
         $fieldsbycategory[$field->categoryid][] = $field;
     }
     $deletetxt = get_string('delete');
     $edittxt = get_string('edit');
     $syncerr = false;
     if (empty($category_names)) {
         echo $OUTPUT->heading(get_string('field_no_categories_defined', 'local_elisprogram'));
     }
     foreach ($fieldsbycategory as $categoryid => $fields) {
         $categorypage = new moodle_url($this->url);
         $categorypage->params(array('action' => 'deletecategory', 'id' => $categoryid, 'level' => $level));
         $deletelink = $categorypage->out();
         $categorypage->param('action', 'editcategory');
         $editlink = $categorypage->out();
         if (isset($category_names[$categoryid])) {
             echo "<h2>{$category_names[$categoryid]} ";
             echo "<a href=\"{$editlink}\" class=\"elisicon elisicon-edit\" alt=\"{$edittxt}\" title=\"{$edittxt}\"></a>";
             echo "<a href=\"{$deletelink}\" class=\"elisicon elisicon-remove\" alt=\"{$deletetxt}\" title=\"{$deletetxt}\"></a>";
             echo "</h2>\n";
         }
         if (empty($fields)) {
             print_string('field_no_fields_defined', 'local_elisprogram');
         } else {
             if ($level == 'user') {
                 require_once elis::plugin_file('elisfields_moodleprofile', 'custom_fields.php');
                 $table = new customuserfieldtable($fields, array('name' => array('header' => get_string('name')), 'datatype' => array('header' => get_string('field_datatype', 'local_elisprogram')), 'syncwithmoodle' => array('header' => get_string('field_syncwithmoodle', 'local_elisprogram')), 'buttons' => array('header' => '')), $this->url);
             } else {
                 $table = new customfieldtable($fields, array('name' => array('header' => get_string('name')), 'datatype' => array('header' => 'Data type'), 'buttons' => array('header' => '')), $this->url);
             }
             echo $table->get_html();
             $syncerr = $syncerr || !empty($table->syncerr);
         }
     }
     if ($syncerr) {
         print_string('moodle_field_sync_warning', 'local_elisprogram');
     }
     // button for new category
     $options = array('s' => 'field', 'action' => 'editcategory', 'level' => $level);
     $button = new single_button(new moodle_url('index.php', $options), get_string('field_create_category', 'local_elisprogram'), 'get', array('disabled' => false, 'title' => get_string('field_create_category', 'local_elisprogram'), 'id' => ''));
     echo $OUTPUT->render($button);
     if (!empty($category_names)) {
         if ($level == 'user') {
             // create new field from Moodle field
             $sql = 'shortname NOT IN
                     (SELECT shortname FROM {' . field::TABLE . '} ef
                     INNER JOIN {' . field_contextlevel::TABLE . '} cl
                     ON ef.id = cl.fieldid WHERE cl.contextlevel = :contextlevel)';
             $moodlefields = $DB->get_records_select('user_info_field', $sql, array('contextlevel' => $ctxlvl, 'sortorder' => 'id,name'));
             $moodlefields = $moodlefields ? $moodlefields : array();
             $tmppage->param('action', 'editfield');
             $tmppage->param('from', 'moodle');
             $tmppage->param('level', 'user');
             echo '<div>';
             //popup_form("{$tmppage->url}&amp;id=",
             //           array_map(create_function('$x', 'return $x->name;'), $moodlefields),
             //           'frommoodleform', '', 'choose', '', '', false, 'self', get_string('field_from_moodle', 'local_elisprogram'));
             $actionurl = new moodle_url($tmppage->out());
             $single_select = new single_select($actionurl, 'id', array_map(create_function('$x', 'return $x->name;'), $moodlefields), null, array('' => get_string('field_from_moodle', 'local_elisprogram')));
             echo $OUTPUT->render($single_select);
             echo '</div>';
             $options = array('s' => 'field', 'action' => 'forceresync');
             $button = new single_button(new moodle_url('index.php', $options), get_string('field_force_resync', 'local_elisprogram'), 'get', array('disabled' => false, 'title' => get_string('field_force_resync', 'local_elisprogram'), 'id' => ''));
             echo $OUTPUT->render($button);
         } else {
             // create new field from scratch
             $options = array('s' => 'field', 'action' => 'editfield', 'level' => $level);
             $button = new single_button(new moodle_url('index.php', $options), get_string('field_create_new', 'local_elisprogram'), 'get', array('disabled' => false, 'title' => get_string('field_create_new', 'local_elisprogram'), 'id' => ''));
             echo $OUTPUT->render($button);
         }
     }
 }
Ejemplo n.º 6
0
 /**
  * ELIS-4797: Test Various Custom Field Operations
  */
 public function test_customfieldoperations()
 {
     $contextlevels = \local_eliscore\context\helper::get_legacy_levels();
     foreach ($contextlevels as $ctxname => $ctxlvl) {
         $category = $this->create_field_category($ctxlvl);
         $field = $this->create_field($category, $ctxlvl);
         $fieldsfetched = field::get_for_context_level($ctxlvl);
         $fieldfound = false;
         foreach ($fieldsfetched as $fieldfetched) {
             if ($fieldfetched->shortname === $field->shortname) {
                 $fieldfound = true;
             }
         }
         $this->assertTrue($fieldfound);
         $fieldfetched = field::get_for_context_level_with_name($ctxlvl, $field->shortname);
         $this->assertEquals($field->shortname, $fieldfetched->shortname);
         $fieldfetched = field::ensure_field_exists_for_context_level($field, $ctxlvl, $category);
         $this->assertEquals($field->shortname, $fieldfetched->shortname);
         $catsfetched = field_category::get_for_context_level($ctxlvl);
         $catfound = false;
         foreach ($catsfetched as $catfetched) {
             if ($catfetched->id == $category->id) {
                 $catfound = true;
             }
         }
         $this->assertTrue($catfound);
         if ($ctxlvl === CONTEXT_ELIS_PROGRAM) {
             $cur = $this->create_curriculum();
             $fielddata = field_data::get_for_context_and_field(null, $field);
             $fielddata = $fielddata->current();
             $res = $fielddata->set_for_context_from_datarecord($ctxlvl, $cur);
             $this->assertTrue($res);
         }
     }
 }
 function action_default()
 {
     global $CFG, $CURMAN;
     $level = $this->required_param('level', PARAM_ACTION);
     $ctxlvl = context_level_base::get_custom_context_level($level, 'block_curr_admin');
     if (!$ctxlvl) {
         print_error('invalid_context_level', 'block_curr_admin');
     }
     $tmppage = new customfieldpage();
     $tabs = array();
     require "{$CFG->dirroot}/blocks/curr_admin/db/access.php";
     foreach ($block_curr_admin_contextlevels as $contextlevel => $val) {
         $tmppage->params['level'] = $contextlevel;
         $tabs[] = new tabobject($contextlevel, $tmppage->get_url(), get_string($contextlevel, 'block_curr_admin'));
     }
     print_tabs(array($tabs), $level);
     $fields = field::get_for_context_level($ctxlvl);
     $fields = $fields ? $fields : array();
     $categories = field_category::get_for_context_level($ctxlvl);
     $categories = $categories ? $categories : array();
     // divide the fields into categories
     $fieldsbycategory = array();
     foreach ($categories as $category) {
         $fieldsbycategory[$category->id] = array();
     }
     foreach ($fields as $field) {
         $fieldsbycategory[$field->categoryid][] = $field;
     }
     $deletetxt = get_string('delete');
     $edittxt = get_string('edit');
     $syncerr = false;
     if (empty($categories)) {
         print_heading(get_string('field_no_categories_defined', 'block_curr_admin'));
     }
     foreach ($fieldsbycategory as $categoryid => $fields) {
         $tmppage = new customfieldpage();
         $tmppage->params = array('action' => 'deletecategory', 'id' => $categoryid, 'level' => $level);
         $deletelink = $tmppage->get_url();
         $tmppage->params['action'] = 'editcategory';
         $editlink = $tmppage->get_url();
         echo "<h2>{$categories[$categoryid]->name} <a href=\"{$editlink}\">";
         echo "<img src=\"{$CFG->wwwroot}/curriculum/pix/edit.gif\" alt=\"{$edittxt}\" title=\"{$edittxt}\" /></a>";
         echo "<a href=\"{$deletelink}\"><img src=\"{$CFG->wwwroot}/curriculum/pix/delete.gif\" alt=\"{$deletetxt}\" title=\"{$deletetxt}\" /></a>";
         echo "</h2>\n";
         if (empty($fields)) {
             print_string('field_no_fields_defined', 'block_curr_admin');
         } else {
             if ($level == 'user') {
                 require_once CURMAN_DIRLOCATION . '/plugins/moodle_profile/custom_fields.php';
                 $table = new customuserfieldtable($fields, array('name' => get_string('name'), 'datatype' => get_string('field_datatype', 'block_curr_admin'), 'syncwithmoodle' => get_string('field_syncwithmoodle', 'block_curr_admin'), 'buttons' => ''), $this->get_moodle_url(array('level' => $level)));
             } else {
                 $table = new customfieldtable($fields, array('name' => get_string('name'), 'datatype' => 'Data type', 'buttons' => ''), $this->get_moodle_url(array('level' => $level)));
             }
             $table->print_table();
             $syncerr = $syncerr || !empty($table->syncerr);
         }
     }
     if ($syncerr) {
         print_string('moodle_field_sync_warning', 'block_curr_admin');
     }
     // button for new category
     $options = array('s' => 'field', 'action' => 'editcategory', 'level' => $level);
     print_single_button('index.php', $options, get_string('field_create_category', 'block_curr_admin'));
     if (!empty($categories)) {
         if ($level == 'user') {
             // create new field from Moodle field
             $select = "shortname NOT IN (SELECT shortname FROM {$CURMAN->db->prefix_table(FIELDTABLE)})";
             $moodlefields = $CURMAN->db->get_records_select('user_info_field', $select, 'sortorder', 'id,name');
             $moodlefields = $moodlefields ? $moodlefields : array();
             $tmppage->params['action'] = 'editfield';
             $tmppage->params['from'] = 'moodle';
             $tmppage->params['level'] = 'user';
             echo '<div>';
             popup_form("{$tmppage->get_url()}&amp;id=", array_map(create_function('$x', 'return $x->name;'), $moodlefields), 'frommoodleform', '', 'choose', '', '', false, 'self', get_string('field_from_moodle', 'block_curr_admin'));
             echo '</div>';
             $options = array('s' => 'field', 'action' => 'forceresync');
             print_single_button('index.php', $options, get_string('field_force_resync', 'block_curr_admin'));
         } else {
             // create new field from scratch
             $options = array('s' => 'field', 'action' => 'editfield', 'level' => $level);
             print_single_button('index.php', $options, get_string('field_create_new', 'block_curr_admin'));
         }
     }
 }
Ejemplo n.º 8
0
 /**
  * Custom field form definition method
  *
  * @uses $CFG
  * @uses $DB
  * @uses $PAGE
  */
 function definition()
 {
     global $CFG, $DB, $PAGE;
     $attrs = array();
     $form =& $this->_form;
     $form->addElement('hidden', 'id');
     $form->setType('id', PARAM_INT);
     // Include required yui javascript
     $PAGE->requires->yui_module('moodle-local_eliscore-customfieldsform', 'M.local_eliscore.init_customfieldsform', array(get_string('profiledefaultdata', 'admin')), null, true);
     $fid = $this->_customdata['id'];
     $from = $this->_customdata['from'];
     // common form elements (copied from /user/profile/definelib.php)
     $form->addElement('header', '_commonsettings', get_string('profilecommonsettings', 'admin'));
     $strrequired = get_string('required');
     $form->addElement('text', 'shortname', get_string('profileshortname', 'admin'), array('maxlength' => '100', 'size' => '25'));
     $form->setType('shortname', PARAM_SAFEDIR);
     $form->addElement('text', 'name', get_string('profilename', 'admin'), array('size' => '50'));
     $form->addRule('name', $strrequired, 'required', null, 'client');
     $form->setType('name', PARAM_MULTILANG);
     $level = $this->_customdata['level'];
     $ctxlvl = \local_eliscore\context\helper::get_level_from_name($level);
     $categories = field_category::get_for_context_level($ctxlvl);
     $choices = array();
     foreach ($categories as $category) {
         $choices[$category->id] = $category->name;
     }
     $form->addElement('select', 'categoryid', get_string('profilecategory', 'admin'), $choices);
     $form->addElement('htmleditor', 'description', get_string('profiledescription', 'admin'));
     $form->setType('description', PARAM_CLEAN);
     //$form->addHelpButton('description', 'helptext');
     $choices = array('text' => get_string('field_datatype_text', 'local_elisprogram'), 'char' => get_string('field_datatype_char', 'local_elisprogram'), 'int' => get_string('field_datatype_int', 'local_elisprogram'), 'num' => get_string('field_datatype_num', 'local_elisprogram'), 'bool' => get_string('field_datatype_bool', 'local_elisprogram'), 'datetime' => get_string('field_datatype_datetime', 'local_elisprogram'));
     $form->addElement('select', 'datatype', get_string('field_datatype', 'local_elisprogram'), $choices);
     $form->addElement('advcheckbox', 'forceunique', get_string('profileforceunique', 'admin'));
     $form->setAdvanced('forceunique');
     $form->addElement('advcheckbox', 'multivalued', get_string('field_multivalued', 'local_elisprogram'), '', array('group' => false));
     $form->setAdvanced('multivalued');
     $form->disabledIf('multivalued', 'datatype', 'eq', 'datetime');
     // ELIS-4592: default needs to use custom field type control
     // for checkbox OR datetime which requires javascript to update this
     // when control type is changed!
     $form->addElement('html', '<fieldset class="clearfix" id="datatype_text">');
     $form->addElement('text', 'defaultdata_text', get_string('profiledefaultdata', 'admin'), array('size' => '50'));
     $form->setType('defaultdata_text', PARAM_MULTILANG);
     // TBD???
     $form->addElement('html', '</fieldset>');
     $form->addElement('html', '<fieldset class="accesshide" id="datatype_checkbox">');
     $form->addElement('advcheckbox', 'defaultdata_checkbox', get_string('profiledefaultdata', 'admin'));
     $form->addElement('html', '</fieldset>');
     $form->addElement('html', '<fieldset class="accesshide" id="datatype_menu">');
     $menu_options = array();
     if ($from == 'moodle') {
         $moptions = $DB->get_field('user_info_field', 'param1', array('id' => $fid));
         $menu_options = explode("\n", $moptions);
     } else {
         if ($fid) {
             $fparams = $DB->get_field(field_owner::TABLE, 'params', array('fieldid' => $fid, 'plugin' => 'manual'));
             $foptions = unserialize($fparams);
             $menu_options = !empty($foptions['options']) ? explode("\n", $foptions['options']) : array();
         }
     }
     if (!empty($menu_options)) {
         array_walk($menu_options, array($this, 'trim_crlf'));
         $menu_options = array_combine($menu_options, $menu_options);
     }
     if ($this->defaultdata_menu = $form->createElement('select', 'defaultdata_menu', get_string('profiledefaultdata', 'admin'), $menu_options, array('multiple' => 'multiple'))) {
         $form->addElement($this->defaultdata_menu);
     }
     //$form->setType('defaultdata_menu', PARAM_TEXT);
     $form->addElement('html', '</fieldset>');
     $form->addElement('hidden', 'defaultdata_radio');
     // *REQUIRED* place-hoolder!!!
     $form->setType('defaultdata_radio', PARAM_TEXT);
     $form->addElement('html', '<fieldset class="accesshide" id="datatype_radio">');
     $form->addElement('html', '</fieldset>');
     // Loop thru all possible sources for menu options
     require_once elis::plugin_file('elisfields_manual', 'sources.php');
     $basedir = elis::plugin_file('elisfields_manual', 'sources');
     $dirhandle = opendir($basedir);
     while (false !== ($file = readdir($dirhandle))) {
         if (filetype($basedir . '/' . $file) === 'dir') {
             continue;
         }
         if (substr($file, -4) !== '.php') {
             continue;
         }
         require_once $basedir . '/' . $file;
         $file = substr($file, 0, -4);
         $classname = "manual_options_{$file}";
         $plugin = new $classname();
         if ($plugin->is_applicable($level)) {
             $poptions = $plugin->get_options(array());
             // TBD
             $form->addElement('html', '<fieldset class="accesshide" id="datatype_menu_' . $file . '">');
             $form->addElement('select', "defaultdata_menu_{$file}", get_string('profiledefaultdata', 'admin'), $poptions);
             $form->addElement('html', '</fieldset>');
             $form->addElement('html', '<fieldset class="accesshide" id="datatype_radio_' . $file . '">');
             $radios = array();
             foreach ($poptions as $poption) {
                 $radios[] =& $form->createElement('radio', "defaultdata_radio_{$file}_", $poption, $poption, $poption);
             }
             $form->addGroup($radios, "defaultdata_radio_{$file}", get_string('profiledefaultdata', 'admin'), array('<br/>'), false);
             $form->addElement('html', '</fieldset>');
         }
     }
     $form->addElement('html', '<fieldset class="accesshide" id="datatype_datetime">');
     $startyear = $stopyear = $inctime = false;
     if ($from == 'moodle') {
         $startyear = $DB->get_field('user_info_field', 'param1', array('id' => $fid));
         $stopyear = $DB->get_field('user_info_field', 'param2', array('id' => $fid));
         $inctime = $DB->get_field('user_info_field', 'param3', array('id' => $fid));
     } else {
         if ($fid) {
             $fparams = $DB->get_field(field_owner::TABLE, 'params', array('fieldid' => $fid, 'plugin' => 'manual'));
             $foptions = unserialize($fparams);
             $startyear = !empty($foptions['startyear']) ? $foptions['startyear'] : false;
             $stopyear = !empty($foptions['stopyear']) ? $foptions['stopyear'] : false;
             $inctime = !empty($foptions['inctime']);
         }
     }
     if (empty($startyear)) {
         $startyear = 1970;
     }
     if (empty($stopyear)) {
         $stopyear = 2038;
     }
     if ($startyear < 1902 || $startyear > 2038) {
         $startyear = 1970;
     }
     if ($stopyear < 1902 || $stopyear > 2038) {
         $stopyear = 2038;
     }
     $form->addElement('date_time_selector', 'defaultdata_datetime', get_string('profiledefaultdata', 'admin'), array('startyear' => $startyear, 'stopyear' => $stopyear, 'timezone' => 99, 'optional' => false));
     // TBD!?!
     $form->addElement('html', '</fieldset>');
     $plugins = core_component::get_plugin_list('elisfields');
     foreach ($plugins as $plugin => $dir) {
         // error_log("customfieldform: plugin file = ".elis::plugin_file("elisfields_{$plugin}",'custom_fields.php'));
         if (is_readable(elis::plugin_file("elisfields_{$plugin}", 'custom_fields.php'))) {
             include_once elis::plugin_file("elisfields_{$plugin}", 'custom_fields.php');
             if (function_exists("{$plugin}_field_edit_form_definition")) {
                 call_user_func("{$plugin}_field_edit_form_definition", $form, $attrs);
             }
         }
     }
     $this->add_action_buttons(true);
 }