本文整理汇总了PHP中forum_is_user_group_discussion函数的典型用法代码示例。如果您正苦于以下问题:PHP forum_is_user_group_discussion函数的具体用法?PHP forum_is_user_group_discussion怎么用?PHP forum_is_user_group_discussion使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了forum_is_user_group_discussion函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: forum_print_recent_activity
/**
* Given a course and a date, prints a summary of all the new
* messages posted in the course since that date
*
* @global object
* @global object
* @global object
* @uses CONTEXT_MODULE
* @uses VISIBLEGROUPS
* @param object $course
* @param bool $viewfullnames capability
* @param int $timestart
* @return bool success
*/
function forum_print_recent_activity($course, $viewfullnames, $timestart)
{
global $CFG, $USER, $DB, $OUTPUT;
// do not use log table if possible, it may be huge and is expensive to join with other tables
$allnamefields = user_picture::fields('u', null, 'duserid');
if (!($posts = $DB->get_records_sql("SELECT p.*, f.type AS forumtype, d.forum, d.groupid,\n d.timestart, d.timeend, {$allnamefields}\n FROM {forum_posts} p\n JOIN {forum_discussions} d ON d.id = p.discussion\n JOIN {forum} f ON f.id = d.forum\n JOIN {user} u ON u.id = p.userid\n WHERE p.created > ? AND f.course = ?\n ORDER BY p.id ASC", array($timestart, $course->id)))) {
// order by initial posting date
return false;
}
$modinfo = get_fast_modinfo($course);
$groupmodes = array();
$cms = array();
$strftimerecent = get_string('strftimerecent');
$printposts = array();
foreach ($posts as $post) {
if (!isset($modinfo->instances['forum'][$post->forum])) {
// not visible
continue;
}
$cm = $modinfo->instances['forum'][$post->forum];
if (!$cm->uservisible) {
continue;
}
$context = context_module::instance($cm->id);
if (!has_capability('mod/forum:viewdiscussion', $context)) {
continue;
}
if (!empty($CFG->forum_enabletimedposts) and $USER->id != $post->duserid and ($post->timestart > 0 and $post->timestart > time() or $post->timeend > 0 and $post->timeend < time())) {
if (!has_capability('mod/forum:viewhiddentimedposts', $context)) {
continue;
}
}
// Check that the user can see the discussion.
if (forum_is_user_group_discussion($cm, $post->groupid)) {
$printposts[] = $post;
}
}
unset($posts);
if (!$printposts) {
return false;
}
echo $OUTPUT->heading(get_string('newforumposts', 'forum') . ':', 3);
echo "\n<ul class='unlist'>\n";
foreach ($printposts as $post) {
$subjectclass = empty($post->parent) ? ' bold' : '';
echo '<li><div class="head">' . '<div class="date">' . userdate($post->modified, $strftimerecent) . '</div>' . '<div class="name">' . fullname($post, $viewfullnames) . '</div>' . '</div>';
echo '<div class="info' . $subjectclass . '">';
if (empty($post->parent)) {
echo '"<a href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $post->discussion . '">';
} else {
echo '"<a href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $post->discussion . '&parent=' . $post->parent . '#p' . $post->id . '">';
}
$post->subject = break_up_long_words(format_string($post->subject, true));
echo $post->subject;
echo "</a>\"</div></li>\n";
}
echo "</ul>\n";
return true;
}
示例2: forum_print_recent_activity
/**
* Given a course and a date, prints a summary of all the new
* messages posted in the course since that date
*
* @global object
* @global object
* @global object
* @uses CONTEXT_MODULE
* @uses VISIBLEGROUPS
* @param object $course
* @param bool $viewfullnames capability
* @param int $timestart
* @return bool success
*/
function forum_print_recent_activity($course, $viewfullnames, $timestart)
{
global $CFG, $USER, $DB, $OUTPUT;
// do not use log table if possible, it may be huge and is expensive to join with other tables
$allnamefields = user_picture::fields('u', null, 'duserid');
if (!($posts = $DB->get_records_sql("SELECT p.*, f.type AS forumtype, d.forum, d.groupid,\n d.timestart, d.timeend, {$allnamefields}\n FROM {forum_posts} p\n JOIN {forum_discussions} d ON d.id = p.discussion\n JOIN {forum} f ON f.id = d.forum\n JOIN {user} u ON u.id = p.userid\n WHERE p.created > ? AND f.course = ?\n ORDER BY p.id ASC", array($timestart, $course->id)))) {
// order by initial posting date
return false;
}
$modinfo = get_fast_modinfo($course);
$groupmodes = array();
$cms = array();
$strftimerecent = get_string('strftimerecent');
$printposts = array();
foreach ($posts as $post) {
if (!isset($modinfo->instances['forum'][$post->forum])) {
// not visible
continue;
}
$cm = $modinfo->instances['forum'][$post->forum];
if (!$cm->uservisible) {
continue;
}
$context = context_module::instance($cm->id);
if (!has_capability('mod/forum:viewdiscussion', $context)) {
continue;
}
if (!empty($CFG->forum_enabletimedposts) and $USER->id != $post->duserid and ($post->timestart > 0 and $post->timestart > time() or $post->timeend > 0 and $post->timeend < time())) {
if (!has_capability('mod/forum:viewhiddentimedposts', $context)) {
continue;
}
}
// Check that the user can see the discussion.
if (forum_is_user_group_discussion($cm, $post->groupid)) {
$printposts[] = $post;
}
}
unset($posts);
if (!$printposts) {
return false;
}
echo $OUTPUT->heading(get_string('newforumposts', 'forum') . ':', 3);
$list = html_writer::start_tag('ul', ['class' => 'unlist']);
foreach ($printposts as $post) {
$subjectclass = empty($post->parent) ? ' bold' : '';
$authorhidden = forum_is_author_hidden($post, (object) ['type' => $post->forumtype]);
$list .= html_writer::start_tag('li');
$list .= html_writer::start_div('head');
$list .= html_writer::div(userdate($post->modified, $strftimerecent), 'date');
if (!$authorhidden) {
$list .= html_writer::div(fullname($post, $viewfullnames), 'name');
}
$list .= html_writer::end_div();
// Head.
$list .= html_writer::start_div('info' . $subjectclass);
$discussionurl = new moodle_url('/mod/forum/discuss.php', ['d' => $post->discussion]);
if (!empty($post->parent)) {
$discussionurl->param('parent', $post->parent);
$discussionurl->set_anchor('p' . $post->id);
}
$post->subject = break_up_long_words(format_string($post->subject, true));
$list .= html_writer::link($discussionurl, $post->subject);
$list .= html_writer::end_div();
// Info.
$list .= html_writer::end_tag('li');
}
$list .= html_writer::end_tag('ul');
echo $list;
return true;
}