当前位置: 首页>>代码示例>>PHP>>正文


PHP comments::add_comments_to_posts方法代码示例

本文整理汇总了PHP中comments::add_comments_to_posts方法的典型用法代码示例。如果您正苦于以下问题:PHP comments::add_comments_to_posts方法的具体用法?PHP comments::add_comments_to_posts怎么用?PHP comments::add_comments_to_posts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在comments的用法示例。


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

示例1: add_posts_data

 /**
  * Add all post data, which is necessary for rendering the posts
  * 
  * @param object $course
  * @param  object $postsdata containing retrieved posts in $postdata->post
  * @return object the postdata object with all of the data added
  */
 protected function add_posts_data($course, &$postsdata)
 {
     global $DB;
     if (empty($postsdata->posts)) {
         return $postsdata;
     }
     $courseid = $course->id;
     // ... gather all the authors ids from posts.
     foreach ($postsdata->posts as &$post) {
         $postsdata->authors[$post->fromuserid] = $post->fromuserid;
     }
     // ... add all comments, replies to comments and add more authors.
     comments::add_comments_to_posts($postsdata, $course->tlnumcomments, $course->tlnumreplies);
     // ... add all likes from this user.
     $likes = likes::instance($course);
     $likes->add_likes_to_posts($postsdata);
     // ... add all attachments.
     attaches::add_attaches_to_posts($courseid, $postsdata);
     // ... finally gather all the required userdata for authors.
     if (!($users = $DB->get_records_list('user', 'id', array_keys($postsdata->authors)))) {
         debugging('error while retrieving post authors');
     }
     $postsdata->authors = $users;
     return $postsdata;
 }
开发者ID:HarcourtsAcademy,项目名称:moodle-format_socialwall,代码行数:32,代码来源:posts.php

示例2: add_posts_data

 /** add all post data, which is necessary for rendering the posts
  * 
  * @global object $DB
  * @param record $course
  * @param  object $postsdata containing retrieved posts in $postdata->post
  * @return object the postdata object with all of the data added
  */
 protected function add_posts_data($course, &$postsdata)
 {
     global $DB;
     if (empty($postsdata->posts)) {
         return $postsdata;
     }
     $courseid = $course->id;
     // ... gather all the authors ids from posts.
     foreach ($postsdata->posts as &$post) {
         $postsdata->authors[$post->fromuserid] = $post->fromuserid;
     }
     // ... add all comments and add more authors.
     comments::add_comments_to_posts($postsdata, $course->tlnumcomments);
     // ... add all likes from this user.
     $likes = likes::instance($course);
     $likes->add_likes_to_posts($postsdata);
     // ... add all attachments.
     attaches::add_attaches_to_posts($courseid, $postsdata);
     // ... finally gather all the required userdata for authors.
     $params = array();
     list($inuserids, $params) = $DB->get_in_or_equal(array_keys($postsdata->authors));
     $sql = "SELECT * FROM {user} WHERE id {$inuserids}";
     if (!($users = $DB->get_records_sql($sql, $params))) {
         debugging('error while retrieving post authors');
     }
     $postsdata->authors = $users;
     return $postsdata;
 }
开发者ID:nadavkav,项目名称:moodle-format_socialwall,代码行数:35,代码来源:posts.php


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