$forum->intro = $updatepost->message;
     $forum->timemodified = time();
     $DB->update_record("hsuforum", $forum);
 }
 $timemessage = 2;
 if (!empty($message)) {
     // if we're printing stuff about the file upload
     $timemessage = 4;
 }
 if ($realpost->userid == $USER->id) {
     $message .= '<br />' . get_string("postupdated", "hsuforum");
 } else {
     $realuser = $DB->get_record('user', array('id' => $realpost->userid));
     $freshpost = $DB->get_record('hsuforum_posts', array('id' => $fromform->id));
     if ($realuser && $freshpost) {
         $postuser = hsuforum_get_postuser($realuser, $freshpost, $forum, $modcontext);
         $message .= '<br />' . get_string('editedpostupdated', 'hsuforum', $postuser->fullname);
     } else {
         $message .= '<br />' . get_string('postupdated', 'hsuforum');
     }
 }
 if ($subscribemessage = hsuforum_post_subscription($fromform, $forum)) {
     $timemessage = 4;
 }
 if ($forum->type == 'single') {
     // Single discussion forums are an exception. We show
     // the forum itself since it only has one discussion
     // thread.
     $discussionurl = "view.php?f={$forum->id}";
 } else {
     $discussionurl = "discuss.php?d={$discussion->id}#p{$fromform->id}";
/**
 * Extract the user object from the post object
 *
 * @param $post
 * @param $forum
 * @param context_module $context
 * @return stdClass
 */
function hsuforum_extract_postuser($post, $forum, context_module $context)
{
    $postuser = new stdClass();
    $postuser->id = $post->userid;
    $fields = array_merge(get_all_user_name_fields(), array('imagealt', 'picture', 'email'));
    foreach ($fields as $field) {
        if (property_exists($post, $field)) {
            $postuser->{$field} = $post->{$field};
        }
    }
    return hsuforum_get_postuser($postuser, $post, $forum, $context);
}