ascott

Entity - Accounts

Jul 4th, 2012
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 11.59 KB | None | 0 0
  1. <?php
  2.  
  3. namespace RedK\Core\IndexBundle\Entity;
  4.  
  5. use Assetic\Asset\StringAsset;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Doctrine\ORM\Mapping\InheritanceType;
  9. use Symfony\Component\Security\Core\User\UserInterface;
  10. use Symfony\Component\Security\Core\User\AdvancedUserInterface;
  11. use Symfony\Component\Validator\Constraints as Assert;
  12.  
  13. /**
  14.  * RedK\Core\IndexBundle\Entity\Accounts
  15.  *
  16.  * @ORM\Table(name="accounts")
  17.  * @ORM\Entity(repositoryClass="RedK\Core\IndexBundle\Entity\AccountsRepository")
  18.  */
  19. class Accounts implements AdvancedUserInterface
  20. {
  21.     /**
  22.      * @var integer $accountsID
  23.      *
  24.      * @ORM\Column(name="AccountsID", type="integer", nullable=false)
  25.      * @ORM\Id()
  26.      * @ORM\GeneratedValue(strategy="AUTO")
  27.      */
  28.     private $accountsID;
  29.  
  30.     /**
  31.      * @var string $activationKey
  32.      *
  33.      * @ORM\Column(name="ActivationKey", type="string", length=32, nullable=true)
  34.      */
  35.     private $activationKey;
  36.  
  37.     /**
  38.      * @var string $accountStatus
  39.      *
  40.      * @ORM\Column(name="AccountStatus", type="string", length=10, nullable=false)
  41.      */
  42.     private $accountStatus;
  43.  
  44.     /**
  45.      * @var integer $organizationID
  46.      *
  47.      * @ORM\Column(name="OrganizationID", type="integer", nullable=true)
  48.      */
  49.     private $organizationID;
  50.  
  51.     /**
  52.      * @var string $type
  53.      *
  54.      * @ORM\Column(name="Type", type="string", length=2, nullable=true)
  55.      */
  56.     private $type;
  57.  
  58.     /**
  59.      * @var string $firstName
  60.      *
  61.      * @ORM\Column(name="FirstName", type="string", length=100, nullable=false)
  62.      * @Assert\NotBlank()
  63.      * @Assert\Regex(pattern="/\d+/", match=false, message="First Name is invalid")
  64.      */
  65.     private $firstName;
  66.  
  67.     /**
  68.      * @var string $lastName
  69.      *
  70.      * @ORM\Column(name="LastName", type="string", length=100, nullable=false)
  71.      * @Assert\NotBlank()
  72.      * @Assert\Regex(pattern="/\d+/", match=false, message="Last Name is invalid")
  73.      */
  74.     private $lastName;
  75.  
  76.     /**
  77.      * @var string $email
  78.      *
  79.      * @ORM\Column(name="Email", type="string", length=100, nullable=false)
  80.      * @Assert\NotBlank(groups={"recovery", "Default"})
  81.      * @Assert\Email(groups={"recovery", "Default"})
  82.      */
  83.     private $email;
  84.  
  85.     /**
  86.      * @var string $password
  87.      *
  88.      * @ORM\Column(name="Password", type="string", length=255, nullable=false)
  89.      * @Assert\NotBlank(groups={"reset", "Default"})
  90.      * @Assert\MinLength(limit=8, groups={"reset", "Default"})
  91.      * @Assert\MaxLength(limit=24, groups={"reset", "Default"})
  92.      */
  93.     private $password;
  94.  
  95.     /**
  96.      * @var string $salt
  97.      *
  98.      * @ORM\Column(name="Salt", type="string", length=32, nullable=false)
  99.      */
  100.     private $salt;
  101.  
  102.     /**
  103.      * @var string $passwordResetKey
  104.      *
  105.      * @ORM\Column(name="PasswordResetKey", type="string", length=24, nullable=true)
  106.      */
  107.     private $passwordResetKey;
  108.  
  109.     /**
  110.      * @var datetime $passwordResetStamp
  111.      *
  112.      * @ORM\Column(name="PasswordResetStamp", type="datetime", nullable=true)
  113.      */
  114.     private $passwordResetStamp;
  115.  
  116.     /**
  117.      * @var string $notifyEmail
  118.      *
  119.      * @ORM\Column(name="NotifyEmail", type="string", length=10, nullable=true)
  120.      */
  121.     private $notifyEmail;
  122.  
  123.     /**
  124.      * @var datetime $lastVisit
  125.      *
  126.      * @ORM\Column(name="LastVisit", type="datetime", nullable=true)
  127.      */
  128.     private $lastVisit;
  129.  
  130.     /**
  131.      * @var datetime $addStamp
  132.      *
  133.      * @ORM\Column(name="AddStamp", type="datetime", nullable=false)
  134.      */
  135.     private $addStamp;
  136.  
  137.     /**
  138.      * @var string $emailVerify
  139.      * @Assert\NotBlank()
  140.      * @Assert\Email
  141.      */
  142.     private $emailVerify;
  143.  
  144.     /**
  145.      * @var string $passwordVerify
  146.      * @Assert\NotBlank(groups={"reset", "Default"})
  147.      * @Assert\MinLength(limit=8, groups={"reset", "Default"})
  148.      * @Assert\MaxLength(limit=24, groups={"reset", "Default"})
  149.      */
  150.     private $passwordVerify;
  151.  
  152.     /**
  153.      * @ORM\ManyToMany(targetEntity="AccountsRoles", inversedBy="users")
  154.      */
  155.     private $groups;
  156.  
  157.     /**
  158.      * Get accountsID
  159.      *
  160.      * @return integer
  161.      */
  162.     public function getAccountsID()
  163.     {
  164.         return $this->accountsID;
  165.     }
  166.  
  167.     /**
  168.      * Set activationKey
  169.      *
  170.      * @param string $activationKey
  171.      */
  172.     public function setActivationKey($activationKey)
  173.     {
  174.         $this->activationKey = $activationKey;
  175.     }
  176.  
  177.     /**
  178.      * Get activationKey
  179.      *
  180.      * @return string
  181.      */
  182.     public function getActivationKey()
  183.     {
  184.         return $this->activationKey;
  185.     }
  186.  
  187.     /**
  188.      * Set accountStatus
  189.      *
  190.      * @param string $accountStatus
  191.      */
  192.     public function setAccountStatus($accountStatus)
  193.     {
  194.         $this->accountStatus = $accountStatus;
  195.     }
  196.  
  197.     /**
  198.      * Get accountStatus
  199.      *
  200.      * @return string
  201.      */
  202.     public function getAccountStatus()
  203.     {
  204.         return $this->accountStatus;
  205.     }
  206.  
  207.     /**
  208.      * Set organizationID
  209.      *
  210.      * @param integer $organizationID
  211.      */
  212.     public function setOrganizationID($organizationID)
  213.     {
  214.         $this->organizationID = $organizationID;
  215.     }
  216.  
  217.     /**
  218.      * Get organizationID
  219.      *
  220.      * @return integer
  221.      */
  222.     public function getOrganizationID()
  223.     {
  224.         return $this->organizationID;
  225.     }
  226.  
  227.     /**
  228.      * Set type
  229.      *
  230.      * @param string $type
  231.      */
  232.     public function setType($type)
  233.     {
  234.         $this->type = $type;
  235.     }
  236.  
  237.     /**
  238.      * Get type
  239.      *
  240.      * @return string
  241.      */
  242.     public function getType()
  243.     {
  244.         return $this->type;
  245.     }
  246.  
  247.     /**
  248.      * Set firstname
  249.      *
  250.      * @param string $firstName
  251.      */
  252.     public function setFirstName($firstName)
  253.     {
  254.         $this->firstName = $firstName;
  255.     }
  256.  
  257.     /**
  258.      * Get firstName
  259.      *
  260.      * @return string
  261.      */
  262.     public function getFirstName()
  263.     {
  264.         return $this->firstName;
  265.     }
  266.  
  267.     /**
  268.      * Set lastName
  269.      *
  270.      * @param string $lastName
  271.      */
  272.     public function setLastName($lastName)
  273.     {
  274.         $this->lastName = $lastName;
  275.     }
  276.  
  277.     /**
  278.      * Get lastName
  279.      *
  280.      * @return string
  281.      */
  282.     public function getLastName()
  283.     {
  284.         return $this->lastName;
  285.     }
  286.  
  287.     /**
  288.      * Set email
  289.      *
  290.      * @param string $email
  291.      */
  292.     public function setEmail($email)
  293.     {
  294.         $this->email = $email;
  295.     }
  296.  
  297.     /**
  298.      * Get email
  299.      *
  300.      * @return string
  301.      */
  302.     public function getEmail()
  303.     {
  304.         return $this->email;
  305.     }
  306.  
  307.     /**
  308.      * Set password
  309.      *
  310.      * @param string $password
  311.      */
  312.     public function setPassword($password)
  313.     {
  314.         $this->password = $password;
  315.     }
  316.  
  317.     /**
  318.      * Get password
  319.      *
  320.      * @return string
  321.      */
  322.     public function getPassword()
  323.     {
  324.         return $this->password;
  325.     }
  326.  
  327.     /**
  328.      * Set salt
  329.      *
  330.      * @param string $salt
  331.      */
  332.     public function setSalt($salt)
  333.     {
  334.         $this->salt = $salt;
  335.     }
  336.  
  337.     /**
  338.      * Get salt
  339.      *
  340.      * @return string
  341.      */
  342.     public function getSalt()
  343.     {
  344.         return $this->salt;
  345.     }
  346.  
  347.     /**
  348.      * Set passwordResetKey
  349.      *
  350.      * @param string $passwordResetKey
  351.      */
  352.     public function setPasswordResetKey($passwordResetKey)
  353.     {
  354.         $this->passwordResetKey = $passwordResetKey;
  355.     }
  356.  
  357.     /**
  358.      * Get passwordResetKey
  359.      *
  360.      * @return string
  361.      */
  362.     public function getPasswordResetKey()
  363.     {
  364.         return $this->passwordResetKey;
  365.     }
  366.  
  367.     /**
  368.      * Set passwordResetStamp
  369.      *
  370.      * @param datetime $passwordResetStamp
  371.      */
  372.     public function setPasswordResetStamp($passwordResetStamp)
  373.     {
  374.         $this->passwordResetStamp = $passwordResetStamp;
  375.     }
  376.  
  377.     /**
  378.      * Get passwordResetStamp
  379.      *
  380.      * @return datetime
  381.      */
  382.     public function getPasswordResetStamp()
  383.     {
  384.         return $this->passwordResetStamp;
  385.     }
  386.  
  387.     /**
  388.      * Set notifyEmail
  389.      *
  390.      * @param string $notifyEmail
  391.      */
  392.     public function setNotifyEmail($notifyEmail)
  393.     {
  394.         $this->notifyEmail = $notifyEmail;
  395.     }
  396.  
  397.     /**
  398.      * Get notifyEmail
  399.      *
  400.      * @return string
  401.      */
  402.     public function getNotifyEmail()
  403.     {
  404.         return $this->notifyEmail;
  405.     }
  406.  
  407.     /**
  408.      * Set lastVisit
  409.      *
  410.      * @param datetime $lastVisit
  411.      */
  412.     public function setLastVisit($lastVisit)
  413.     {
  414.         $this->lastVisit = $lastVisit;
  415.     }
  416.  
  417.     /**
  418.      * Get lastVisit
  419.      *
  420.      * @return datetime
  421.      */
  422.     public function getLastVisit()
  423.     {
  424.         return $this->lastVisit;
  425.     }
  426.  
  427.     /**
  428.      * Set addStamp
  429.      *
  430.      * @param datetime $addStamp
  431.      */
  432.     public function setAddStamp($addStamp)
  433.     {
  434.         $this->addStamp = $addStamp;
  435.     }
  436.  
  437.     /**
  438.      * Get addStamp
  439.      *
  440.      * @return datetime
  441.      */
  442.     public function getAddStamp()
  443.     {
  444.         return $this->addStamp;
  445.     }
  446.  
  447.     /**
  448.      * Get emailVerify
  449.      */
  450.     public function getEmailVerify()
  451.     {
  452.         return $this->emailVerify;
  453.     }
  454.  
  455.     /**
  456.      * Set emailVerify
  457.      */
  458.     public function setEmailVerify($emailVerify)
  459.     {
  460.         return $this->emailVerify = $emailVerify;
  461.     }
  462.  
  463.     /**
  464.      * Get passwordVerify
  465.      */
  466.     public function getPasswordVerify()
  467.     {
  468.         return $this->passwordVerify;
  469.     }
  470.  
  471.     /**
  472.      * Set passwordVerify
  473.      */
  474.     public function setPasswordVerify($passwordVerify)
  475.     {
  476.         return $this->passwordVerify = $passwordVerify;
  477.     }
  478.  
  479.     /**
  480.      *
  481.      */
  482.     public function __construct()
  483.     {
  484.         $this->accountStatus = '18.100.009';
  485.         $this->salt          = md5(uniqid(null, true));
  486.         $this->addStamp      = new \DateTime("now");
  487.         $this->groups        = new ArrayCollection();
  488.     }
  489.  
  490.     /**
  491.      * @inheritDoc
  492.      */
  493.     public function getUsername()
  494.     {
  495.         return $this->email;
  496.     }
  497.  
  498.     /**
  499.      * @inheritDoc
  500.      */
  501.     public function getRoles()
  502.     {
  503.         //return array('ROLE_USER');
  504.         return $this->groups->toArray();
  505.     }
  506.  
  507.     /**
  508.      * @inheritDoc
  509.      */
  510.     public function eraseCredentials()
  511.     {
  512.     }
  513.  
  514.     public function isAccountNonExpired()
  515.     {
  516.         return true;
  517.     }
  518.  
  519.     public function isAccountNonLocked()
  520.     {
  521.         return true;
  522.     }
  523.  
  524.     public function isCredentialsNonExpired()
  525.     {
  526.         return true;
  527.     }
  528.  
  529.     public function isEnabled()
  530.     {
  531.         if ($this->getAccountStatus() == '18.100.010') {
  532.             return true;
  533.         }
  534.  
  535.         return false;
  536.     }
  537.  
  538.     /**
  539.      * @inheritDoc
  540.      */
  541.     public function equals(UserInterface $user)
  542.     {
  543.         return $this->email === $user->getUsername();
  544.     }
  545.  
  546.     /**
  547.      * @Assert\True(message="Email Address and Verify Email Address values do not match")
  548.      */
  549.     public function isEmailVerified()
  550.     {
  551.         return $this->email === $this->emailVerify;
  552.     }
  553.  
  554.     /**
  555.      * @Assert\True(message="Password and Verify Password values do not match", groups={"reset", "Default"})
  556.      */
  557.     public function isPasswordVerified()
  558.     {
  559.         return $this->password === $this->passwordVerify;
  560.     }
  561.  
  562.     /**
  563.      * Get groups
  564.      *
  565.      * @return string
  566.      */
  567.     public function getGroups()
  568.     {
  569.         return $this->groups;
  570.     }
  571.  
  572.     /**
  573.      * Set groups
  574.      *
  575.      * @param string $groups
  576.      */
  577.     public function setGroups($groups)
  578.     {
  579.         $this->groups = $groups;
  580.     }
  581. }
Add Comment
Please, Sign In to add comment