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


PHP forum_discussion_update_last_post函数代码示例

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


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

示例1: forum_delete_post

/**
 * Deletes a single forum post.
 *
 * @global object
 * @param object $post Forum post object
 * @param mixed $children Whether to delete children. If false, returns false
 *   if there are any children (without deleting the post). If true,
 *   recursively deletes all children. If set to special value 'ignore', deletes
 *   post regardless of children (this is for use only when deleting all posts
 *   in a disussion).
 * @param object $course Course
 * @param object $cm Course-module
 * @param object $forum Forum
 * @param bool $skipcompletion True to skip updating completion state if it
 *   would otherwise be updated, i.e. when deleting entire forum anyway.
 * @return bool
 */
function forum_delete_post($post, $children, $course, $cm, $forum, $skipcompletion=false) {
    global $DB, $CFG;
    require_once($CFG->libdir.'/completionlib.php');

    $context = context_module::instance($cm->id);

    if ($children !== 'ignore' && ($childposts = $DB->get_records('forum_posts', array('parent'=>$post->id)))) {
       if ($children) {
           foreach ($childposts as $childpost) {
               forum_delete_post($childpost, true, $course, $cm, $forum, $skipcompletion);
           }
       } else {
           return false;
       }
    }

    //delete ratings
    require_once($CFG->dirroot.'/rating/lib.php');
    $delopt = new stdClass;
    $delopt->contextid = $context->id;
    $delopt->component = 'mod_forum';
    $delopt->ratingarea = 'post';
    $delopt->itemid = $post->id;
    $rm = new rating_manager();
    $rm->delete_ratings($delopt);

    //delete attachments
    $fs = get_file_storage();
    $fs->delete_area_files($context->id, 'mod_forum', 'attachment', $post->id);
    $fs->delete_area_files($context->id, 'mod_forum', 'post', $post->id);

    if ($DB->delete_records("forum_posts", array("id" => $post->id))) {

        forum_tp_delete_read_records(-1, $post->id);

    // Just in case we are deleting the last post
        forum_discussion_update_last_post($post->discussion);

        // Update completion state if we are tracking completion based on number of posts
        // But don't bother when deleting whole thing

        if (!$skipcompletion) {
            $completion = new completion_info($course);
            if ($completion->is_enabled($cm) == COMPLETION_TRACKING_AUTOMATIC &&
               ($forum->completiondiscussions || $forum->completionreplies || $forum->completionposts)) {
                $completion->update_state($cm, COMPLETION_INCOMPLETE, $post->userid);
            }
        }

        return true;
    }
    return false;
}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:70,代码来源:lib.php

示例2: create_forum_post

    /**
     * Function to create a dummy post.
     *
     * @param array|stdClass $record
     * @return stdClass the post object
     */
    public function create_forum_post($record = null) {
        global $DB;

        // Increment the forum post count.
        $this->forumpostcount++;

        // Variable to store time.
        $time = time() + $this->forumpostcount;

        $record = (array) $record;

        if (!isset($record['discussion'])) {
            throw new coding_exception('discussion must be present in phpunit_util::create_forum_post() $record');
        }

        if (!isset($record['userid'])) {
            throw new coding_exception('userid must be present in phpunit_util::create_forum_post() $record');
        }

        if (!isset($record['parent'])) {
            $record['parent'] = 0;
        }

        if (!isset($record['subject'])) {
            $record['subject'] = 'Forum post subject ' . $this->forumpostcount;
        }

        if (!isset($record['message'])) {
            $record['message'] = html_writer::tag('p', 'Forum message post ' . $this->forumpostcount);
        }

        if (!isset($record['created'])) {
            $record['created'] = $time;
        }

        if (!isset($record['modified'])) {
            $record['modified'] = $time;
        }

        $record = (object) $record;

        // Add the post.
        $record->id = $DB->insert_record('forum_posts', $record);

        // Update the last post.
        forum_discussion_update_last_post($record->discussion);

        return $record;
    }
开发者ID:Burick,项目名称:moodle,代码行数:55,代码来源:data_generator.php

