function definition()
 {
     global $DB, $USER, $CFG;
     $mform =& $this->_form;
     $mform->addElement('header', 'general', get_string('general', 'form'));
     $mform->addElement('text', 'name', get_string('name'));
     if (!empty($CFG->formatstringstriptags)) {
         $mform->setType('name', PARAM_TEXT);
     } else {
         $mform->setType('name', PARAM_CLEAN);
     }
     $mform->addRule('name', null, 'required', null, 'client');
     $mform->addElement('htmleditor', 'summary', get_string('summary'));
     $mform->setType('summary', PARAM_RAW);
     $typeoptions = cr_get_report_plugins($this->_customdata['courseid']);
     $eloptions = array();
     if (isset($this->_customdata['report']->id) && $this->_customdata['report']->id) {
         $eloptions = array('disabled' => 'disabled');
     }
     $mform->addElement('select', 'type', get_string("typeofreport", 'block_configurable_reports'), $typeoptions, $eloptions);
     $mform->addHelpButton('type', 'typeofreport', 'block_configurable_reports');
     for ($i = 0; $i <= 100; $i++) {
         $pagoptions[$i] = $i;
     }
     $mform->addElement('select', 'pagination', get_string("pagination", 'block_configurable_reports'), $pagoptions);
     $mform->setDefault('pagination', 0);
     $mform->addHelpButton('pagination', 'pagination', 'block_configurable_reports');
     $mform->addElement('checkbox', 'jsordering', get_string('ordering', 'block_configurable_reports'), get_string('enablejsordering', 'block_configurable_reports'));
     $mform->addHelpButton('jsordering', 'jsordering', 'block_configurable_reports');
     $mform->addElement('header', 'exportoptions', get_string('exportoptions', 'block_configurable_reports'));
     $options = cr_get_export_plugins();
     foreach ($options as $key => $val) {
         $mform->addElement('checkbox', 'export_' . $key, null, $val);
     }
     if (isset($this->_customdata['report']->id) && $this->_customdata['report']->id) {
         $mform->addElement('hidden', 'id', $this->_customdata['report']->id);
     }
     $mform->addElement('hidden', 'courseid', $this->_customdata['courseid']);
     // buttons
     $this->add_action_buttons(true, get_string('add'));
 }
    function definition() {
        global $DB, $USER, $CFG;

        $adminmode = optional_param('adminmode', null, PARAM_INT);

        $mform = & $this->_form;

        $mform->addElement('header', 'general', get_string('general', 'form'));

        $mform->addElement('text', 'name', get_string('name'), array('maxlength' => 60, 'size' => 58));
        if (!empty($CFG->formatstringstriptags)) {
            $mform->setType('name', PARAM_TEXT);
        } else {
            $mform->setType('name', PARAM_NOTAGS);
        }
        $mform->addRule('name', null, 'required', null, 'client');

        $mform->addElement('htmleditor', 'summary', get_string('summary'));
        $mform->setType('summary', PARAM_RAW);

        $typeoptions = cr_get_report_plugins($this->_customdata['courseid']);

        $eloptions = array();
        if (isset($this->_customdata['report']->id) && $this->_customdata['report']->id)
            $eloptions = array('disabled' => 'disabled');
        $select = $mform->addElement('select', 'type', get_string("typeofreport", 'block_cobalt_reports'), $typeoptions, $eloptions);
        $mform->addHelpButton('type', 'typeofreport', 'block_cobalt_reports');
        $select->setSelected('sql');

        for ($i = 0; $i <= 100; $i++)
            $pagoptions[$i] = $i;
        $mform->addElement('select', 'pagination', get_string("pagination", 'block_cobalt_reports'), $pagoptions);
        $mform->setDefault('pagination', 0);
        $mform->addHelpButton('pagination', 'pagination', 'block_cobalt_reports');

        $mform->addElement('checkbox', 'global', get_string('global', 'block_cobalt_reports'), get_string('enableglobal', 'block_cobalt_reports'));
        $mform->addHelpButton('global', 'global', 'block_cobalt_reports');
        $mform->setDefault('global', 0);

        $mform->addElement('checkbox', 'jsordering', get_string('ordering', 'block_cobalt_reports'), get_string('enablejsordering', 'block_cobalt_reports'));
        $mform->addHelpButton('jsordering', 'jsordering', 'block_cobalt_reports');
        $mform->setDefault('jsordering', 1);

        $mform->addElement('checkbox', 'cron', get_string('cron', 'block_cobalt_reports'), get_string('crondescription', 'block_cobalt_reports'));
        $mform->addHelpButton('cron', 'cron', 'block_cobalt_reports');
        $mform->setDefault('cron', 0);
        $mform->disabledIf('cron', 'type', 'neq', 'sql');

        $mform->addElement('header', 'exportoptions', get_string('exportoptions', 'block_cobalt_reports'));
        $options = cr_get_export_plugins();

        foreach ($options as $key => $val) {
            $mform->addElement('checkbox', 'export_' . $key, null, $val);
        }

        if (isset($this->_customdata['report']->id) && $this->_customdata['report']->id)
            $mform->addElement('hidden', 'id', $this->_customdata['report']->id);
        $mform->setType('id', PARAM_INT);
        if (!empty($adminmode)) {
            $mform->addElement('text', 'courseid', get_string("setcourseid", 'block_cobalt_reports'), $this->_customdata['courseid']);
            $mform->setType('courseid', PARAM_INT);
        } else {
            $mform->addElement('hidden', 'courseid', $this->_customdata['courseid']);
            $mform->setType('courseid', PARAM_INT);
        }


        // buttons
        $this->add_action_buttons(true, get_string('add'));
    }