/**
  * Check to see if a comment was updated within the last seven days
  *
  * @param Blog\Comment $comment
  *
  * @return bool
  */
 private function _commentFromThisWeek(Blog\Comment $comment)
 {
     if (null === $this->_aWeekAgo) {
         $this->_aWeekAgo = $this->_getDayTimestamp(new \DateTime('-1 week'));
     }
     return $this->_getDayTimestamp($comment->getUpdatedAt()) >= $this->_aWeekAgo;
 }
 /**
  * Add a query to save an individual comment to the transaction
  *
  * @param Comment $comment
  * @param UserInterface $user
  */
 private function _save(Comment $comment, UserInterface $user)
 {
     $this->_trans->add("\n\t\t\tUPDATE\n\t\t\t\tblog_comment\n\t\t\tSET\n\t\t\t\tpage_id       = :pageID?i,\n\t\t\t\tuser_id       = :userID?i,\n\t\t\t\t`name`        = :name?s,\n\t\t\t\temail_address = :email?s,\n\t\t\t\twebsite       = :website?sn,\n\t\t\t\tcontent       = :content?s,\n\t\t\t\tip_address    = :ipAddress?s,\n\t\t\t\tupdated_at    = :updatedAt?d,\n\t\t\t\tupdated_by    = :updatedBy?in,\n\t\t\t\tstatus        = :status?s\n\t\t\tWHERE\n\t\t\t\tcomment_id    = :id?i\n\t\t", ['id' => $comment->getID(), 'pageID' => $comment->getPageID(), 'userID' => $comment->getUserID(), 'name' => $comment->getName(), 'email' => $comment->getEmail(), 'website' => $comment->getWebsite(), 'content' => $comment->getContent(), 'ipAddress' => $comment->getIpAddress(), 'updatedAt' => new \DateTime(), 'updatedBy' => $user->id, 'status' => $comment->getStatus()]);
 }
 /**
  * Set the status of the comment, depending on the configuration of the blog post, and who is making the comment.
  * A super admin's comment will always be approved right away
  *
  * @param Comment $comment
  * @param Content $content
  *
  * @return Comment
  */
 private function _setStatus(Comment $comment, Content $content)
 {
     if (!$this->_user instanceof AnonymousUser) {
         $userGroups = $this->_userGroupLoader->getByUser($this->_user);
         foreach ($userGroups as $group) {
             if ($group->getName() === 'ms-super-admin') {
                 $comment->setStatus(Statuses::APPROVED);
                 return $comment;
             }
         }
     }
     $allowed = $content->{ContentOptions::COMMENTS}->{ContentOptions::ALLOW_COMMENTS}->getValue();
     $comment->setStatus($allowed === ContentOptions::APPROVE ? Statuses::PENDING : Statuses::APPROVED);
     return $comment;
 }
Ejemplo n.º 4
0
 /**
  * Render avatar to display next to comment
  *
  * @param Comment $comment
  * @param int $size
  * @param null $default
  *
  * @return \Message\Cog\HTTP\Response
  */
 public function renderAvatar(Comment $comment, $size = 50, $default = null)
 {
     $avatar = $this->get('avatar.provider.collection')->get($this->get('cfg')->blog->avatarProvider)->getAvatar($comment->getEmail(), $size, $default);
     return $this->render('Message:Mothership:CMS::modules:blog:avatar', ['avatar' => $avatar]);
 }
 /**
  * Save a new, individual comment
  *
  * @param Comment $comment
  * @return Comment
  */
 public function save(Comment $comment)
 {
     $result = $this->_query->run("\n\t\t\tINSERT INTO\n\t\t\t\tblog_comment\n\t\t\tSET\n\t\t\t\tpage_id = :pageID?i,\n\t\t\t\tuser_id = :userID?in,\n\t\t\t\t`name`  = :name?s,\n\t\t\t\temail_address = :email?s,\n\t\t\t\twebsite = :website?sn,\n\t\t\t\tcontent = :content?s,\n\t\t\t\tip_address = :ipAddress?s,\n\t\t\t\tcreated_at = :createdAt?d,\n\t\t\t\tupdated_at = :updatedAt?d,\n\t\t\t\tupdated_by = :updatedBy?in,\n\t\t\t\tstatus = :status?s\n\t\t", ['pageID' => $comment->getPageID(), 'userID' => $comment->getUserID(), 'name' => $comment->getName(), 'email' => $comment->getEmail(), 'website' => $comment->getWebsite(), 'content' => $comment->getContent(), 'ipAddress' => $comment->getIpAddress(), 'createdAt' => new \DateTime(), 'updatedAt' => new \DateTime(), 'updatedBy' => $comment->getUserID(), 'status' => $comment->getStatus()]);
     $comment->setID($result->id());
     return $comment;
 }