本文整理汇总了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;
}
示例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;
}