/**
  * @param  string                    $projectId
  * @param  string                    $userId
  * @param  \libraries\shared\Website $website
  * @param  string                    $commentId
  * @param  string                    $replyId
  * @throws \Exception
  */
 public static function deleteReply($projectId, $userId, $website, $commentId, $replyId)
 {
     // if the userId is different from the author, throw if user does not have DELETE privilege
     $project = new LexiconProjectModel($projectId);
     $comment = new LexCommentModel($project, $commentId);
     $reply = $comment->getReply($replyId);
     if ($reply->authorInfo->createdByUserRef->asString() != $userId) {
         // if the userId is different from the author, throw if user does not have DELETE privilege
         $rh = new RightsHelper($userId, $project, $website);
         if (!$rh->userHasProjectRight(Domain::COMMENTS + Operation::DELETE)) {
             throw new \Exception("No permission to delete other people's comment replies!");
         }
     }
     $comment->deleteReply($replyId);
     $comment->write();
 }
 public function testPlusOneComment_UserAlready_ScoreIsSame()
 {
     $environ = new LexiconMongoTestEnvironment();
     $environ->clean();
     $project = $environ->createProject(SF_TESTPROJECT, SF_TESTPROJECTCODE);
     $user1Id = $environ->createUser('joe', 'joe', 'joe');
     $regarding = array('field' => 'lexeme', 'fieldValue' => 'Word 1', 'inputSystem' => 'th', 'word' => '', 'meaning' => '');
     $data = array('id' => '', 'content' => 'hi there!', 'regarding' => $regarding);
     $commentId = LexCommentCommands::updateComment($project->id->asString(), $user1Id, $environ->website, $data);
     $comment = new LexCommentModel($project, $commentId);
     $this->assertEquals(0, $comment->score);
     LexCommentCommands::plusOneComment($project->id->asString(), $user1Id, $commentId);
     LexCommentCommands::plusOneComment($project->id->asString(), $user1Id, $commentId);
     $comment->read($commentId);
     $this->assertEquals(1, $comment->score);
 }