示例3: stdClass

     $newdiscussion->userid = $discussion->userid;
     $newdiscussion->groupid = $discussion->groupid;
     $newdiscussion->assessed = $discussion->assessed;
     $newdiscussion->usermodified = $post->userid;
     $newdiscussion->timestart = $discussion->timestart;
     $newdiscussion->timeend = $discussion->timeend;
     $newid = $DB->insert_record('forum_discussions', $newdiscussion);
     $newpost = new stdClass();
     $newpost->id = $post->id;
     $newpost->parent = 0;
     $newpost->subject = $name;
     $DB->update_record("forum_posts", $newpost);
     forum_change_discussionid($post->id, $newid);
     // update last post in each discussion
     forum_discussion_update_last_post($discussion->id);
     forum_discussion_update_last_post($newid);
     add_to_log($discussion->course, "forum", "prune post", "discuss.php?d={$newid}", "{$post->id}", $cm->id);
     redirect(forum_go_back_to("discuss.php?d={$newid}"));
 } else {
     // User just asked to prune something
     $course = $DB->get_record('course', array('id' => $forum->course));
     $PAGE->set_cm($cm);
     $PAGE->set_context($modcontext);
     $PAGE->navbar->add(format_string($post->subject, true), new moodle_url('/mod/forum/discuss.php', array('d' => $discussion->id)));
     $PAGE->navbar->add(get_string("prune", "forum"));
     $PAGE->set_title(format_string($discussion->name) . ": " . format_string($post->subject));
     $PAGE->set_heading($course->fullname);
     echo $OUTPUT->header();
     echo $OUTPUT->heading(get_string('pruneheading', 'forum'));
     echo '<center>';
     include 'prune.html';
开发者ID:njorth,项目名称:marginalia,代码行数:31,代码来源:post.php

示例4: forum_delete_post

/**
 * Deletes a single forum post.
 *
 * @global object
 * @param object $post Forum post object
 * @param mixed $children Whether to delete children. If false, returns false
 *   if there are any children (without deleting the post). If true,
 *   recursively deletes all children. If set to special value 'ignore', deletes
 *   post regardless of children (this is for use only when deleting all posts
 *   in a disussion).
 * @param object $course Course
 * @param object $cm Course-module
 * @param object $forum Forum
 * @param bool $skipcompletion True to skip updating completion state if it
 *   would otherwise be updated, i.e. when deleting entire forum anyway.
 * @return bool
 */
function forum_delete_post($post, $children, $course, $cm, $forum, $skipcompletion = false)
{
    global $DB, $CFG, $USER;
    require_once $CFG->libdir . '/completionlib.php';
    $context = context_module::instance($cm->id);
    if ($children !== 'ignore' && ($childposts = $DB->get_records('forum_posts', array('parent' => $post->id)))) {
        if ($children) {
            foreach ($childposts as $childpost) {
                forum_delete_post($childpost, true, $course, $cm, $forum, $skipcompletion);
            }
        } else {
            return false;
        }
    }
    // Delete ratings.
    require_once $CFG->dirroot . '/rating/lib.php';
    $delopt = new stdClass();
    $delopt->contextid = $context->id;
    $delopt->component = 'mod_forum';
    $delopt->ratingarea = 'post';
    $delopt->itemid = $post->id;
    $rm = new rating_manager();
    $rm->delete_ratings($delopt);
    // Delete attachments.
    $fs = get_file_storage();
    $fs->delete_area_files($context->id, 'mod_forum', 'attachment', $post->id);
    $fs->delete_area_files($context->id, 'mod_forum', 'post', $post->id);
    // Delete cached RSS feeds.
    if (!empty($CFG->enablerssfeeds)) {
        require_once $CFG->dirroot . '/mod/forum/rsslib.php';
        forum_rss_delete_file($forum);
    }
    if ($DB->delete_records("forum_posts", array("id" => $post->id))) {
        forum_tp_delete_read_records(-1, $post->id);
        // Just in case we are deleting the last post
        forum_discussion_update_last_post($post->discussion);
        // Update completion state if we are tracking completion based on number of posts
        // But don't bother when deleting whole thing
        if (!$skipcompletion) {
            $completion = new completion_info($course);
            if ($completion->is_enabled($cm) == COMPLETION_TRACKING_AUTOMATIC && ($forum->completiondiscussions || $forum->completionreplies || $forum->completionposts)) {
                $completion->update_state($cm, COMPLETION_INCOMPLETE, $post->userid);
            }
        }
        $params = array('context' => $context, 'objectid' => $post->id, 'other' => array('discussionid' => $post->discussion, 'forumid' => $forum->id, 'forumtype' => $forum->type));
        if ($post->userid !== $USER->id) {
            $params['relateduserid'] = $post->userid;
        }
        $event = \mod_forum\event\post_deleted::create($params);
        $event->add_record_snapshot('forum_posts', $post);
        $event->trigger();
        return true;
    }
    return false;
}
开发者ID:rezaies,项目名称:moodle,代码行数:72,代码来源:lib.php

示例5: forum_delete_post

/**
 *
 */
function forum_delete_post($post, $children = false)
{
    if ($childposts = get_records('forum_posts', 'parent', $post->id)) {
        if ($children) {
            foreach ($childposts as $childpost) {
                forum_delete_post($childpost, true);
            }
        } else {
            return false;
        }
    }
    if (delete_records("forum_posts", "id", $post->id)) {
        delete_records("forum_ratings", "post", $post->id);
        // Just in case
        forum_tp_delete_read_records(-1, $post->id);
        if ($post->attachment) {
            $discussion = get_record("forum_discussions", "id", $post->discussion);
            $post->course = $discussion->course;
            $post->forum = $discussion->forum;
            forum_delete_old_attachments($post);
        }
        // Just in case we are deleting the last post
        forum_discussion_update_last_post($post->discussion);
        return true;
    }
    return false;
}
开发者ID:r007,项目名称:PMoodle,代码行数:30,代码来源:lib.php

示例6: forum_delete_post

/**
 * Deletes a single forum post.
 * @param object $post Forum post object
 * @param mixed $children Whether to delete children. If false, returns false
 *   if there are any children (without deleting the post). If true,
 *   recursively deletes all children. If set to special value 'ignore', deletes
 *   post regardless of children (this is for use only when deleting all posts
 *   in a disussion).
 * @param object $course Course
 * @param object $cm Course-module
 * @param object $forum Forum
 * @param bool $skipcompletion True to skip updating completion state if it
 *   would otherwise be updated, i.e. when deleting entire forum anyway.
 */
function forum_delete_post($post, $children, $course, $cm, $forum, $skipcompletion = false)
{
    global $DB;
    $context = get_context_instance(CONTEXT_MODULE, $cm->id);
    if ($children != 'ignore' && ($childposts = $DB->get_records('forum_posts', array('parent' => $post->id)))) {
        if ($children) {
            foreach ($childposts as $childpost) {
                forum_delete_post($childpost, true, $course, $cm, $forum, $skipcompletion);
            }
        } else {
            return false;
        }
    }
    //delete ratings
    $DB->delete_records("forum_ratings", array("post" => $post->id));
    //delete attachments
    $fs = get_file_storage();
    $fs->delete_area_files($context->id, 'forum_attachment', $post->id);
    if ($DB->delete_records("forum_posts", array("id" => $post->id))) {
        forum_tp_delete_read_records(-1, $post->id);
        // Just in case we are deleting the last post
        forum_discussion_update_last_post($post->discussion);
        // Update completion state if we are tracking completion based on number of posts
        // But don't bother when deleting whole thing
        if (!$skipcompletion) {
            $completion = new completion_info($course);
            if ($completion->is_enabled($cm) == COMPLETION_TRACKING_AUTOMATIC && ($forum->completiondiscussions || $forum->completionreplies || $forum->completionposts)) {
                $completion->update_state($cm, COMPLETION_INCOMPLETE, $post->userid);
            }
        }
        return true;
    }
    return false;
}
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:48,代码来源:lib.php


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