예제 #1
0
            //print an error message
            print_error(get_string("reportcreationerror", 'block_ilp'), 'block_ilp');
        }
        //if the report_id has not already been set
        $report_id = empty($report_id) ? $success : $report_id;
        //decide whether the user has chosen to save and exit or save or display
        if (isset($formdata->saveanddisplaybutton)) {
            $return_url = $CFG->wwwroot . '/blocks/ilp/actions/edit_prompt.php?report_id=' . $report_id;
            redirect($return_url, get_string("reportcreationsuc", 'block_ilp'), ILP_REDIRECT_DELAY);
        }
    }
}
//set the page title
$pagetitle = empty($report_id) ? get_string('createreport', 'block_ilp') : get_string('editreport', 'block_ilp');
if (!empty($report_id)) {
    $reportrecord = $dbc->get_report_by_id($report_id);
    $mform->set_data($reportrecord);
}
// setup the navigation breadcrumbs
//siteadmin or modules
//we need to determine which moodle we are in and give the correct area name
$sectionname = stripos($CFG->release, "2.") !== false ? get_string('administrationsite') : get_string('administration');
$PAGE->navbar->add($sectionname, null, 'title');
//plugins or modules
//we need to determine which moodle we are in and give the correct area name
$sectionname = stripos($CFG->release, "2.") !== false ? get_string('plugins', 'admin') : get_string('managemodules');
$PAGE->navbar->add($sectionname, null, 'title');
$PAGE->navbar->add(get_string('blocks'), null, 'title');
//block name
$url = $CFG->wwwroot . "/admin/settings.php?section=blocksettingilp";
$PAGE->navbar->add(get_string('blockname', 'block_ilp'), $url, 'title');
//if set get the id of the report
$report_id = $PARSER->required_param('report_id', PARAM_INT);
//get the id of the course that is currently being used
$user_id = $PARSER->required_param('user_id', PARAM_INT);
//if set get the id of the report entry to be edited
$entry_id = $PARSER->required_param('entry_id', PARAM_INT);
//get the id of the course that is currently being used
$course_id = $PARSER->optional_param('course_id', NULL, PARAM_INT);
//get the id the comment if one is being edited
$selectedtab = $PARSER->optional_param('selectedtab', NULL, PARAM_RAW);
//get the id the comment if one is being edited
$tabitem = $PARSER->optional_param('tabitem', NULL, PARAM_RAW);
// instantiate the db
$dbc = new ilp_db();
//get the report
$report = $dbc->get_report_by_id($report_id);
//if the report is not found throw an error of if the report has a status of disabled
if (empty($report) || empty($report->status)) {
    print_error('reportnotfouund', 'block_ilp');
}
//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
//get the id of the state selectors reportfield
$reportfield_id = $PARSER->required_param('reportfield_id', PARAM_INT);
//get the id of the state selectors entry
$entry_id = $PARSER->required_param('entry_id', PARAM_INT);
//get the id of the state selectors entry
$item_id = $PARSER->required_param('item_id', PARAM_INT);
//get the selectedtab param if present
$selectedtab = $PARSER->optional_param('selectedtab', NULL, PARAM_INT);
//get the tabitem param if present
$tabitem = $PARSER->optional_param('tabitem', NULL, PARAM_INT);
// instantiate the db
$dbc = new ilp_db();
//get the reportfield
$reportfield = $dbc->get_reportfield_by_id($reportfield_id);
//get the report
$report = !empty($reportfield) ? $dbc->get_report_by_id($reportfield->report_id) : false;
//if the report is not found throw an error of if the report has a status of disabled
if (empty($report) || empty($report->status) || !empty($report->deleted)) {
    print_error('reportnotfouund', 'block_ilp');
}
/*
if ($USER->id != $user_id)	{
		//the user doesnt have the capability to edit this type of report entry
		print_error('userdoesnothaveeditcapability','block_ilp');	
}	
*/
$stateplugin = $dbc->get_plugin_by_name('block_ilp_plugin', 'ilp_element_plugin_state');
$resulttext = get_string('statenotchanged', 'block_ilp');
if ($stateplugin) {
    //get the entry
    $entry = $dbc->get_pluginentry($stateplugin->tablename, $entry_id, $reportfield_id, true);