예제 #1
0
 /**
  *
  * @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;
 }
예제 #2
0
 /**
  * Sets the post author.
  *
  * @param FrontendUser $author The post author.
  *
  * @return void
  */
 public function setAuthor(FrontendUser $author)
 {
     if ($author->isAnonymous()) {
         $this->author = NULL;
     } else {
         $this->author = $author;
     }
 }
예제 #3
0
 /**
  * Matches a certain user against this access rule.
  *
  * @throws \Exception
  * @param FrontendUser $user The user to be matched. Can also be NULL (for anonymous  users).
  * @return bool TRUE if this access rule matches the given user, otherwise FALSE. This result may be negated using the "negate" property.
  */
 public function matches(FrontendUser $user = NULL)
 {
     $result = FALSE;
     if ($this->loginLevel === self::LOGIN_LEVEL_EVERYONE) {
         $result = TRUE;
     }
     if ($this->loginLevel === self::LOGIN_LEVEL_ANYLOGIN && $user !== NULL && !$user->isAnonymous()) {
         $result = TRUE;
     }
     if ($this->loginLevel === self::LOGIN_LEVEL_SPECIFIC) {
         if (!$this->affectedGroup instanceof FrontendUserGroup) {
             throw new \Exception('access record #' . $this->getUid() . ' is of login level type "specific", but has not valid affected user group', 1436527735);
         }
         if ($user !== NULL) {
             foreach ($user->getUsergroup() as $group) {
                 /** @var $group \Mittwald\Typo3Forum\Domain\Model\User\FrontendUserGroup */
                 if ($group->getUid() === $this->affectedGroup->getUid()) {
                     $result = TRUE;
                     break;
                 }
             }
         }
     }
     return $result;
 }