当前位置: 首页>>代码示例>>PHP>>正文


PHP mod_forum_post_form类代码示例

本文整理汇总了PHP中mod_forum_post_form的典型用法代码示例。如果您正苦于以下问题:PHP mod_forum_post_form类的具体用法?PHP mod_forum_post_form怎么用?PHP mod_forum_post_form使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了mod_forum_post_form类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: forum_add_discussion

/**
 * Given an object containing all the necessary data,
 * create a new discussion and return the id
 *
 * @param object $post
 * @param mixed $mform
 * @param string $unused
 * @param int $userid
 * @return object
 */
function forum_add_discussion($discussion, $mform=null, $unused=null, $userid=null) {
    global $USER, $CFG, $DB;

    $timenow = time();

    if (is_null($userid)) {
        $userid = $USER->id;
    }

    // The first post is stored as a real post, and linked
    // to from the discuss entry.

    $forum = $DB->get_record('forum', array('id'=>$discussion->forum));
    $cm    = get_coursemodule_from_instance('forum', $forum->id);

    $post = new stdClass();
    $post->discussion    = 0;
    $post->parent        = 0;
    $post->userid        = $userid;
    $post->created       = $timenow;
    $post->modified      = $timenow;
    $post->mailed        = FORUM_MAILED_PENDING;
    $post->subject       = $discussion->name;
    $post->message       = $discussion->message;
    $post->messageformat = $discussion->messageformat;
    $post->messagetrust  = $discussion->messagetrust;
    $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);

    // 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 = context_module::instance($cm->id);
        $text = file_save_draft_area_files($discussion->itemid, $context->id, 'mod_forum', 'post', $post->id,
                mod_forum_post_form::editor_options(), $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

    $discussion->firstpost    = $post->id;
    $discussion->timemodified = $timenow;
    $discussion->usermodified = $post->userid;
    $discussion->userid       = $userid;

    $post->discussion = $DB->insert_record("forum_discussions", $discussion);

    // Finally, set the pointer on the post.
    $DB->set_field("forum_posts", "discussion", $post->discussion, array("id"=>$post->id));

    if (!empty($cm->id)) {
        forum_add_attachment($post, $forum, $cm, $mform, $unused);
    }

    if (forum_tp_can_track_forums($forum) && forum_tp_is_tracked($forum)) {
        forum_tp_mark_post_read($post->userid, $post, $post->forum);
    }

    // Let Moodle know that assessable content is uploaded (eg for plagiarism detection)
    if (!empty($cm->id)) {
        forum_trigger_content_uploaded_event($post, $cm, 'forum_add_discussion');
    }

    return $post->discussion;
}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:78,代码来源:lib.php

示例2: get_context_instance

    }
}
if (!isset($coursecontext)) {
    // Has not yet been set by post.php.
    $coursecontext = get_context_instance(CONTEXT_COURSE, $forum->course);
}
if (!($cm = get_coursemodule_from_instance('forum', $forum->id, $course->id))) {
    // For the logs
    error('Could not get the course module for the forum instance.');
}
$modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
// setup course variable to force form language
// fix for MDL-6926
course_setup($course->id);
require_once 'post_form.php';
$mform_post = new mod_forum_post_form('post.php', array('course' => $course, 'coursecontext' => $coursecontext, 'modcontext' => $modcontext, 'forum' => $forum, 'post' => $post));
if ($fromform = $mform_post->get_data()) {
    require_login($course, false, $cm);
    if (empty($SESSION->fromurl)) {
        $errordestination = "{$CFG->wwwroot}/mod/forum/view.php?f={$forum->id}";
    } else {
        $errordestination = $SESSION->fromurl;
    }
    // TODO add attachment processing
    //$fromform->attachment = isset($_FILES['attachment']) ? $_FILES['attachment'] : NULL;
    trusttext_after_edit($fromform->message, $modcontext);
    if ($fromform->edit) {
        // Updating a post
        $fromform->id = $fromform->edit;
        $message = '';
        //fix for bug #4314
开发者ID:veritech,项目名称:pare-project,代码行数:31,代码来源:post.php

示例3: print_error

if (!($cm = get_coursemodule_from_instance('forum', $forum->id, $course->id))) {
    // For the logs
    print_error('invalidcoursemodule');
}
$modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
require_login($course, false, $cm);
if (isguestuser()) {
    // just in case
    print_error('noguest');
}
if (!isset($forum->maxattachments)) {
    // TODO - delete this once we add a field to the forum table
    $forum->maxattachments = 3;
}
require_once 'post_form.php';
$mform_post = new mod_forum_post_form('post.php', array('course' => $course, 'cm' => $cm, 'coursecontext' => $coursecontext, 'modcontext' => $modcontext, 'forum' => $forum, 'post' => $post));
$draftitemid = file_get_submitted_draft_itemid('attachments');
file_prepare_draft_area($draftitemid, $modcontext->id, 'mod_forum', 'attachment', empty($post->id) ? null : $post->id);
//load data into form NOW!
if ($USER->id != $post->userid) {
    // Not the original author, so add a message to the end
    $data->date = userdate($post->modified);
    if ($post->messageformat == FORMAT_HTML) {
        $data->name = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $USER->id . '&course=' . $post->course . '">' . fullname($USER) . '</a>';
        $post->message .= '<p>(<span class="edited">' . get_string('editedby', 'forum', $data) . '</span>)</p>';
    } else {
        $data->name = fullname($USER);
        $post->message .= "\n\n(" . get_string('editedby', 'forum', $data) . ')';
    }
}
if (!empty($parent)) {
开发者ID:njorth,项目名称:marginalia,代码行数:31,代码来源:post.php


注:本文中的mod_forum_post_form类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。