forum MDL-22477 Fixed single discussion forum so it works, and also fixed a bunch of other little regressions and bad formatting while there. Blog forum now 100% wide too.
This commit is contained in:
+27
-18
@@ -77,9 +77,10 @@ function forum_add_instance($forum) {
|
||||
$discussion->course = $forum->course;
|
||||
$discussion->forum = $forum->id;
|
||||
$discussion->name = $forum->name;
|
||||
$discussion->intro = $forum->intro;
|
||||
$discussion->assessed = $forum->assessed;
|
||||
$discussion->messageformat = $forum->messageformat;
|
||||
$discussion->message = $forum->intro;
|
||||
$discussion->messageformat = $forum->introformat;
|
||||
$discussion->messagetrust = trusttext_trusted(get_context_instance(CONTEXT_COURSE, $forum->course));
|
||||
$discussion->mailnow = false;
|
||||
$discussion->groupid = -1;
|
||||
|
||||
@@ -153,9 +154,10 @@ function forum_update_instance($forum) {
|
||||
$discussion->course = $forum->course;
|
||||
$discussion->forum = $forum->id;
|
||||
$discussion->name = $forum->name;
|
||||
$discussion->intro = $forum->intro;
|
||||
$discussion->assessed = $forum->assessed;
|
||||
$discussion->messageformat = $forum->messageformat;
|
||||
$discussion->message = $forum->intro;
|
||||
$discussion->messageformat = $forum->introformat;
|
||||
$discussion->messagetrust = true;
|
||||
$discussion->mailnow = false;
|
||||
$discussion->groupid = -1;
|
||||
|
||||
@@ -170,10 +172,15 @@ function forum_update_instance($forum) {
|
||||
print_error('cannotfindfirstpost', 'forum');
|
||||
}
|
||||
|
||||
$post->subject = $forum->name;
|
||||
$post->message = $forum->intro;
|
||||
$post->modified = $forum->timemodified;
|
||||
$post->userid = $USER->id; // MDL-18599, so that current teacher can take ownership of activities
|
||||
$cm = get_coursemodule_from_instance('forum', $forum->id);
|
||||
$modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
|
||||
$post->subject = $forum->name;
|
||||
$post->message = $forum->intro;
|
||||
$post->messageformat = $forum->introformat;
|
||||
$post->messagetrust = trusttext_trusted($modcontext);
|
||||
$post->modified = $forum->timemodified;
|
||||
$post->userid = $USER->id; // MDL-18599, so that current teacher can take ownership of activities
|
||||
|
||||
$DB->update_record('forum_posts', $post);
|
||||
$discussion->name = $forum->name;
|
||||
@@ -1871,9 +1878,6 @@ function forum_get_readable_forums($userid, $courseid=0) {
|
||||
|
||||
} // End foreach $courses
|
||||
|
||||
//print_object($courses);
|
||||
//print_object($readableforums);
|
||||
|
||||
return $readableforums;
|
||||
}
|
||||
|
||||
@@ -2486,8 +2490,6 @@ function forum_get_discussions($cm, $forumsort="d.timemodified DESC", $fullpost=
|
||||
|
||||
$timelimit = '';
|
||||
|
||||
$modcontext = null;
|
||||
|
||||
$now = round(time(), -2);
|
||||
$params = array($cm->instance);
|
||||
|
||||
@@ -3919,6 +3921,10 @@ function forum_add_attachment($post, $forum, $cm, $mform=null, &$message=null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (empty($post->attachments)) {
|
||||
return true; // Nothing to do
|
||||
}
|
||||
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
|
||||
$info = file_get_draft_area_info($post->attachments);
|
||||
@@ -4043,7 +4049,6 @@ function forum_add_discussion($discussion, $mform=null, &$message=null, $userid=
|
||||
|
||||
$forum = $DB->get_record('forum', array('id'=>$discussion->forum));
|
||||
$cm = get_coursemodule_from_instance('forum', $forum->id);
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
|
||||
$post = new object();
|
||||
$post->discussion = 0;
|
||||
@@ -4053,18 +4058,22 @@ function forum_add_discussion($discussion, $mform=null, &$message=null, $userid=
|
||||
$post->modified = $timenow;
|
||||
$post->mailed = 0;
|
||||
$post->subject = $discussion->name;
|
||||
$post->message = $discussion->intro;
|
||||
$post->message = $discussion->message;
|
||||
$post->messageformat = $discussion->messageformat;
|
||||
$post->messagetrust = $discussion->messagetrust;
|
||||
$post->attachments = $discussion->attachments;
|
||||
$post->attachments = isset($discussion->attachments) ? $discussion->attachments : null;
|
||||
$post->forum = $forum->id; // speedup
|
||||
$post->course = $forum->course; // speedup
|
||||
$post->mailnow = $discussion->mailnow;
|
||||
|
||||
$post->id = $DB->insert_record("forum_posts", $post);
|
||||
|
||||
$text = file_save_draft_area_files($discussion->itemid, $context->id, 'forum_post', $post->id, array('subdirs'=>true), $post->message);
|
||||
$DB->set_field('forum_posts', 'message', $text, array('id'=>$post->id));
|
||||
// TODO: Fix the calling code so that there always is a $cm when this function is called
|
||||
if (!empty($cm->id) && !empty($discussion->itemid)) { // In "single simple discussions" this may not exist yet
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
$text = file_save_draft_area_files($discussion->itemid, $context->id, 'forum_post', $post->id, array('subdirs'=>true), $post->message);
|
||||
$DB->set_field('forum_posts', 'message', $text, array('id'=>$post->id));
|
||||
}
|
||||
|
||||
// Now do the main entry for the discussion, linking to this first post
|
||||
|
||||
|
||||
+4
-4
@@ -697,11 +697,11 @@ if ($fromform = $mform_post->get_data()) {
|
||||
}
|
||||
|
||||
$fromform->mailnow = empty($fromform->mailnow) ? 0 : 1;
|
||||
$discussion = $fromform;
|
||||
$discussion->name = $fromform->subject;
|
||||
$discussion->intro = $fromform->message;
|
||||
$newstopic = false;
|
||||
|
||||
$discussion = $fromform;
|
||||
$discussion->name = $fromform->subject;
|
||||
|
||||
$newstopic = false;
|
||||
if ($forum->type == 'news' && !$fromform->parent) {
|
||||
$newstopic = true;
|
||||
}
|
||||
|
||||
@@ -160,8 +160,8 @@
|
||||
$sd->course = $forum->course;
|
||||
$sd->forum = $newid;
|
||||
$sd->name = $forum->name;
|
||||
$sd->intro = $forum->intro;
|
||||
$sd->assessed = $forum->assessed;
|
||||
$sd->message = $forum->intro;
|
||||
$sd->messageformat = $defaultformat;
|
||||
$sd->mailnow = false;
|
||||
//Insert dicussion/post data
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#page-mod-forum-view .groupmenu {float: left;text-align:left;white-space: nowrap;}
|
||||
#page-mod-forum-index .subscription,
|
||||
#page-mod-forum-view .subscription {float: right;text-align:right;white-space: nowrap;margin: 5px 0;}
|
||||
#page-mod-forum-view.forumtype-blog table.forumpost {width:100%;}
|
||||
|
||||
/** Styles for search.php */
|
||||
#page-mod-forum-search .introcontent {padding: 15px;font-weight:bold;}
|
||||
@@ -45,4 +46,4 @@
|
||||
/** Unknown Styles ??? */
|
||||
#user-view .forumpost,
|
||||
.course .forumpost {width: 100%;}
|
||||
#email .unsubscribelink {margin-top:20px;}
|
||||
#email .unsubscribelink {margin-top:20px;}
|
||||
|
||||
+3
-1
@@ -97,7 +97,6 @@
|
||||
rss_add_http_header($context, 'forum', $forum, $rsstitle);
|
||||
}
|
||||
|
||||
|
||||
/// Print header.
|
||||
/// Add ajax-related libs for ratings if required MDL-20119
|
||||
$PAGE->requires->yui2_lib('event');
|
||||
@@ -105,7 +104,9 @@
|
||||
$PAGE->requires->yui2_lib('json');
|
||||
|
||||
$PAGE->set_title(format_string($forum->name));
|
||||
$PAGE->add_body_class('forumtype-'.$forum->type);
|
||||
$PAGE->set_heading(format_string($course->fullname));
|
||||
|
||||
echo $OUTPUT->header();
|
||||
|
||||
/// Some capability checks.
|
||||
@@ -129,6 +130,7 @@
|
||||
add_to_log($course->id, "forum", "view forum", "view.php?f=$forum->id", "$forum->id");
|
||||
}
|
||||
|
||||
$SESSION->fromdiscussion = $FULLME; // Return here if we post or set subscription etc
|
||||
|
||||
|
||||
/// Print settings and things across the top
|
||||
|
||||
Reference in New Issue
Block a user