diff --git a/backup/backup_execute.html b/backup/backup_execute.html index 4276c885be3..dabed9e04df 100644 --- a/backup/backup_execute.html +++ b/backup/backup_execute.html @@ -9,7 +9,7 @@ if (empty($to)) { error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php"); } else { - if (!isteacheredit($to)) { + if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_COURSE, $to))) { error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php"); } } diff --git a/backup/restore_check.html b/backup/restore_check.html index e97182335fa..fb1dba3637b 100644 --- a/backup/restore_check.html +++ b/backup/restore_check.html @@ -175,7 +175,7 @@ print_heading(get_string("choosecourse")); print_simple_box_start("center"); foreach ($courses as $course) { - if (!isteacheredit($course->id)) { + if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_COURSE, $course->id))) { continue; } if (empty($course->visible)) { @@ -195,7 +195,7 @@ //Final access control check if ($restore->course_id == 0 and !has_capability('moodle/course:create', get_context_instance(CONTEXT_SYSTEM, SITEID))) { error("You need to be a creator or admin to restore into new course!"); - } else if ($restore->course_id != 0 and !isteacheredit($restore->course_id)) { + } else if ($restore->course_id != 0 and !has_capability('moodle/site:backup', get_context_instance(CONTEXT_COURSE, $restore->course_id))) { error("You need to be an edit teacher or admin to restore into selected course!"); } $show_continue_button = true; diff --git a/blocks/news_items/block_news_items.php b/blocks/news_items/block_news_items.php index ac8cdb0e5e6..f23d30d0bc8 100644 --- a/blocks/news_items/block_news_items.php +++ b/blocks/news_items/block_news_items.php @@ -35,7 +35,7 @@ class block_news_items extends block_base { /// First work out whether we can post to this group and if so, include a link - if (isteacheredit($COURSE->id)) { /// Teachers can always post + if (has_capability('moodle/site:accessallgroups', get_context_instance(CONTEXT_COURSE, $COURSE->id))) { /// Teachers can always post $visiblegroups = -1; $text .= '
("; print_string("scalestip"); echo ")
"; diff --git a/course/student.php b/course/student.php index 773b0e1bdbb..094a6b68d15 100644 --- a/course/student.php +++ b/course/student.php @@ -1,6 +1,6 @@ id); - if (! isteacheredit($course->id) ) { - error("You need to be a teacher with editing privileges"); - } + require_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id)); function html_footer() { global $course, $choose; @@ -798,7 +796,7 @@ function displaydir ($wdir) { } else if ($icon == "zip.gif") { $edittext .= "sesskey&choose=$choose\">$strunzip "; $edittext .= "sesskey&choose=$choose\">$strlist "; - if (!empty($CFG->backup_version) and isteacheredit($id)) { + if (!empty($CFG->backup_version) and has_capability('moodle/site:restore', get_context_instance(CONTEXT_COURSE, $id))) { $edittext .= "sesskey&choose=$choose\">$strrestore "; } } diff --git a/lib/accesslib.php b/lib/accesslib.php index fe015e25504..c1c7abb1c53 100755 --- a/lib/accesslib.php +++ b/lib/accesslib.php @@ -850,6 +850,13 @@ function moodle_install_roles() { if (in_array($CFG->prefix.'user_teachers', $dbtables)) { if ($userteachers = get_records('user_teachers')) { foreach ($userteachers as $teacher) { + // populate the user_lastaccess table + unset($access); + $access->timeaccess = $teacher->timeaccess; + $access->userid = $teacher->userid; + $access->courseid = $teacher->course; + insert_record('user_lastaccess', $access); + // assign the default student role $coursecontext = get_context_instance(CONTEXT_COURSE, $teacher->course); // needs cache if ($teacher->editall) { // editting teacher role_assign($editteacherrole, $teacher->userid, 0, $coursecontext->id); @@ -866,7 +873,14 @@ function moodle_install_roles() { */ if (in_array($CFG->prefix.'user_students', $dbtables)) { if ($userstudents = get_records('user_students')) { - foreach ($userstudents as $student) { + foreach ($userstudents as $student) { + // populate the user_lastaccess table + unset($access); + $access->timeaccess = $student->timeaccess; + $access->userid = $student->userid; + $access->courseid = $student->course; + insert_record('user_lastaccess', $access); + // assign the default student role $coursecontext = get_context_instance(CONTEXT_COURSE, $student->course); role_assign($studentrole, $student->userid, 0, $coursecontext->id); } diff --git a/lib/editor/htmlarea/coursefiles.php b/lib/editor/htmlarea/coursefiles.php index 9d3d73f88a7..0755aa8d882 100644 --- a/lib/editor/htmlarea/coursefiles.php +++ b/lib/editor/htmlarea/coursefiles.php @@ -32,9 +32,7 @@ require_login($course->id); - if (! isteacheredit($course->id) ) { - error("Only teachers can edit files"); - } + require_capability('moodle/course:managefiles', get_context_instance(CONTEXT_COURSE, $id)); function html_footer() { echo "\n\n