• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP forum_delete_discussion函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: forum_delete_instance

/**
 * Given an ID of an instance of this module,
 * this function will permanently delete the instance
 * and any data that depends on it.
 *
 * @global object
 * @param int $id forum instance id
 * @return bool success
 */
function forum_delete_instance($id) {
    global $DB;

    if (!$forum = $DB->get_record('forum', array('id'=>$id))) {
        return false;
    }
    if (!$cm = get_coursemodule_from_instance('forum', $forum->id)) {
        return false;
    }
    if (!$course = $DB->get_record('course', array('id'=>$cm->course))) {
        return false;
    }

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

    // now get rid of all files
    $fs = get_file_storage();
    $fs->delete_area_files($context->id);

    $result = true;

    if ($discussions = $DB->get_records('forum_discussions', array('forum'=>$forum->id))) {
        foreach ($discussions as $discussion) {
            if (!forum_delete_discussion($discussion, true, $course, $cm, $forum)) {
                $result = false;
            }
        }
    }

    if (!$DB->delete_records('forum_subscriptions', array('forum'=>$forum->id))) {
        $result = false;
    }

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

    if (!$DB->delete_records('forum', array('id'=>$forum->id))) {
        $result = false;
    }

    forum_grade_item_delete($forum);

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


示例2: time

 $timepassed = time() - $post->created;
 if ($timepassed > $CFG->maxeditingtime && !has_capability('mod/forum:deleteanypost', $modcontext)) {
     print_error("cannotdeletepost", "forum", forum_go_back_to("discuss.php?d={$post->discussion}"));
 }
 if ($post->totalscore) {
     notice(get_string('couldnotdeleteratings', 'rating'), forum_go_back_to("discuss.php?d={$post->discussion}"));
 } else {
     if ($replycount && !has_capability('mod/forum:deleteanypost', $modcontext)) {
         print_error("couldnotdeletereplies", "forum", forum_go_back_to("discuss.php?d={$post->discussion}"));
     } else {
         if (!$post->parent) {
             // post is a discussion topic as well, so delete discussion
             if ($forum->type == 'single') {
                 notice("Sorry, but you are not allowed to delete that discussion!", forum_go_back_to("discuss.php?d={$post->discussion}"));
             }
             forum_delete_discussion($discussion, false, $course, $cm, $forum);
             add_to_log($discussion->course, "forum", "delete discussion", "view.php?id={$cm->id}", "{$forum->id}", $cm->id);
             redirect("view.php?f={$discussion->forum}");
         } else {
             if (forum_delete_post($post, has_capability('mod/forum:deleteanypost', $modcontext), $course, $cm, $forum)) {
                 if ($forum->type == 'single') {
                     // Single discussion forums are an exception. We show
                     // the forum itself since it only has one discussion
                     // thread.
                     $discussionurl = "view.php?f={$forum->id}";
                 } else {
                     $discussionurl = "discuss.php?d={$post->discussion}";
                 }
                 add_to_log($discussion->course, "forum", "delete post", $discussionurl, "{$post->id}", $cm->id);
                 redirect(forum_go_back_to($discussionurl));
             } else {
开发者ID:njorth,项目名称:marginalia,代码行数:31,代码来源:post.php


示例3: forum_delete_instance

/**
 * Given an ID of an instance of this module,
 * this function will permanently delete the instance
 * and any data that depends on it.
 * @param int forum instance id
 * @return bool success
 */
function forum_delete_instance($id)
{
    if (!($forum = get_record('forum', 'id', $id))) {
        return false;
    }
    $result = true;
    if ($discussions = get_records('forum_discussions', 'forum', $forum->id)) {
        foreach ($discussions as $discussion) {
            if (!forum_delete_discussion($discussion, true)) {
                $result = false;
            }
        }
    }
    if (!delete_records('forum_subscriptions', 'forum', $forum->id)) {
        $result = false;
    }
    forum_tp_delete_read_records(-1, -1, -1, $forum->id);
    if (!delete_records('forum', 'id', $forum->id)) {
        $result = false;
    }
    forum_grade_item_delete($forum);
    return $result;
}
开发者ID:r007,项目名称:PMoodle,代码行数:30,代码来源:lib.php


示例4: forum_count_replies

 }
 $replycount = forum_count_replies($post);
 if (!empty($confirm) && confirm_sesskey()) {
     // User has confirmed the delete
     if ($post->totalscore) {
         notice(get_string("couldnotdeleteratings", "forum"), forum_go_back_to("discuss.php?d={$post->discussion}"));
     } else {
         if ($replycount && !has_capability('mod/forum:deleteanypost', $modcontext)) {
             error(get_string("couldnotdeletereplies", "forum"), forum_go_back_to("discuss.php?d={$post->discussion}"));
         } else {
             if (!$post->parent) {
                 // post is a discussion topic as well, so delete discussion
                 if ($forum->type == 'single') {
                     notice("Sorry, but you are not allowed to delete that discussion!", forum_go_back_to("discuss.php?d={$post->discussion}"));
                 }
                 forum_delete_discussion($discussion);
                 add_to_log($discussion->course, "forum", "delete discussion", "view.php?id={$cm->id}", "{$forum->id}", $cm->id);
                 redirect("view.php?f={$discussion->forum}");
             } else {
                 if (forum_delete_post($post, has_capability('mod/forum:deleteanypost', $modcontext))) {
                     if ($forum->type == 'single') {
                         // Single discussion forums are an exception. We show
                         // the forum itself since it only has one discussion
                         // thread.
                         $discussionurl = "view.php?f={$forum->id}";
                     } else {
                         $discussionurl = "discuss.php?d={$post->discussion}";
                     }
                     add_to_log($discussion->course, "forum", "delete post", $discussionurl, "{$post->id}", $cm->id);
                     redirect(forum_go_back_to($discussionurl));
                 } else {
开发者ID:veritech,项目名称:pare-project,代码行数:31,代码来源:post.php


示例5: test_post_deleted

 /**
  * Test post_deleted event.
  */
 public function test_post_deleted()
 {
     global $DB;
     // Setup test data.
     $course = $this->getDataGenerator()->create_course();
     $forum = $this->getDataGenerator()->create_module('forum', array('course' => $course->id));
     $user = $this->getDataGenerator()->create_user();
     $cm = get_coursemodule_from_instance('forum', $forum->id, $forum->course);
     // Add a discussion.
     $record = array();
     $record['course'] = $course->id;
     $record['forum'] = $forum->id;
     $record['userid'] = $user->id;
     $discussion = $this->getDataGenerator()->get_plugin_generator('mod_forum')->create_discussion($record);
     // When creating a discussion we also create a post, so get the post.
     $discussionpost = $DB->get_records('forum_posts');
     // Will only be one here.
     $discussionpost = reset($discussionpost);
     // Add a few posts.
     $record = array();
     $record['discussion'] = $discussion->id;
     $record['userid'] = $user->id;
     $posts = array();
     $posts[$discussionpost->id] = $discussionpost;
     for ($i = 0; $i < 3; $i++) {
         $post = $this->getDataGenerator()->get_plugin_generator('mod_forum')->create_post($record);
         $posts[$post->id] = $post;
     }
     // Delete the last post and capture the event.
     $lastpost = end($posts);
     $sink = $this->redirectEvents();
     forum_delete_post($lastpost, true, $course, $cm, $forum);
     $events = $sink->get_events();
     $this->assertCount(1, $events);
     $event = reset($events);
     // Check that the events contain the expected values.
     $this->assertInstanceOf('\\mod_forum\\event\\post_deleted', $event);
     $this->assertEquals(context_module::instance($forum->cmid), $event->get_context());
     $expected = array($course->id, 'forum', 'delete post', "discuss.php?d={$discussion->id}", $lastpost->id, $forum->cmid);
     $this->assertEventLegacyLogData($expected, $event);
     $url = new \moodle_url('/mod/forum/discuss.php', array('d' => $discussion->id));
     $this->assertEquals($url, $event->get_url());
     $this->assertEventContextNotUsed($event);
     $this->assertNotEmpty($event->get_name());
     // Delete the whole discussion and capture the events.
     $sink = $this->redirectEvents();
     forum_delete_discussion($discussion, true, $course, $cm, $forum);
     $events = $sink->get_events();
     // We will have 3 events. One for the discussion (creating a discussion creates a post), and two for the posts.
     $this->assertCount(3, $events);
     // Loop through the events and check they are valid.
     foreach ($events as $event) {
         $post = $posts[$event->objectid];
         // Check that the event contains the expected values.
         $this->assertInstanceOf('\\mod_forum\\event\\post_deleted', $event);
         $this->assertEquals(context_module::instance($forum->cmid), $event->get_context());
         $expected = array($course->id, 'forum', 'delete post', "discuss.php?d={$discussion->id}", $post->id, $forum->cmid);
         $this->assertEventLegacyLogData($expected, $event);
         $url = new \moodle_url('/mod/forum/discuss.php', array('d' => $discussion->id));
         $this->assertEquals($url, $event->get_url());
         $this->assertEventContextNotUsed($event);
         $this->assertNotEmpty($event->get_name());
     }
 }
开发者ID:evltuma,项目名称:moodle,代码行数:67,代码来源:events_test.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP forum_delete_post函数代码示例发布时间:2022-05-15
下一篇:
PHP forum_cron_minimise_user_record函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap