$access_report_deletereports = 0;
$access_report_viewreports = 0;
$access_report_viewilp = 0;
$access_report_viewotherilp = 0;
//comment capabilites
$access_report_addcomment = 0;
$access_report_editcomment = 0;
$access_report_deletecomment = 0;
$access_report_viewcomment = 0;
//we only need to check if a report permission has been assigned
//if the user has the capability in the current context
if (!empty($access_createreports)) {
    //moodle 2.0 throws an error whena comparison is carried out for the context name in
    //pure sql. This could have something to do with the /: in the context name. So I am
    //having to get the capability record id first and then pass it to the
    $capability = $dbc->get_capability_by_name('block/ilp:addreport');
    $access_report_createreports = $dbc->has_report_permission($report_id, $role_ids, $capability->id);
}
if ($access_editreports) {
    $capability = $dbc->get_capability_by_name('block/ilp:editreport');
    if (!empty($capability)) {
        $access_report_editreports = $dbc->has_report_permission($report_id, $role_ids, $capability->id);
    }
}
if ($access_deletereports) {
    $capability = $dbc->get_capability_by_name('block/ilp:deletereport');
    if (!empty($capability)) {
        $access_report_deletereports = $dbc->has_report_permission($report_id, $role_ids, $capability->id);
    }
}
if ($access_viewreports) {