本文整理汇总了PHP中forum_tp_clean_read_records函数的典型用法代码示例。如果您正苦于以下问题:PHP forum_tp_clean_read_records函数的具体用法?PHP forum_tp_clean_read_records怎么用?PHP forum_tp_clean_read_records使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了forum_tp_clean_read_records函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: forum_cron
//.........这里部分代码省略.........
}
if (!isset($userfrom->groups[$forum->id])) {
if (!isset($userfrom->groups)) {
$userfrom->groups = array();
if (isset($users[$userfrom->id])) {
$users[$userfrom->id]->groups = array();
}
}
$userfrom->groups[$forum->id] = groups_get_all_groups($course->id, $userfrom->id, $cm->groupingid);
if (isset($users[$userfrom->id])) {
$users[$userfrom->id]->groups[$forum->id] = $userfrom->groups[$forum->id];
}
}
// Headers to help prevent auto-responders.
$userfrom->customheaders = array("Precedence: Bulk", 'X-Auto-Response-Suppress: All', 'Auto-Submitted: auto-generated');
$maildigest = forum_get_user_maildigest_bulk($digests, $userto, $forum->id);
if (!isset($userto->canpost[$discussion->id])) {
$canreply = forum_user_can_post($forum, $discussion, $userto, $cm, $course, $modcontext);
} else {
$canreply = $userto->canpost[$discussion->id];
}
$data = new \mod_forum\output\forum_post_email($course, $cm, $forum, $discussion, $post, $userfrom, $userto, $canreply);
if (!isset($userto->viewfullnames[$forum->id])) {
$data->viewfullnames = has_capability('moodle/site:viewfullnames', $modcontext, $userto->id);
} else {
$data->viewfullnames = $userto->viewfullnames[$forum->id];
}
if ($maildigest == 2) {
// Subjects and link only.
$posttext .= $textdigestbasicout->render($data);
$posthtml .= $htmldigestbasicout->render($data);
} else {
// The full treatment.
$posttext .= $textdigestfullout->render($data);
$posthtml .= $htmldigestfullout->render($data);
// Create an array of postid's for this user to mark as read.
if (!$CFG->forum_usermarksread) {
$userto->markposts[$post->id] = $post->id;
}
}
$sentcount++;
}
$footerlinks = array();
if ($canunsubscribe) {
$footerlinks[] = "<a href=\"{$CFG->wwwroot}/mod/forum/subscribe.php?id={$forum->id}\">" . get_string("unsubscribe", "forum") . "</a>";
} else {
$footerlinks[] = get_string("everyoneissubscribed", "forum");
}
$footerlinks[] = "<a href='{$CFG->wwwroot}/mod/forum/index.php?id={$forum->course}'>" . get_string("digestmailpost", "forum") . '</a>';
$posthtml .= "\n<div class='mdl-right'><font size=\"1\">" . implode(' ', $footerlinks) . '</font></div>';
$posthtml .= '<hr size="1" noshade="noshade" /></p>';
}
if (empty($userto->mailformat) || $userto->mailformat != 1) {
// This user DOESN'T want to receive HTML
$posthtml = '';
}
$eventdata = new \core\message\message();
$eventdata->courseid = SITEID;
$eventdata->component = 'mod_forum';
$eventdata->name = 'digests';
$eventdata->userfrom = core_user::get_noreply_user();
$eventdata->userto = $userto;
$eventdata->subject = $postsubject;
$eventdata->fullmessage = $posttext;
$eventdata->fullmessageformat = FORMAT_PLAIN;
$eventdata->fullmessagehtml = $posthtml;
$eventdata->notification = 1;
$eventdata->smallmessage = get_string('smallmessagedigest', 'forum', $sentcount);
$mailresult = message_send($eventdata);
if (!$mailresult) {
mtrace("ERROR: mod/forum/cron.php: Could not send out digest mail to user {$userto->id} " . "({$userto->email})... not trying again.");
} else {
mtrace("success.");
$usermailcount++;
// Mark post as read if forum_usermarksread is set off
if (get_user_preferences('forum_markasreadonnotification', 1, $userto->id) == 1) {
forum_tp_mark_posts_read($userto, $userto->markposts);
}
}
}
}
/// We have finishied all digest emails, update $CFG->digestmailtimelast
set_config('digestmailtimelast', $timenow);
}
cron_setup_user();
if (!empty($usermailcount)) {
mtrace(get_string('digestsentusers', 'forum', $usermailcount));
}
if (!empty($CFG->forum_lastreadclean)) {
$timenow = time();
if ($CFG->forum_lastreadclean + 24 * 3600 < $timenow) {
set_config('forum_lastreadclean', $timenow);
mtrace('Removing old forum read tracking info...');
forum_tp_clean_read_records();
}
} else {
set_config('forum_lastreadclean', time());
}
return true;
}
示例2: forum_cron
//.........这里部分代码省略.........
}
} else {
mtrace('Could not find user '.$post->userid);
continue;
}
if (!isset($userfrom->groups[$forum->id])) {
if (!isset($userfrom->groups)) {
$userfrom->groups = array();
if (isset($users[$userfrom->id])) {
$users[$userfrom->id]->groups = array();
}
}
$userfrom->groups[$forum->id] = groups_get_all_groups($course->id, $userfrom->id, $cm->groupingid);
if (isset($users[$userfrom->id])) {
$users[$userfrom->id]->groups[$forum->id] = $userfrom->groups[$forum->id];
}
}
$userfrom->customheaders = array ("Precedence: Bulk");
if ($userto->maildigest == 2) {
// Subjects only
$by = new stdClass();
$by->name = fullname($userfrom);
$by->date = userdate($post->modified);
$posttext .= "\n".format_string($post->subject,true).' '.get_string("bynameondate", "forum", $by);
$posttext .= "\n---------------------------------------------------------------------";
$by->name = "<a target=\"_blank\" href=\"$CFG->wwwroot/user/view.php?id=$userfrom->id&course=$course->id\">$by->name</a>";
$posthtml .= '<div><a target="_blank" href="'.$CFG->wwwroot.'/mod/forum/discuss.php?d='.$discussion->id.'#p'.$post->id.'">'.format_string($post->subject,true).'</a> '.get_string("bynameondate", "forum", $by).'</div>';
} else {
// The full treatment
$posttext .= forum_make_mail_text($course, $cm, $forum, $discussion, $post, $userfrom, $userto, true);
$posthtml .= forum_make_mail_post($course, $cm, $forum, $discussion, $post, $userfrom, $userto, false, $canreply, true, false);
// Create an array of postid's for this user to mark as read.
if (!$CFG->forum_usermarksread) {
$userto->markposts[$post->id] = $post->id;
}
}
}
if ($canunsubscribe) {
$posthtml .= "\n<div class='mdl-right'><font size=\"1\"><a href=\"$CFG->wwwroot/mod/forum/subscribe.php?id=$forum->id\">".get_string("unsubscribe", "forum")."</a></font></div>";
} else {
$posthtml .= "\n<div class='mdl-right'><font size=\"1\">".get_string("everyoneissubscribed", "forum")."</font></div>";
}
$posthtml .= '<hr size="1" noshade="noshade" /></p>';
}
$posthtml .= '</body>';
if (empty($userto->mailformat) || $userto->mailformat != 1) {
// This user DOESN'T want to receive HTML
$posthtml = '';
}
$attachment = $attachname='';
// Directly email forum digests rather than sending them via messaging, use the
// site shortname as 'from name', the noreply address will be used by email_to_user.
$mailresult = email_to_user($userto, $site->shortname, $postsubject, $posttext, $posthtml, $attachment, $attachname);
if (!$mailresult) {
mtrace("ERROR!");
echo "Error: mod/forum/cron.php: Could not send out digest mail to user $userto->id ($userto->email)... not trying again.\n";
add_to_log($course->id, 'forum', 'mail digest error', '', '', $cm->id, $userto->id);
} else {
mtrace("success.");
$usermailcount++;
// Mark post as read if forum_usermarksread is set off
forum_tp_mark_posts_read($userto, $userto->markposts);
}
}
}
/// We have finishied all digest emails, update $CFG->digestmailtimelast
set_config('digestmailtimelast', $timenow);
}
cron_setup_user();
if (!empty($usermailcount)) {
mtrace(get_string('digestsentusers', 'forum', $usermailcount));
}
if (!empty($CFG->forum_lastreadclean)) {
$timenow = time();
if ($CFG->forum_lastreadclean + (24*3600) < $timenow) {
set_config('forum_lastreadclean', $timenow);
mtrace('Removing old forum read tracking info...');
forum_tp_clean_read_records();
}
} else {
set_config('forum_lastreadclean', time());
}
return true;
}
示例3: forum_cron
//.........这里部分代码省略.........
$posthtml .= "<p><font face=\"sans-serif\">" . "<a target=\"_blank\" href=\"{$CFG->wwwroot}/course/view.php?id={$course->id}\">{$course->shortname}</a> -> " . "<a target=\"_blank\" href=\"{$CFG->wwwroot}/mod/forum/index.php?id={$course->id}\">{$strforums}</a> -> " . "<a target=\"_blank\" href=\"{$CFG->wwwroot}/mod/forum/view.php?f={$forum->id}\">" . format_string($forum->name, true) . "</a>";
if ($discussion->name == $forum->name) {
$posthtml .= "</font></p>";
} else {
$posthtml .= " -> <a target=\"_blank\" href=\"{$CFG->wwwroot}/mod/forum/discuss.php?d={$discussion->id}\">" . format_string($discussion->name, true) . "</a></font></p>";
}
$posthtml .= '<p>';
$postsarray = $discussionposts[$discussionid];
sort($postsarray);
foreach ($postsarray as $postid) {
$post = $posts[$postid];
if (array_key_exists($post->userid, $users)) {
// we might know him/her already
$userfrom = $users[$post->userid];
} else {
if ($userfrom = get_record('user', 'id', $post->userid)) {
$users[$userfrom->id] = $userfrom;
// fetch only once, we can add it to user list, it will be skipped anyway
} else {
mtrace('Could not find user ' . $post->userid);
continue;
}
}
if (!isset($userfrom->groups[$forum->id])) {
if (!isset($userfrom->groups)) {
$userfrom->groups = array();
$users[$userfrom->id]->groups = array();
}
$userfrom->groups[$forum->id] = groups_get_all_groups($course->id, $userfrom->id, $cm->groupingid);
$users[$userfrom->id]->groups[$forum->id] = $userfrom->groups[$forum->id];
}
$userfrom->customheaders = array("Precedence: Bulk");
if ($userto->maildigest == 2) {
// Subjects only
$by = new object();
$by->name = fullname($userfrom);
$by->date = userdate($post->modified);
$posttext .= "\n" . format_string($post->subject, true) . ' ' . get_string("bynameondate", "forum", $by);
$posttext .= "\n---------------------------------------------------------------------";
$by->name = "<a target=\"_blank\" href=\"{$CFG->wwwroot}/user/view.php?id={$userfrom->id}&course={$course->id}\">{$by->name}</a>";
$posthtml .= '<div><a target="_blank" href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $discussion->id . '#p' . $post->id . '">' . format_string($post->subject, true) . '</a> ' . get_string("bynameondate", "forum", $by) . '</div>';
} else {
// The full treatment
$posttext .= forum_make_mail_text($course, $forum, $discussion, $post, $userfrom, $userto, true);
$posthtml .= forum_make_mail_post($course, $forum, $discussion, $post, $userfrom, $userto, false, $canreply, true, false);
// Create an array of postid's for this user to mark as read.
if (!$CFG->forum_usermarksread) {
$userto->markposts[$post->id] = $post->id;
}
}
}
if ($canunsubscribe) {
$posthtml .= "\n<div align=\"right\"><font size=\"1\"><a href=\"{$CFG->wwwroot}/mod/forum/subscribe.php?id={$forum->id}\">" . get_string("unsubscribe", "forum") . "</a></font></div>";
} else {
$posthtml .= "\n<div align=\"right\"><font size=\"1\">" . get_string("everyoneissubscribed", "forum") . "</font></div>";
}
$posthtml .= '<hr size="1" noshade="noshade" /></p>';
}
$posthtml .= '</body>';
if ($userto->mailformat != 1) {
// This user DOESN'T want to receive HTML
$posthtml = '';
}
if (!($mailresult = email_to_user($userto, $site->shortname, $postsubject, $posttext, $posthtml, '', '', $CFG->forum_replytouser))) {
mtrace("ERROR!");
echo "Error: mod/forum/cron.php: Could not send out digest mail to user {$userto->id} ({$userto->email})... not trying again.\n";
add_to_log($course->id, 'forum', 'mail digest error', '', '', $cm->id, $userto->id);
} else {
if ($mailresult === 'emailstop') {
// should not happen anymore - see check above
} else {
mtrace("success.");
$usermailcount++;
// Mark post as read if forum_usermarksread is set off
forum_tp_mark_posts_read($userto, $userto->markposts);
}
}
}
}
/// We have finishied all digest emails, update $CFG->digestmailtimelast
set_config('digestmailtimelast', $timenow);
}
$USER = $cronuser;
course_setup(SITEID);
// reset cron user language, theme and timezone settings
if (!empty($usermailcount)) {
mtrace(get_string('digestsentusers', 'forum', $usermailcount));
}
if (!empty($CFG->forum_lastreadclean)) {
$timenow = time();
if ($CFG->forum_lastreadclean + 24 * 3600 < $timenow) {
set_config('forum_lastreadclean', $timenow);
mtrace('Removing old forum read tracking info...');
forum_tp_clean_read_records();
}
} else {
set_config('forum_lastreadclean', time());
}
return true;
}