/** * * @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; }
/** * Performs an access check for this post. * * @access private * * @param FrontendUser $user * @param string $accessType * @return boolean */ public function checkAccess(FrontendUser $user = NULL, $accessType = 'moderate') { switch ($accessType) { default: foreach ($user->getUsergroup() as $group) { if ($group->getUserMod()) { return TRUE; } } return FALSE; } }
/** * 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; }