/**
  * Renders the contents of this view helper, when a user has subscribed a
  * specific subscribeable object.
  *
  * @param \Mittwald\Typo3Forum\Domain\Model\SubscribeableInterface $object
  *                             The object that needs to be subscribed in order
  *                             for the contents to be rendered.
  * @param \Mittwald\Typo3Forum\Domain\Model\User\FrontendUser      $user
  * @return string
  *
  */
 public function render(\Mittwald\Typo3Forum\Domain\Model\SubscribeableInterface $object, \Mittwald\Typo3Forum\Domain\Model\User\FrontendUser $user = NULL)
 {
     if ($user === NULL) {
         $user =& \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Mittwald\\Typo3Forum\\Domain\\Repository\\User\\FrontendUserRepository')->findCurrent();
     }
     foreach ($object->getFavSubscribers() as $subscriber) {
         if ($subscriber->getUid() == $user->getUid()) {
             return $this->renderThenChild();
         }
     }
     return $this->renderElseChild();
 }
 /**
  *
  * @param \Mittwald\Typo3Forum\Domain\Model\User\FrontendUser $user
  * @param boolean $showOnlineStatus
  * @param boolean $showOnline
  * @return string
  */
 public function render(\Mittwald\Typo3Forum\Domain\Model\User\FrontendUser $user = NULL, $showOnlineStatus = TRUE, $showOnline = FALSE)
 {
     // if user anonymous: show only the username
     if ($user->isAnonymous()) {
         return $user->getUsername();
     }
     // use uribuilder to genreate the uri for the userprofile
     $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();
     $class = 'user-link';
     if ($this->hasArgument('class')) {
         $class .= ' ' . $this->arguments['class'];
     }
     $fullUsername = htmlspecialchars($user->getUsername());
     $limit = (int) $this->settings['cutUsernameOnChar'];
     if ($limit == 0 || strlen($fullUsername) <= $limit) {
         $username = $fullUsername;
     } else {
         $username = substr($fullUsername, 0, $limit) . "...";
     }
     $moderatorMark = "";
     if ($this->settings['moderatorMark']['image']) {
         foreach ($user->getUsergroup() as $group) {
             /** @var FrontendUserGroup $group */
             if ($group->getUserMod() === 1) {
                 $moderatorMark = '<img src="' . $this->settings['moderatorMark']['image'] . '" title="' . $this->settings['moderatorMark']['title'] . '" />';
                 break;
             }
         }
     }
     if ($showOnlineStatus) {
         if ($showOnline) {
             $onlineStatus = 'user_onlinepoint iconset-8-user-online';
         } else {
             $onlineStatus = 'user_onlinepoint iconset-8-user-offline';
         }
         $link = '<a href="' . $uri . '" class="' . $class . '" title="' . $fullUsername . '">' . $username . ' <i class="' . $onlineStatus . '" data-uid="' . $user->getUid() . '"></i> ' . $moderatorMark . '</a>';
     } else {
         $link = '<a href="' . $uri . '" class="' . $class . '" title="' . $fullUsername . '">' . $username . ' ' . $moderatorMark . '</a>';
     }
     return $link;
 }
Beispiel #3
0
 /**
  * Checks if a user has solution access to this topic.
  *
  * @param \Mittwald\Typo3Forum\Domain\Model\User\FrontendUser $user
  *
  * @return boolean
  */
 public function checkSolutionAccess(\Mittwald\Typo3Forum\Domain\Model\User\FrontendUser $user = NULL)
 {
     if ($this->getAuthor()->getUid() == $user->getUid() || $this->checkModerationAccess($user)) {
         return true;
     } else {
         return false;
     }
 }
    /**
     * @param Forum $forum
     * @param FrontendUser $user
     * @return array
     */
    public function getUnreadTopics(Forum $forum, FrontendUser $user)
    {
        $sql = 'SELECT t.uid
			   FROM tx_typo3forum_domain_model_forum_topic AS t
			   LEFT JOIN tx_typo3forum_domain_model_user_readtopic AS rt
					   ON rt.uid_foreign = t.uid AND rt.uid_local = ' . (int) $user->getUid() . '
			   WHERE rt.uid_local IS NULL AND t.forum=' . (int) $forum->getUid();
        /** @var Query $query */
        $query = $this->createQuery();
        $query->statement($sql);
        return $query->execute()->toArray();
    }