Ejemplo n.º 1
0
 /**
  * @param QueryResultInterface $objects
  * @param string $action
  * @return array
  */
 protected function filterByAccess(QueryResultInterface $objects, $action = 'read')
 {
     $result = array();
     foreach ($objects as $forum) {
         if ($this->authenticationService->checkAuthorization($forum, $action)) {
             $result[] = $forum;
         }
     }
     return $result;
 }
 /**
  * render
  *
  * @param bool|TRUE $link
  *
  * @return string
  */
 public function render($link = TRUE)
 {
     $user = $this->authenticationService->getUser();
     if ($link) {
         $uriBuilder = $this->controllerContext->getUriBuilder();
         $uri = $uriBuilder->setTargetPageUid($this->settings['pids']['UserShow'])->setArguments(array('tx_typo3forum_pi1[user]' => $user->getUid(), 'tx_typo3forum_pi1[controller]' => 'User', 'tx_typo3forum_pi1[action]' => 'show'))->build();
         return '<a href="' . $uri . '" title="' . $user->getUsername() . '">' . $user->getUsername() . '</a>';
     } else {
         return $user->getUsername();
     }
 }
 /**
  * @param \Mittwald\Typo3Forum\Domain\Model\Forum\Post $post
  * @param string $countTarget
  * @param string $countUserTarget
  * @param string $title
  * @return string
  */
 public function render(\Mittwald\Typo3Forum\Domain\Model\Forum\Post $post, $countTarget = NULL, $countUserTarget = NULL, $title = '')
 {
     $class = $this->settings['forum']['post']['helpfulBtn']['iconClass'];
     if ($this->hasArgument('class')) {
         $class .= ' ' . $this->arguments['class'];
     }
     if ($post->getAuthor()->getUid() != $this->authenticationService->getUser()->getUid() and !$this->authenticationService->getUser()->isAnonymous()) {
         $class .= ' tx-typo3forum-helpfull-btn';
     }
     if ($post->hasBeenSupportedByUser($this->authenticationService->getUser())) {
         $class .= ' supported';
     }
     $btn = '<div data-toogle="tooltip" title="' . $title . '" data- class="' . $class . '" data-countusertarget="' . $countUserTarget . '" data-counttarget="' . $countTarget . '" data-post="' . $post->getUid() . '" data-pageuid="' . $this->settings['pids']['Forum'] . '" data-eid="' . $this->settings['forum']['post']['helpfulBtn']['eID'] . '"></div>';
     return $btn;
 }
Ejemplo n.º 4
0
 /**
  * Gets all VISIBLE child forums. This function does NOT simply return
  * all child forums, but performs an access check on each forum, so
  * that only forums visible to the current user are returned.
  *
  * @return ObjectStorage<\Mittwald\Typo3Forum\Domain\Model\Forum\Forum> All visible child forums
  */
 public function getChildren()
 {
     if ($this->visibleChildren === NULL) {
         $this->visibleChildren = new \ArrayObject();
         // Note: Use the authentication service instead of performing the
         // access checks on the domain objects themselves, since the authentication
         // service caches its results (which should be safe in this case).
         foreach ($this->children as $child) {
             if ($this->authenticationService->checkAuthorization($child, 'read')) {
                 $this->visibleChildren->append($child);
             }
         }
     }
     return $this->visibleChildren;
 }