mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
relacing deprecated functions with capability checks
This commit is contained in:
parent
0dde27bb52
commit
9ce384ba1e
10 changed files with 17 additions and 20 deletions
|
@ -81,7 +81,7 @@
|
|||
}
|
||||
$hotpotids = implode(',', $hotpotids);
|
||||
|
||||
if (isadmin()) {
|
||||
if (has_capability('mod/hotpot:grade', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
|
||||
|
||||
// get regrade settings, if any
|
||||
$regrade = optional_param("regrade");
|
||||
|
@ -248,7 +248,7 @@
|
|||
$select .= " AND a.userid='$USER->id'";
|
||||
}
|
||||
$usejoin = 1;
|
||||
if (isadmin() && $usejoin) {
|
||||
if (has_capability('mod/hotpot:grade', get_context_instance(CONTEXT_SYSTEM, SITEID)) && $usejoin) {
|
||||
// join attempts table and details table
|
||||
$tables .= ",{$CFG->prefix}hotpot_details AS d";
|
||||
$fields .= ',COUNT(DISTINCT d.id) AS detailcount';
|
||||
|
@ -259,7 +259,7 @@
|
|||
}
|
||||
$totals = get_records_sql("SELECT $fields FROM $tables WHERE $select GROUP BY a.hotpot");
|
||||
|
||||
if (isadmin() && empty($usejoin)) {
|
||||
if (ihas_capability('mod/hotpot:grade', get_context_instance(CONTEXT_SYSTEM, SITEID)) && empty($usejoin)) {
|
||||
foreach ($hotpots as $hotpot) {
|
||||
$totals[$hotpot->id]->detailcount = 0;
|
||||
if ($ids = get_records('hotpot_attempts', 'hotpot', $hotpot->id)) {
|
||||
|
@ -368,7 +368,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
if (isadmin()) {
|
||||
if (has_capability('mod/hotpot:grade', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
|
||||
if (in_array($hotpot->id, $regradehotpots)) {
|
||||
$report .= ' <font color="red">'.$strregraderequired.'</font>';
|
||||
}
|
||||
|
@ -393,7 +393,7 @@
|
|||
|
||||
array_push($data, $quizname, $quizclose, $bestscore, $report);
|
||||
|
||||
if (isadmin()) {
|
||||
if (has_capability('mod/hotpot:grade', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
|
||||
if (empty($totals[$hotpot->id]->detailcount)) {
|
||||
// no details records for this hotpot, so disable regrade
|
||||
$regradebutton = ' ';
|
||||
|
|
|
@ -120,8 +120,7 @@ $text_source_options = array(
|
|||
</td>
|
||||
<td align="left"><?PHP
|
||||
|
||||
|
||||
if (isadmin()) {
|
||||
if (has_capability('moodle/course:managefiles', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
|
||||
$site = get_site();
|
||||
if ($course->id==$site->id) {
|
||||
$id = $site->id;
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
// assemble array of form data
|
||||
$formdata = array(
|
||||
'mode' => $mode,
|
||||
'reportcourse' => isadmin() ? optional_param('reportcourse', get_user_preferences('hotpot_reportcourse', 'this')) : 'this',
|
||||
'reportcourse' => has_capability('mod/hotpot:viewreport', get_context_instance(CONTEXT_SYSTEM, SITEID)) ? optional_param('reportcourse', get_user_preferences('hotpot_reportcourse', 'this')) : 'this',
|
||||
'reportusers' => has_capability('mod/hotpot:viewreport',$context) ? optional_param('reportusers', get_user_preferences('hotpot_reportusers', 'all')) : 'this',
|
||||
'reportattempts' => optional_param('reportattempts', get_user_preferences('hotpot_reportattempts', 'all')),
|
||||
'reportformat' => optional_param('reportformat', 'htm'),
|
||||
|
@ -457,7 +457,7 @@ function hotpot_print_report_selector(&$course, &$hotpot, &$formdata) {
|
|||
$menus['mode'][$name] = get_string("report$name", $module);
|
||||
}
|
||||
}
|
||||
if (isadmin()) {
|
||||
if (has_capability('mod/hotpot:viewreport', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
|
||||
$menus['reportcourse'] = array(
|
||||
'this' => get_string('thiscourse', 'hotpot'), // $course->shortname,
|
||||
'all' => get_string('allmycourses', 'hotpot')
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
if (!has_capability('mod/hotpot:viewreport',get_context_instance(CONTEXT_COURSE, $params->course))) {
|
||||
error("You are not allowed to view this page!");
|
||||
}
|
||||
if (isadmin()) {
|
||||
if (has_capability('mod/hotpot:viewreport', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
|
||||
$params->location = optional_param('location', HOTPOT_LOCATION_COURSEFILES);
|
||||
} else {
|
||||
$params->location = HOTPOT_LOCATION_COURSEFILES;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue