本文整理汇总了PHP中forum_subscribed_users函数的典型用法代码示例。如果您正苦于以下问题:PHP forum_subscribed_users函数的具体用法?PHP forum_subscribed_users怎么用?PHP forum_subscribed_users使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了forum_subscribed_users函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: forum_cron
//.........这里部分代码省略.........
if (!isset($forums[$forumid])) {
if ($forum = $DB->get_record('forum', array('id' => $forumid))) {
$forums[$forumid] = $forum;
} else {
mtrace('Could not find forum '.$forumid);
unset($posts[$pid]);
continue;
}
}
$courseid = $forums[$forumid]->course;
if (!isset($courses[$courseid])) {
if ($course = $DB->get_record('course', array('id' => $courseid))) {
$courses[$courseid] = $course;
} else {
mtrace('Could not find course '.$courseid);
unset($posts[$pid]);
continue;
}
}
if (!isset($coursemodules[$forumid])) {
if ($cm = get_coursemodule_from_instance('forum', $forumid, $courseid)) {
$coursemodules[$forumid] = $cm;
} else {
mtrace('Could not find course module for forum '.$forumid);
unset($posts[$pid]);
continue;
}
}
// caching subscribed users of each forum
if (!isset($subscribedusers[$forumid])) {
$modcontext = context_module::instance($coursemodules[$forumid]->id);
if ($subusers = forum_subscribed_users($courses[$courseid], $forums[$forumid], 0, $modcontext, "u.*")) {
foreach ($subusers as $postuser) {
// this user is subscribed to this forum
$subscribedusers[$forumid][$postuser->id] = $postuser->id;
$userscount++;
if ($userscount > FORUM_CRON_USER_CACHE) {
// Store minimal user info.
$minuser = new stdClass();
$minuser->id = $postuser->id;
$users[$postuser->id] = $minuser;
} else {
// Cache full user record.
forum_cron_minimise_user_record($postuser);
$users[$postuser->id] = $postuser;
}
}
// Release memory.
unset($subusers);
unset($postuser);
}
}
$mailcount[$pid] = 0;
$errorcount[$pid] = 0;
}
}
if ($users && $posts) {
$urlinfo = parse_url($CFG->wwwroot);
$hostname = $urlinfo['host'];
foreach ($users as $userto) {
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:67,代码来源:lib.php
示例2: foreach
} else {
if (!empty($frm->remove) and !empty($frm->removeselect)) {
foreach ($frm->removeselect as $removesubscriber) {
if (!forum_unsubscribe($removesubscriber, $id)) {
print_error('cannotremovesubscriber', 'forum', '', $removesubscriber);
}
}
} else {
if (!empty($frm->showall)) {
$searchtext = '';
}
}
}
}
/// Get all existing subscribers for this forum.
if (!($subscribers = forum_subscribed_users($course, $forum, $currentgroup, $context))) {
$subscribers = array();
}
/// Get all the potential subscribers excluding users already subscribed
$users = forum_get_potential_subscribers($context, $currentgroup, 'id,email,firstname,lastname', 'firstname ASC, lastname ASC');
if (!$users) {
$users = array();
}
foreach ($subscribers as $subscriber) {
unset($users[$subscriber->id]);
}
/// This is yucky, but do the search in PHP, becuase the list we are using comes from get_users_by_capability,
/// which does not allow searching in the database. Fortunately the list is only this list of users in this
/// course, which is normally OK, except on the site course of a big site. But before you can enter a search
/// term, you have already seen a page that lists everyone, since this code never does paging, so you have probably
/// already crashed your server if you are going to. This will be fixed properly for Moodle 2.0: MDL-17550.
开发者ID:ajv,项目名称:Offline-Caching,代码行数:31,代码来源:subscribers.php
示例3: test_forum_disallow_subscribe_on_create
/**
* Test subscription using disallow subscription on create.
*/
public function test_forum_disallow_subscribe_on_create()
{
global $CFG;
$this->resetAfterTest();
$usercount = 5;
$course = $this->getDataGenerator()->create_course();
$users = array();
for ($i = 0; $i < $usercount; $i++) {
$user = $this->getDataGenerator()->create_user();
$users[] = $user;
$this->getDataGenerator()->enrol_user($user->id, $course->id);
}
$options = array('course' => $course->id, 'forcesubscribe' => FORUM_DISALLOWSUBSCRIBE);
// Subscription prevented.
$forum = $this->getDataGenerator()->create_module('forum', $options);
$result = forum_subscribed_users($course, $forum);
// No subscriptions by default.
$this->assertEquals(0, count($result));
foreach ($users as $user) {
$this->assertFalse(forum_is_subscribed($user->id, $forum));
}
}
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:25,代码来源:lib_test.php
示例4: forum_cron
/**
* Function to be run periodically according to the moodle cron
* Finds all posts that have yet to be mailed out, and mails them
* out to all subscribers
* @return void
*/
function forum_cron()
{
global $CFG, $USER;
$cronuser = clone $USER;
$site = get_site();
// all users that are subscribed to any post that needs sending
$users = array();
// status arrays
$mailcount = array();
$errorcount = array();
// caches
$discussions = array();
$forums = array();
$courses = array();
$coursemodules = array();
$subscribedusers = array();
// Posts older than 2 days will not be mailed. This is to avoid the problem where
// cron has not been running for a long time, and then suddenly people are flooded
// with mail from the past few weeks or months
$timenow = time();
$endtime = $timenow - $CFG->maxeditingtime;
$starttime = $endtime - 48 * 3600;
// Two days earlier
if ($posts = forum_get_unmailed_posts($starttime, $endtime, $timenow)) {
// Mark them all now as being mailed. It's unlikely but possible there
// might be an error later so that a post is NOT actually mailed out,
// but since mail isn't crucial, we can accept this risk. Doing it now
// prevents the risk of duplicated mails, which is a worse problem.
if (!forum_mark_old_posts_as_mailed($endtime)) {
mtrace('Errors occurred while trying to mark some posts as being mailed.');
return false;
// Don't continue trying to mail them, in case we are in a cron loop
}
// checking post validity, and adding users to loop through later
foreach ($posts as $pid => $post) {
$discussionid = $post->discussion;
if (!isset($discussions[$discussionid])) {
if ($discussion = get_record('forum_discussions', 'id', $post->discussion)) {
$discussions[$discussionid] = $discussion;
} else {
mtrace('Could not find discussion ' . $discussionid);
unset($posts[$pid]);
continue;
}
}
$forumid = $discussions[$discussionid]->forum;
if (!isset($forums[$forumid])) {
if ($forum = get_record('forum', 'id', $forumid)) {
$forums[$forumid] = $forum;
} else {
mtrace('Could not find forum ' . $forumid);
unset($posts[$pid]);
continue;
}
}
$courseid = $forums[$forumid]->course;
if (!isset($courses[$courseid])) {
if ($course = get_record('course', 'id', $courseid)) {
$courses[$courseid] = $course;
} else {
mtrace('Could not find course ' . $courseid);
unset($posts[$pid]);
continue;
}
}
if (!isset($coursemodules[$forumid])) {
if ($cm = get_coursemodule_from_instance('forum', $forumid, $courseid)) {
$coursemodules[$forumid] = $cm;
} else {
mtrace('Could not course module for forum ' . $forumid);
unset($posts[$pid]);
continue;
}
}
// caching subscribed users of each forum
if (!isset($subscribedusers[$forumid])) {
if ($subusers = forum_subscribed_users($courses[$courseid], $forums[$forumid], 0, false)) {
foreach ($subusers as $postuser) {
// do not try to mail users with stopped email
if ($postuser->emailstop) {
if (!empty($CFG->forum_logblocked)) {
add_to_log(SITEID, 'forum', 'mail blocked', '', '', 0, $postuser->id);
}
continue;
}
// this user is subscribed to this forum
$subscribedusers[$forumid][$postuser->id] = $postuser->id;
// this user is a user we have to process later
$users[$postuser->id] = $postuser;
}
unset($subusers);
// release memory
}
}
//.........这里部分代码省略.........
开发者ID:r007,项目名称:PMoodle,代码行数:101,代码来源:lib.php
示例5: get_string
}
}
$subscriberselector->invalidate_selected_users();
$existingselector->invalidate_selected_users();
$subscriberselector->set_existing_subscribers($existingselector->find_users(''));
}
$strsubscribers = get_string("subscribers", "forum");
$PAGE->navbar->add($strsubscribers);
$PAGE->set_title($strsubscribers);
$PAGE->set_heading($COURSE->fullname);
if (has_capability('mod/forum:managesubscriptions', $context)) {
$PAGE->set_button(forum_update_subscriptions_button($course->id, $id));
if ($edit != -1) {
$USER->subscriptionsediting = $edit;
}
} else {
unset($USER->subscriptionsediting);
}
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('forum', 'forum') . ' ' . $strsubscribers);
if (empty($USER->subscriptionsediting)) {
echo $forumoutput->subscriber_overview(forum_subscribed_users($course, $forum, $currentgroup, $context), $forum, $course);
} else {
if (forum_is_forcesubscribed($forum)) {
$subscriberselector->set_force_subscribed(true);
echo $forumoutput->subscribed_users($subscriberselector);
} else {
echo $forumoutput->subscriber_selection_form($existingselector, $subscriberselector);
}
}
echo $OUTPUT->footer();
开发者ID:vuchannguyen,项目名称:web,代码行数:31,代码来源:subscribers.php
注:本文中的forum_subscribed_users函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论