Public: Check if current user has liked the comment

$user - user object

Returns true or false
342158
public function userLikedComment($ip, $useragent)
    {
        $count = BaseManager::build('FelixOnline\Core\Comment', 'comment_like')
            ->filter("ip = '%s'", array($ip))
            ->filter("user_agent = '%s'", array($useragent))
            ->filter("comment = %i", array($this->getId()))
            ->filter("binlike = 1")
            ->count();

        return (boolean) $count;
    }
252988
protected function check_edit_permission( $comment ) {
		if ( 0 === (int) get_current_user_id() ) {
			return false;
		}

		if ( ! current_user_can( 'moderate_comments' ) ) {
			return false;
		}

		return current_user_can( 'edit_comment', $comment->comment_ID );
	}
1336551
public function can_manually_control_post_read_status(stdClass $user) : bool {
        global $CFG;
        return $CFG->forum_usermarksread && isloggedin() && forum_tp_is_tracked($this->get_forum_record(), $user);
    }
1141927
public function liked($userId = null)
    {
        return app(LikeableServiceContract::class)->isLiked($this, LikeType::LIKE, $userId);
    }
1250386
public static function likeButton($id)
    {
        if (! is_user_logged_in()) {
            return;
        }

        $likes = get_comment_meta($id, '_likes', true);

        if (empty($likes) || is_array($likes) == false) {
            $count = 0;
        } else {
            $count = count($likes);
        }

        $classes = array('like-button');

        if (is_array($likes) == true && in_array(get_current_user_id(), $likes)) {
            $classes[] = 'active';
        }

        $output = '<a class="' . implode(' ', $classes) . '" href="javascript:void(0)" data-comment-id="' . $id . '">';
        $output .= '<span id="like-count">' . $count . '</span>';
        $output .= '</a>';

        return $output;
    }
965420
public function isUnread(User $user)
    {
        if ($this->posts->count() === 0) {
            return false;
        }

        return $this->posts->last()->isUnread($user);
    }
248445
def has_user(self, username):
        
        return self.model.objects.filter(
            **self._filter_user_by(username)
        ).exists()
1023915
public function should_show_for_user() {
        if (!$this->is_enabled()) {
            // The tour is disabled - it should not be shown.
            return false;
        }

        if ($tourcompletiondate = get_user_preferences(self::TOUR_LAST_COMPLETED_BY_USER . $this->get_id(), null)) {
            if ($tourresetdate = get_user_preferences(self::TOUR_REQUESTED_BY_USER . $this->get_id(), null)) {
                if ($tourresetdate >= $tourcompletiondate) {
                    return true;
                }
            }
            $lastmajorupdate = $this->get_config('majorupdatetime', time());
            if ($tourcompletiondate > $lastmajorupdate) {
                // The user has completed the tour since the last major update.
                return false;
            }
        }

        return true;
    }
1007814
function activity_userComments ($per_page = NULL, $page = NULL)
    {
        /** http://www.flickr.com/services/api/flickr.activity.userComments.html */
        $this->request('flickr.activity.userComments', array("per_page" => $per_page, "page" => $page));
        return $this->parsed_response ? $this->parsed_response['items']['item'] : false;
    }
