本文整理汇总了PHP中forum_print_discussion函数的典型用法代码示例。如果您正苦于以下问题:PHP forum_print_discussion函数的具体用法?PHP forum_print_discussion怎么用?PHP forum_print_discussion使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了forum_print_discussion函数的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: grading_popup
/**
* Makes the pop up contents for the grading interface
*
* @param array $params
* @param $coursemodule
* @global moodle_database $DB
* @global $PAGE
* @global stdClass $CFG
* @global $SESSION
* @global $USER
* @global $OUTPUT
* @params object $coursemodule
* @return string HTML
*/
public function grading_popup($params, $coursemodule)
{
global $DB, $PAGE, $CFG, $SESSION, $USER, $OUTPUT;
$output = '';
// Lifted from /mod/forum/discuss.php...
/*
$parent = $params['parent']; // If set, then display this post and all children.
$mode = $params['mode']; // If set, changes the layout of the thread
$move = $params['move']; // If set, moves this discussion to another forum
$mark = $params['mark']; // Used for tracking read posts if user initiated.
$postid = $params['postid']; // Used for tracking read posts if user initiated.
*/
$discussion = $DB->get_record('forum_discussions', array('id' => $params['discussionid']), '*', MUST_EXIST);
$course = $DB->get_record('course', array('id' => $discussion->course), '*', MUST_EXIST);
$forum = $DB->get_record('forum', array('id' => $discussion->forum), '*', MUST_EXIST);
$cm = get_coursemodule_from_instance('forum', $forum->id, $course->id, false, MUST_EXIST);
$modcontext = context_module::instance($cm->id);
// Security - cmid is used to check context permissions earlier on, so it must match when
// derived from the discussion.
if (!($cm->id == $params['coursemoduleid'])) {
print_error('Bad params!');
return false;
}
// Add ajax-related libs.
$PAGE->requires->yui2_lib('event');
$PAGE->requires->yui2_lib('connection');
$PAGE->requires->yui2_lib('json');
// Move this down fix for MDL-6926.
require_once $CFG->dirroot . '/mod/forum/lib.php';
// Restrict news forums - should not be graded.
if ($forum->type == 'news') {
print_error('invaliddiscussionid', 'forum', "{$CFG->wwwroot}/mod/forum/view.php?f={$forum->id}");
}
unset($SESSION->fromdiscussion);
// In case the user has used the drop-down to change from threaded to flat or something.
if (isset($params['mode'])) {
set_user_preference('forum_displaymode', $params['mode']);
}
$displaymode = get_user_preferences('forum_displaymode', $CFG->forum_displaymode);
$parent = $discussion->firstpost;
$post = forum_get_post_full($parent);
if (!$post) {
print_error("notexists", 'forum', "{$CFG->wwwroot}/mod/forum/view.php?f={$forum->id}");
}
if (!forum_user_can_view_post($post, $course, $cm, $forum, $discussion)) {
print_error('nopermissiontoview', 'forum', "{$CFG->wwwroot}/mod/forum/view.php?id={$forum->id}");
}
// For now, restrict to rating only.
$canreply = false;
// Without this, the nesting doesn't work properly as the css isn't picked up.
$output .= html_writer::start_tag('div', array('class' => 'path-mod-forum'));
$output .= html_writer::start_tag('div', array('class' => 'discussioncontrols clearfix'));
$output .= html_writer::start_tag('div', array('class' => 'discussioncontrol displaymode'));
// We don't want to have the current mode returned in the url as well as the new one.
unset($params['mode']);
$newurl = new moodle_url('/blocks/ajax_marking/actions/grading_popup.php', $params);
$select = new single_select($newurl, 'mode', forum_get_layout_modes(), $displaymode, null, "mode");
$output .= $OUTPUT->render($select);
$output .= html_writer::end_tag('div');
// If user has not already posted and it's a Q & A forum...
$forumisqanda = $forum->type == 'qanda';
$noviewwithoutposting = !has_capability('mod/forum:viewqandawithoutposting', $modcontext);
$hasnotposted = !forum_user_has_posted($forum->id, $discussion->id, $USER->id);
if ($forumisqanda && $noviewwithoutposting && $hasnotposted) {
$output .= $OUTPUT->notification(get_string('qandanotify', 'forum'));
}
$canrate = has_capability('mod/forum:rate', $modcontext);
ob_start();
forum_print_discussion($course, $cm, $forum, $discussion, $post, $displaymode, $canreply, $canrate);
$output .= ob_get_contents();
ob_end_clean();
$output .= html_writer::end_tag('div');
$output .= html_writer::end_tag('div');
return $output;
}