本文整理汇总了PHP中forum_discussion_view函数的典型用法代码示例。如果您正苦于以下问题:PHP forum_discussion_view函数的具体用法?PHP forum_discussion_view怎么用?PHP forum_discussion_view使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了forum_discussion_view函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: view_forum_discussion
/**
* Simulate the forum/discuss.php web interface page: trigger events
*
* @param int $discussionid the discussion id
* @return array of warnings and status result
* @since Moodle 2.9
* @throws moodle_exception
*/
public static function view_forum_discussion($discussionid)
{
global $DB, $CFG;
require_once $CFG->dirroot . "/mod/forum/lib.php";
$params = self::validate_parameters(self::view_forum_discussion_parameters(), array('discussionid' => $discussionid));
$warnings = array();
$discussion = $DB->get_record('forum_discussions', array('id' => $params['discussionid']), '*', MUST_EXIST);
$forum = $DB->get_record('forum', array('id' => $discussion->forum), '*', MUST_EXIST);
list($course, $cm) = get_course_and_cm_from_instance($forum, 'forum');
// Validate the module context. It checks everything that affects the module visibility (including groupings, etc..).
$modcontext = context_module::instance($cm->id);
self::validate_context($modcontext);
require_capability('mod/forum:viewdiscussion', $modcontext, null, true, 'noviewdiscussionspermission', 'forum');
// Call the forum/lib API.
forum_discussion_view($modcontext, $forum, $discussion);
$result = array();
$result['status'] = true;
$result['warnings'] = $warnings;
return $result;
}
开发者ID:educakanchay,项目名称:campus,代码行数:28,代码来源:externallib.php
示例2: test_forum_discussion_view
/**
* Test forum_discussion_view.
*/
public function test_forum_discussion_view()
{
global $CFG, $USER;
$this->resetAfterTest();
// Setup test data.
$course = $this->getDataGenerator()->create_course();
$forum = $this->getDataGenerator()->create_module('forum', array('course' => $course->id));
$discussion = $this->create_single_discussion_with_replies($forum, $USER, 2);
$context = context_module::instance($forum->cmid);
$cm = get_coursemodule_from_instance('forum', $forum->id);
// Trigger and capture the event.
$sink = $this->redirectEvents();
$this->setAdminUser();
forum_discussion_view($context, $forum, $discussion);
$events = $sink->get_events();
$this->assertCount(1, $events);
$event = array_pop($events);
// Checking that the event contains the expected values.
$this->assertInstanceOf('\\mod_forum\\event\\discussion_viewed', $event);
$this->assertEquals($context, $event->get_context());
$expected = array($course->id, 'forum', 'view discussion', "discuss.php?d={$discussion->id}", $discussion->id, $forum->cmid);
$this->assertEventLegacyLogData($expected, $event);
$this->assertEventContextNotUsed($event);
$this->assertNotEmpty($event->get_name());
}
开发者ID:rushi963,项目名称:moodle,代码行数:28,代码来源:lib_test.php
示例3: array
}
}
$params = array('context' => $destinationctx, 'objectid' => $discussion->id, 'other' => array('fromforumid' => $forum->id, 'toforumid' => $forumto->id));
$event = \mod_forum\event\discussion_moved::create($params);
$event->add_record_snapshot('forum_discussions', $discussion);
$event->add_record_snapshot('forum', $forum);
$event->add_record_snapshot('forum', $forumto);
$event->trigger();
// Delete the RSS files for the 2 forums to force regeneration of the feeds
require_once $CFG->dirroot . '/mod/forum/rsslib.php';
forum_rss_delete_file($forum);
forum_rss_delete_file($forumto);
redirect($return . '&moved=-1&sesskey=' . sesskey());
}
// Trigger discussion viewed event.
forum_discussion_view($modcontext, $forum, $discussion);
unset($SESSION->fromdiscussion);
if ($mode) {
set_user_preference('forum_displaymode', $mode);
}
$displaymode = get_user_preferences('forum_displaymode', $CFG->forum_displaymode);
if ($parent) {
// If flat AND parent, then force nested display this time
if ($displaymode == FORUM_MODE_FLATOLDEST or $displaymode == FORUM_MODE_FLATNEWEST) {
$displaymode = FORUM_MODE_NESTED;
}
} else {
$parent = $discussion->firstpost;
}
if (!($post = forum_get_post_full($parent))) {
print_error("notexists", 'forum', "{$CFG->wwwroot}/mod/forum/view.php?f={$forum->id}");
开发者ID:mongo0se,项目名称:moodle,代码行数:31,代码来源:discuss.php
注:本文中的forum_discussion_view函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论