コード例 #1
0
$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);
    $entry = array_shift($entry);
    //get the value that matches the given one in the
    $item = $dbc->get_state_item_id($stateplugin->tablename, false, $item_id, 'id', $stateplugin->tablename . '_items');
    if (!empty($item)) {
        $entry->parent_id = $item->id;
        $entry->value = $item->value;
    }
    if ($dbc->update_plugin_record($stateplugin->tablename . '_ent', $entry)) {
        $resulttext = get_string('statechanged', 'block_ilp');
    }
}