當前位置: 首頁>>代碼示例>>PHP>>正文


PHP notification::enqueue_comment_created方法代碼示例

本文整理匯總了PHP中notification::enqueue_comment_created方法的典型用法代碼示例。如果您正苦於以下問題:PHP notification::enqueue_comment_created方法的具體用法?PHP notification::enqueue_comment_created怎麽用?PHP notification::enqueue_comment_created使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在notification的用法示例。


在下文中一共展示了notification::enqueue_comment_created方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: save_comment_from_submit

 /** 
  * Save a new comment from submit
  * 
  * @param object $comment submitted data from form.
  * @return array result array to use for ajax and non ajax request.
  */
 public function save_comment_from_submit($comment, $course)
 {
     global $USER, $DB;
     // Ensure that post exists and get the right courseid.
     if (!($post = $DB->get_record('format_socialwall_posts', array('id' => $comment->postid)))) {
         print_error('invalidpostid', 'format_socialwall');
     }
     // ... if post is locked or user has no cap to save, don't save the comment.
     $coursecontext = \context_course::instance($post->courseid);
     if (!has_capability('format/socialwall:writecomment', $coursecontext)) {
         print_error('missingcapwritecomment', 'format_socialwall');
     }
     $comment->courseid = $post->courseid;
     $comment->fromuserid = $USER->id;
     $comment->timecreated = time();
     $comment->timemodified = $comment->timecreated;
     // ... check if post is locked.
     if ($post->locked != 0) {
         print_error('postislocked', 'format_socialwall');
     }
     // ...insert comment.
     if (!($comment->id = $DB->insert_record('format_socialwall_comments', $comment))) {
         print_error('commentsaveerror', 'format_socialwall');
     }
     $result = array('error' => '0', 'message' => 'commentsaved', 'commentid' => $comment->id, 'postid' => $comment->postid, 'replycommentid' => $comment->replycommentid, 'countlikes' => 0, 'countcomments' => 0);
     $posts = posts::instance($comment->courseid);
     if ($post = $posts->refresh_comments_count($comment->postid)) {
         $result['countlikes'] = $post->countlikes;
         $result['countcomments'] = $post->countcomments;
     }
     // If this new comment is a reply update the countreplies attribute.
     if ($comment->replycommentid > 0) {
         $result['countreplies'] = $this->refresh_replies_count($comment->replycommentid);
     }
     // We use a instant enqueueing, if needed you might use events here.
     notification::enqueue_comment_created($comment);
     return $result;
 }
開發者ID:HarcourtsAcademy,項目名稱:moodle-format_socialwall,代碼行數:44,代碼來源:comments.php


注:本文中的notification::enqueue_comment_created方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。