本文整理汇总了PHP中forum_get_user_digest_options函数的典型用法代码示例。如果您正苦于以下问题:PHP forum_get_user_digest_options函数的具体用法?PHP forum_get_user_digest_options怎么用?PHP forum_get_user_digest_options使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了forum_get_user_digest_options函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_string
$strdiscussions = get_string('discussions', 'forum');
$strsubscribed = get_string('subscribed', 'forum');
$strunreadposts = get_string('unreadposts', 'forum');
$strtracking = get_string('tracking', 'forum');
$strmarkallread = get_string('markallread', 'forum');
$strtrackforum = get_string('trackforum', 'forum');
$strnotrackforum = get_string('notrackforum', 'forum');
$strsubscribe = get_string('subscribe', 'forum');
$strunsubscribe = get_string('unsubscribe', 'forum');
$stryes = get_string('yes');
$strno = get_string('no');
$strrss = get_string('rss');
$stremaildigest = get_string('emaildigest');
$searchform = forum_search_form($course);
// Retrieve the list of forum digest options for later.
$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';
}
$subscribed_forums = forum_get_subscribed_forums($course);
$can_subscribe = is_enrolled($coursecontext);
示例2: forum_set_user_maildigest
/**
* Set the per-forum maildigest option for the specified user.
*
* @param stdClass $forum The forum to set the option for.
* @param int $maildigest The maildigest option.
* @param stdClass $user The user object. This defaults to the global $USER object.
* @throws invalid_digest_setting thrown if an invalid maildigest option is provided.
*/
function forum_set_user_maildigest($forum, $maildigest, $user = null)
{
global $DB, $USER;
if (is_number($forum)) {
$forum = $DB->get_record('forum', array('id' => $forum));
}
if ($user === null) {
$user = $USER;
}
$course = $DB->get_record('course', array('id' => $forum->course), '*', MUST_EXIST);
$cm = get_coursemodule_from_instance('forum', $forum->id, $course->id, false, MUST_EXIST);
$context = context_module::instance($cm->id);
// User must be allowed to see this forum.
require_capability('mod/forum:viewdiscussion', $context, $user->id);
// Validate the maildigest setting.
$digestoptions = forum_get_user_digest_options($user);
if (!isset($digestoptions[$maildigest])) {
throw new moodle_exception('invaliddigestsetting', 'mod_forum');
}
// Attempt to retrieve any existing forum digest record.
$subscription = $DB->get_record('forum_digests', array('userid' => $user->id, 'forum' => $forum->id));
// Create or Update the existing maildigest setting.
if ($subscription) {
if ($maildigest == -1) {
$DB->delete_records('forum_digests', array('forum' => $forum->id, 'userid' => $user->id));
} else {
if ($maildigest !== $subscription->maildigest) {
// Only update the maildigest setting if it's changed.
$subscription->maildigest = $maildigest;
$DB->update_record('forum_digests', $subscription);
}
}
} else {
if ($maildigest != -1) {
// Only insert the maildigest setting if it's non-default.
$subscription = new stdClass();
$subscription->forum = $forum->id;
$subscription->userid = $user->id;
$subscription->maildigest = $maildigest;
$subscription->id = $DB->insert_record('forum_digests', $subscription);
}
}
}
示例3: render_digest_options
/**
* Create the inplace_editable used to select forum digest options.
*
* @param stdClass $forum The forum to create the editable for.
* @param int $value The current value for this user
* @return inplace_editable
*/
public function render_digest_options($forum, $value)
{
$options = forum_get_user_digest_options();
$editable = new \core\output\inplace_editable('mod_forum', 'digestoptions', $forum->id, true, $options[$value], $value);
$editable->set_type_select($options);
return $editable;
}
示例4: test_get_user_digest_options_sorting
public function test_get_user_digest_options_sorting()
{
global $USER, $DB;
$this->resetAfterTest(true);
// Set up a basic user enrolled in a course.
$helper = $this->helper_setup_user_in_course();
$user = $helper->user;
$course1 = $helper->courses->course1;
$forum1 = $helper->forums->forum1;
// Set to the user.
self::setUser($helper->user);
// Retrieve the list of applicable options.
$options = forum_get_user_digest_options();
// The default option must always be at the top of the list.
$lastoption = -2;
foreach ($options as $value => $description) {
$this->assertGreaterThan($lastoption, $value);
$lastoption = $value;
}
}
示例5: test_mod_forum_get_user_digest_options_sorting
public function test_mod_forum_get_user_digest_options_sorting()
{
global $USER, $DB;
$this->resetAfterTest(true);
// Create a user.
$user = self::getDataGenerator()->create_user();
// Set to the user.
self::setUser($user);
// Retrieve the list of applicable options.
$options = forum_get_user_digest_options();
// The default option must always be at the top of the list.
$lastoption = -2;
foreach ($options as $value => $description) {
$this->assertGreaterThan($lastoption, $value);
$lastoption = $value;
}
}