// Get title
        if ($all) {
            $title = get_string('savedposts_all', 'forumng', $discussion->get_subject());
            $tags = get_string('savedposts_all_tag', 'forumng');
        } else {
            if (count($selected) == 1) {
                $post = $discussion->get_root_post()->find_child(reset($selected));
                $a = (object) array('subject' => $post->get_effective_subject(), 'name' => $post->get_forum()->display_user_name($post->get_user()));
                $title = get_string('savedposts_one', 'forumng', $a);
                $tags = get_string('savedposts_one_tag', 'forumng');
            } else {
                $title = get_string('savedposts_selected', 'forumng', $discussion->get_subject());
                $tags = get_string('savedposts_selected_tag', 'forumng');
            }
        }
        raise_memory_limit('512M');
        // Do portfolio save
        $username = portfolioGetUsername();
        $itemid = "forumngposts" . portfolioGetUUID();
        $dataid = portfolioFormPutContent($itemid, array('ouportfolio:title' => $title, 'ouportfolio:tags' => $tags), $postshtml);
        // Redirect back to discussion
        $discussionurl = $CFG->wwwroot . '/mod/forumng/discuss.php?' . $discussion->get_link_params(forum::PARAM_PLAIN);
        if ($dataid === FALSE) {
            print_error('error_portfoliosave', 'forumng', $discussionurl);
        } else {
            redirect($discussionurl, get_string('savedtoportfolio', 'forumng'));
        }
    }
}
post_selector::go(new portfolio_post_selector());
{
    function get_button_name()
    {
        return get_string('exportword', 'forumng');
    }
    function apply($discussion, $all, $selected, $formdata)
    {
        global $COURSE, $USER, $CFG;
        $a = new stdClass();
        $a->date = userdate(time());
        $a->subject = $discussion->get_subject();
        $title = get_string('exportedtitle', 'forumng', $a);
        $date = date('Ymd-His');
        $allhtml = "<head><title>{$title}</title>" . '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">';
        $allhtml .= "</head>\n<body>\n";
        $poststext = '';
        $postshtml = '';
        $discussion->build_selected_posts_email($selected, $poststext, $postshtml, false);
        $allhtml .= $postshtml . '</body>';
        header('Content-Type: application/msword');
        header('Content-Disposition: attachment; filename=forumthread.' . $date . '.doc');
        print <<<END
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
END;
        print $allhtml;
        print '</body></html>';
    }
}
post_selector::go(new export_post_selector());
    function get_page_name()
    {
        return get_string('print_pagename', 'forumng');
    }
    function apply($discussion, $all, $selected, $formdata)
    {
        global $COURSE, $USER, $CFG;
        $d = $discussion->get_id();
        $forum = $discussion->get_forum();
        print_header($this->get_page_name());
        $printablebacklink = $CFG->wwwroot . '/mod/forumng/discuss.php?' . $discussion->get_link_params(forum::PARAM_HTML);
        print '
<div class="forumng-printable-header">
<div class="forumng-printable-backlink">' . link_arrow_left($discussion->get_subject(), $printablebacklink) . '</div>
<div class="forumng-printable-date">' . get_string('printedat', 'forumng', userdate(time())) . '</div>
<div class="clearer"></div></div>' . "\n" . '<div class="forumng-showprintable">';
        if ($all) {
            print $forum->get_type()->display_discussion($discussion, array(forum_post::OPTION_NO_COMMANDS => true, forum_post::OPTION_CHILDREN_EXPANDED => true, forum_post::OPTION_PRINTABLE_VERSION => true));
        } else {
            $allhtml = '';
            $alltext = '';
            $discussion->build_selected_posts_email($selected, $alltext, $allhtml, true, true);
            print $allhtml;
        }
        print "</div>";
        $forum->print_js(0, true);
        print "\n</body>\n<html>";
    }
}
post_selector::go(new print_post_selector());
            if (!email_to_user($fakeuser, $from, $subject, $alltext, $allhtml)) {
                print_error('error_forwardemail', 'forumng', $formdata->email);
            }
        }
        // Log that it was sent
        $discussion->log('forward discussion', $formdata->email);
        if (!empty($formdata->ccme)) {
            if (!email_to_user($USER, $from, $subject, $alltext, $allhtml)) {
                print_error('error_forwardemail', 'forumng', $USER->email);
            }
        }
        $discussion->print_subpage_header($this->get_page_name());
        print_box(get_string('forward_done', 'forumng'));
        print_continue('../../discuss.php?' . $discussion->get_link_params(forum::PARAM_PLAIN));
        print_footer($COURSE);
    }
    function get_content_after_form($discussion, $all, $selected, $formdata)
    {
        // Print selected messages if they have any (rather than whole
        // discussion)
        if (!$all) {
            // Display selected messages below form
            $allhtml = '';
            $alltext = '';
            $discussion->build_selected_posts_email($selected, $alltext, $allhtml);
            print '<div class="forumng-showemail">' . $allhtml . '</div>';
        }
    }
}
post_selector::go(new forward_post_selector());