本文整理匯總了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;
}