/**
  * Renders this ViewHelper
  *
  * @param AccessibleInterface $object The object for which the access is to be checked.
  * @param string $accessType The operation for which to check the access.
  * @return string The ViewHelper contents if the user has access to the specified operation.
  */
 public function render(AccessibleInterface $object, $accessType = 'read')
 {
     if ($object->checkAccess($this->frontendUserRepository->findCurrent(), $accessType)) {
         return $this->renderThenChild();
     } else {
         return $this->renderElseChild();
     }
 }
 /**
  *
  * Generates a data array that will be passed to the typoscript object for
  * rendering the icon.
  * @param \Mittwald\Typo3Forum\Domain\Model\Forum\Forum $forum
  *                             The topic for which the icon is to be displayed.
  * @return array               The data array for the typoscript object.
  *
  */
 protected function getDataArray(\Mittwald\Typo3Forum\Domain\Model\Forum\Forum $forum = NULL)
 {
     if ($forum === NULL) {
         return array();
     } else {
         $user =& $this->frontendUserRepository->findCurrent();
         return array('new' => !$forum->hasBeenReadByUser($user), 'closed' => !$forum->checkNewPostAccess($user));
     }
 }
 /**
  *
  * Generates a data array that will be passed to the typoscript object for
  * rendering the icon.
  * @param \Mittwald\Typo3Forum\Domain\Model\Forum\Topic $topic
  *                             The topic for which the icon is to be displayed.
  * @return array               The data array for the typoscript object.
  *
  */
 protected function getDataArray(\Mittwald\Typo3Forum\Domain\Model\Forum\Topic $topic = NULL)
 {
     if ($topic === NULL) {
         return array();
     } elseif ($topic instanceof \Mittwald\Typo3Forum\Domain\Model\Forum\ShadowTopic) {
         return array('moved' => TRUE);
     } else {
         return array('important' => $topic->getPostCount() >= $this->arguments['important'], 'new' => !$topic->hasBeenReadByUser($this->frontendUserRepository->findCurrent()), 'closed' => $topic->isClosed(), 'sticky' => $topic->isSticky(), 'solved' => $topic->getIsSolved());
     }
 }
 /**
  * Check if $value is valid. If it is not valid, needs to add an error
  * to Result.
  *
  * @param $value
  *
  * @return void
  */
 protected function isValid($value)
 {
     $result = TRUE;
     if (!$this->userRepository->findOneByUsername($value)) {
         $this->addError('PM reciepient user not found!', 1372429326);
         $result = FALSE;
     }
     $user = $this->userRepository->findCurrent();
     if ($user->getUsername() == $value) {
         $this->addError('You can\'t write yourself a message :)', 1372682275);
         $result = FALSE;
     }
     return $result;
 }
 public function getUser()
 {
     if ($this->user === -1) {
         $this->user = $this->frontendUserRepository->findCurrent();
     }
     return $this->user;
 }
 /**
  * Gets the currently logged in user. Convenience wrapper for the findCurrent
  * method of the frontend user repository.
  *
  * @return FrontendUser The user that is currently logged in.
  */
 protected function getCurrentUser()
 {
     return $this->frontendUserRepository->findCurrent();
 }