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

PHP forum_print_discussion函数代码示例

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

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



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

示例1: grading_popup

 /**
  * Makes the pop up contents for the grading interface
  *
  * @param array $params
  * @param $coursemodule
  * @global moodle_database $DB
  * @global $PAGE
  * @global stdClass $CFG
  * @global $SESSION
  * @global $USER
  * @global $OUTPUT
  * @params object $coursemodule
  * @return string HTML
  */
 public function grading_popup($params, $coursemodule)
 {
     global $DB, $PAGE, $CFG, $SESSION, $USER, $OUTPUT;
     $output = '';
     // Lifted from /mod/forum/discuss.php...
     /*
      $parent = $params['parent'];       // If set, then display this post and all children.
      $mode   = $params['mode'];         // If set, changes the layout of the thread
      $move   = $params['move'];         // If set, moves this discussion to another forum
      $mark   = $params['mark'];       // Used for tracking read posts if user initiated.
      $postid = $params['postid'];       // Used for tracking read posts if user initiated.
     */
     $discussion = $DB->get_record('forum_discussions', array('id' => $params['discussionid']), '*', MUST_EXIST);
     $course = $DB->get_record('course', array('id' => $discussion->course), '*', MUST_EXIST);
     $forum = $DB->get_record('forum', array('id' => $discussion->forum), '*', MUST_EXIST);
     $cm = get_coursemodule_from_instance('forum', $forum->id, $course->id, false, MUST_EXIST);
     $modcontext = context_module::instance($cm->id);
     // Security - cmid is used to check context permissions earlier on, so it must match when
     // derived from the discussion.
     if (!($cm->id == $params['coursemoduleid'])) {
         print_error('Bad params!');
         return false;
     }
     // Add ajax-related libs.
     $PAGE->requires->yui2_lib('event');
     $PAGE->requires->yui2_lib('connection');
     $PAGE->requires->yui2_lib('json');
     // Move this down fix for MDL-6926.
     require_once $CFG->dirroot . '/mod/forum/lib.php';
     // Restrict news forums - should not be graded.
     if ($forum->type == 'news') {
         print_error('invaliddiscussionid', 'forum', "{$CFG->wwwroot}/mod/forum/view.php?f={$forum->id}");
     }
     unset($SESSION->fromdiscussion);
     // In case the user has used the drop-down to change from threaded to flat or something.
     if (isset($params['mode'])) {
         set_user_preference('forum_displaymode', $params['mode']);
     }
     $displaymode = get_user_preferences('forum_displaymode', $CFG->forum_displaymode);
     $parent = $discussion->firstpost;
     $post = forum_get_post_full($parent);
     if (!$post) {
         print_error("notexists", 'forum', "{$CFG->wwwroot}/mod/forum/view.php?f={$forum->id}");
     }
     if (!forum_user_can_view_post($post, $course, $cm, $forum, $discussion)) {
         print_error('nopermissiontoview', 'forum', "{$CFG->wwwroot}/mod/forum/view.php?id={$forum->id}");
     }
     // For now, restrict to rating only.
     $canreply = false;
     // Without this, the nesting doesn't work properly as the css isn't picked up.
     $output .= html_writer::start_tag('div', array('class' => 'path-mod-forum'));
     $output .= html_writer::start_tag('div', array('class' => 'discussioncontrols clearfix'));
     $output .= html_writer::start_tag('div', array('class' => 'discussioncontrol displaymode'));
     // We don't want to have the current mode returned in the url as well as the new one.
     unset($params['mode']);
     $newurl = new moodle_url('/blocks/ajax_marking/actions/grading_popup.php', $params);
     $select = new single_select($newurl, 'mode', forum_get_layout_modes(), $displaymode, null, "mode");
     $output .= $OUTPUT->render($select);
     $output .= html_writer::end_tag('div');
     // If user has not already posted and it's a Q & A forum...
     $forumisqanda = $forum->type == 'qanda';
     $noviewwithoutposting = !has_capability('mod/forum:viewqandawithoutposting', $modcontext);
     $hasnotposted = !forum_user_has_posted($forum->id, $discussion->id, $USER->id);
     if ($forumisqanda && $noviewwithoutposting && $hasnotposted) {
         $output .= $OUTPUT->notification(get_string('qandanotify', 'forum'));
     }
     $canrate = has_capability('mod/forum:rate', $modcontext);
     ob_start();
     forum_print_discussion($course, $cm, $forum, $discussion, $post, $displaymode, $canreply, $canrate);
     $output .= ob_get_contents();
     ob_end_clean();
     $output .= html_writer::end_tag('div');
     $output .= html_writer::end_tag('div');
     return $output;
 }
开发者ID:nadavkav,项目名称:moodle-block_ajax_marking,代码行数:89,代码来源:block_ajax_marking_forum.class.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP forum_print_discussion_header函数代码示例发布时间:2022-05-15
下一篇:
PHP forum_print_attachments函数代码示例发布时间: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