Fixed up "Assign teacher" page, and moved it to admin directory.
This commit is contained in:
+6
-7
@@ -1,10 +1,9 @@
|
||||
<?PHP // $Id$
|
||||
// Admin-only script to assign administrative rights to users
|
||||
// !!! based on ../course/teacher.php (cut and pasted, then mangled)
|
||||
|
||||
define("MAX_USERS_PER_PAGE", 30);
|
||||
|
||||
require_once("../config.php");
|
||||
|
||||
define("MAX_USERS_PER_PAGE", 30);
|
||||
|
||||
optional_variable($add, "");
|
||||
optional_variable($remove, "");
|
||||
@@ -121,7 +120,7 @@
|
||||
foreach ($admins as $admin) {
|
||||
$adminarray[] = $admin->id;
|
||||
echo "<p align=right>$admin->firstname $admin->lastname,
|
||||
$admin->email ";
|
||||
$admin->email ";
|
||||
if ($primaryadmin->id == $admin->id){
|
||||
print_spacer(10, 9, false);
|
||||
} else {
|
||||
@@ -151,7 +150,7 @@
|
||||
} else {
|
||||
|
||||
if ($search) {
|
||||
echo "<p align=center>($strsearchresults)</p>";
|
||||
echo "<p align=center>($strsearchresults : $search)</p>";
|
||||
}
|
||||
|
||||
if (!$users = get_users(true, $search, true, $adminlist)) {
|
||||
@@ -159,9 +158,9 @@
|
||||
}
|
||||
|
||||
foreach ($users as $user) {
|
||||
echo "<p align=left><A HREF=\"{$_SERVER['PHP_SELF']}?add=$user->id\"".
|
||||
echo "<p align=left><a href=\"{$_SERVER['PHP_SELF']}?add=$user->id\"".
|
||||
"title=\"$straddadmin\"><img src=\"../pix/t/left.gif\"".
|
||||
"border=0></A> $user->firstname $user->lastname, $user->email";
|
||||
"border=0></a> $user->firstname $user->lastname, $user->email";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -337,7 +337,7 @@
|
||||
$table->data[0][0] .= "<p><a href=\"$CFG->dbtype/frame.php\">".get_string("managedatabase")."</a></p>";
|
||||
}
|
||||
$table->data[0][1] = "<p><a href=\"../course/edit.php\">".get_string("addnewcourse")."</a></p>".
|
||||
"<p><a href=\"../course/teacher.php\">".get_string("assignteachers")."</a></p>".
|
||||
"<p><a href=\"teacher.php\">".get_string("assignteachers")."</a></p>".
|
||||
"<p><a href=\"../course/delete.php\">".get_string("deletecourse")."</a></p>".
|
||||
"<p><a href=\"../course/categories.php\">".get_string("categories")."</a></p>";
|
||||
if ($CFG->auth == "email" || $CFG->auth == "none" || $CFG->auth == "manual") {
|
||||
@@ -351,7 +351,7 @@
|
||||
$table->head = array (get_string("courses"));
|
||||
$table->align = array ("CENTER");
|
||||
$table->data[0][1] = "<p><a href=\"../course/edit.php\">".get_string("addnewcourse")."</a></p>".
|
||||
"<p><a href=\"../course/teacher.php\">".get_string("assignteachers")."</a></p>";
|
||||
"<p><a href=\"teacher.php\">".get_string("assignteachers")."</a></p>";
|
||||
}
|
||||
|
||||
print_table($table);
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
// Admin-only script to assign teachers to courses
|
||||
|
||||
require_once("../config.php");
|
||||
require_once("../user/lib.php");
|
||||
|
||||
define("MAX_USERS_PER_PAGE", 30);
|
||||
|
||||
optional_variable($id); // course id
|
||||
|
||||
@@ -31,18 +32,17 @@
|
||||
|
||||
if (!$id) {
|
||||
print_header("$site->shortname: $strassignteachers", "$site->fullname",
|
||||
"<A HREF=\"../$CFG->admin/index.php\">$stradministration</A> -> $strassignteachers");
|
||||
"<a href=\"index.php\">$stradministration</a> -> $strassignteachers");
|
||||
|
||||
$isadmin = isadmin(); /// cache value
|
||||
$courses = get_courses();
|
||||
|
||||
|
||||
print_heading(get_string("choosecourse"));
|
||||
print_simple_box_start("CENTER");
|
||||
print_simple_box_start("center");
|
||||
|
||||
foreach ($courses as $course) {
|
||||
if ($isadmin OR isteacher($course->id, $USER->id)){
|
||||
echo "<A HREF=\"teacher.php?id=$course->id\">$course->fullname ($course->shortname)</A><BR>\n";
|
||||
if ($isadmin or isteacher($course->id, $USER->id)){
|
||||
echo "<a href=\"teacher.php?id=$course->id\">$course->fullname ($course->shortname)</a><br>\n";
|
||||
$coursesfound = TRUE;
|
||||
}
|
||||
}
|
||||
@@ -65,9 +65,10 @@
|
||||
|
||||
print_header("$site->shortname: $course->shortname: $strassignteachers",
|
||||
"$site->fullname",
|
||||
"<A HREF=\"../$CFG->admin/index.php\">$stradministration</A> ->
|
||||
<A HREF=\"teacher.php\">$strassignteachers</A> -> $course->shortname", "");
|
||||
print_heading("<A HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->fullname ($course->shortname)</A>");
|
||||
"<a href=\"index.php\">$stradministration</a> ->
|
||||
<a href=\"teacher.php\">$strassignteachers</a> -> $course->shortname", "");
|
||||
|
||||
print_heading("<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->fullname ($course->shortname)</a>");
|
||||
|
||||
|
||||
/// Get all existing teachers for this course.
|
||||
@@ -129,76 +130,63 @@
|
||||
|
||||
/// Print the lists of existing and potential teachers
|
||||
|
||||
echo "<TABLE CELLPADDING=2 CELLSPACING=10 ALIGN=CENTER>";
|
||||
echo "<TR><TH WIDTH=50%>$strexistingteachers</TH><TH WIDTH=50%>$strpotentialteachers</TH></TR>";
|
||||
echo "<TR><TD WIDTH=50% NOWRAP VALIGN=TOP>";
|
||||
echo "<table cellpadding=2 cellspacing=10 align=center>";
|
||||
echo "<tr><th width=50%>$strexistingteachers</th><th width=50%>$strpotentialteachers</th></tr>";
|
||||
echo "<tr><td width=50% nowrap valign=top>";
|
||||
|
||||
/// First, show existing teachers for this course
|
||||
|
||||
if (empty($teachers)) {
|
||||
echo "<P ALIGN=CENTER>$strnoexistingteachers</A>";
|
||||
echo "<p align=center>$strnoexistingteachers</a>";
|
||||
$teacherlist = "";
|
||||
|
||||
} else {
|
||||
$teacherarray = array();
|
||||
foreach ($teachers as $teacher) {
|
||||
echo "<P ALIGN=right>$teacher->firstname $teacher->lastname, $teacher->email <A HREF=\"teacher.php?id=$course->id&remove=$teacher->id\" TITLE=\"$strremoveteacher\"><IMG SRC=\"../pix/t/right.gif\" BORDER=0></A></P>";
|
||||
$teacherarray[] = $teacher->id;
|
||||
echo "<p align=right>$teacher->firstname $teacher->lastname, $teacher->email <a href=\"teacher.php?id=$course->id&remove=$teacher->id\" title=\"$strremoveteacher\"><img src=\"../pix/t/right.gif\" border=0></a></p>";
|
||||
}
|
||||
$teacherlist = implode(",",$teacherarray);
|
||||
unset($teacherarray);
|
||||
}
|
||||
|
||||
echo "<TD WIDTH=50% NOWRAP VALIGN=TOP>";
|
||||
echo "<td width=50% nowrap valign=top>";
|
||||
|
||||
/// Print list of potential teachers
|
||||
|
||||
if (!empty($search)) {
|
||||
$users = get_users_search($search);
|
||||
$usercount = get_users(false, $search, true, $teacherlist);
|
||||
|
||||
if ($usercount == 0) {
|
||||
echo "<p align=center>$strnopotentialteachers</p>";
|
||||
|
||||
} else if ($usercount > MAX_USERS_PER_PAGE) {
|
||||
echo "<p align=center>$strtoomanytoshow</p>";
|
||||
|
||||
} else {
|
||||
$users = get_users_confirmed();
|
||||
}
|
||||
|
||||
|
||||
if (!empty($users)) {
|
||||
foreach ($users as $user) { // Remove users who are already teachers
|
||||
if (!empty($teachers)) {
|
||||
foreach ($teachers as $teacher) {
|
||||
if ($teacher->id == $user->id) {
|
||||
continue 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
$potential[] = $user;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($potential)) {
|
||||
echo "<P ALIGN=CENTER>$strnopotentialteachers</A>";
|
||||
if ($search) {
|
||||
echo "<FORM ACTION=teacher.php METHOD=GET>";
|
||||
echo "<INPUT TYPE=hidden NAME=id VALUE=\"$course->id\">";
|
||||
echo "<INPUT TYPE=text NAME=search SIZE=20>";
|
||||
echo "<INPUT TYPE=submit VALUE=\"$strsearchagain\">";
|
||||
echo "</FORM>";
|
||||
echo "<p align=center>($strsearchresults : $search)</p>";
|
||||
}
|
||||
|
||||
} else {
|
||||
if (!empty($search)) {
|
||||
echo "<P ALIGN=CENTER>($strsearchresults)</P>";
|
||||
if (!$users = get_users(true, $search, true, $teacherlist)) {
|
||||
error("Could not get users!");
|
||||
}
|
||||
if (count($potential) <= 20) {
|
||||
foreach ($potential as $user) {
|
||||
echo "<P ALIGN=LEFT><A HREF=\"teacher.php?id=$course->id&add=$user->id\" TITLE=\"$straddteacher\"><IMG SRC=\"../pix/t/left.gif\" BORDER=0></A> $user->firstname $user->lastname, $user->email";
|
||||
}
|
||||
} else {
|
||||
echo "<P ALIGN=CENTER>There are too many users to show.<BR>";
|
||||
echo "Enter a search word here.";
|
||||
echo "<FORM ACTION=teacher.php METHOD=GET>";
|
||||
echo "<INPUT TYPE=hidden NAME=id VALUE=\"$course->id\">";
|
||||
echo "<INPUT TYPE=text NAME=search SIZE=20>";
|
||||
echo "<INPUT TYPE=submit VALUE=\"$strsearch\">";
|
||||
echo "</FORM>";
|
||||
|
||||
foreach ($users as $user) {
|
||||
echo "<p align=left><a href=\"{$_SERVER['PHP_SELF']}?id=$course->id&add=$user->id\"".
|
||||
"title=\"$straddteacher\"><img src=\"../pix/t/left.gif\"".
|
||||
"border=0></a> $user->firstname $user->lastname, $user->email";
|
||||
}
|
||||
}
|
||||
|
||||
echo "</TR></TABLE>";
|
||||
if ($search or $usercount > MAX_USERS_PER_PAGE) {
|
||||
echo "<form action={$_SERVER['PHP_SELF']} method=post>";
|
||||
echo "<input type=text name=search size=20>";
|
||||
echo "<input type=submit value=\"$searchstring\">";
|
||||
echo "</form>";
|
||||
}
|
||||
|
||||
echo "</tr></table>";
|
||||
|
||||
print_footer();
|
||||
|
||||
+1
-1
@@ -64,7 +64,7 @@
|
||||
add_to_log($newcourseid, "course", "new", "view.php?id=$newcourseid", "");
|
||||
|
||||
if (isadmin()) { // Redirect admin to add teachers
|
||||
redirect("teacher.php?id=$newcourseid", get_string("changessaved"));
|
||||
redirect("../$CFG->admin/teacher.php?id=$newcourseid", get_string("changessaved"));
|
||||
|
||||
} else { // Add current teacher and send to course
|
||||
|
||||
|
||||
+1
-1
@@ -749,7 +749,7 @@ function print_admin_links ($siteid, $width=180) {
|
||||
if (iscreator()) {
|
||||
$moddata[]="<a href=\"$CFG->wwwroot/course/edit.php\">".get_string("addnewcourse")."</a>";
|
||||
$modicon[]=$icon;
|
||||
$moddata[]="<a href=\"$CFG->wwwroot/course/teacher.php\">".get_string("assignteachers")."</a>";
|
||||
$moddata[]="<a href=\"$CFG->wwwroot/$CFG->admin/teacher.php\">".get_string("assignteachers")."</a>";
|
||||
$modicon[]=$icon;
|
||||
$fulladmin = "";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user