当前位置: 首页>>代码示例>>PHP>>正文


PHP notification::enqueue_like_deleted方法代码示例

本文整理汇总了PHP中notification::enqueue_like_deleted方法的典型用法代码示例。如果您正苦于以下问题:PHP notification::enqueue_like_deleted方法的具体用法?PHP notification::enqueue_like_deleted怎么用?PHP notification::enqueue_like_deleted使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在notification的用法示例。


在下文中一共展示了notification::enqueue_like_deleted方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: save_likes_from_submit

 /** save a new comment from submit
  * 
  * @global record $USER
  * @global object $DB
  * @return array, result array.
  */
 public function save_likes_from_submit()
 {
     global $USER, $DB;
     if (empty($this->course->enablelikes)) {
         print_error('likesaredisabled', 'format_socialwall');
     }
     // Ensure that post exists and get the right courseid.
     $postid = required_param('postid', PARAM_INT);
     if (!($post = $DB->get_record('format_socialwall_posts', array('id' => $postid)))) {
         print_error('invalidpostid', 'format_socialwall');
     }
     $userlike = optional_param('userlike', '0', PARAM_INT);
     // ... check capability.
     $coursecontext = \context_course::instance($post->courseid);
     if (!has_capability('format/socialwall:like', $coursecontext)) {
         print_error('missingcaplikepost', 'format_socialwall');
     }
     $refresh = false;
     if (empty($userlike)) {
         if ($like = $DB->get_records('format_socialwall_likes', array('postid' => $postid, 'fromuserid' => $USER->id))) {
             $DB->delete_records_select('format_socialwall_likes', 'fromuserid = ? AND postid = ?', array($USER->id, $postid));
             $refresh = true;
             // We use a instant enqueueing, if needed you might use events here.
             notification::enqueue_like_deleted($post);
         }
     } else {
         if (!($like = $DB->get_records('format_socialwall_likes', array('postid' => $postid, 'fromuserid' => $USER->id)))) {
             $newlike = new \stdClass();
             $newlike->courseid = $this->course->id;
             $newlike->postid = $postid;
             $newlike->fromuserid = $USER->id;
             $newlike->timecreated = time();
             $DB->insert_record('format_socialwall_likes', $newlike);
             $refresh = true;
             notification::enqueue_like_created($post);
         }
     }
     $result = array('error' => '0', 'message' => 'likesaved', 'postid' => $postid, 'userlike' => $userlike, 'countcomments' => $post->countcomments, 'countlikes' => $post->countlikes);
     if ($refresh) {
         $posts = posts::instance($this->course->id);
         $result['countlikes'] = $posts->refresh_likes_count($postid);
     }
     return $result;
 }
开发者ID:nadavkav,项目名称:moodle-format_socialwall,代码行数:50,代码来源:likes.php


注:本文中的notification::enqueue_like_deleted方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。