/** * Find the rank of a specific user * * @param \Mittwald\Typo3Forum\Domain\Model\User\FrontendUser $user * * @return \Mittwald\Typo3Forum\Domain\Model\User\Rank[] */ public function findRankByUser(\Mittwald\Typo3Forum\Domain\Model\User\FrontendUser $user) { $query = $this->createQuery(); $query->matching($query->lessThan('point_limit', $user->getPoints())); $query->setOrderings(array('point_limit' => 'DESC')); $query->setLimit(1); return $query->execute(); }
/** * Gets the topic to which the reported post belongs to. * @return \Mittwald\Typo3Forum\Domain\Model\User\FrontendUser Frontend User */ public function getUser() { if ($this->feuser instanceof \TYPO3\CMS\Extbase\Persistence\Generic\LazyLoadingProxy) { $this->feuser->_loadRealInstance(); } if ($this->feuser === NULL) { $this->feuser = new \Mittwald\Typo3Forum\Domain\Model\User\AnonymousFrontendUser(); } return $this->feuser; }
/** * Renders the avatar. * * @param \Mittwald\Typo3Forum\Domain\Model\User\FrontendUser|NULL $user * * @return null|string */ public function render(\Mittwald\Typo3Forum\Domain\Model\User\FrontendUser $user = NULL) { // if user ist not set $avatarFilename = NULL; if ($user != NULL) { $avatarFilename = $user->getImagePath(); } if ($avatarFilename === NULL) { $avatarFilename = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath('typo3_forum') . 'Resources/Public/Images/Icons/AvatarEmpty.png'; } return $avatarFilename; }
/** * 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(); }
/** * Determines the value for this userfield and a specific user. * * @param \Mittwald\Typo3Forum\Domain\Model\User\FrontendUser $user * The user for which the value of this userfield is * to be determined. * * @return string The userfield value. */ public function getValueForUser(\Mittwald\Typo3Forum\Domain\Model\User\FrontendUser $user) { if ($this->isMappedToUserObject()) { $propertyNames = explode('|', $this->getUserObjectPropertyName()); $propertyValues = array(); foreach ($propertyNames as $propertyName) { $propertyValues[] = $user->_getProperty($propertyName); } return $propertyValues; } else { foreach ($user->getUserfieldValues() as $userfieldValue) { if ($userfieldValue->getUserfield() == $userfield) { return array($userfieldValue->getValue()); } } return NULL; } }
/** * Get the User who is related with this notification * @return FrontendUser */ public function getFeuser() { if ($this->feuser instanceof LazyLoadingProxy) { $this->feuser->_loadRealInstance(); } if ($this->feuser === NULL) { $this->feuser = new AnonymousFrontendUser(); } return $this->feuser; }
/** * Get the other User who is involved in this message * @return FrontendUser The other User who is involved in this message */ public function getOpponent() { if ($this->opponent instanceof LazyLoadingProxy) { $this->opponent->_loadRealInstance(); } if ($this->opponent === NULL) { $this->opponent = new AnonymousFrontendUser(); } return $this->opponent; }
/** * * @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; }
/** * 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; } }
/** * 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; }
/** * disableUserAction * * @param FrontendUser $user * * @return void * @throws NotLoggedInException * @throws \TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException */ public function disableUserAction(FrontendUser $user = NULL) { $currentUser = $this->getCurrentUser(); if ($currentUser->isAnonymous()) { throw new NotLoggedInException("You need to be logged in.", 1288084981); } $allowed = false; foreach ($currentUser->getUsergroup() as $group) { if ($group->getUserMod()) { $allowed = true; } } if (!$allowed) { throw new NotLoggedInException("You need to be logged in as Admin.", 1288344981); } $user->setDisable(true); $this->frontendUserRepository->update($user); $this->redirect('show', 'User', 'typo3forum', array('user' => $user)); }
/** * 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(); }