本文整理汇总了PHP中forum_tp_add_read_record函数的典型用法代码示例。如果您正苦于以下问题:PHP forum_tp_add_read_record函数的具体用法?PHP forum_tp_add_read_record怎么用?PHP forum_tp_add_read_record使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了forum_tp_add_read_record函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: forum_tp_mark_post_read
/**
* If its an old post, do nothing. If the record exists, the maintenance will clear it up later.
*
* @return bool
*/
function forum_tp_mark_post_read($userid, $post, $forumid) {
if (!forum_tp_is_post_old($post)) {
return forum_tp_add_read_record($userid, $post->id);
} else {
return true;
}
}
示例2: print_error
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);
}
}
}
$searchform = forum_search_form($course);
$forumnode = $PAGE->navigation->find($cm->id, navigation_node::TYPE_ACTIVITY);
if (empty($forumnode)) {
$forumnode = $PAGE->navbar;
} else {
$forumnode->make_active();
}
$node = $forumnode->add(format_string($discussion->name), new moodle_url('/mod/forum/discuss.php', array('d' => $discussion->id)));
$node->display = false;
示例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'));
}
示例4: format_string
}
$navtail = '';
} else {
$parent = $discussion->firstpost;
$navtail = '-> ' . format_string($discussion->name);
}
if (!forum_user_can_view_post($parent, $course, $cm, $forum, $discussion)) {
error('You do not have permissions to view this post', "{$CFG->wwwroot}/mod/forum/view.php?f={$forum->id}");
}
if (!($post = forum_get_post_full($parent))) {
error("Discussion no longer exists", "{$CFG->wwwroot}/mod/forum/view.php?f={$forum->id}");
}
$post->modcontext = $modcontext;
if (forum_tp_can_track_forums($forum) && forum_tp_is_tracked($forum) && $CFG->forum_usermarksread) {
if ($mark == 'read') {
forum_tp_add_read_record($USER->id, $postid, $discussion->id, $forum->id);
} else {
if ($mark == 'unread') {
forum_tp_delete_read_records($USER->id, $postid);
}
}
}
if (empty($navtail)) {
$navtail = "-> <a href=\"discuss.php?d={$discussion->id}\">" . format_string($discussion->name, true) . "</a> -> " . format_string($post->subject);
}
if ($forum->type == 'single') {
$navforum = '';
} else {
$navforum = "<a href=\"../forum/view.php?f={$forum->id}\">" . format_string($forum->name, true) . "</a> ";
}
$navmiddle = "<a href=\"../forum/index.php?id={$course->id}\">" . get_string("forums", "forum") . '</a> -> ' . $navforum;