當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。