本文整理匯總了PHP中mod_forum\subscriptions::fill_subscription_cache_for_course方法的典型用法代碼示例。如果您正苦於以下問題:PHP subscriptions::fill_subscription_cache_for_course方法的具體用法?PHP subscriptions::fill_subscription_cache_for_course怎麽用?PHP subscriptions::fill_subscription_cache_for_course使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類mod_forum\subscriptions
的用法示例。
在下文中一共展示了subscriptions::fill_subscription_cache_for_course方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: forum_get_user_digest_options
$digestoptions = forum_get_user_digest_options();
$digestoptions_selector = new single_select(new moodle_url('/mod/forum/maildigest.php', array('backtoindex' => 1)), 'maildigest', $digestoptions, null, '');
$digestoptions_selector->method = 'post';
// Start of the table for General Forums
$generaltable = new html_table();
$generaltable->head = array($strforum, $strdescription, $strdiscussions);
$generaltable->align = array('left', 'left', 'center');
if ($usetracking = forum_tp_can_track_forums()) {
$untracked = forum_tp_get_untracked_forums($USER->id, $course->id);
$generaltable->head[] = $strunreadposts;
$generaltable->align[] = 'center';
$generaltable->head[] = $strtracking;
$generaltable->align[] = 'center';
}
// Fill the subscription cache for this course and user combination.
\mod_forum\subscriptions::fill_subscription_cache_for_course($course->id, $USER->id);
$can_subscribe = is_enrolled($coursecontext);
if ($can_subscribe) {
$generaltable->head[] = $strsubscribed;
$generaltable->align[] = 'center';
$generaltable->head[] = $stremaildigest . ' ' . $OUTPUT->help_icon('emaildigesttype', 'mod_forum');
$generaltable->align[] = 'center';
}
if ($show_rss = ($can_subscribe || $course->id == SITEID) && isset($CFG->enablerssfeeds) && isset($CFG->forum_enablerssfeeds) && $CFG->enablerssfeeds && $CFG->forum_enablerssfeeds) {
$generaltable->head[] = $strrss;
$generaltable->align[] = 'center';
}
$usesections = course_format_uses_sections($course->format);
$table = new html_table();
// Parse and organise all the forums. Most forums are course modules but
// some special ones are not. These get placed in the general forums
示例2: test_discussion_subscription_cache_fill_for_course
/**
* Test that the discussion subscription cache can filled course-at-a-time.
*/
public function test_discussion_subscription_cache_fill_for_course()
{
global $DB;
$this->resetAfterTest(true);
// Create a course, with a forum.
$course = $this->getDataGenerator()->create_course();
// Create the forums.
$options = array('course' => $course->id, 'forcesubscribe' => FORUM_DISALLOWSUBSCRIBE);
$disallowforum = $this->getDataGenerator()->create_module('forum', $options);
$options = array('course' => $course->id, 'forcesubscribe' => FORUM_CHOOSESUBSCRIBE);
$chooseforum = $this->getDataGenerator()->create_module('forum', $options);
$options = array('course' => $course->id, 'forcesubscribe' => FORUM_INITIALSUBSCRIBE);
$initialforum = $this->getDataGenerator()->create_module('forum', $options);
// Create some users and keep a reference to the first user.
$users = $this->helper_create_users($course, 20);
$user = reset($users);
// Reset the subscription caches.
\mod_forum\subscriptions::reset_forum_cache();
$startcount = $DB->perf_get_reads();
$result = \mod_forum\subscriptions::fill_subscription_cache_for_course($course->id, $user->id);
$this->assertNull($result);
$postfillcount = $DB->perf_get_reads();
$this->assertEquals(1, $postfillcount - $startcount);
$this->assertFalse(\mod_forum\subscriptions::fetch_subscription_cache($disallowforum->id, $user->id));
$this->assertFalse(\mod_forum\subscriptions::fetch_subscription_cache($chooseforum->id, $user->id));
$this->assertTrue(\mod_forum\subscriptions::fetch_subscription_cache($initialforum->id, $user->id));
$finalcount = $DB->perf_get_reads();
$this->assertEquals(0, $finalcount - $postfillcount);
// Test for all users.
foreach ($users as $user) {
$result = \mod_forum\subscriptions::fill_subscription_cache_for_course($course->id, $user->id);
$this->assertFalse(\mod_forum\subscriptions::fetch_subscription_cache($disallowforum->id, $user->id));
$this->assertFalse(\mod_forum\subscriptions::fetch_subscription_cache($chooseforum->id, $user->id));
$this->assertTrue(\mod_forum\subscriptions::fetch_subscription_cache($initialforum->id, $user->id));
}
$finalcount = $DB->perf_get_reads();
$this->assertEquals(count($users), $finalcount - $postfillcount);
}