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

PHP forum_tp_stop_tracking函数代码示例

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

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



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

示例1: test_forum_tp_get_untracked_forums

 /**
  * Test the logic in the test_forum_tp_get_untracked_forums() function.
  */
 public function test_forum_tp_get_untracked_forums()
 {
     global $CFG;
     $this->resetAfterTest();
     $useron = $this->getDataGenerator()->create_user(array('trackforums' => 1));
     $useroff = $this->getDataGenerator()->create_user(array('trackforums' => 0));
     $course = $this->getDataGenerator()->create_course();
     $options = array('course' => $course->id, 'trackingtype' => FORUM_TRACKING_OFF);
     // Off.
     $forumoff = $this->getDataGenerator()->create_module('forum', $options);
     $options = array('course' => $course->id, 'trackingtype' => FORUM_TRACKING_FORCED);
     // On.
     $forumforce = $this->getDataGenerator()->create_module('forum', $options);
     $options = array('course' => $course->id, 'trackingtype' => FORUM_TRACKING_OPTIONAL);
     // Optional.
     $forumoptional = $this->getDataGenerator()->create_module('forum', $options);
     // Allow force.
     $CFG->forum_allowforcedreadtracking = 1;
     // On user with force on.
     $result = forum_tp_get_untracked_forums($useron->id, $course->id);
     $this->assertEquals(1, count($result));
     $this->assertEquals(true, isset($result[$forumoff->id]));
     // Off user with force on.
     $result = forum_tp_get_untracked_forums($useroff->id, $course->id);
     $this->assertEquals(2, count($result));
     $this->assertEquals(true, isset($result[$forumoff->id]));
     $this->assertEquals(true, isset($result[$forumoptional->id]));
     // Don't allow force.
     $CFG->forum_allowforcedreadtracking = 0;
     // On user with force off.
     $result = forum_tp_get_untracked_forums($useron->id, $course->id);
     $this->assertEquals(1, count($result));
     $this->assertEquals(true, isset($result[$forumoff->id]));
     // Off user with force off.
     $result = forum_tp_get_untracked_forums($useroff->id, $course->id);
     $this->assertEquals(3, count($result));
     $this->assertEquals(true, isset($result[$forumoff->id]));
     $this->assertEquals(true, isset($result[$forumoptional->id]));
     $this->assertEquals(true, isset($result[$forumforce->id]));
     // Stop tracking so we can test again.
     forum_tp_stop_tracking($forumforce->id, $useron->id);
     forum_tp_stop_tracking($forumoptional->id, $useron->id);
     forum_tp_stop_tracking($forumforce->id, $useroff->id);
     forum_tp_stop_tracking($forumoptional->id, $useroff->id);
     // Allow force.
     $CFG->forum_allowforcedreadtracking = 1;
     // On user with force on.
     $result = forum_tp_get_untracked_forums($useron->id, $course->id);
     $this->assertEquals(2, count($result));
     $this->assertEquals(true, isset($result[$forumoff->id]));
     $this->assertEquals(true, isset($result[$forumoptional->id]));
     // Off user with force on.
     $result = forum_tp_get_untracked_forums($useroff->id, $course->id);
     $this->assertEquals(2, count($result));
     $this->assertEquals(true, isset($result[$forumoff->id]));
     $this->assertEquals(true, isset($result[$forumoptional->id]));
     // Don't allow force.
     $CFG->forum_allowforcedreadtracking = 0;
     // On user with force off.
     $result = forum_tp_get_untracked_forums($useron->id, $course->id);
     $this->assertEquals(3, count($result));
     $this->assertEquals(true, isset($result[$forumoff->id]));
     $this->assertEquals(true, isset($result[$forumoptional->id]));
     $this->assertEquals(true, isset($result[$forumforce->id]));
     // Off user with force off.
     $result = forum_tp_get_untracked_forums($useroff->id, $course->id);
     $this->assertEquals(3, count($result));
     $this->assertEquals(true, isset($result[$forumoff->id]));
     $this->assertEquals(true, isset($result[$forumoptional->id]));
     $this->assertEquals(true, isset($result[$forumforce->id]));
 }
开发者ID:rushi963,项目名称:moodle,代码行数:74,代码来源:lib_test.php


