Update the comment
@param $comment comment to be updated
@param $notified change the notification
@param $time
@param $user user to change
@return
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;
    }
888827
def comment_sync(self, comment):
        """"""
        self.host.update(key="comment", value=comment)
        self.host.emit("commented", comment=comment)
1026898
public function ircKick($channel, $user, $comment = null)
    {
        return $this->getIrcMessage('KICK', array($channel, $user, $comment));
    }
1279462
public function addComment($comment)
    {
        $comment->setPaymentId($this->getPaymentId());
        $comment->save();

        $this->load($this->getPaymentId());

        return $comment;
    }
361776
public function changeCommentState()
    {
        $userIsAllowed = $this
            ->userCredentialsProvider
            ->isAllowed();
        if (!$userIsAllowed) {
            return new JsonResponse([
                'status' => 'Error',
                'message' => 'The user is not allowed to do this',
            ], 401);
        }

        $userIsModerator = $this->userCredentialsProvider->isModerator();
        if (!$userIsModerator) {
            return new JsonResponse([
                'status' => 'Error',
                'message' => 'User must have the moderator role',
            ], 401);
        }

        $sourceUUID = $this->getSourceUUID();
        if (empty($sourceUUID)) {
            return new JsonResponse([
                'status' => 'Error',
                'message' => 'Source UUID header must be defined',
            ], 400);
        }

        $postParameterBag = $this
            ->request
            ->request;
        $newState = $postParameterBag->get('new_state');
        $commentId = $postParameterBag->get('comment_id');

        if (
            empty($newState) ||
            empty($commentId)
        ) {
            return new JsonResponse([
                'status' => 'Error',
                'message' => 'Some query parameters are missing',
            ], 400);
        }

        $comment = $this
            ->commentRepository
            ->findComment(new CommentUUID($commentId))
            ->getFirstComment();

        if (!$comment instanceof Comment) {
            return new JsonResponse([
                'status' => 'Error',
                'message' => 'Comment not found',
            ], 404);
        }

        $comment->setState((int) $newState);
        $this
            ->commentRepository
            ->addComment($comment);
        $this->flushRepository();

        return new JsonResponse([
            'status' => 'OK',
            'comment' => $comment->toArray(),
            'user' => $this->userCredentialsProvider->toArray(),
        ], 200);
    }
409927
public function UpdateUser($UserID, $Inc = FALSE) {
      if ($Inc) {
         // Just increment the comment count.
         $this->SQL
            ->Update('User')
            ->Set('CountComments', 'CountComments + 1', FALSE)
            ->Where('UserID', $UserID)
            ->Put();
      } else {
         // Retrieve a comment count
         $CountComments = $this->SQL
            ->Select('c.CommentID', 'count', 'CountComments')
            ->From('Comment c')
            ->Where('c.InsertUserID', $UserID)
            ->Get()
            ->FirstRow()
            ->CountComments;

         // Save to the attributes column of the user table for this user.
         Gdn::UserModel()->SetField($UserID, 'CountComments', $CountComments);
      }
   }
535122
public function changeComment($comment)
    {
        $this->actions->addAction(new ChangeComment($this->table, $comment));

        return $this;
    }
