当前位置: 首页>>代码示例>>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;未经允许,请勿转载。