165449
public function next_user() {
        if (!$this->users_rs) {
            return false; // no users present
        }

        if (!$this->users_rs->valid()) {
            if ($current = $this->_pop()) {
                // this is not good - user or grades updated between the two reads above :-(
            }

            return false; // no more users
        } else {
            $user = $this->users_rs->current();
            $this->users_rs->next();
        }

        // find grades of this user
        $grade_records = array();
        while (true) {
            if (!$current = $this->_pop()) {
                break; // no more grades
            }

            if (empty($current->userid)) {
                break;
            }

            if ($current->userid != $user->id) {
                // grade of the next user, we have all for this user
                $this->_push($current);
                break;
            }

            $grade_records[$current->itemid] = $current;
        }

        $grades = array();
        $feedbacks = array();

        if (!empty($this->grade_items)) {
            foreach ($this->grade_items as $grade_item) {
                if (!isset($feedbacks[$grade_item->id])) {
                    $feedbacks[$grade_item->id] = new stdClass();
                }
                if (array_key_exists($grade_item->id, $grade_records)) {
                    $feedbacks[$grade_item->id]->feedback       = $grade_records[$grade_item->id]->feedback;
                    $feedbacks[$grade_item->id]->feedbackformat = $grade_records[$grade_item->id]->feedbackformat;
                    unset($grade_records[$grade_item->id]->feedback);
                    unset($grade_records[$grade_item->id]->feedbackformat);
                    $grades[$grade_item->id] = new grade_grade($grade_records[$grade_item->id], false);
                } else {
                    $feedbacks[$grade_item->id]->feedback       = '';
                    $feedbacks[$grade_item->id]->feedbackformat = FORMAT_MOODLE;
                    $grades[$grade_item->id] =
                        new grade_grade(array('userid'=>$user->id, 'itemid'=>$grade_item->id), false);
                }
                $grades[$grade_item->id]->grade_item = $grade_item;
            }
        }

        // Set user suspended status.
        $user->suspendedenrolment = isset($this->suspendedusers[$user->id]);
        $result = new stdClass();
        $result->user      = $user;
        $result->grades    = $grades;
        $result->feedbacks = $feedbacks;
        return $result;
    }
517112
public function dislikeComment($ip, $useragent)
    {
        $app = App::getInstance();

        if (!$this->userLikedOrDislikedComment($ip, $useragent)) { // check user hasn't already liked the comment
            $sql = $app['safesql']->query(
                "INSERT INTO `comment_like`
				(
					ip,
					user_agent,
					comment,
					binlike,
					deleted
				) VALUES (
					'%s',
					'%s',
					%i,
					0,
					0
				)",
                array(
                    $ip,
                    $useragent,
                    $this->getId(),
                ));
            $app['db']->query($sql);

            $dislikes = $this->getDislikes() + 1;
            $this->setDislikes($dislikes)
                ->save();

            return $dislikes;
        } else {
            return false;
        }
    }
1046953
public function like($userId=null)
	{
		if(is_null($userId)) {
			$userId = $this->loggedInUserId();
		}
		
		if($userId) {
			$like = $this->likes()
				->where('user_id', '=', $userId)
				->first();
	
			if($like) return;
	
			$like = new Like();
			$like->user_id = $userId;
			$this->likes()->save($like);
		}

		$this->incrementLikeCount();
	}
971566
public function updateComment( $comment, $user=null, $time = null , $notified = null )
    {
        if ( $time === null )
        {
            $time = time();
        }

        $beforeUpdating = $this->beforeUpdatingComment( $comment, $notified, $time );
        if ( $beforeUpdating !== true )
        {
            return $beforeUpdating;
        }
        $comment->store();

        $afterUpdating = $this->afterUpdatingComment( $comment, $notified, $time );
        if ( $afterUpdating !== true )
        {
            return $afterUpdating;
        }
        return true;
    }
621974
def check_user_can_attach_file_to_comments(user_info, recid):
    
    # First can we find an authorization for this case action, for
    # this collection?
    record_primary_collection = guess_primary_collection_of_a_record(recid)
    return acc_authorize_action(
        user_info,
        'attachcommentfile',
        authorized_if_no_roles=False,
        collection=record_primary_collection)
536456
public function can_subscribe_to_forum(stdClass $user) : bool {
        if ($this->forum->get_type() == 'single') {
            return false;
        }

        return !is_guest($this->get_context(), $user) &&
            subscriptions::is_subscribable($this->get_forum_record());
    }
1274676
def updated(self, user, options):
        
        for comment in self.comments:
            created = dateutil.parser.parse(comment["created"]).date()
            try:
                if (comment["author"]["emailAddress"] == user.email and
                        created >= options.since.date and
                        created < options.until.date):
                    return True
            except KeyError:
                pass
        return False
1027080
public function can_view_post_shell(stdClass $user, post_entity $post) : bool {
        if (!$post->is_private_reply()) {
            return true;
        }

        if ($post->is_private_reply_intended_for_user($user)) {
            return true;
        }

        return $this->can_view_any_private_reply($user);
    }