636678
public function Comment($Comment) {
      $Comment['InsertUserID'] = Gdn::Session()->UserID;
      $Comment['DateInserted'] = Gdn_Format::ToDateTime();
      $Comment['InsertIPAddress'] = Gdn::Request()->IpAddress();
      
      $this->Validation->ApplyRule('ActivityID', 'Required');
      $this->Validation->ApplyRule('Body', 'Required');
      $this->Validation->ApplyRule('DateInserted', 'Required');
      $this->Validation->ApplyRule('InsertUserID', 'Required');
      
      $this->EventArguments['Comment'] = $Comment;
      $this->FireEvent('BeforeSaveComment');
      
      if ($this->Validate($Comment)) {
         $Activity = $this->GetID($Comment['ActivityID'], DATASET_TYPE_ARRAY);
         Gdn::Controller()->Json('Activity', $CommentActivityID);
         
         $_ActivityID = $Comment['ActivityID'];
         // Check to see if this is a shared activity/notification.
         if ($CommentActivityID = GetValue('CommentActivityID', $Activity['Data'])) {
            Gdn::Controller()->Json('CommentActivityID', $CommentActivityID);
            $Comment['ActivityID'] = $CommentActivityID;
         }
         
         // Check for spam.
         $Spam = SpamModel::IsSpam('ActivityComment', $Comment);
         if ($Spam)
            return SPAM;
         
         // Check for approval
         $ApprovalRequired = CheckRestriction('Vanilla.Approval.Require');
         if ($ApprovalRequired && !GetValue('Verified', Gdn::Session()->User)) {
         	LogModel::Insert('Pending', 'ActivityComment', $Comment);
         	return UNAPPROVED;
         }
         
         $ID = $this->SQL->Insert('ActivityComment', $Comment);
         
         if ($ID) {
            // Check to see if this comment bumps the activity.
            if ($Activity && GetValue('Bump', $Activity['Data'])) {
               $this->SQL->Put('Activity', array('DateUpdated' => $Comment['DateInserted']), array('ActivityID' => $Activity['ActivityID']));
               if ($_ActivityID != $Comment['ActivityID']) {
                  $this->SQL->Put('Activity', array('DateUpdated' => $Comment['DateInserted']), array('ActivityID' => $_ActivityID));
               }
            }
         }
         
         return $ID;
      }
      return FALSE;
   }
1089252
public function commentAction(Request $request, $resourceId, User $user)
    {
        $text = $request->get('social_media_comment_text');

        if ($text !== null) {
            $comment = new CommentAction();
            $comment->setText($text);
            $comment->setUser($user);
            $commentManager = $this->getCommentActionManager();
            $userIds = $commentManager->getHasCommentedUserIds($resourceId);
            $commentManager->createComment($resourceId, $comment);
            $this->dispatchCommentEvent($comment, $userIds);
        }
        if ($request->isXmlHttpRequest()) {
            $response = new JsonResponse(true);
        } else {
            $response = $this->redirectToRoute('icap_socialmedia_comments_view', array('resourceId' => $resourceId));
        }

        return $response;
    }
886630
public function dispatchCommentOnAddEvent(CommentInterface $comment)
    {
        $event = new CommentOnAddEvent(
            $comment
        );

        $this
            ->eventDispatcher
            ->dispatch(ElcodiCommentEvents::COMMENT_ONADD, $event);

        return $this;
    }
248863
private function updateComment($id=NULL)
	{
		$model = $this->getCommentModel($id);

		// Make sure the user has permission to edit this comment
		if ($this->user->user_role != 6 && $this->user->user_role != 9)
		{
			if ($model->user_id != $this->user->id)
				throw new CHttpException(403, Yii::t('Api.comment', 'You do not have permission to edit this comment'));
		}

		$model->attributes = $_POST;
		$model->user_id = $this->user->id;

		if ($model->save())
			return $model->getApiAttributes();

		return $this->returnError(400, NULL, $model->getErrors());
	}
1371053
public function update(Request $request, Comment $comment)
    {
        $this->authorize('edit-comment', $comment);

        $this->validate($request, [
            'message' => 'required|string'
        ]);

        $comment->update([
            'comment' => $request->message
        ]);

        return redirect()->to(url()->previous() . '#comment-' . $comment->id);
    }
870810
public function setComment(\Haven\CmsBundle\Entity\Comment $comment = null)
    {
        $this->comment = $comment;

        return $this;
    }
