Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merging the isteacher() ---> isteacherinanycourse() fix from HEAD.

This should take care of SC#65 for good.
  • Loading branch information...
commit 12f60822fcde0ca1f7281d72b6ed0312c9d3af6b 1 parent 3081fef
defacer authored
View
2  blocks/participants/block_participants.php
@@ -27,7 +27,7 @@ function get_content() {
$strgroups = get_string('groups');
$strgroupmy = get_string('groupmy');
- if ($this->course->category or $CFG->showsiteparticipantslist > 1 or ($CFG->showsiteparticipantslist == 1 and isteacher()) or isteacher(SITEID)) {
+ if ($this->course->category or $CFG->showsiteparticipantslist > 1 or ($CFG->showsiteparticipantslist == 1 and isteacherinanycourse()) or isteacher(SITEID)) {
$this->content->items[]='<a title="'.get_string('listofallpeople').'" href="'.$CFG->wwwroot.'/user/index.php?id='.$this->course->id.'">'.get_string('participants').'</a>';
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/users.gif" height="16" width="16" alt="">';
}
View
2  lib/datalib.php
@@ -2515,7 +2515,7 @@ function count_login_failures($mode, $username, $lastlogin) {
$count->accounts = count_records_select('log', $select, 'COUNT(DISTINCT info)');
return $count;
}
- } else if ($mode == 'everybody' or ($mode == 'teacher' and isteacher())) {
+ } else if ($mode == 'everybody' or ($mode == 'teacher' and isteacherinanycourse())) {
if ($count->attempts = count_records_select('log', "$select AND info = '$username'")) {
return $count;
}
View
24 lib/moodlelib.php
@@ -758,6 +758,11 @@ function isteacher($courseid=0, $userid=0, $includeadmin=true) {
return true;
}
+ if (empty($courseid)) {
+ notify('isteacher() should not be used without a valid course id as argument');
+ return isteacherinanycourse($userid, $includeadmin);
+ }
+
if (!$userid) {
if ($courseid) {
return !empty($USER->teacher[$courseid]);
@@ -768,11 +773,24 @@ function isteacher($courseid=0, $userid=0, $includeadmin=true) {
$userid = $USER->id;
}
- if (!$courseid) {
- return record_exists("user_teachers","userid",$userid);
+ return record_exists("user_teachers", "userid", $userid, "course", $courseid);
+}
+
+function isteacherinanycourse($userid = 0, $includeadmin = true) {
+ global $USER;
+
+ if(empty($userid)) {
+ if(empty($USER) || empty($USER->id)) {
+ return false;
+ }
+ $userid = $USER->id;
+ }
+
+ if (isadmin($userid) && $includeadmin) { // admins can do anything
+ return true;
}
- return record_exists("user_teachers", "userid", $userid, "course", $courseid);
+ return record_exists('user_teachers', 'userid', $userid);
}
function isteacheredit($courseid, $userid=0) {
View
2  user/index.php
@@ -26,7 +26,7 @@
if (!$CFG->showsiteparticipantslist and !isteacher(SITEID)) {
notice(get_string('sitepartlist0'));
}
- if ($CFG->showsiteparticipantslist < 2 and !isteacher()) {
+ if ($CFG->showsiteparticipantslist < 2 and !isteacherinanycourse()) {
notice(get_string('sitepartlist1'));
}
}
View
2  user/view.php
@@ -69,7 +69,7 @@
}
if (!$course->category and !$currentuser) { // To reduce possibility of "browsing" userbase at site level
- if (!isteacher() and !isteacher(0, $user->id) ) { // Teachers can browse and be browsed at site level
+ if (!isteacherinanycourse() and !isteacherinanycourse($user->id) ) { // Teachers can browse and be browsed at site level
print_header("$personalprofile: ", "$personalprofile: ",
"<a href=\"index.php?id=$course->id\">$participants</a>",
"", "", true, "&nbsp;", navmenu($course));
Please sign in to comment.
Something went wrong with that request. Please try again.