/** * TODO comment this */ function definition() { global $USER, $CFG; // include the assmgr db require_once $CFG->dirroot . '/blocks/ilp/db/ilp_db.php'; $dbc = new ilp_db(); $mform =& $this->_form; //get all of the fields in the current report, they will be returned in order as //no position has been specified $reportfields = $this->dbc->get_report_fields_by_position($this->report_id); $report = $this->dbc->get_report_by_id($this->report_id); $user = $this->dbc->get_user_by_id($this->user_id); $title = "{$report->name} " . get_string('for', 'block_ilp') . " {$user->firstname} {$user->lastname}"; //create a new fieldset $mform->addElement('html', '<fieldset id="reportfieldset" class="clearfix ilpfieldset">'); $mform->addElement('html', '<legend class="ftoggler">' . $title . '</legend>'); $desc = html_entity_decode($report->description); $mform->addElement('html', '<div class="descritivetext">' . $desc . '</div>'); $mform->addElement('hidden', 'entry_id', $this->entry_id); $mform->setType('entry_id', PARAM_INT); $mform->addElement('hidden', 'report_id', $this->report_id); $mform->setType('report_id', PARAM_INT); $mform->addElement('hidden', 'user_id', $this->user_id); $mform->setType('user_id', PARAM_INT); $mform->addElement('hidden', 'course_id', $this->course_id); $mform->setType('course_id', PARAM_INT); if (!empty($reportfields)) { foreach ($reportfields as $field) { //get the plugin record that for the plugin $pluginrecord = $dbc->get_plugin_by_id($field->plugin_id); //take the name field from the plugin as it will be used to call the instantiate the plugin class $classname = $pluginrecord->name; // include the class for the plugin include_once "{$CFG->dirroot}/blocks/ilp/classes/form_elements/plugins/{$classname}.php"; if (!class_exists($classname)) { print_error('noclassforplugin', 'block_ilp', '', $pluginrecord->name); } //instantiate the plugin class $pluginclass = new $classname(); $pluginclass->load($field->id); //call the plugins entry_form function which will add an instance of the plugin //to the form $pluginclass->entry_form($mform); } } $buttonarray[] =& $mform->createElement('submit', 'submitbutton', get_string('submit')); $buttonarray[] =& $mform->createElement('cancel'); $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false); //close the fieldset $mform->addElement('html', '</fieldset>'); }
/** * TODO comment this */ function definition() { global $USER, $CFG; // include the assmgr db require_once $CFG->dirroot . '/blocks/ilp/db/ilp_db.php'; $dbc = new ilp_db(); $mform =& $this->_form; //get all of the fields in the current report, they will be returned in order as //no position has been specified $reportfields = $this->dbc->get_report_fields_by_position($this->report_id); $report = $this->dbc->get_report_by_id($this->report_id); //create a new fieldset $mform->addElement('html', '<fieldset id="reportfieldset" class="clearfix ilpfieldset">'); $mform->addElement('html', '<legend class="ftoggler">' . $report->name . '</legend>'); $desc = html_entity_decode($report->description); $mform->addElement('html', '<div class="descritivetext">' . $desc . '</div>'); foreach ($reportfields as $field) { //get the plugin record that for the plugin $pluginrecord = $dbc->get_plugin_by_id($field->plugin_id); //take the name field from the plugin as it will be used to call the instantiate the plugin class $classname = $pluginrecord->name; // include the class for the plugin include_once "{$CFG->dirroot}/blocks/ilp/classes/form_elements/plugins/{$classname}.php"; if (!class_exists($classname)) { print_error('noclassforplugin', 'block_ilp', '', $pluginrecord->name); } //instantiate the plugin class $pluginclass = new $classname(); $pluginclass->load($field->id); //call the plugins entry_form function which will add an instance of the plugin //to the form $pluginclass->entry_form($mform); } //close the fieldset $mform->addElement('html', '</fieldset>'); }
} //get the entry $entry = $dbc->get_entry_by_id($entry_id); //if the report is not found throw an error of if the report has a status of disabled if (empty($entry)) { print_error('entrynotfouund', 'block_ilp'); } if (empty($report->frequency)) { //entries can only be deleted from reports that allow multiple entries print_error('entrycannotbedeleted', 'block_ilp'); } //check if the user has the delete record capability if (empty($access_report_deletereports)) { //the user doesnt have the capability to create this type of report entry print_error('userdoesnothavedeletecapability', 'block_ilp'); } // instantiate the db $dbc = new ilp_db(); //get all of the fields in the current report, they will be returned in order as //no position has been specified $reportfields = $dbc->get_report_fields_by_position($report_id); if (!empty($reportfields)) { foreach ($reportfields as $field) { //get the plugin record that for the plugin $pluginrecord = $dbc->get_plugin_by_id($field->plugin_id); $dbc->delete_element_record_by_id($pluginrecord->tablename . '_ent', $field->id); } } $dbc->delete_entry_by_id($entry_id); $return_url = $CFG->wwwroot . "/blocks/ilp/actions/view_main.php?user_id={$user_id}&course_id={$course_id}&selectedtab={$selectedtab}&tabitem={$tabitem}"; redirect($return_url, get_string('entrydeleted', 'block_ilp'), ILP_REDIRECT_DELAY);
//section name $PAGE->navbar->add(get_string('reportconfiguration', 'block_ilp'), $CFG->wwwroot . "/blocks/ilp/actions/edit_report_configuration.php", 'title'); //get string for create report $PAGE->navbar->add(get_string('reportfields', 'block_ilp'), null, 'title'); $pagetitle = !empty($reportfield_id) ? get_string('editfield', 'block_ilp') : get_string('addfield', 'block_ilp'); //get string for page $PAGE->navbar->add($pagetitle, null, 'title'); // setup the page title and heading $SITE = $dbc->get_course_by_id(SITEID); $PAGE->set_title($SITE->fullname . " : " . get_string('blockname', 'block_ilp')); $PAGE->set_heading($SITE->fullname); $PAGE->set_pagetype('ilp-configuration'); $PAGE->set_pagelayout('ilp'); $PAGE->set_url('/blocks/ilp/actions/edit_field.php', $PARSER->get_params()); //get the plugin record that for the plugin $pluginrecord = $dbc->get_plugin_by_id($plugin_id); //take the name field from the plugin as it will be used to call the instantiate the plugin class $classname = $pluginrecord->name; // include the class for the plugin include_once "{$CFG->dirroot}/blocks/ilp/classes/form_elements/plugins/{$classname}.php"; if (!class_exists($classname)) { print_error('noclassforplugin', 'block_ilp', '', $pluginrecord->name); } //instantiate the plugin class $pluginclass = new $classname(); //has the maximum number of this field type in this report been reached? if (!$pluginclass->can_add($report_id) && empty($reportfield_id)) { $return_url = $CFG->wwwroot . '/blocks/ilp/actions/edit_prompt.php?report_id=' . $report_id; redirect($return_url, get_string("fieldmaximum", 'block_ilp', $pluginclass->audit_type()), ILP_REDIRECT_DELAY); } //call the plugin edit function inside of which the plugin configuration mform