251432
public function SetWatch($Discussion, $Limit, $Offset, $TotalComments) {
      
      $NewComments = FALSE;
      
      $Session = Gdn::Session();
      if ($Session->UserID > 0) {
         
         // Max comments we could have seen
         $CountWatch = $Limit * ($Offset + 1);
         if ($CountWatch > $TotalComments)
            $CountWatch = $TotalComments;
         
         // This dicussion looks familiar...
         if (is_numeric($Discussion->CountCommentWatch)) {
            
            if (isset($Discussion->DateLastViewed))
               $NewComments |= Gdn_Format::ToTimestamp($Discussion->DateLastComment) > Gdn_Format::ToTimestamp($Discussion->DateLastViewed);
            
            if ($TotalComments > $Discussion->CountCommentWatch)
               $NewComments |= TRUE;

            // Update the watch data.
				if ($NewComments) {
               
					// Only update the watch if there are new comments.
					$this->SQL->Put(
						'UserDiscussion',
						array(
							'CountComments' => $CountWatch,
                     'DateLastViewed' => Gdn_Format::ToDateTime()
						),
						array(
							'UserID' => $Session->UserID,
							'DiscussionID' => $Discussion->DiscussionID
						)
					);
				}
            
         } else {
				// Make sure the discussion isn't archived.
				$ArchiveDate = C('Vanilla.Archive.Date', FALSE);
				if (!$ArchiveDate || (Gdn_Format::ToTimestamp($Discussion->DateLastComment) > Gdn_Format::ToTimestamp($ArchiveDate))) {
               
               $NewComments = TRUE;
               
					// Insert watch data.
               $this->SQL->Options('Ignore', TRUE);
					$this->SQL->Insert(
						'UserDiscussion',
						array(
							'UserID' => $Session->UserID,
							'DiscussionID' => $Discussion->DiscussionID,
							'CountComments' => $CountWatch,
                     'DateLastViewed' => Gdn_Format::ToDateTime()
						)
					);
				}
			}
         
         /**
          * Fuzzy way of trying to automatically mark a cateogyr read again
          * if the user reads all the comments on the first few pages.
          */
         
         // If this discussion is in a category that has been marked read, 
         // check if reading this thread causes it to be completely read again
         $CategoryID = GetValue('CategoryID', $Discussion);
         if ($CategoryID) {
            
            $Category = CategoryModel::Categories($CategoryID);
            if ($Category) {
               
               $DateMarkedRead = GetValue('DateMarkedRead', $Category);
               if ($DateMarkedRead) {
                  
                  // Fuzzy way of looking back about 2 pages into the past
                  $LookBackCount = C('Vanilla.Discussions.PerPage', 50) * 2;
                  
                  // Find all discussions with content from after DateMarkedRead
                  $DiscussionModel = new DiscussionModel();
                  $Discussions = $DiscussionModel->Get(0, 101, array(
                     'CategoryID'         => $CategoryID,
                     'DateLastComment>'   => $DateMarkedRead
                  ));
                  unset($DiscussionModel);
                  
                  // Abort if we get back as many as we asked for, meaning a 
                  // lot has happened.
                  $NumDiscussions = $Discussions->NumRows();
                  if ($NumDiscussions <= $LookBackCount) {
                  
                     // Loop over these and see if any are still unread
                     $MarkAsRead = TRUE;
                     while ($Discussion = $Discussions->NextRow(DATASET_TYPE_ARRAY)) {
                        if ($Discussion['Read']) continue;
                        $MarkAsRead = FALSE;
                        break;
                     }

                     // Mark this category read if all the new content is read
                     if ($MarkAsRead) {
                        $CategoryModel = new CategoryModel();
                        $CategoryModel->SaveUserTree($CategoryID, array('DateMarkedRead' => Gdn_Format::ToDateTime()));
                        unset($CategoryModel);
                     }
                     
                  }
               }
            }
         }
         
		}
   }
470485
public function dispatchCommentUpdateEvent(Post $post, Comment $comment, $changeSet)
    {
        $event = new LogCommentUpdateEvent($post, $comment, $changeSet, $this->translator);

        return $this->dispatch($event);
    }
822312
public function getNewComment(Portfolio $portfolio, User $user)
    {
        $comment = $this->commentFactory->createComment($portfolio, $user);

        return $comment;
    }
63739
public function dispatchCommentCreateEvent(Post $post, Comment $comment)
    {
        $event = new LogCommentCreateEvent($post, $comment, $this->translator);

        return $this->dispatch($event);
    }