Added new teacher forum. TABLE CHANGED: forum
This commit is contained in:
+5
-1
@@ -82,9 +82,13 @@
|
||||
} else {
|
||||
$admindata[]="<A HREF=\"view.php?id=$course->id&edit=on\">Turn editing on</A>";
|
||||
}
|
||||
if ($teacherforum = get_course_teacher_forum($course->id)) {
|
||||
$admindata[]="<A HREF=\"../mod/forum/view.php?f=$teacherforum->id\">Teacher Forum...</A>";
|
||||
$adminicon[]="<IMG SRC=\"../mod/forum/icon.gif\" HEIGHT=16 WIDTH=16 ALT=\"Teacher Forum\">";
|
||||
}
|
||||
|
||||
$admindata[]="<A HREF=\"edit.php?id=$course->id\">Course settings...</A>";
|
||||
$adminicon[]="<IMG SRC=\"../pix/i/settings.gif\" HEIGHT=16 WIDTH=16 ALT=\"Course\">";
|
||||
$adminicon[]="<IMG SRC=\"../pix/i/settings.gif\" HEIGHT=16 WIDTH=16 ALT=\"Course settings\">";
|
||||
$admindata[]="<A HREF=\"log.php?id=$course->id\">Logs...</A>";
|
||||
$adminicon[]="<IMG SRC=\"../pix/i/log.gif\" HEIGHT=16 WIDTH=16 ALT=\"Log\">";
|
||||
$admindata[]="<A HREF=\"../files/index.php?id=$course->id\">Files...</A>";
|
||||
|
||||
@@ -73,6 +73,10 @@
|
||||
$admindata[]="<A HREF=\"view.php?id=$course->id&edit=on\">Turn editing on</A>";
|
||||
}
|
||||
|
||||
if ($teacherforum = get_course_teacher_forum($course->id)) {
|
||||
$admindata[]="<A HREF=\"../mod/forum/view.php?f=$teacherforum->id\">Teacher Forum...</A>";
|
||||
$adminicon[]="<IMG SRC=\"../mod/forum/icon.gif\" HEIGHT=16 WIDTH=16 ALT=\"Teacher Forum\">";
|
||||
}
|
||||
$admindata[]="<A HREF=\"edit.php?id=$course->id\">Course settings...</A>";
|
||||
$adminicon[]="<IMG SRC=\"../pix/i/settings.gif\" HEIGHT=16 WIDTH=16 ALT=\"Course\">";
|
||||
$admindata[]="<A HREF=\"log.php?id=$course->id\">Logs...</A>";
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
CREATE TABLE forum (
|
||||
id int(10) unsigned NOT NULL auto_increment,
|
||||
course int(10) unsigned NOT NULL default '0',
|
||||
type enum('discussion','news','general','social','eachuser') NOT NULL default 'general',
|
||||
type enum('discussion','news','general','social','eachuser','teacher') NOT NULL default 'general',
|
||||
name varchar(255) NOT NULL default '',
|
||||
intro tinytext NOT NULL,
|
||||
open tinyint(1) unsigned NOT NULL default '0',
|
||||
|
||||
@@ -40,6 +40,11 @@
|
||||
|
||||
if ($forums = get_records("forum", "course", $id, "name ASC")) {
|
||||
foreach ($forums as $forum) {
|
||||
if ($forum->type == "teacher") {
|
||||
if (!isteacher($course->id)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
$count = count_records("discuss", "forum", "$forum->id");
|
||||
|
||||
if ($can_subscribe) {
|
||||
|
||||
@@ -40,6 +40,8 @@ function user_can_post_discussion($forum) {
|
||||
|
||||
if ($forum->type == "eachuser") {
|
||||
return (! user_has_posted_discussion($forum->id, $USER->id));
|
||||
} else if ($forum->type == "teacher") {
|
||||
return isteacher($forum->course);
|
||||
} else if (isteacher($forum->course)) {
|
||||
return true;
|
||||
} else {
|
||||
@@ -113,6 +115,23 @@ function get_course_discussion_forum($courseid) {
|
||||
}
|
||||
}
|
||||
|
||||
function get_course_teacher_forum($courseid) {
|
||||
if ($forum = get_record_sql("SELECT * from forum WHERE course = '$courseid' AND type = 'teacher'")) {
|
||||
return $forum;
|
||||
} else {
|
||||
// Doesn't exist, so create one now.
|
||||
$forum->course = $courseid;
|
||||
$forum->type = "teacher";
|
||||
$forum->name = "Teacher Forum";
|
||||
$forum->intro= "For teacher-only notes and discussion";
|
||||
$forum->open = 0;
|
||||
$forum->assessed = 0;
|
||||
$forum->timemodified = time();
|
||||
$forum->id = insert_record("forum", $forum);
|
||||
return get_record_sql("SELECT * from forum WHERE id = '$forum->id'");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function print_forum_latest_topics($forum_id=0, $forum_numtopics=5, $forum_style="plain", $forum_sort="DESC") {
|
||||
global $CFG, $USER;
|
||||
|
||||
@@ -25,6 +25,13 @@
|
||||
require_login();
|
||||
}
|
||||
|
||||
if ($forum->type == "teacher") {
|
||||
if (!isteacher($course->id)) {
|
||||
error("You must be a $course->teacher to subscribe to this forum");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$returnto = go_back_to("index.php?id=$course->id");
|
||||
|
||||
if ( is_subscribed($USER->id, $forum->id) ) {
|
||||
|
||||
@@ -38,6 +38,13 @@
|
||||
<A HREF=\"index.php?id=$course->id\">Forums</A> ->";
|
||||
}
|
||||
|
||||
if ($forum->type == "teacher") {
|
||||
if (!isteacher($course->id)) {
|
||||
error("You must be a $course->teacher to view this forum");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
add_to_log($course->id, "forum", "view forum", "view.php?f=$forum->id", "$forum->id");
|
||||
|
||||
print_header("$course->shortname: $forum->name", "$course->fullname",
|
||||
|
||||
Reference in New Issue
Block a user