Skip to content

Commit

Permalink
Merge pull request #6 from pixelant/development
Browse files Browse the repository at this point in the history
[!!!][TASK] New version release
  • Loading branch information
MattiasNilsson authored May 26, 2017
2 parents c6ef826 + 0edb603 commit 898b618
Show file tree
Hide file tree
Showing 28 changed files with 1,240 additions and 2,490 deletions.
833 changes: 237 additions & 596 deletions Classes/Controller/NewsletterSubscriptionController.php

Large diffs are not rendered by default.

166 changes: 65 additions & 101 deletions Classes/Domain/Model/FrontendUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,105 +35,69 @@
*
*/

class FrontendUser extends \TYPO3\CMS\Extbase\Domain\Model\FrontendUser {

/**
* @var boolean
*/
protected $disable;

/**
* @var boolean
*/
protected $deleted;

/**
* @param boolean $disable
*/
public function setDisable($disable) {
$this->disable = $disable;
}

/**
* @return boolean
*/
public function getDisable() {
return $this->disable;
}

/**
* @param boolean $deleted
*/
public function setDeleted($deleted) {
$this->deleted = $deleted;
}

/**
* @return boolean
*/
public function getDeleted() {
return $this->deleted;
}

/**
* Sets password with a random generated password.
*
* @param int $length The length of the password.
* @return void
*/
public function setRandomPassword($length = 12) {

$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_-=+;:,.?";
$password = substr( str_shuffle( $chars ), 0, $length );

$this->password = $password;

}

/**
* Sets random hash (uses fax property).
*
* @return void
*/
public function setHash()
{
$randomHash = substr(md5(uniqid(rand(), true)), 16, 16);
$this->fax = $randomHash;
}

/**
* Gets random hash (uses fax property).
*
* @return string
*/
public function getHash()
{
return $this->fax;
}

/**
* Creates a new Frontend User as a subscriber.
*
* @param int $pid The page to store the Frontend User on.
* @param string $email The email of the user.
* @param string $name The name of the user.
* @param bool $confirm If the user needs to confirm subscription by email.
* @param \TYPO3\CMS\Extbase\Domain\Model\FrontendUserGroup $usergroup The usergroup user should be a member of.
* @return void
*/
public function setAsSubscriber($pid, $email, $name, $confirm, \TYPO3\CMS\Extbase\Domain\Model\FrontendUserGroup $usergroup) {

$this->setPid(intval($pid));
$this->setUsername($email);
$this->setEmail($email);
$this->setName($name);
$this->setDisable(intval($confirm));
$this->setHash();
$this->setRandomPassword(12);
$this->addUsergroup($usergroup);

}


class FrontendUser extends \TYPO3\CMS\Extbase\Domain\Model\FrontendUser
{

/**
* @var boolean
*/
protected $disable;

/**
* @param boolean $disable
*/
public function setDisable($disable)
{
$this->disable = $disable;
}

/**
* @return boolean
*/
public function getDisable()
{
return $this->disable;
}

/**
* Sets password with a random generated password.
*
* @param int $length The length of the password.
* @return void
*/
public function setRandomPassword($length = 12)
{

$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_-=+;:,.?";
$password = substr(str_shuffle($chars), 0, $length);

$this->password = $password;
}

/**
* Creates a new Frontend User as a subscriber.
*
* @param int $pid The page to store the Frontend User on.
* @param string $email The email of the user.
* @param string $name The name of the user.
* @param bool $confirm If the user needs to confirm subscription by email.
* @param \TYPO3\CMS\Extbase\Domain\Model\FrontendUserGroup $usergroup The usergroup user should be a member of.
* @return void
*/
public function setAsSubscriber(
$pid,
$email,
$name,
$confirm,
\TYPO3\CMS\Extbase\Domain\Model\FrontendUserGroup $usergroup
) {

$this->setPid(intval($pid));
$this->setUsername($email);
$this->setEmail($email);
$this->setName($name);
$this->setDisable(intval($confirm));
$this->setRandomPassword(12);
$this->addUsergroup($usergroup);
}
}
?>
4 changes: 3 additions & 1 deletion Classes/Domain/Model/FrontendUserGroup.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace Pixelant\PxaNewsletterSubscription\Domain\Model;

/***************************************************************
Expand Down Expand Up @@ -34,6 +35,7 @@
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 or later
*
*/
class FrontendUserGroup extends \TYPO3\CMS\Extbase\Domain\Model\FrontendUserGroup {
class FrontendUserGroup extends \TYPO3\CMS\Extbase\Domain\Model\FrontendUserGroup
{

}
41 changes: 19 additions & 22 deletions Classes/Domain/Repository/FrontendUserGroupRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,30 +34,27 @@
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 or later
*
*/
class FrontendUserGroupRepository extends \TYPO3\CMS\Extbase\Domain\Repository\FrontendUserGroupRepository
{

class FrontendUserGroupRepository extends \TYPO3\CMS\Extbase\Domain\Repository\FrontendUserGroupRepository {
/**
* Gets a Frontend User Group by uid without respecting storage page.
*
* @param int $uid
* @return object
*/
public function getFrontendUserGroupByUid($uid)
{

/**
* Gets a Frontend User Group by uid without respecting storage page.
*
* @param int $uid
* @return int
*/
public function getFrontendUserGroupByUid($uid) {
$query = $this->createQuery();

$query = $this->createQuery();

$query->getQuerySettings()->setRespectStoragePage(FALSE);

$frontendUserGroup = $query
->matching(
$query->equals('uid',$uid)
)
->execute()
->getFirst();

return $frontendUserGroup;
}
$query->getQuerySettings()->setRespectStoragePage(false);

return $query
->matching(
$query->equals('uid', $uid)
)
->execute()
->getFirst();
}
}
?>
Loading

0 comments on commit 898b618

Please sign in to comment.