No need for ismainteacher() ... it's enough to check that the user is

a teacher in a course, and a creator.
This commit is contained in:
moodler
2003-02-26 05:55:31 +00:00
parent c0f271aa5c
commit d92a53d182
2 changed files with 4 additions and 22 deletions
+4 -4
View File
@@ -13,7 +13,7 @@
require_login();
if (!iscreator()) {
error("You must be an administrator or teacher to use this page.");
error("You must be an administrator or course creator to use this page.");
}
$strassignteachers = get_string("assignteachers");
@@ -40,7 +40,7 @@
print_simple_box_start("CENTER");
foreach ($courses as $course) {
if ($isadmin OR ismainteacher($course->id, $USER->id)){
if ($isadmin OR isteacher($course->id, $USER->id)){
echo "<A HREF=\"teacher.php?id=$course->id\">$course->fullname</A><BR>\n";
$coursesfound = TRUE;
}
@@ -76,7 +76,7 @@
/// Add a teacher if one is specified
if (!empty($add)) {
if (!ismainteacher($course->id, $USER->id)){
if (!isteacher($course->id, $USER->id)){
error("You must be an administrator or teacher to modify this course.");
}
@@ -110,7 +110,7 @@
if (!empty($remove)) {
if (!ismainteacher($course->id, $USER->id)){
if (!isteacher($course->id, $USER->id)){
error("You must be an administrator or teacher to modify this course.");
}
if (! $user = get_record("user", "id", $remove)) {
-18
View File
@@ -418,24 +418,6 @@ function iscreator ($userid=0) {
return record_exists("user_coursecreators", "userid", $userid);
}
function ismainteacher ($courseid, $userid=0){
/// Is user the main teacher of course
global $USER;
if (isadmin($userid)) { // admins can do anything the teacher can
return true;
}
if (empty($userid)) {
if (empty($USER->id)) {
return false;
}
$userid = $USER->id;
}
return record_exists("user_teachers", "userid", $userid, "course", $courseid, "authority", "1");
}
function isstudent($courseid, $userid=0) {
/// Is the user a student in this course?
global $USER;