/** * * Sends a mail with a certain subject and bodytext to a recipient in form of a * frontend user. * * @param \TYPO3\CMS\Extbase\Domain\Model\FrontendUser $recipient * The recipient of the mail. This is a plain * frontend user. * @param string $subject The mail's subject * @param string $bodyText The mail's bodytext * * @return void * */ public function sendMail(\TYPO3\CMS\Extbase\Domain\Model\FrontendUser $recipient, $subject, $bodyText) { if ($recipient->getEmail()) { $mail = new \TYPO3\CMS\Core\Mail\MailMessage(); $mail->setTo(array($recipient->getEmail()))->setFrom($this->getDefaultSenderAddress(), $this->getDefaultSenderName())->setSubject($subject)->setBody($bodyText)->send(); } }
/** * @return ObjectStorage */ public function constructObjectStorageContainingFrontendUsersWithUserGroups() { $storage = new ObjectStorage(); $userGroup1 = new FrontendUserGroup('my first group'); $userGroup2 = new FrontendUserGroup('my second group'); $user1 = new FrontendUser(); $user2 = new FrontendUser(); $user1->addUsergroup($userGroup1); $user2->addUsergroup($userGroup2); $storage->attach($user1); $storage->attach($user2); return $storage; }
/** * @param int $uid * @param string $begin * @param string $end * @param array $speakerIds * @param bool $expected * * @test * @dataProvider collidingSessionsAreDeterminedDataProvider */ public function collidingSessionsAreDetermined($uid, $begin, $end, array $speakerIds, $exclude, $expected) { $beginDateTime = \DateTime::createFromFormat(DATE_ISO8601, $begin); $endDateTime = \DateTime::createFromFormat(DATE_ISO8601, $end); $session = new AnySession(); $session->_setProperty('uid', $uid); $session->setBegin($beginDateTime); $session->setEnd($endDateTime); foreach ($speakerIds as $speakerId) { $speaker = new FrontendUser(); $speaker->_setProperty('uid', $speakerId); $session->addSpeaker($speaker); } $result = $this->subject->getCollidingSessions($session, $exclude); $this->assertEquals($expected, is_array($result) ? count($result) : $result); }
public function setPassword($password) { if (\TYPO3\CMS\Saltedpasswords\Utility\SaltedPasswordsUtility::isUsageEnabled('FE')) { $objSalt = \TYPO3\CMS\Saltedpasswords\Salt\SaltFactory::getSaltingInstance(NULL); if (is_object($objSalt)) { $password = $objSalt->getHashedPassword($password); } } parent::setPassword($password); }
/** * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage */ public function getBookmarksForCurrentConfigAndFeUser() { $allBookmarks = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage(); if ($this->bookmarkConfiguration->getShowPrivateBookmarks() && $this->feUser != NULL) { $privateBookmarks = $this->bookmarkRepository->findPrivateBookmarksByFeUserAndListIdentifier($this->feUser, $this->listIdentifier); $this->addObjectsToObjectStorageByArray($allBookmarks, $privateBookmarks); } if ($this->bookmarkConfiguration->getShowGroupBookmarks() && $this->feUser != NULL && count($this->feUser->getUsergroup()) > 0) { $groupBookmarks = $this->bookmarkRepository->findGroupBookmarksByFeUserAndListIdentifier($this->feUser, $this->listIdentifier); $this->addObjectsToObjectStorageByArray($allBookmarks, $groupBookmarks); } if ($this->bookmarkConfiguration->getShowPublicBookmarks()) { $publicBookmarks = $this->bookmarkRepository->findPublicBookmarksByListIdentifier($this->listIdentifier); $this->addObjectsToObjectStorageByArray($allBookmarks, $publicBookmarks); } return $allBookmarks; }
public function createAction(\TYPO3\CMS\Extbase\Domain\Model\FrontendUser $feUser) { //TODO prüfen ob username doppelt vergeben wird. if ($feUser->getPassword() == $this->request->getArgument('passwordConfirmation')) { $feUser->setPid($this->settings['pidFrontendUser']); $feUser->_setProperty('tx_extbase_type', 'Tx_Extbase_Domain_Model_FrontendUser'); $feUser->addUserGroup($this->frontendUserGroupRepository->findByUid($this->settings['frontendUserGroup'])); $this->frontendUserRepository->add($feUser); //it is not persistent already, we have to do it! $persistenceManager = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\PersistenceManager'); $persistenceManager->persistAll(); //now feuser ist persistent // Message for User $GLOBALS['TSFE']->fe_user->setKey("ses", "feuserCreate", 'Der User <b>' . $feUser->getUsername() . '</b> wurde neu angelegt.'); $redirectParams['feUser'] = $feUser; $this->redirect('successUpdate', 'FrontendUser', NULL, $redirectParams); } else { $GLOBALS['TSFE']->fe_user->setKey("ses", "feuserCreate", 'Das Passwort stimmt nicht überein.'); $GLOBALS['TSFE']->fe_user->setKey("ses", "feuserData", array('username' => $feUser->getUsername())); $redirectParams['feUser'] = $feUser; $this->redirect('new', 'FrontendUser', NULL, array()); } }
/** * Workaround to disable persistence in updateAction * * @param null $propertyName * @return bool */ public function _isDirty($propertyName = null) { return $this->getIgnoreDirty() ? false : parent::_isDirty($propertyName); }
/** * Constructs a new Front-End User * * @param string $username * @param string $password * @return self */ public function __construct($username = '', $password = '') { parent::__construct($username, $password); }
/** * __construct * * @return void */ public function __construct() { parent::__construct(); //Do not remove the next line: It would break the functionality $this->initStorageObjects(); }
/** * Returns TRUE only if a FrontendUser is currently logged in. Use argument * to return TRUE only if the FrontendUser logged in must be that specific user. * * @param \TYPO3\CMS\Extbase\Domain\Model\FrontendUser $frontendUser * @return boolean * @api */ public function assertFrontendUserLoggedIn(FrontendUser $frontendUser = NULL) { $currentFrontendUser = $this->getCurrentFrontendUser(); if (FALSE === $currentFrontendUser instanceof \TYPO3\CMS\Extbase\Domain\Model\FrontendUser) { return FALSE; } if (TRUE === $frontendUser instanceof \TYPO3\CMS\Extbase\Domain\Model\FrontendUser && TRUE === $currentFrontendUser instanceof \TYPO3\CMS\Extbase\Domain\Model\FrontendUser) { if ($currentFrontendUser->getUid() === $frontendUser->getUid()) { return TRUE; } else { return FALSE; } } return (bool) (TRUE === is_object($currentFrontendUser)); }
/** * Returns all group bookmarks for a given user and a given list of group uids for which bookmarks should be collected for a given list identifier. * * Example: * User is in Groups (1,2,3,4) * Groups to be shown (3,4) * ==> all bookmarks for groups 3,4 are returned * * @param \TYPO3\CMS\Extbase\Domain\Model\FrontendUser $feUser * @param string $groupIds Comma-separated list of group uids * @param string $listIdentifier * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<Tx_PtExtlist_Domain_Model_Bookmarks_Bookmark> */ public function findBookmarksByFeUserGroupIdsAndListIdentifier(\TYPO3\CMS\Extbase\Domain\Model\FrontendUser $feUser, $groupIds, $listIdentifier) { Tx_PtExtbase_Assertions_Assert::isNotEmptyString($listIdentifier, array('message' => 'List identifier must not be empty! 1283117069')); if (!is_array($groupIds)) { $groupIds = explode(',', $groupIds); } $groupBookmarks = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage(); $feUserGroups = $feUser->getUsergroups(); foreach ($feUserGroups as $feUserGroup) { /* @var $feUserGroup \TYPO3\CMS\Extbase\Domain\Model\FrontendUserGroup */ if (in_array($feUserGroup->getUid(), $groupIds)) { $bookmarks = $this->findGroupBookmarksByFeGroupAndListIdentifier($feUserGroup, $listIdentifier); foreach ($bookmarks as $bookmark) { $groupBookmarks->attach($bookmark); } } } return $groupBookmarks; }
/** * Check if FE Session exists * * @param FrontendUser $user * @return bool */ public static function checkFrontendSessionToUser(FrontendUser $user) { $select = 'ses_id'; $from = 'fe_sessions'; $where = 'ses_userid = ' . intval($user->getUid()); $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($select, $from, $where); $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res); if (!empty($row['ses_id'])) { return TRUE; } return FALSE; }
/** * @test */ public function setLastloginSetsLastlogin() { $date = new \DateTime(); $this->fixture->setLastlogin($date); $this->assertSame($date, $this->fixture->getLastlogin()); }
/** * @return array */ public function getAssertFrontendUserGroupLoggedInTestValues() { $frontendUserGroup = new FrontendUserGroup(); $frontendUserGroups = new ObjectStorage(); $frontendUserGroups->attach($frontendUserGroup); $user1 = new FrontendUser(); ObjectAccess::setProperty($user1, 'uid', 1, TRUE); $user2 = new FrontendUser(); $user2->setUsergroup($frontendUserGroups); ObjectAccess::setProperty($user2, 'uid', 2, TRUE); return array(array(NULL, NULL, FALSE), array(NULL, $user1, FALSE), array(NULL, $user2, TRUE), array($frontendUserGroup, $user1, FALSE), array($frontendUserGroup, $user2, TRUE), array($frontendUserGroups, $user1, FALSE), array($frontendUserGroups, $user2, TRUE), array('unsupportedtype', $user1, FALSE)); }
/** * Sends a mail with a certain subject and bodytext to a recipient in form of a frontend user. * * @param FrontendUser $recipient The recipient of the mail. This is a plain frontend user. * @param string $subject The mail's subject * @param string $bodyText The mail's bodytext * @return void */ public function sendMail(FrontendUser $recipient, $subject, $bodyText) { $typo3Mail = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Mail\\MailMessage'); $typo3Mail->setFrom([$this->getDefaultSenderAddress() => $this->getDefaultSenderName()])->setTo($recipient->getEmail())->setSubject($subject)->setBody($bodyText, 'text/html')->send(); }
/** * Constructor. * * @param string $username The user's username. * @param string $password The user's password. */ public function __construct($username = '', $password = '') { parent::__construct($username, $password); $this->readTopics = new ObjectStorage(); $this->readForum = new ObjectStorage(); }
/** * Workaround to disable persistence in updateAction * * @param null $propertyName * @return bool */ public function _isDirty($propertyName = NULL) { return $this->getIgnoreDirty() ? FALSE : parent::_isDirty($propertyName); }
/** * Find all of the lists not subscribed to by the given user. * * @param \TYPO3\CMS\Extbase\Domain\Model\FrontendUser $user * @return \TYPO3\CMS\Extbase\Persistence\QueryResultInterface */ public function findAllNotSubscribedToBy(FrontendUser $user) { $q = $this->createQuery(); $q->matching($q->logicalNot($q->contains('feUsers', [$user->getUid()]))); return $q->execute(); }
/** * @param int $amount * @return FrontendUser[] */ protected function createSpeakers($amount) { $speakers = []; for ($i = 1; $i <= $amount; $i++) { $speaker = new FrontendUser(); $speaker->_setProperty('uid', $i + 2000); $speaker->setName('Speaker #' . $i); $speakers[] = $speaker; } return $speakers; }
/** * Returns TRUE only if a FrontendUser is currently logged in. Use argument * to return TRUE only if the FrontendUser logged in must be that specific user. * * @param FrontendUser $frontendUser * @return boolean * @api */ public function assertFrontendUserLoggedIn(FrontendUser $frontendUser = null) { $currentFrontendUser = $this->getCurrentFrontendUser(); if (false === $currentFrontendUser instanceof FrontendUser) { return false; } if (true === $frontendUser instanceof FrontendUser && true === $currentFrontendUser instanceof FrontendUser) { if ($currentFrontendUser->getUid() === $frontendUser->getUid()) { return true; } else { return false; } } return (bool) (true === is_object($currentFrontendUser)); }