示例2: print_error

}
if (!($cm = get_coursemodule_from_instance("forum", $forum->id, $course->id))) {
    print_error('invalidcoursemodule');
}
require_login($course, false, $cm);
$returnpageurl = new moodle_url('/mod/forum/' . $returnpage, array('id' => $course->id, 'f' => $forum->id));
$returnto = forum_go_back_to($returnpageurl);
if (!forum_tp_can_track_forums($forum)) {
    redirect($returnto);
}
$info = new stdClass();
$info->name = fullname($USER);
$info->forum = format_string($forum->name);
$eventparams = array('context' => context_module::instance($cm->id), 'relateduserid' => $USER->id, 'other' => array('forumid' => $forum->id));
if (forum_tp_is_tracked($forum)) {
    if (forum_tp_stop_tracking($forum->id)) {
        $event = \mod_forum\event\readtracking_disabled::create($eventparams);
        $event->trigger();
        redirect($returnto, get_string("nownottracking", "forum", $info), 1);
    } else {
        print_error('cannottrack', '', get_local_referer(false));
    }
} else {
    // subscribe
    if (forum_tp_start_tracking($forum->id)) {
        $event = \mod_forum\event\readtracking_enabled::create($eventparams);
        $event->trigger();
        redirect($returnto, get_string("nowtracking", "forum", $info), 1);
    } else {
        print_error('cannottrack', '', get_local_referer(false));
    }
开发者ID:evltuma,项目名称:moodle,代码行数:31,代码来源:settracking.php


示例3: test_observers

 /**
  * Test mod_forum_observer methods.
  */
 public function test_observers()
 {
     global $DB, $CFG;
     require_once $CFG->dirroot . '/mod/forum/lib.php';
     $forumgen = $this->getDataGenerator()->get_plugin_generator('mod_forum');
     $course = $this->getDataGenerator()->create_course();
     $trackedrecord = array('course' => $course->id, 'type' => 'general', 'forcesubscribe' => FORUM_INITIALSUBSCRIBE);
     $untrackedrecord = array('course' => $course->id, 'type' => 'general');
     $trackedforum = $this->getDataGenerator()->create_module('forum', $trackedrecord);
     $untrackedforum = $this->getDataGenerator()->create_module('forum', $untrackedrecord);
     // Used functions don't require these settings; adding
     // them just in case there are APIs changes in future.
     $user = $this->getDataGenerator()->create_user(array('maildigest' => 1, 'trackforums' => 1));
     $manplugin = enrol_get_plugin('manual');
     $manualenrol = $DB->get_record('enrol', array('courseid' => $course->id, 'enrol' => 'manual'));
     $student = $DB->get_record('role', array('shortname' => 'student'));
     // The role_assign observer does it's job adding the forum_subscriptions record.
     $manplugin->enrol_user($manualenrol, $user->id, $student->id);
     // They are not required, but in a real environment they are supposed to be required;
     // adding them just in case there are APIs changes in future.
     set_config('forum_trackingtype', 1);
     set_config('forum_trackreadposts', 1);
     $record = array();
     $record['course'] = $course->id;
     $record['forum'] = $trackedforum->id;
     $record['userid'] = $user->id;
     $discussion = $forumgen->create_discussion($record);
     $record = array();
     $record['discussion'] = $discussion->id;
     $record['userid'] = $user->id;
     $post = $forumgen->create_post($record);
     forum_tp_add_read_record($user->id, $post->id);
     forum_set_user_maildigest($trackedforum, 2, $user);
     forum_tp_stop_tracking($untrackedforum->id, $user->id);
     $this->assertEquals(1, $DB->count_records('forum_subscriptions'));
     $this->assertEquals(1, $DB->count_records('forum_digests'));
     $this->assertEquals(1, $DB->count_records('forum_track_prefs'));
     $this->assertEquals(1, $DB->count_records('forum_read'));
     // The course_module_created observer does it's job adding a subscription.
     $forumrecord = array('course' => $course->id, 'type' => 'general', 'forcesubscribe' => FORUM_INITIALSUBSCRIBE);
     $extraforum = $this->getDataGenerator()->create_module('forum', $forumrecord);
     $this->assertEquals(2, $DB->count_records('forum_subscriptions'));
     $manplugin->unenrol_user($manualenrol, $user->id);
     $this->assertEquals(0, $DB->count_records('forum_digests'));
     $this->assertEquals(0, $DB->count_records('forum_subscriptions'));
     $this->assertEquals(0, $DB->count_records('forum_track_prefs'));
     $this->assertEquals(0, $DB->count_records('forum_read'));
 }
开发者ID:Keneth1212,项目名称:moodle,代码行数:51,代码来源:events_test.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP forum_trigger_content_uploaded_event函数代码示例发布时间:2022-05-15
下一篇:
PHP forum_tp_mark_posts_read函数代码示例发布时间: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