本文整理汇总了PHP中forum_get_post_full函数的典型用法代码示例。如果您正苦于以下问题:PHP forum_get_post_full函数的具体用法?PHP forum_get_post_full怎么用?PHP forum_get_post_full使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了forum_get_post_full函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: get_discussionid
public function get_discussionid($forumdata)
{
list($querystrid, $discussionid, $reply, $edit, $delete) = explode('_', $forumdata);
if (empty($discussionid)) {
$parent = '';
if ($reply != 0) {
$parent = forum_get_post_full($reply);
} else {
if ($edit != 0) {
$parent = forum_get_post_full($edit);
} else {
if ($delete != 0) {
$parent = forum_get_post_full($delete);
}
}
}
if (!empty($parent)) {
$discussionid = $parent->discussion;
}
}
return $discussionid;
}
开发者ID:University-of-Strathclyde-LTE-Team,项目名称:moodle-plagiarism_turnitin,代码行数:22,代码来源:turnitin_forum.class.php
示例2: unset
$event->add_record_snapshot('forum', $forum);
$event->trigger();
unset($SESSION->fromdiscussion);
if ($mode) {
set_user_preference('forum_displaymode', $mode);
}
$displaymode = get_user_preferences('forum_displaymode', $CFG->forum_displaymode);
if ($parent) {
// If flat AND parent, then force nested display this time
if ($displaymode == FORUM_MODE_FLATOLDEST or $displaymode == FORUM_MODE_FLATNEWEST) {
$displaymode = FORUM_MODE_NESTED;
}
} else {
$parent = $discussion->firstpost;
}
if (!($post = forum_get_post_full($parent))) {
print_error("notexists", 'forum', "{$CFG->wwwroot}/mod/forum/view.php?f={$forum->id}");
}
if (!forum_user_can_see_post($forum, $discussion, $post, null, $cm)) {
print_error('noviewdiscussionspermission', 'forum', "{$CFG->wwwroot}/mod/forum/view.php?id={$forum->id}");
}
if ($mark == 'read' or $mark == 'unread') {
if ($CFG->forum_usermarksread && forum_tp_can_track_forums($forum) && forum_tp_is_tracked($forum)) {
if ($mark == 'read') {
forum_tp_add_read_record($USER->id, $postid);
} else {
// unread
forum_tp_delete_read_records($USER->id, $postid);
}
}
}
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:31,代码来源:discuss.php
示例3: get_post
/**
* Returns the specified forum post from its internal cache.
*
* @throws \dml_missing_record_exception
* @param int $postid
* @return stdClass
*/
protected function get_post($postid)
{
if (empty($this->postsdata[$postid])) {
$this->postsdata[$postid] = forum_get_post_full($postid);
if (!$this->postsdata[$postid]) {
throw new \dml_missing_record_exception('forum_posts');
}
}
return $this->postsdata[$postid];
}
开发者ID:kevin-bruton,项目名称:moodle,代码行数:17,代码来源:post.php
示例4: forum_tp_is_tracked
$forumtracked = forum_tp_is_tracked($forum);
$posts = forum_get_all_discussion_posts($discussion->id, "created ASC", $forumtracked);
forum_print_posts_nested($course, $cm, $forum, $discussion, $post, false, false, $forumtracked, $posts);
}
} else {
echo $OUTPUT->header();
echo $OUTPUT->confirm(get_string("deletesure", "forum", $replycount), "post.php?delete={$delete}&confirm={$delete}", $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $post->discussion . '#p' . $post->id);
forum_print_post($post, $discussion, $forum, $cm, $course, false, false, false);
}
}
echo $OUTPUT->footer();
die;
} else {
if (!empty($prune)) {
// Pruning
if (!($post = forum_get_post_full($prune))) {
print_error('invalidpostid', 'forum');
}
if (!($discussion = $DB->get_record("forum_discussions", array("id" => $post->discussion)))) {
print_error('notpartofdiscussion', 'forum');
}
if (!($forum = $DB->get_record("forum", array("id" => $discussion->forum)))) {
print_error('invalidforumid', 'forum');
}
if ($forum->type == 'single') {
print_error('cannotsplit', 'forum');
}
if (!$post->parent) {
print_error('alreadyfirstpost', 'forum');
}
if (!($cm = get_coursemodule_from_instance("forum", $forum->id, $forum->course))) {
开发者ID:njorth,项目名称:marginalia,代码行数:31,代码来源:post.php
示例5: get_forum_discussion_posts
/**
* Returns a list of forum posts for a discussion
*
* @param int $discussionid the post ids
* @param string $sortby sort by this element (id, created or modified)
* @param string $sortdirection sort direction: ASC or DESC
*
* @return array the forum post details
* @since Moodle 2.7
*/
public static function get_forum_discussion_posts($discussionid, $sortby = "created", $sortdirection = "DESC")
{
global $CFG, $DB, $USER;
$warnings = array();
// Validate the parameter.
$params = self::validate_parameters(self::get_forum_discussion_posts_parameters(), array('discussionid' => $discussionid, 'sortby' => $sortby, 'sortdirection' => $sortdirection));
// Compact/extract functions are not recommended.
$discussionid = $params['discussionid'];
$sortby = $params['sortby'];
$sortdirection = $params['sortdirection'];
$sortallowedvalues = array('id', 'created', 'modified');
if (!in_array($sortby, $sortallowedvalues)) {
throw new invalid_parameter_exception('Invalid value for sortby parameter (value: ' . $sortby . '),' . 'allowed values are: ' . implode(',', $sortallowedvalues));
}
$sortdirection = strtoupper($sortdirection);
$directionallowedvalues = array('ASC', 'DESC');
if (!in_array($sortdirection, $directionallowedvalues)) {
throw new invalid_parameter_exception('Invalid value for sortdirection parameter (value: ' . $sortdirection . '),' . 'allowed values are: ' . implode(',', $directionallowedvalues));
}
$discussion = $DB->get_record('forum_discussions', array('id' => $discussionid), '*', MUST_EXIST);
$forum = $DB->get_record('forum', array('id' => $discussion->forum), '*', MUST_EXIST);
$course = $DB->get_record('course', array('id' => $forum->course), '*', MUST_EXIST);
$cm = get_coursemodule_from_instance('forum', $forum->id, $course->id, false, MUST_EXIST);
// Validate the module context. It checks everything that affects the module visibility (including groupings, etc..).
$modcontext = context_module::instance($cm->id);
self::validate_context($modcontext);
// This require must be here, see mod/forum/discuss.php.
require_once $CFG->dirroot . "/mod/forum/lib.php";
// Check they have the view forum capability.
require_capability('mod/forum:viewdiscussion', $modcontext, null, true, 'noviewdiscussionspermission', 'forum');
if (!($post = forum_get_post_full($discussion->firstpost))) {
throw new moodle_exception('notexists', 'forum');
}
// This function check groups, qanda, timed discussions, etc.
if (!forum_user_can_see_post($forum, $discussion, $post, null, $cm)) {
throw new moodle_exception('noviewdiscussionspermission', 'forum');
}
$canviewfullname = has_capability('moodle/site:viewfullnames', $modcontext);
// We will add this field in the response.
$canreply = forum_user_can_post($forum, $discussion, $USER, $cm, $course, $modcontext);
$forumtracked = forum_tp_is_tracked($forum);
$sort = 'p.' . $sortby . ' ' . $sortdirection;
$posts = forum_get_all_discussion_posts($discussion->id, $sort, $forumtracked);
foreach ($posts as $pid => $post) {
if (!forum_user_can_see_post($forum, $discussion, $post, null, $cm)) {
$warning = array();
$warning['item'] = 'post';
$warning['itemid'] = $post->id;
$warning['warningcode'] = '1';
$warning['message'] = 'You can\'t see this post';
$warnings[] = $warning;
continue;
}
// Function forum_get_all_discussion_posts adds postread field.
// Note that the value returned can be a boolean or an integer. The WS expects a boolean.
if (empty($post->postread)) {
$posts[$pid]->postread = false;
} else {
$posts[$pid]->postread = true;
}
$posts[$pid]->canreply = $canreply;
if (!empty($posts[$pid]->children)) {
$posts[$pid]->children = array_keys($posts[$pid]->children);
} else {
$posts[$pid]->children = array();
}
$user = new stdclass();
$user = username_load_fields_from_object($user, $post);
$posts[$pid]->userfullname = fullname($user, $canviewfullname);
$posts[$pid] = (array) $post;
}
$result = array();
$result['posts'] = $posts;
$result['warnings'] = $warnings;
return $result;
}
开发者ID:educacionbe,项目名称:cursos,代码行数:86,代码来源:externallib.php
示例6: add_discussion_post
/**
* Create new posts into an existing discussion.
*
* @param int $postid the post id we are going to reply to
* @param string $subject new post subject
* @param string $message new post message (only html format allowed)
* @param array $options optional settings
* @return array of warnings and the new post id
* @since Moodle 3.0
* @throws moodle_exception
*/
public static function add_discussion_post($postid, $subject, $message, $options = array()) {
global $DB, $CFG, $USER;
require_once($CFG->dirroot . "/mod/forum/lib.php");
$params = self::validate_parameters(self::add_discussion_post_parameters(),
array(
'postid' => $postid,
'subject' => $subject,
'message' => $message,
'options' => $options
));
// Validate options.
$options = array(
'discussionsubscribe' => true
);
foreach ($params['options'] as $option) {
$name = trim($option['name']);
switch ($name) {
case 'discussionsubscribe':
$value = clean_param($option['value'], PARAM_BOOL);
break;
default:
throw new moodle_exception('errorinvalidparam', 'webservice', '', $name);
}
$options[$name] = $value;
}
$warnings = array();
if (!$parent = forum_get_post_full($params['postid'])) {
throw new moodle_exception('invalidparentpostid', 'forum');
}
if (!$discussion = $DB->get_record("forum_discussions", array("id" => $parent->discussion))) {
throw new moodle_exception('notpartofdiscussion', 'forum');
}
// Request and permission validation.
$forum = $DB->get_record('forum', array('id' => $discussion->forum), '*', MUST_EXIST);
list($course, $cm) = get_course_and_cm_from_instance($forum, 'forum');
$context = context_module::instance($cm->id);
self::validate_context($context);
if (!forum_user_can_post($forum, $discussion, $USER, $cm, $course, $context)) {
throw new moodle_exception('nopostforum', 'forum');
}
$thresholdwarning = forum_check_throttling($forum, $cm);
forum_check_blocking_threshold($thresholdwarning);
// Create the post.
$post = new stdClass();
$post->discussion = $discussion->id;
$post->parent = $parent->id;
$post->subject = $params['subject'];
$post->message = $params['message'];
$post->messageformat = FORMAT_HTML; // Force formatting for now.
$post->messagetrust = trusttext_trusted($context);
$post->itemid = 0;
if ($postid = forum_add_new_post($post, null)) {
$post->id = $postid;
// Trigger events and completion.
$params = array(
'context' => $context,
'objectid' => $post->id,
'other' => array(
'discussionid' => $discussion->id,
'forumid' => $forum->id,
'forumtype' => $forum->type,
)
);
$event = \mod_forum\event\post_created::create($params);
$event->add_record_snapshot('forum_posts', $post);
$event->add_record_snapshot('forum_discussions', $discussion);
$event->trigger();
// Update completion state.
$completion = new completion_info($course);
if ($completion->is_enabled($cm) &&
($forum->completionreplies || $forum->completionposts)) {
$completion->update_state($cm, COMPLETION_COMPLETE);
}
$settings = new stdClass();
$settings->discussionsubscribe = $options['discussionsubscribe'];
//.........这里部分代码省略.........
开发者ID:uniedpa,项目名称:moodle,代码行数:101,代码来源:externallib.php
示例7: leaf_get_newsitem
function leaf_get_newsitem($d)
{
global $DB, $USER, $CFG, $OUTPUT;
static $str;
require_once $CFG->libdir . '/filelib.php';
$discussion = $DB->get_record('forum_discussions', array('id' => $d, 'course' => 1), '*', 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);
$parent = $discussion->firstpost;
$post = forum_get_post_full($parent);
$displaymode = -1;
$canreply = false;
$canrate = false;
$sort = "p.created ASC";
$posts = forum_get_all_discussion_posts($discussion->id, $sort, false);
foreach ($posts as $post) {
$post->course = $course->id;
$post->forum = $forum->id;
$postuser = new stdClass();
$postuser->id = $post->userid;
$postuser->firstname = $post->firstname;
$postuser->lastname = $post->lastname;
$postuser->imagealt = $post->imagealt;
$postuser->picture = $post->picture;
$postuser->email = $post->email;
$postuser->fullname = fullname($postuser);
$output = '';
$output .= html_writer::tag('a', '', array('id' => 'p' . $post->id));
$output .= html_writer::start_tag('div', array('class' => 'forumpost clearfix firstpost starter'));
$output .= html_writer::start_tag('div', array('class' => 'row header clearfix'));
$output .= html_writer::start_tag('div', array('class' => 'left picture'));
$output .= $OUTPUT->user_picture($postuser, array('courseid' => $course->id));
$output .= html_writer::end_tag('div');
$output .= html_writer::start_tag('div', array('class' => 'topic firstpost starter'));
$postsubject = $post->subject;
if (empty($post->subjectnoformat)) {
$postsubject = format_string($postsubject);
}
$output .= html_writer::tag('div', $postsubject, array('class' => 'subject'));
$output .= html_writer::tag('div', $postuser->fullname, array('class' => 'author'));
$output .= html_writer::end_tag('div');
//topic
$output .= html_writer::end_tag('div');
//row
$output .= html_writer::start_tag('div', array('class' => 'row maincontent clearfix'));
$output .= html_writer::start_tag('div', array('class' => 'left'));
$output .= html_writer::tag('div', ' ', array('class' => 'grouppictures'));
$output .= html_writer::end_tag('div');
//left side
$output .= html_writer::start_tag('div', array('class' => 'no-overflow'));
$output .= html_writer::start_tag('div', array('class' => 'content'));
$options = new stdClass();
$options->para = false;
$options->trusted = $post->messagetrust;
// Prepare whole post
$postclass = 'fullpost';
$postcontent = format_text($post->message, $post->messageformat, $options, $course->id);
// Output the post content
$output .= html_writer::tag('div', $postcontent, array('class' => 'posting ' . $postclass));
$output .= html_writer::end_tag('div');
// Content
$output .= html_writer::end_tag('div');
// Content mask
$output .= html_writer::end_tag('div');
// Row
$output .= html_writer::start_tag('div', array('class' => 'row side'));
$output .= html_writer::tag('div', ' ', array('class' => 'left'));
$output .= html_writer::start_tag('div', array('class' => 'options clearfix'));
// Close remaining open divs
$output .= html_writer::end_tag('div');
// content
$output .= html_writer::end_tag('div');
// row
$output .= html_writer::end_tag('div');
// forumpost
echo $output;
}
}
开发者ID:bmbrands,项目名称:moodle-theme_leaf,代码行数:79,代码来源:lib.php
示例8: 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;
}
开发者ID:nadavkav,项目名称:moodle-block_ajax_marking,代码行数:89,代码来源:block_ajax_marking_forum.class.php
示例9: get_links
//.........这里部分代码省略.........
}
} else {
if (!empty($linkarray["content"])) {
// Get turnitin text content details.
$submissiontype = $cm->modname == "forum" ? 'forum_post' : 'text_content';
switch ($cm->modname) {
case 'assign':
$moodletextsubmission = $DB->get_record('assignsubmission_onlinetext', array('submission' => $submission->id), 'onlinetext');
if (empty($moodletextsubmission)) {
$content = '';
$submission_status = false;
} else {
$content = $moodletextsubmission->onlinetext;
}
break;
case 'workshop':
$submission = $DB->get_record('workshop_submissions', array('authorid' => $linkarray["userid"], 'workshopid' => $moduledata->id));
$content = $linkarray["content"];
break;
case 'forum':
static $discussionid;
// Use query string id to check whether we are on forum home page.
$querystrid = optional_param('id', 0, PARAM_INT);
// Work out the discussion id from query string.
if (empty($discussionid)) {
$discussionid = optional_param('d', 0, PARAM_INT);
}
if (empty($discussionid)) {
$reply = optional_param('reply', 0, PARAM_INT);
$edit = optional_param('edit', 0, PARAM_INT);
$delete = optional_param('delete', 0, PARAM_INT);
$parent = '';
if ($reply != 0) {
$parent = forum_get_post_full($reply);
} else {
if ($edit != 0) {
$parent = forum_get_post_full($edit);
} else {
if ($delete != 0) {
$parent = forum_get_post_full($delete);
}
}
}
if (!empty($parent)) {
$discussionid = $parent->discussion;
}
}
// Some forum types don't pass in certain values on main forum page.
if ((empty($discussionid) || $querystrid != 0) && ($forum->type == 'blog' || $forum->type == 'single')) {
if (!($discussion = $DB->get_record_sql('SELECT FD.id
FROM {forum_posts} FP JOIN {forum_discussions} FD
ON FP.discussion = FD.id
WHERE FD.forum = ? AND FD.course = ?
AND FP.userid = ? AND FP.message LIKE ? ', array($forum->id, $forum->course, $linkarray["userid"], $linkarray["content"])))) {
print_error('notpartofdiscussion', 'forum');
}
$discussionid = $discussion->id;
}
$submission = $DB->get_record_select('forum_posts', " userid = ? AND message LIKE ? AND discussion = ? ", array($linkarray["userid"], $linkarray["content"], $discussionid));
$itemid = $submission->id;
$submission->timemodified = $submission->modified;
$content = $linkarray["content"];
break;
}
// Get plagiarism file info.
$identifier = sha1($content);
开发者ID:aolley,项目名称:MoodleDirectV2,代码行数:67,代码来源:lib.php
注:本文中的forum_get_post_full函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论