• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP forum_get_discussion_neighbours函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中forum_get_discussion_neighbours函数的典型用法代码示例。如果您正苦于以下问题:PHP forum_get_discussion_neighbours函数的具体用法?PHP forum_get_discussion_neighbours怎么用?PHP forum_get_discussion_neighbours使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了forum_get_discussion_neighbours函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: forum_user_can_post

/// Check to see if groups are being used in this forum
/// If so, make sure the current person is allowed to see this discussion
/// Also, if we know they should be able to reply, then explicitly set $canreply for performance reasons
$canreply = forum_user_can_post($forum, $discussion, $USER, $cm, $course, $modcontext);
if (!$canreply and $forum->type !== 'news') {
    if (isguestuser() or !isloggedin()) {
        $canreply = true;
    }
    if (!is_enrolled($modcontext) and !is_viewing($modcontext)) {
        // allow guests and not-logged-in to see the link - they are prompted to log in after clicking the link
        // normal users with temporary guest access see this link too, they are asked to enrol instead
        $canreply = enrol_selfenrol_available($course->id);
    }
}
// Output the links to neighbour discussions.
$neighbours = forum_get_discussion_neighbours($cm, $discussion);
$neighbourlinks = $renderer->neighbouring_discussion_navigation($neighbours['prev'], $neighbours['next']);
echo $neighbourlinks;
/// Print the controls across the top
echo '<div class="discussioncontrols clearfix">';
if (!empty($CFG->enableportfolios) && has_capability('mod/forum:exportdiscussion', $modcontext)) {
    require_once $CFG->libdir . '/portfoliolib.php';
    $button = new portfolio_add_button();
    $button->set_callback_options('forum_portfolio_caller', array('discussionid' => $discussion->id), 'mod_forum');
    $button = $button->to_html(PORTFOLIO_ADD_FULL_FORM, get_string('exportdiscussion', 'mod_forum'));
    $buttonextraclass = '';
    if (empty($button)) {
        // no portfolio plugin available.
        $button = '&nbsp;';
        $buttonextraclass = ' noavailable';
    }
开发者ID:mongo0se,项目名称:moodle,代码行数:31,代码来源:discuss.php


示例2: test_pinned_timed_discussions_with_timed_discussions

 /**
  * Test test_pinned_timed_discussions_with_timed_discussions.
  */
 public function test_pinned_timed_discussions_with_timed_discussions()
 {
     global $CFG;
     $CFG->forum_enabletimedposts = true;
     $this->resetAfterTest();
     $course = $this->getDataGenerator()->create_course();
     // Create an user.
     $user = $this->getDataGenerator()->create_user();
     $this->getDataGenerator()->enrol_user($user->id, $course->id);
     // Create a forum.
     $record = new stdClass();
     $record->course = $course->id;
     $forum = $this->getDataGenerator()->create_module('forum', (object) array('course' => $course->id, 'groupmode' => SEPARATEGROUPS));
     $coursemodule = get_coursemodule_from_instance('forum', $forum->id);
     $now = time();
     $discussions = array();
     $discussiongenerator = $this->getDataGenerator()->get_plugin_generator('mod_forum');
     $record = new stdClass();
     $record->course = $course->id;
     $record->userid = $user->id;
     $record->forum = $forum->id;
     $record->pinned = FORUM_DISCUSSION_PINNED;
     $record->timemodified = $now;
     $record->timestart = $now + 10;
     $discussions[] = $discussiongenerator->create_discussion($record);
     $record->pinned = FORUM_DISCUSSION_UNPINNED;
     $discussions[] = $discussiongenerator->create_discussion($record);
     $record->timestart = $now;
     $discussions[] = $discussiongenerator->create_discussion($record);
     $record->pinned = FORUM_DISCUSSION_PINNED;
     $discussions[] = $discussiongenerator->create_discussion($record);
     // Expected order of discussions:
     // D2, d1, d3, d0.
     $this->setUser($user->id);
     // CHECK 1.
     $neighbours = forum_get_discussion_neighbours($coursemodule, $discussions[2], $forum);
     // Null check.
     $this->assertEmpty($neighbours['prev']);
     // D1 check.
     $this->assertEquals($discussions[1]->id, $neighbours['next']->id);
     // CHECK 2.
     $neighbours = forum_get_discussion_neighbours($coursemodule, $discussions[1], $forum);
     // D2 check.
     $this->assertEquals($discussions[2]->id, $neighbours['prev']->id);
     // D3 check.
     $this->assertEquals($discussions[3]->id, $neighbours['next']->id);
     // CHECK 3.
     $neighbours = forum_get_discussion_neighbours($coursemodule, $discussions[3], $forum);
     // D1 check.
     $this->assertEquals($discussions[1]->id, $neighbours['prev']->id);
     // D0 check.
     $this->assertEquals($discussions[0]->id, $neighbours['next']->id);
     // CHECK 4.
     $neighbours = forum_get_discussion_neighbours($coursemodule, $discussions[0], $forum);
     // D3 check.
     $this->assertEquals($discussions[3]->id, $neighbours['prev']->id);
     // Null check.
     $this->assertEmpty($neighbours['next']);
 }
开发者ID:rushi963,项目名称:moodle,代码行数:62,代码来源:lib_test.php


示例3: test_forum_get_neighbours_with_groups

 /**
  * Test getting the neighbour threads of a discussion.
  */
 public function test_forum_get_neighbours_with_groups()
 {
     $this->resetAfterTest();
     // Setup test data.
     $forumgen = $this->getDataGenerator()->get_plugin_generator('mod_forum');
     $course = $this->getDataGenerator()->create_course();
     $group1 = $this->getDataGenerator()->create_group(array('courseid' => $course->id));
     $group2 = $this->getDataGenerator()->create_group(array('courseid' => $course->id));
     $user1 = $this->getDataGenerator()->create_user();
     $user2 = $this->getDataGenerator()->create_user();
     $this->getDataGenerator()->enrol_user($user1->id, $course->id);
     $this->getDataGenerator()->enrol_user($user2->id, $course->id);
     $this->getDataGenerator()->create_group_member(array('userid' => $user1->id, 'groupid' => $group1->id));
     $forum1 = $this->getDataGenerator()->create_module('forum', array('course' => $course->id, 'groupmode' => VISIBLEGROUPS));
     $forum2 = $this->getDataGenerator()->create_module('forum', array('course' => $course->id, 'groupmode' => SEPARATEGROUPS));
     $cm1 = get_coursemodule_from_instance('forum', $forum1->id);
     $cm2 = get_coursemodule_from_instance('forum', $forum2->id);
     $context1 = context_module::instance($cm1->id);
     $context2 = context_module::instance($cm2->id);
     // Creating discussions in both forums.
     $record = new stdClass();
     $record->course = $course->id;
     $record->userid = $user1->id;
     $record->forum = $forum1->id;
     $record->groupid = $group1->id;
     $record->timemodified = time();
     $disc11 = $forumgen->create_discussion($record);
     $record->forum = $forum2->id;
     $record->timemodified++;
     $disc21 = $forumgen->create_discussion($record);
     $record->timemodified++;
     $record->userid = $user2->id;
     $record->forum = $forum1->id;
     $record->groupid = $group2->id;
     $disc12 = $forumgen->create_discussion($record);
     $record->forum = $forum2->id;
     $disc22 = $forumgen->create_discussion($record);
     $record->timemodified++;
     $record->userid = $user1->id;
     $record->forum = $forum1->id;
     $record->groupid = null;
     $disc13 = $forumgen->create_discussion($record);
     $record->forum = $forum2->id;
     $disc23 = $forumgen->create_discussion($record);
     $record->timemodified++;
     $record->userid = $user2->id;
     $record->forum = $forum1->id;
     $record->groupid = $group2->id;
     $disc14 = $forumgen->create_discussion($record);
     $record->forum = $forum2->id;
     $disc24 = $forumgen->create_discussion($record);
     $record->timemodified++;
     $record->userid = $user1->id;
     $record->forum = $forum1->id;
     $record->groupid = $group1->id;
     $disc15 = $forumgen->create_discussion($record);
     $record->forum = $forum2->id;
     $disc25 = $forumgen->create_discussion($record);
     // Admin user can see all groups.
     $this->setAdminUser();
     $neighbours = forum_get_discussion_neighbours($cm1, $disc11);
     $this->assertEmpty($neighbours['prev']);
     $this->assertEquals($disc12->id, $neighbours['next']->id);
     $neighbours = forum_get_discussion_neighbours($cm2, $disc21);
     $this->assertEmpty($neighbours['prev']);
     $this->assertEquals($disc22->id, $neighbours['next']->id);
     $neighbours = forum_get_discussion_neighbours($cm1, $disc12);
     $this->assertEquals($disc11->id, $neighbours['prev']->id);
     $this->assertEquals($disc13->id, $neighbours['next']->id);
     $neighbours = forum_get_discussion_neighbours($cm2, $disc22);
     $this->assertEquals($disc21->id, $neighbours['prev']->id);
     $this->assertEquals($disc23->id, $neighbours['next']->id);
     $neighbours = forum_get_discussion_neighbours($cm1, $disc13);
     $this->assertEquals($disc12->id, $neighbours['prev']->id);
     $this->assertEquals($disc14->id, $neighbours['next']->id);
     $neighbours = forum_get_discussion_neighbours($cm2, $disc23);
     $this->assertEquals($disc22->id, $neighbours['prev']->id);
     $this->assertEquals($disc24->id, $neighbours['next']->id);
     $neighbours = forum_get_discussion_neighbours($cm1, $disc14);
     $this->assertEquals($disc13->id, $neighbours['prev']->id);
     $this->assertEquals($disc15->id, $neighbours['next']->id);
     $neighbours = forum_get_discussion_neighbours($cm2, $disc24);
     $this->assertEquals($disc23->id, $neighbours['prev']->id);
     $this->assertEquals($disc25->id, $neighbours['next']->id);
     $neighbours = forum_get_discussion_neighbours($cm1, $disc15);
     $this->assertEquals($disc14->id, $neighbours['prev']->id);
     $this->assertEmpty($neighbours['next']);
     $neighbours = forum_get_discussion_neighbours($cm2, $disc25);
     $this->assertEquals($disc24->id, $neighbours['prev']->id);
     $this->assertEmpty($neighbours['next']);
     // Admin user is only viewing group 1.
     $_POST['group'] = $group1->id;
     $this->assertEquals($group1->id, groups_get_activity_group($cm1, true));
     $this->assertEquals($group1->id, groups_get_activity_group($cm2, true));
     $neighbours = forum_get_discussion_neighbours($cm1, $disc11);
     $this->assertEmpty($neighbours['prev']);
     $this->assertEquals($disc13->id, $neighbours['next']->id);
//.........这里部分代码省略.........
开发者ID:sree443,项目名称:JNS,代码行数:101,代码来源:lib_test.php



注:本文中的forum_get_discussion_neighbours函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP forum_get_discussion_subscription_icon函数代码示例发布时间:2022-05-15
下一篇:
PHP forum_get_courses_user_posted_in函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap