コード例 #1
0
}
//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);
コード例 #2
0
// Meta includes
require_once $CFG->dirroot . '/blocks/ilp/admin_actions_includes.php';
//get the id of the course that is currently being used
//$course_id = $PARSER->required_param('course_id', PARAM_INT);
//the id of the report  that the field will be in
$report_id = $PARSER->required_param('report_id', PARAM_INT);
//the id of the reportfield used when editing
$reportfield_id = $PARSER->required_param('reportfield_id', PARAM_INT);
//the id of the reportfield used when editing
$position = $PARSER->required_param('position', PARAM_INT);
//the id of the reportfield used when editing
$move = $PARSER->required_param('move', PARAM_INT);
// instantiate the db
$dbc = new ilp_db();
//change field position
$reportfields = $dbc->get_report_fields_by_position($report_id, $position, $move);
$movesuc = true;
//loop through fields returned
if (!empty($reportfields)) {
    foreach ($reportfields as $field) {
        if ($field->id != $reportfield_id) {
            //if the field is being moved up all other fields have postion value increased
            //if the field is being moved down all other fields have postion value decreased
            //move up = 1 move down = 0
            $newposition = empty($move) ? $field->position - 1 : $field->position + 1;
        } else {
            //move the field
            $newposition = !empty($move) ? $field->position - 1 : $field->position + 1;
        }
        if (!$dbc->set_new_position($field->id, $newposition)) {
            $movesuc = false;